Closed Bug 1591991 Opened 5 years ago Closed 4 years ago

Add a fixed issues count to the ResultSummary

Categories

(Developer Infrastructure :: Lint and Formatting, task)

task
Not set
normal

Tracking

(firefox87 fixed)

RESOLVED FIXED
87 Branch
Tracking Status
firefox87 --- fixed

People

(Reporter: ahal, Assigned: baka, Mentored)

Details

(Whiteboard: [lang=py])

Attachments

(1 file, 1 obsolete file)

When passing --fix it would be good to try and count the number of issues that were fixed. This way, the formatters can indicate how many fixes were applied to the user. E.g, the stylish formatter might print:

x 4 problems (3 errors, 1 warning, 20 fixed)

How this information is obtained will need to depend on the individual lint integrations. For some it might not even be possible to compute (without doing a two-pass lint). So this information will need to be best effort.

Hi, I would like to work on this bug. I am fairly new to contributing and would like to a hand in getting started. I do have a good amount of experience with python and this sounds like it would be right up my alley.

Hi, i think i can work on this, can you please answer my few doubts:

  1. Are we required to implement this in each linter?
  2. If it is to be done in each individual linter then should i implement this in a stack of patches, with each patch implementing this feature in 1 linter?
  3. Should we re-run all linters (./mach lint) to check for number of fixes?

Requesting information from Sylvestre Ledru [:Sylvestre] as Andrew Halberstadt [:ahal] (PTO until March) is not accepting needinfo requests at this time.

Are we required to implement this in each linter?

In theory, it should probably be done at the mozlint level, not for each checker!
Not sure it can be easily done.

Should we re-run all linters (./mach lint) to check for number of fixes?

It should be 0 for most of them as we trigger error otherwise

Hello :ahal,:Sylvestre, while going through mozlint directory and try to figure out right place to insert this enhancement and also trying to understand the project here's what I found and also what I am confused of(last point) :

  1. python/mozlint/mozlint/result.py this file keeps track of the result(warnings,errors) and after this can also keep a variable count number of issues that we fixed. Something like this can work. Link to file
diff -r 808f29b01392 python/mozlint/mozlint/result.py
--- a/python/mozlint/mozlint/result.py  Sun Jan 10 15:41:34 2021 +0530
+++ b/python/mozlint/mozlint/result.py  Wed Jan 13 22:12:50 2021 +0530
@@ -27,6 +27,7 @@
         self.failed_run = set()
         self.failed_setup = set()
         self.suppressed_warnings = defaultdict(int)
+        self.fixed = 0
 
     @property
     def returncode(self):
@@ -46,6 +47,11 @@
     def total_suppressed_warnings(self):
         return sum(self.suppressed_warnings.values())
 
+    @property
+    def total_fixed(self):
+        return self.fixed
+    
+
     def update(self, other):
         """Merge results from another ResultSummary into this one."""
         for path, obj in other.issues.items():
@@ -53,6 +59,7 @@
 
         self.failed_run |= other.failed_run
         self.failed_setup |= other.failed_setup
+        self.fixed += other.fixed
         for k, v in other.suppressed_warnings.items():
             self.suppressed_warnings[k] += v

  1. python/mozlint/mozlint/formatters/stylish.py In this file what we can modify fmt,fmt_summary to actually include the counted results into the output shown on terminal.Link to file
diff -r 808f29b01392 python/mozlint/mozlint/formatters/stylish.py
--- a/python/mozlint/mozlint/formatters/stylish.py      Sun Jan 10 15:41:34 2021 +0530
+++ b/python/mozlint/mozlint/formatters/stylish.py      Wed Jan 13 22:17:29 2021 +0530
@@ -30,7 +30,7 @@
 {diff}""".lstrip(
         "\n"
     )
-    fmt_summary = "{t.bold}{c}\u2716 {problem} ({error}, {warning}{failure}){t.normal}"
+    fmt_summary = "{t.bold}{c}\u2716 {problem} ({error}, {warning}{failure}, {fixed}){t.normal}"
 
     def __init__(self, disable_colors=False):
         self.term = Terminal(disable_styling=disable_colors)
@@ -77,6 +77,7 @@
 
         num_errors = 0
         num_warnings = 0
+        num_fixed = result.fixed
         for path, errors in sorted(result.issues.items()):
             self._reset_max()
 
@@ -139,6 +140,7 @@
                 failure=", {}".format(pluralize("failure", len(failed)))
                 if failed
                 else "",
+                fixed=pluralize("fix" if num_fixed==1 else "fixe",num_fixed)
             )
         )
 

  1. I was trying to find how --fix command affects the config parameter is sent to types.py::supported_types(here) but actually it doesn't and yet when the value is returned from func(files, config, **lintargs) it is either a proper Issue type object or an empty list, So i don't know how linters realise weather they need to fix the file or not, Any information on this will be helpful. Then we can return an integer which can be recieved in roller.py (here) and result.fixed can be increased to count those as well.

I am sorry if this is not the right (or best way to do it). Please guide me, any information will be helpful.

Flags: needinfo?(sledru)

please use phabricator for pushing patches:
https://firefox-source-docs.mozilla.org/contributing/contribution_quickref.html

we don't use bugzilla for code review. thanks

Flags: needinfo?(sledru)

(In reply to Sylvestre Ledru [:Sylvestre] from comment #5)

please use phabricator for pushing patches:
https://firefox-source-docs.mozilla.org/contributing/contribution_quickref.html

we don't use bugzilla for code review. thanks

Thankyou :Sylvestre, but I dont have enough information to push a patch, please read the last point and help me out or should I go ahead and push the patch of information I have?

Yeah, please go ahead, thanks

Assignee: nobody → akshat.dixit71
Status: NEW → ASSIGNED
Attachment #9197073 - Attachment is obsolete: true
Pushed by archaeopteryx@coole-files.de: https://hg.mozilla.org/integration/autoland/rev/34576b06e591 Add lint Fixed count support to linters r=sylvestre
Status: ASSIGNED → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → 87 Branch
Product: Firefox Build System → Developer Infrastructure
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: