Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve lint-chromium to output actionable information #16607

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 24 additions & 17 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -326,33 +326,40 @@ function checkChromePreferencesFile(chromePrefsPath, webPrefs) {
const chromePrefsKeys = Object.keys(chromePrefs.properties).filter(key => {
const description = chromePrefs.properties[key].description;
// Deprecated keys are allowed in the managed preferences file.
// The code maintained is responsible for adding migration logic to
// The code maintainer is responsible for adding migration logic to
// extensions/chromium/options/migration.js and web/chromecom.js .
return !description || !description.startsWith("DEPRECATED.");
});
chromePrefsKeys.sort();

const webPrefsKeys = Object.keys(webPrefs);
webPrefsKeys.sort();

if (webPrefsKeys.length !== chromePrefsKeys.length) {
console.log("Warning: Pref objects doesn't have the same length.");
return false;
}

let ret = true;
for (let i = 0, ii = webPrefsKeys.length; i < ii; i++) {
const value = webPrefsKeys[i];
if (chromePrefsKeys[i] !== value) {
// Verify that every entry in webPrefs is also in preferences_schema.json.
for (const [key, value] of Object.entries(webPrefs)) {
if (!chromePrefsKeys.includes(key)) {
// Note: this would also reject keys that are present but marked as
// DEPRECATED. A key should not be marked as DEPRECATED if it is still
// listed in webPrefs.
ret = false;
console.log(
`Warning: ${chromePrefsPath} does not contain an entry for pref: ${key}`
);
} else if (chromePrefs.properties[key].default !== value) {
ret = false;
console.log(
`Warning: not the same keys: ${chromePrefsKeys[i]} !== ${value}`
`Warning: not the same values (for "${key}"): ` +
`${chromePrefs.properties[key].default} !== ${value}`
);
} else if (chromePrefs.properties[value].default !== webPrefs[value]) {
}
}

// Verify that preferences_schema.json does not contain entries that are not
// in webPrefs (app_options.js).
for (const key of chromePrefsKeys) {
if (!(key in webPrefs)) {
ret = false;
console.log(
`Warning: not the same values (for "${value}"): ` +
`${chromePrefs.properties[value].default} !== ${webPrefs[value]}`
`Warning: ${chromePrefsPath} contains an unrecognized pref: ${key}. ` +
`Remove it, or prepend "DEPRECATED. " and add migration logic to ` +
`extensions/chromium/options/migration.js and web/chromecom.js.`
);
}
}
Expand Down