Closed Bug 1907129 Opened 5 months ago Closed 3 months ago

Add a Fenix and AC Linter to run ktlintFormat and detekt

Categories

(Fenix :: Tooling, task)

All
Android
task

Tracking

(firefox131 fixed)

RESOLVED FIXED
131 Branch
Tracking Status
firefox131 --- fixed

People

(Reporter: olivia, Assigned: adhingra)

References

(Blocks 1 open bug)

Details

Attachments

(2 files, 3 obsolete files)

(Adding this bug as a stepping stone for bug 1891723.)

This bug is to add a linter that runs ./gradlew ktlintFormat detekt .

Right now to run the core AC/Fenix lints, the developer must CD into .../mobile/android/fenix or .../mobile/android/android-components and run ./gradlew ktlintFormat and ./gradlew detekt.

Consider creating:

./mach lint android-ac
./mach lint android-fenix
./mach lint firefox-android (Runs both AC and Fenix lints -> basing naming idea from preset that runs AC and Fenix) 
See Also: → 1891723
Assignee: nobody → adhingra
Attachment #9413010 - Attachment description: WIP: Bug 1907129 - Modify linters to run ./gradlew ktlint detekt on Fenix and AC. → Bug 1907129 - Modify linters to run ./gradlew ktlint detekt on Fenix and AC.
Attachment #9413010 - Attachment description: Bug 1907129 - Modify linters to run ./gradlew ktlint detekt on Fenix and AC. → WIP: Bug 1907129 - Modify linters to run ./gradlew ktlint detekt on Fenix and AC.
Attachment #9412530 - Attachment is obsolete: true

Just a bit of explanation on the edits made here to make reviewing easy

  • build.gradle: To generate ktlint json reports. Detekt already used to generate reports and lints.py used to read reports created by spotless (GV lints). I used the same idea here, first to read the existing detekt reports, then realized that ktlint didnt generate reports by default so made changes to this file to generate ktlint json reports and read those too in lints.py.
  • mozlint-android.yml: This is so that when ./mach lint is ran, it runs the new linters too
  • android-{ac|fenix}.yml: These are the linter configurations. Based on documentation from https://firefox-source-docs.mozilla.org/code-quality/lint/create.html and android-format.yml as reference.
  • lints.py: The new methods here fenix_format and ac_format are called from payload field in android-{ac|fenix}.yml. This is the main file which handles running ./gradlew ktlint detekt and reading/reporting the errors in the format that reviewbot reads it.

An example of how reviewbot will report errors is this patch.

Pushed by ohall@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/7bdb0fe9dac8 Modify linters to run ./gradlew ktlint detekt on Fenix and AC. r=android-reviewers,nalexander,gl,pollymce
Status: NEW → ASSIGNED
Status: ASSIGNED → RESOLVED
Closed: 3 months ago
Resolution: --- → FIXED
Target Milestone: --- → 131 Branch
Duplicate of this bug: 1826800

A patch has been attached on this bug, which was already closed. Filing a separate bug will ensure better tracking. If this was not by mistake and further action is needed, please alert the appropriate party. (Or: if the patch doesn't change behavior -- e.g. landing a test case, or fixing a typo -- then feel free to disregard this message)

Attached file WIP: Bug 1907129: Testing ktlint (obsolete) —
Pushed by ohall@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/27bb234b5808 Report line and column in the link to error when ran locally. r=gl,android-reviewers
Attachment #9420843 - Attachment is obsolete: true
Attachment #9413010 - Attachment is obsolete: true
Duplicate of this bug: 1892731
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: