flake8
-
bot/reviewbot/tools/fbinfer.py (Diff revision 1) Show all issues -
-
-
bot/reviewbot/tools/fbinfer.py (Diff revision 1) E124 closing bracket does not match visual indentation
-
-
Review Request #11202 — Created Sept. 24, 2020 and submitted
FBInfer Tool is now working for all the following build configurations:
The usability of this tool is largely dependent on the setup of a
user's ReviewBoard environment. Meaning that if a user would like to
use Review Bot to test an Android project. The user must have a working
Android SDK in the server instance in which the Review Bot is pulling
down the repository. Setups for each particular environment will be
offered in the documentation. The latest revisions include
optimizations that reduce the usage of infer run
. So that it is
executed minimally, to enhance speed and efficiency.
Each build configuration was tested manually with its own environment
and repository. More information about the tests can be found in
Week 3 and Week 4 of my Notion journal: https://bit.ly/351ttRQ.
Description | From | Last Updated |
---|---|---|
Can you update the screenshot to show the latest text? |
david | |
Summary should say "Review Bot", rather than "ReviewBot." We've altered the name a bit, but still have places where we … |
chipx86 | |
Something seems to have gone wrong with the hange description. Guessing it's because there's no blank line before or after … |
chipx86 | |
F401 'reviewbot.utils.process.execute' imported but unused |
reviewbot | |
E302 expected 2 blank lines, found 1 |
reviewbot | |
W293 blank line contains whitespace |
reviewbot | |
E124 closing bracket does not match visual indentation |
reviewbot | |
E303 too many blank lines (2) |
reviewbot | |
W391 blank line at end of file |
reviewbot | |
F401 'reviewbot.utils.process.execute' imported but unused |
reviewbot | |
W291 trailing whitespace |
reviewbot | |
Could you add a comment at the start of the file? e.g. Following the doc8.py, """Review Bot tool to run … |
ceciliawei | |
Yep, that is definitely an artifact from shuffling my code around. Good catch, seems that flake8 did not complain about … |
jblazusi | |
Were you intended to put the command in the end? Shouldn't it just be list.extend(...)? |
ceciliawei | |
Since this change is in another CR for review, is it possible to remove the change from this CR? So … |
ceciliawei | |
I was reading something related to json then I thought about this code review. Would it be helpful to put … |
ceciliawei | |
This should probably be dedented one space. |
david | |
This should use single quotes. |
david | |
Let's use double quotes around "build" |
david | |
Let's add a trailing comma to this line. |
david | |
This should use single quotes. |
david | |
Let's add a trailing comma to this line. |
david | |
This should use single quotes. |
david | |
Let's use double quotes around "iphonesimulator", which lets us avoid the \\ characters. |
david | |
Let's add a trailing comma to this line. |
david | |
Can you add periods to the end of the comments in here? This line and others below. |
david | |
Let's add a trailing comma to this line. |
david | |
There are a bunch of places where we use settings['build_type']. Perhaps pull that out into a build_type variable? |
david | |
Let's add a trailing comma to this line. |
david | |
Please add a blank line between these two. |
david | |
Add a blank line between these two please. |
david | |
The comma within the function call here can go away. |
david | |
I don't think we need to list the file here, since the diff comment will be attached to the file … |
david | |
Just for consistency, can we call the entry point fbinfer? |
david | |
I just realized, we should use shlex.split(build_type) here, to parse it as a shell would. Otherwise if there are quoted … |
david | |
"fbinfer" or "FBInfer"? |
chipx86 | |
How about putting the string inside of the () on the next line, indented 4 spaces? That'll give it breathing … |
chipx86 | |
This can be one statement. |
chipx86 | |
You'll want a try/except around this, since it can fail. |
chipx86 | |
Typo: "compilation". The comment could use an adjustment. I wasn't sure at first glance what it was saying. |
chipx86 | |
How about: build_type = 'make' settings['build_type'] = build_type This is a bit cleaner, since you're not having to store a … |
chipx86 | |
It's best to use += instead of .extend(). Operators are faster to invoke than functions. |
chipx86 | |
Better to use += here too. |
chipx86 | |
And here. |
chipx86 | |
This will need a try/except. |
chipx86 | |
This becomes a bit easier to see as one concrete operation if you do: execute(['infer', 'run', '--'] + shlex.split(build_type) + … |
chipx86 | |
+= here as well. |
chipx86 | |
This needs a try/except. |
chipx86 | |
fp is the standard variable for a file pointer when opening a file. You should also specify an explicit mode … |
chipx86 | |
Can we break after this match? |
chipx86 | |
Formatting will be more consistent with our standards by doing: f.comment('Bug Type: %s\n%s: %s' % (entry['bug_type_hum'], entry['severity'] entry['qualifier']), entry['line']) Or, … |
chipx86 | |
No blank line here. |
chipx86 | |
E128 continuation line under-indented for visual indent |
reviewbot | |
E231 missing whitespace after ',' |
reviewbot | |
If you make the change to handle_files that I suggested below, then cmake should be added to this list as … |
david | |
By my reading of the code, if the build type is one of multi_file_build_types, we'll never load the report and … |
david | |
Would it be better to initialize build_type in __init__ instead of defining it in the method? |
ceciliawei | |
Same comment as in the other CR. |
ceciliawei | |
^ |
ceciliawei | |
^ |
ceciliawei |
bot/reviewbot/tools/fbinfer.py (Diff revision 1) |
---|
bot/reviewbot/tools/fbinfer.py (Diff revision 1) |
---|
E124 closing bracket does not match visual indentation
Commit: |
|
||||
---|---|---|---|---|---|
Diff: |
Revision 2 (+56) |
bot/reviewbot/tools/fbinfer.py (Diff revision 2) |
---|
F401 'reviewbot.utils.process.execute' imported but unused
Commit: |
|
||||
---|---|---|---|---|---|
Diff: |
Revision 3 (+106 -1) |
Commit: |
|
||||
---|---|---|---|---|---|
Diff: |
Revision 4 (+106 -1) |
Description: |
|
|||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Testing Done: |
|
|||||||||||||||||||||
Groups: |
|
|||||||||||||||||||||
People: |
|
|||||||||||||||||||||
Added Files: |
Description: |
|
|||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Testing Done: |
|
bot/reviewbot/tools/fbinfer.py (Diff revision 4) |
---|
Could you add a comment at the start of the file? e.g. Following the doc8.py,
"""Review Bot tool to run doc8.""" from __future__ import unicode_literals import logging from reviewbot.tools import Tool from reviewbot.utils.process import execute, is_exe_in_path
Commit: |
|
||||
---|---|---|---|---|---|
Diff: |
Revision 5 (+182 -1) |
Summary: |
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Description: |
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Testing Done: |
|
Description: |
|
---|
Description: |
|
---|
bot/reviewbot/tools/fbinfer.py (Diff revision 5) |
---|
Were you intended to put the command in the end? Shouldn't it just be
list.extend(...)
?
extension/reviewbotext/resources.py (Diff revision 5) |
---|
Since this change is in another CR for review, is it possible to remove the change from this CR? So that the description could reflect the content better.
bot/reviewbot/tools/fbinfer.py (Diff revision 5) |
---|
Yep, that is definitely an artifact from shuffling my code around. Good catch, seems that flake8 did not complain about this.
Commit: |
|
||||
---|---|---|---|---|---|
Diff: |
Revision 6 (+182 -1) |
Description: |
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Testing Done: |
|
Commit: |
|
||||
---|---|---|---|---|---|
Diff: |
Revision 7 (+175) |
bot/reviewbot/tools/fbinfer.py (Diff revision 7) |
---|
I was reading something related to json then I thought about this code review. Would it be helpful to put the
json.load(file)
in a try/catch block and add loggings? e.g.
try: # json.load except Exception as e: logger.exception('Could not read the json: %s', e)
Commit: |
|
||||
---|---|---|---|---|---|
Diff: |
Revision 8 (+182) |
This is looking great. There are a bunch of comments here but they're pretty much all just style nitpicks.
bot/reviewbot/tools/fbinfer.py (Diff revision 8) |
---|
Let's use double quotes around "iphonesimulator", which lets us avoid the
\\
characters.
bot/reviewbot/tools/fbinfer.py (Diff revision 8) |
---|
Can you add periods to the end of the comments in here? This line and others below.
bot/reviewbot/tools/fbinfer.py (Diff revision 8) |
---|
There are a bunch of places where we use
settings['build_type']
. Perhaps pull that out into abuild_type
variable?
bot/reviewbot/tools/fbinfer.py (Diff revision 8) |
---|
The comma within the function call here can go away.
bot/reviewbot/tools/fbinfer.py (Diff revision 8) |
---|
I don't think we need to list the file here, since the diff comment will be attached to the file already.
Adjusted code with respect to David's requests.
Commit: |
|
||||
---|---|---|---|---|---|
Diff: |
Revision 9 (+186) |
Commit: |
|
||||
---|---|---|---|---|---|
Diff: |
Revision 10 (+219) |
Description: |
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Added Files: |
bot/reviewbot/tools/fbinfer.py (Diff revision 10) |
---|
I just realized, we should use
shlex.split(build_type)
here, to parse it as a shell would. Otherwise if there are quoted arguments it might not be correct.
Commit: |
|
||||
---|---|---|---|---|---|
Diff: |
Revision 11 (+220) |
Summary should say "Review Bot", rather than "ReviewBot." We've altered the name a bit, but still have places where we have the old version.
Something seems to have gone wrong with the hange description. Guessing it's because there's no blank line before or after the list, which is needed for Markdown so it doesn't turn into italics.
bot/reviewbot/tools/fbinfer.py (Diff revision 11) |
---|
How about putting the string inside of the
()
on the next line, indented 4 spaces? That'll give it breathing room. Like:{ ... 'help_text': ( 'Include a ...' '...' ), }
bot/reviewbot/tools/fbinfer.py (Diff revision 11) |
---|
You'll want a
try/except
around this, since it can fail.
bot/reviewbot/tools/fbinfer.py (Diff revision 11) |
---|
Typo: "compilation".
The comment could use an adjustment. I wasn't sure at first glance what it was saying.
bot/reviewbot/tools/fbinfer.py (Diff revision 11) |
---|
How about:
build_type = 'make' settings['build_type'] = build_type
This is a bit cleaner, since you're not having to store a value and then look it up immediately after.
bot/reviewbot/tools/fbinfer.py (Diff revision 11) |
---|
It's best to use
+=
instead of.extend()
. Operators are faster to invoke than functions.
bot/reviewbot/tools/fbinfer.py (Diff revision 11) |
---|
This becomes a bit easier to see as one concrete operation if you do:
execute(['infer', 'run', '--'] + shlex.split(build_type) + [path])
bot/reviewbot/tools/fbinfer.py (Diff revision 11) |
---|
fp
is the standard variable for a file pointer when opening a file.You should also specify an explicit mode parameter.
One last thing: This can fail (due to non-existence or permissions issues), so you will need to capture exceptions here. Maybe move this into the
try
.
bot/reviewbot/tools/fbinfer.py (Diff revision 11) |
---|
Formatting will be more consistent with our standards by doing:
f.comment('Bug Type: %s\n%s: %s' % (entry['bug_type_hum'], entry['severity'] entry['qualifier']), entry['line'])
Or, maybe better:
f.comment('Bug Type: %(bug_type_hum)s\n' '%(severity)s %(qualifier)s' % entry, entry['line'])
By the way, is it
bug_type_hum
orbug_type_num
?
Addressed comments made by Christian.
Summary: |
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Description: |
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Commit: |
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
People: |
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Diff: |
Revision 12 (+215) |
bot/reviewbot/tools/fbinfer.py (Diff revision 12) |
---|
E128 continuation line under-indented for visual indent
Addressed styling issues raised by Review Bot.
Description: |
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Commit: |
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Diff: |
Revision 13 (+215) |
I just noticed a pretty significant bug with the
multi_file_build_types
. It will require some reworking, but other than that much of this implementation looks very solid.
bot/reviewbot/tools/fbinfer.py (Diff revision 13) |
---|
If you make the change to
handle_files
that I suggested below, thencmake
should be added to this list as well.
bot/reviewbot/tools/fbinfer.py (Diff revision 13) |
---|
By my reading of the code, if the build type is one of
multi_file_build_types
, we'll never load the report and create comments.I think perhaps we should split things up so that this method is very simple:
if settings['build_type'] in self.multi_file_build_types: self.run_multi_file_build(files) else: for f in files: self.run_single_file_build(f)
We can then have
run_multi_file_build
do all the infer_cmd work that's done above here (plus actually loadreport.json
and create comments for any files that are changed), andrun_single_file_build
would look a lot like what your currenthandle_file
implementation looks like.
Fixed major bug that David pointed out and restructured some code into functions for easier readability.
Commit: |
|
||||
---|---|---|---|---|---|
Diff: |
Revision 14 (+239) |
bot/reviewbot/tools/fbinfer.py (Diff revision 14) |
---|
Would it be better to initialize
build_type
in__init__
instead of defining it in the method?
Fixed
logger.exception
formatting.
Commit: |
|
||||
---|---|---|---|---|---|
Diff: |
Revision 15 (+237) |