Bug 33620 - check-webkit-style: Move error() from cpp_style.py to checker.py
Summary: check-webkit-style: Move error() from cpp_style.py to checker.py
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Tools / Tests (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Chris Jerdonek
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-01-13 13:06 PST by Chris Jerdonek
Modified: 2010-01-14 02:19 PST (History)
6 users (show)

See Also:


Attachments
Proposed patch (22.92 KB, patch)
2010-01-13 20:59 PST, Chris Jerdonek
hamaji: review+
cjerdonek: commit-queue-
Details | Formatted Diff | Diff
Proposed patch 2 (23.90 KB, patch)
2010-01-13 23:07 PST, Chris Jerdonek
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Jerdonek 2010-01-13 13:06:33 PST
This is part of the FIXME to move more code from cpp_style.py to checker.py, where appropriate.
Comment 1 Chris Jerdonek 2010-01-13 20:59:13 PST
Created attachment 46538 [details]
Proposed patch
Comment 2 Chris Jerdonek 2010-01-13 21:03:14 PST
(In reply to comment #1)
> Created an attachment (id=46538) [details]
> Proposed patch

I noticed that we can also now remove this line from cpp_style_unittest.py:

> from checker import CategoryFilter

I'll do that after the review.
Comment 3 Shinichiro Hamaji 2010-01-13 22:17:51 PST
Comment on attachment 46538 [details]
Proposed patch

Looks a sane code migration.

> -    def __init__(self, output_format, verbosity=1, filter=None,
> +    def __init__(self, output_format="emacs", verbosity=1, filter=None,

I think we can utilize DEFAULT_OUTPUT_FORMAT and DEFAULT_VERBOSITY?

> +        if ((verbosity < 1) or (verbosity > 5)):

I think we usually don't have parentheses for the condition of if-statement, but I don't care. Please remove them if you have no preference about this.

> +        ProcessorOptions() # No ValueError: works

I slightly prefer to examine the constructed value if it has sane attributes.

> +        # Spurious white space in filter rules.
> +        (files, options) = parse(['--filter=+foo ,-bar'])
> +        self.assertEquals(options.filter,
> +                          CategoryFilter(["-", "+whitespace", "+foo", "-bar"]))

Thanks for adding this!
Comment 4 Chris Jerdonek 2010-01-13 23:05:27 PST
(In reply to comment #3)

Thanks for the quick review, Shinichiro!  Submitting patch for cq shortly.

> > -    def __init__(self, output_format, verbosity=1, filter=None,
> > +    def __init__(self, output_format="emacs", verbosity=1, filter=None,
> 
> I think we can utilize DEFAULT_OUTPUT_FORMAT and DEFAULT_VERBOSITY?

The default parameter values above are meant more for convenience and internal use (like unit testing) rather than to be substantive.  That is why, for example, the default filter here should be the empty rule rather than the global variable list of filter rules for check-webkit-style.  Maybe in a future patch I can rename the DEFAULT values to something like SCRIPT_DEFAULT_OUTPUT_FORMAT to make clearer the distinction that those global variable defaults are for use by check-webkit-style.

> 
> > +        if ((verbosity < 1) or (verbosity > 5)):
> 
> I think we usually don't have parentheses for the condition of if-statement,
> but I don't care. Please remove them if you have no preference about this.

Thanks for the catch.  I also made this same change in a second place in the file.

> 
> > +        ProcessorOptions() # No ValueError: works
> 
> I slightly prefer to examine the constructed value if it has sane attributes.

Good suggestion.  Done.
Comment 5 Chris Jerdonek 2010-01-13 23:07:00 PST
Created attachment 46543 [details]
Proposed patch 2
Comment 6 Shinichiro Hamaji 2010-01-14 01:06:38 PST
Comment on attachment 46543 [details]
Proposed patch 2

Thanks for the description and fixing issues. I've found you fixed s/self.handle_error/self._handle_error/ . Thanks for catching this issue and sorry I didn't notice it. I think this means we want StyleCheckerTest later. Could you work for this? Otherwise, I'll write it.
Comment 7 Chris Jerdonek 2010-01-14 01:21:11 PST
(In reply to comment #6)
> (From update of attachment 46543 [details])
> Thanks for the description and fixing issues. I've found you fixed
> s/self.handle_error/self._handle_error/ . Thanks for catching this issue and
> sorry I didn't notice it. I think this means we want StyleCheckerTest later.
> Could you work for this? Otherwise, I'll write it.

I wasn't planning on doing it soon.  If you could do it, that would be great.  Thanks.
Comment 8 WebKit Commit Bot 2010-01-14 02:19:20 PST
Comment on attachment 46543 [details]
Proposed patch 2

Clearing flags on attachment: 46543

Committed r53251: <http://trac.webkit.org/changeset/53251>
Comment 9 WebKit Commit Bot 2010-01-14 02:19:26 PST
All reviewed patches have been landed.  Closing bug.