RESOLVED FIXED 51451
check-webkit-style should be able to parse function declaration parameters.
https://bugs.webkit.org/show_bug.cgi?id=51451
Summary check-webkit-style should be able to parse function declaration parameters.
David Levin
Reported 2010-12-21 23:02:01 PST
See summary.
Attachments
Patch (11.78 KB, patch)
2010-12-21 23:04 PST, David Levin
no flags
Patch (15.86 KB, patch)
2010-12-22 17:19 PST, David Levin
no flags
Patch (15.85 KB, patch)
2010-12-22 17:20 PST, David Levin
no flags
Patch (16.56 KB, patch)
2010-12-22 23:35 PST, David Levin
no flags
Patch (19.09 KB, patch)
2010-12-23 18:11 PST, David Levin
no flags
Patch (19.09 KB, patch)
2010-12-23 18:16 PST, David Levin
no flags
Patch (24.29 KB, patch)
2010-12-26 00:42 PST, David Levin
no flags
Patch (27.02 KB, patch)
2010-12-26 09:26 PST, David Levin
no flags
David Levin
Comment 1 2010-12-21 23:04:04 PST
David Levin
Comment 2 2010-12-22 00:32:23 PST
Comment on attachment 77192 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=77192&action=review > Tools/Scripts/webkitpy/style/checkers/cpp.py:371 > + # to ensure only the parameters remain without the surrounding paranthesis. typo: paranthesis > Tools/Scripts/webkitpy/style/checkers/cpp.py:1322 > + extra blank line
David Levin
Comment 3 2010-12-22 17:09:42 PST
Comment on attachment 77192 [details] Patch Making some improvements.
David Levin
Comment 4 2010-12-22 17:19:42 PST
David Levin
Comment 5 2010-12-22 17:20:43 PST
WebKit Review Bot
Comment 6 2010-12-22 17:20:53 PST
Attachment 77282 [details] did not pass style-queue: Failed to run "['Tools/Scripts/check-webkit-style', '--diff-files', u'Tools/ChangeLog', u'Tools/Scripts/webkitpy/style/checkers/cpp.py', u'Tools/Scripts/webkitpy/style/checkers/cpp_unittest.py']" exit_code: 1 Tools/Scripts/webkitpy/style/checkers/cpp.py:391: whitespace before ')' [pep8/E202] [5] Total errors found: 1 in 3 files If any of these errors are false positives, please file a bug against check-webkit-style.
David Levin
Comment 7 2010-12-22 23:35:37 PST
Eric Seidel (no email)
Comment 8 2010-12-23 01:18:01 PST
Comment on attachment 77308 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=77308&action=review Should we have a separate helper class for this? Seems like a lot of logic. Or at least we could break thsi huge new function down into smaller parts. > Tools/Scripts/webkitpy/style/checkers/cpp.py:352 > + def get_parameter_list(self): Do we really use get in names? This function is also huge :((
David Levin
Comment 9 2010-12-23 08:39:48 PST
Comment on attachment 77308 [details] Patch Need to address comments.
David Levin
Comment 10 2010-12-23 18:11:41 PST
WebKit Review Bot
Comment 11 2010-12-23 18:13:41 PST
Attachment 77391 [details] did not pass style-queue: Failed to run "['Tools/Scripts/check-webkit-style', '--diff-files', u'Tools/ChangeLog', u'Tools/Scripts/webkitpy/style/checkers/cpp.py', u'Tools/Scripts/webkitpy/style/checkers/cpp_unittest.py']" exit_code: 1 Tools/Scripts/webkitpy/style/checkers/cpp.py:310: expected 2 blank lines, found 1 [pep8/E302] [5] Total errors found: 1 in 3 files If any of these errors are false positives, please file a bug against check-webkit-style.
David Levin
Comment 12 2010-12-23 18:16:55 PST
David Levin
Comment 13 2010-12-23 18:20:34 PST
(In reply to comment #11) > Attachment 77391 [details] did not pass style-queue: > > Failed to run "['Tools/Scripts/check-webkit-style', '--diff-files', u'Tools/ChangeLog', u'Tools/Scripts/webkitpy/style/checkers/cpp.py', u'Tools/Scripts/webkitpy/style/checkers/cpp_unittest.py']" exit_code: 1 > Tools/Scripts/webkitpy/style/checkers/cpp.py:310: expected 2 blank lines, found 1 [pep8/E302] [5] > Total errors found: 1 in 3 files > > > If any of these errors are false positives, please file a bug against check-webkit-style. I should change the webkit-patch upload to warn you if you have local changes that aren't in the change or something like that :( (The style step warned me. I fixed it and then uploaded without committing first.)
David Levin
Comment 14 2010-12-23 18:21:02 PST
(In reply to comment #8) > (From update of attachment 77308 [details]) > View in context: https://bugs.webkit.org/attachment.cgi?id=77308&action=review > > Should we have a separate helper class for this? Seems like a lot of logic. Or at least we could break thsi huge new function down into smaller parts. > > > Tools/Scripts/webkitpy/style/checkers/cpp.py:352 > > + def get_parameter_list(self): > > Do we really use get in names? Oops. fixed. > This function is also huge :(( If you think things are still too huge or not understand, let me know and I'll work to make it better. At least, it looks a lot better than before to me.
Eric Seidel (no email)
Comment 15 2010-12-23 18:43:59 PST
Comment on attachment 77394 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=77394&action=review I don't fully understand this, but I'm also willing to rs=me. This is definitely a very cool addition to our style-checker. You might consider making it a generator instead. It would simplify the code ever-so-slightly due to not needing current or current_parameter. I guess the main part I don't undestand is PameterIterator.__init__ Tentative r+, but I'd also happily go another round if you have it in you. :) > Tools/Scripts/webkitpy/style/checkers/cpp.py:322 > + def __init__(self, clean_lines, parameters_start, parameters_end): I assume start/end are offsets in a string? > Tools/Scripts/webkitpy/style/checkers/cpp.py:327 > + # Form a single string with all parameters. Trimming the first and last lines > + # to ensure only the parameters remain without the surrounding parenthesis. > + parameters_lines = clean_lines.elided[self._starting_line:parameters_end[0] + 1] > + parameters_lines[-1] = parameters_lines[-1][:parameters_end[1] - 1] I'm confused as to what this does? parameters_lines[-1] = parameters_lines[-1]? > Tools/Scripts/webkitpy/style/checkers/cpp.py:329 > + # Form a single string with all parameters. Trimming the first and last lines > + # to ensure only the parameters remain without the surrounding parenthesis. > + parameters_lines = clean_lines.elided[self._starting_line:parameters_end[0] + 1] > + parameters_lines[-1] = parameters_lines[-1][:parameters_end[1] - 1] > > > + parameters_lines[0] = parameters_lines[0][parameters_start[1] + 1:] > + self._all_parameters = ' '.join(parameters_lines) This could be a separate function and unit tested. > Tools/Scripts/webkitpy/style/checkers/cpp.py:402 > + self._skeleton_parameters = skeleton_parameters Cleaner woudl be to just return the skeleton parameters here and initialize the self. in teh caller. Then this is also much easier to unit test. Would be nice to see some unit tests for this function. :) > Tools/Scripts/webkitpy/style/checkers/cpp.py:449 > + parameter_parser = ParameterIterator(self._clean_lines, self.parameter_start, self.parameter_end) > + while parameter_parser.next(): The python way would be a generator instead of an explicit current function. :) http://docs.python.org/tutorial/classes.html#generators But this is also fine as-is. :) Then you would just do parameter_list(self._clean_lines, ...) and that would be it. You could wrap it in tuple() if you wanted to convert it all at once.
David Levin
Comment 16 2010-12-23 18:46:00 PST
Comment on attachment 77394 [details] Patch I'll address feedback and do another round.
Shinichiro Hamaji
Comment 17 2010-12-23 19:28:24 PST
Comment on attachment 77394 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=77394&action=review A few more comments in addition to Eric's. > Tools/Scripts/webkitpy/style/checkers/cpp.py:313 > + def __init__(self, parameter, type_name_index, line_number): Is the type_name_index good name? I guess parameter_name_index would be better. > Tools/Scripts/webkitpy/style/checkers/cpp.py:316 > + self.name = sub(r'=.*', '', parameter[type_name_index:]).strip() Do we need this line? It looks like line 386 is doing this job already. > Tools/Scripts/webkitpy/style/checkers/cpp.py:399 > + if skeleton_parameters.strip(): I couldn't understand the intention of this if-clause at first. We might want a comment for this.
David Levin
Comment 18 2010-12-26 00:42:17 PST
David Levin
Comment 19 2010-12-26 09:26:34 PST
David Levin
Comment 20 2010-12-26 09:27:39 PST
Comment on attachment 77456 [details] Patch I believe that all feedback has been addressed.
David Levin
Comment 21 2010-12-26 09:30:08 PST
(In reply to comment #17) > (From update of attachment 77394 [details]) > View in context: https://bugs.webkit.org/attachment.cgi?id=77394&action=review > > Tools/Scripts/webkitpy/style/checkers/cpp.py:316 > > + self.name = sub(r'=.*', '', parameter[type_name_index:]).strip() > > Do we need this line? It looks like line 386 is doing this job already. True. Line 386 did the same thing but that was for the purpose of creating the skeleton parameters. This is operating on the original parameters. At this point, the code operates on the original parameters in order to extra the names without the modifications done during the process of creating skeleton parameters. (Of course this part of the change was still useful.)
Eric Seidel (no email)
Comment 22 2010-12-26 11:25:30 PST
Comment on attachment 77456 [details] Patch OK.
WebKit Commit Bot
Comment 23 2010-12-26 12:28:04 PST
Comment on attachment 77456 [details] Patch Clearing flags on attachment: 77456 Committed r74670: <http://trac.webkit.org/changeset/74670>
WebKit Commit Bot
Comment 24 2010-12-26 12:28:12 PST
All reviewed patches have been landed. Closing bug.
WebKit Review Bot
Comment 25 2010-12-26 14:18:49 PST
http://trac.webkit.org/changeset/74670 might have broken GTK Linux 32-bit Release The following tests are not passing: media/controls-strict.html
Note You need to log in before you can comment on or make changes to this bug.