Closed Bug 1587180 Opened 5 years ago Closed 5 years ago

Improve the functionality of Lintpref

Categories

(Core :: Preferences: Backend, enhancement)

enhancement
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla72
Tracking Status
firefox72 --- fixed

People

(Reporter: KrisWright, Assigned: KrisWright)

References

Details

Attachments

(4 files)

There's a few things I would like to do for Lintpref before it can start examining more pref files:

  1. Have Lintpref get its file paths from the yml file rather than statically checking all.js against StaticPrefList.yaml. This is the behavior reflected in other linters, and I didn't worry about it at the time since we were only looking at all.js. In order to write tests for the linter and expand its usage to more files, it's better to get file paths from lintpref.yml.

  2. Improve parsing of all.js and other associated prefs files. Right now it just trusts that the pattern of prefs is regular enough to pull the names out, but it could do this more elegantly. It looked at first that Preferences.read_prefs was the right function to use to do this, but there's some file format mismatches that causes it to have read errors. There may be another function in the library to do this. Or, I can just write a similar function that reads in prefs as a part of lintpref.

  3. Detect value mismatches in duplicates. This is going to require a lot of consideration - right now, value is not considered and so we don't do any preprocessing steps. there are a few ways to address this, including storing all of the possible values found in the value field against each pref, and checking them against the *.js files' values as a list. This is useful for files like mobile.js where there will be a lot of prefs that are overwritten with different values. When there is a value mismatch, the pref can either be ignored completely (since it'll be overwriting the static pref with the new value) or warned as a potential duplicate instead of reporting an error.

  4. Write test files for Lintpref. The linters now have tests, and lintpref should have tests too. Before, it wasn't possible to really create a test case since it was reading all.js exclusively. With the changes in part 1 it will be possible to write tests.

Rather than statically loading the path to all.js, Lintpref should look at any file paths in lintpref.yml. Also added the path field to each error to accommodate multiple files, and a few other code tidiness cleanups.

Replaces the basic pattern-matching in the linter with a more robust regexp. This regexp can strip name and value from the pref, which will be useful in part 3 of bug 1587180.

Teaches Lintpref to look at value matches when considering possible duplicates.

Adds a test for Lintpref and two test files. Also makes some adjustments to lintpref.yml to improve support file loading.

Keywords: leave-open
Pushed by kwright@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/93362c0a7d69 1. Have Lintpref look for the files included in Lintpref.yml. r=ahal https://hg.mozilla.org/integration/autoland/rev/a3b383ec343b 2. Improve Lintpref's pattern-matching r=glandium https://hg.mozilla.org/integration/autoland/rev/bdf7addb1a8f 3. Have lintpref understand the value field r=glandium
Keywords: leave-open
Pushed by malexandru@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/af29b78f16dd Fix linting issue regarding tools/lint/libpref/__init__.py a=lint-fix
Assignee: nobody → kwright
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: