Add a fixed issues count to the ResultSummary
Categories
(Developer Infrastructure :: Lint and Formatting, task)
Tracking
(firefox87 fixed)
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.
Comment 2•4 years ago
|
||
Hi, i think i can work on this, can you please answer my few doubts:
- Are we required to implement this in each linter?
- 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?
- 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.
Comment 3•4 years ago
|
||
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
Assignee | ||
Comment 4•4 years ago
|
||
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) :
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
python/mozlint/mozlint/formatters/stylish.py
In this file what we can modifyfmt,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)
)
)
- I was trying to find how
--fix
command affects the config parameter is sent totypes.py::supported_types
(here) but actually it doesn't and yet when the value is returned fromfunc(files, config, **lintargs)
it is either a properIssue
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 inroller.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.
Comment 5•4 years ago
|
||
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
Assignee | ||
Comment 6•4 years ago
|
||
(In reply to Sylvestre Ledru [:Sylvestre] from comment #5)
please use phabricator for pushing patches:
https://firefox-source-docs.mozilla.org/contributing/contribution_quickref.htmlwe 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?
Comment 7•4 years ago
|
||
Yeah, please go ahead, thanks
Assignee | ||
Comment 8•4 years ago
|
||
Updated•4 years ago
|
Assignee | ||
Comment 9•4 years ago
|
||
Updated•4 years ago
|
Comment 10•4 years ago
|
||
Comment 11•4 years ago
|
||
bugherder |
Updated•3 years ago
|
Description
•