Closed Bug 1479515 Opened 6 years ago Closed 2 years ago

Add manually run linter rules for detecting reference of undefined constants in interfaces and accessing valid properties of Services

Categories

(Developer Infrastructure :: Lint and Formatting, task, P2)

Tracking

(firefox106 fixed)

RESOLVED FIXED
Tracking Status
firefox106 --- fixed

People

(Reporter: standard8, Assigned: standard8)

References

(Blocks 1 open bug)

Details

Attachments

(3 files, 1 obsolete file)

In the dependencies on bug 1479513, you'll see various cases where we do things like: Ci.nsIFoo.BAR and BAR is undefined as it isn't in the interface. Ideally we should have an automated way to catch this. It is probably a job for static analysis.
Attached patch ESLint based interface checks (obsolete) — Splinter Review
This is the patch I whipped up for ESLint. The basic idea here is: 1) Find any item which looks like Ci.IFoo.bar 2) Load the interface JSON information from the hard-coded objdir path `objdir-ff-opt/config/makefiles/xpidl/` (if not already loaded) 3) Search through the interfaces for the IFoo definition 4) Search through the interface definition `consts` value for `bar` 5) If `bar` is not found, repeat 3 and 4 for any parents until `nsISupports` is hit. This isn't really suitable for ESLint in production at the moment as: - here is the obvious build dependency. - I'm not convinced this should be ESLint's role, as this is doing more in-depth analysis. However, maybe there is another way, or this could be hooked up to static analysis of some kind.
See Also: → 1479513
Product: Firefox Build System → Developer Infrastructure
Assignee: nobody → standard8

In this bug we'll get these landed in a way that they can be run manually from ESLint when you have a full build. Bug 1666491 will deal with the hook-up to automation.

Blocks: 1666491
Severity: normal → N/A
Status: NEW → ASSIGNED
Type: enhancement → task
Priority: -- → P2
Summary: Investigate if we can add a linter for detecting reference of undefined constants in interfaces → Add manually run linter rules for detecting reference of undefined constants in interfaces and accessing valid properties of Services
Depends on: 1789232

This is manually run and requires a full build. MOZ_OBJDIR needs to be set to point to the object directory.

Depends on D156421

This is manually run and requires a full build. MOZ_OBJDIR needs to be set to point to the object directory.

Depends on D156425

Depends on: 1479513
See Also: 1479513

I still need to do a lot of tidy up on these patches, the WIP are posting so there's a copy here as well.

Attachment #8996024 - Attachment is obsolete: true
Attachment #9293100 - Attachment description: WIP: Bug 1479515 - Add an ESLint rule to check for unknown property accesses on Ci. → Bug 1479515 - Add an ESLint rule to check for unknown property accesses on Ci. r?Gijs
Attachment #9293101 - Attachment description: WIP: Bug 1479515 - Extend the ESLint rule for checking Ci properties to check for unknown interfaces as well. → Bug 1479515 - Extend the ESLint rule for checking Ci properties to check for unknown interfaces as well. r?Gijs
Attachment #9293102 - Attachment description: WIP: Bug 1479515 - Add an ESLint rule to check for valid property accesses on Services. → Bug 1479515 - Add an ESLint rule to check for valid property accesses on Services. r?Gijs
Blocks: 1790261
Pushed by mbanner@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/4bc3e077b7a2 Add an ESLint rule to check for unknown property accesses on Ci. r=Gijs https://hg.mozilla.org/integration/autoland/rev/5086e62b92ed Extend the ESLint rule for checking Ci properties to check for unknown interfaces as well. r=Gijs,application-update-reviewers,nalexander https://hg.mozilla.org/integration/autoland/rev/5eb9e59194ee Add an ESLint rule to check for valid property accesses on Services. r=Gijs
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: