[Webkit-unassigned] [Bug 27291] Support lint for patches
bugzilla-daemon at webkit.org
bugzilla-daemon at webkit.org
Tue Jul 21 02:00:24 PDT 2009
https://bugs.webkit.org/show_bug.cgi?id=27291
--- Comment #8 from Shinichiro Hamaji <hamaji at chromium.org> 2009-07-21 02:00:24 PDT ---
> The changes done here look good but I think you missed the call in def main()
> to process_file(filename, _cpplint_state.verbose_level)
> It should be easy enough to set the verbose level and omit the second
> parameter.
Ah, thanks, fixed.
> Consider doing this
>
> """ ....""" % {'program_name' sys.argv[0]}
> In the description text replace "webkit-run-lint" and "cpplint" with
> "%{program_name}s"
There is one more change other than the program name. Though cpplint.py
requires at least one file in the arguments and this was mentioned in _USAGE of
cpplint.py, webkit-run-lint is not. I think we will eventually remove main()
and _USAGE from cpplint module when webkit-run-lint is ready. So, can i leave
the copy of _USAGE in run-webkit-lint for now?
> Consider creating this on demand, so if there are no lint errors, it just
> doesn't get created. Like this:
>
> line_numbers = None
> > +
> > + def error_for_patch(filename, line_number, category, confidence, message):
> > + """Wrapper function of cpplint.error for patches.
> > +
> > + This function outputs errors only if the line number
> > + corresponds to lines which are modified or added.
> > + """
> if line_numbers is None:
> line_numbers = set()
> for line in diff.lines:
> line_numbers.add(line[1])
>
> > + if line_number in line_numbers:
> > + cpplint.error(filename, line_number, category, confidence, message)
> > +
> > + cpplint.process_file(filename, error=error_for_patch)
Ah, nice suggestion. However, Python seems not to like this as is. It says:
UnboundLocalError: local variable 'line_numbers' referenced before assignment
I'm not sure what is the best way to fix, but I initialized line_numbers by an
empty set. Maybe it's OK as valid diff chunks should have at least one diff
line.
--
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
More information about the webkit-unassigned
mailing list