Merge pull request #16607 from Rob--W/lint-chromium-actionable-warnings
Improve lint-chromium to output actionable information
This commit is contained in:
		
						commit
						d057caedf5
					
				
							
								
								
									
										41
									
								
								gulpfile.js
									
									
									
									
									
								
							
							
						
						
									
										41
									
								
								gulpfile.js
									
									
									
									
									
								
							@ -323,33 +323,40 @@ function checkChromePreferencesFile(chromePrefsPath, webPrefs) {
 | 
				
			|||||||
  const chromePrefsKeys = Object.keys(chromePrefs.properties).filter(key => {
 | 
					  const chromePrefsKeys = Object.keys(chromePrefs.properties).filter(key => {
 | 
				
			||||||
    const description = chromePrefs.properties[key].description;
 | 
					    const description = chromePrefs.properties[key].description;
 | 
				
			||||||
    // Deprecated keys are allowed in the managed preferences file.
 | 
					    // 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 .
 | 
					    // extensions/chromium/options/migration.js and web/chromecom.js .
 | 
				
			||||||
    return !description || !description.startsWith("DEPRECATED.");
 | 
					    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;
 | 
					  let ret = true;
 | 
				
			||||||
  for (let i = 0, ii = webPrefsKeys.length; i < ii; i++) {
 | 
					  // Verify that every entry in webPrefs is also in preferences_schema.json.
 | 
				
			||||||
    const value = webPrefsKeys[i];
 | 
					  for (const [key, value] of Object.entries(webPrefs)) {
 | 
				
			||||||
    if (chromePrefsKeys[i] !== value) {
 | 
					    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;
 | 
					      ret = false;
 | 
				
			||||||
      console.log(
 | 
					      console.log(
 | 
				
			||||||
        `Warning: not the same keys: ${chromePrefsKeys[i]} !== ${value}`
 | 
					        `Warning: ${chromePrefsPath} does not contain an entry for pref: ${key}`
 | 
				
			||||||
      );
 | 
					      );
 | 
				
			||||||
    } else if (chromePrefs.properties[value].default !== webPrefs[value]) {
 | 
					    } else if (chromePrefs.properties[key].default !== value) {
 | 
				
			||||||
      ret = false;
 | 
					      ret = false;
 | 
				
			||||||
      console.log(
 | 
					      console.log(
 | 
				
			||||||
        `Warning: not the same values (for "${value}"): ` +
 | 
					        `Warning: not the same values (for "${key}"): ` +
 | 
				
			||||||
          `${chromePrefs.properties[value].default} !== ${webPrefs[value]}`
 | 
					          `${chromePrefs.properties[key].default} !== ${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: ${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.`
 | 
				
			||||||
      );
 | 
					      );
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user