Implement FBInfer tool in ReviewBot (WIP)

Review Request #7702 — Created Oct. 15, 2015 and discarded

Information

ReviewBot
release-0.2.x

Reviewers

Add a new static analysis tool for Android/iOS code in ReviewBot.

FBInfer is essentially another static analysis tool, like pep8 or pyflakes, that provides automatic feedback on bugs in Android/iOS apps.

This feature will add support for code written in Java, Objective-C, and C, so that Review Bot can automatically provide bug feedback regarding a review request in these languages. This is a useful tool for Review Bot to have because as of now, there are only tools for code written in Python and C++. Because a lot of programmers use Java, Objective-C, and C, especially for mobile development, it would be helpful for Review Bot to provide support for such languages.

I have tested using a local server and instance of ReviewBoard. From the testing I did, FBInfer didn't seem to be working at all to compile and provide feedback of the files.

Description From Last Updated

You are going to want to add .idea to your global git ignore.

brenniebrennie

Can you revert this change? This typo is actually fixed already in master (but not release-0.2.x, which is why you're …

anselinaanselina

Needs a docstring.

chipx86chipx86

Col: 21 E127 continuation line over-indented for visual indent

reviewbotreviewbot

Col: 14 E251 unexpected spaces around keyword / parameter equals

reviewbotreviewbot

Col: 12 E251 unexpected spaces around keyword / parameter equals

reviewbotreviewbot

Col: 5 E128 continuation line under-indented for visual indent

reviewbotreviewbot

Col: 5 E122 continuation line missing indentation or outdented

reviewbotreviewbot

I believe the executable is actually just infer, instead of fbinfer.

anselinaanselina

Col: 5 E122 continuation line missing indentation or outdented

reviewbotreviewbot

endswith can take a tuple of strings to check. I suggest defining a tuple of allowed file types on the …

chipx86chipx86

Col: 13 E131 continuation line unaligned for hanging indent

reviewbotreviewbot

Blank line between these.

chipx86chipx86

Col: 15 E251 unexpected spaces around keyword / parameter equals

reviewbotreviewbot

Col: 13 E251 unexpected spaces around keyword / parameter equals

reviewbotreviewbot

Col: 17 E251 unexpected spaces around keyword / parameter equals

reviewbotreviewbot

Col: 15 E251 unexpected spaces around keyword / parameter equals

reviewbotreviewbot

infer instead of fbinfer.

anselinaanselina

Col: 9 E123 closing bracket does not match indentation of opening bracket's line

reviewbotreviewbot

Col: 1 W391 blank line at end of file

reviewbotreviewbot

Col: 1 W391 blank line at end of file

reviewbotreviewbot

The PyCharm-specific files should not be included in this review request. To remove the .idea/* files from this RR, you …

anselinaanselina

Can you remove the extra space between """ and Performs...?

anselinaanselina

"Perform" (imperitive mood) Also, this should read something like: """A ReviewBot tool for FBInfer. FBInfer is a static analysis tool …

brenniebrennie

Blank line between these.

brenniebrennie

Add a period at the end of this sentence.

anselinaanselina

... for mobile apps.

brenniebrennie

Col: 21 E127 continuation line over-indented for visual indent

reviewbotreviewbot

Until you implement options for the infer executable, let's get rid of this variable altogether?

anselinaanselina

We don't wan't this running on all java, [obj]c[++] files, so there should probably be per-repository settings for the tool …

brenniebrennie

You can lose the outer parentheses here.

daviddavid

This can all be on one line.

daviddavid

This can be condensed down to a single statement: line_num, col, msg = line.split(':', 3)[1:]

daviddavid

We don't really need to coerce these to integers because we're not doing any processing with them.

brenniebrennie

Col: 1 W391 blank line at end of file

reviewbotreviewbot

This should not be in the project's .gitignore. This should be in your ~/.gitignore_global.

brenniebrennie

Remove this file.

brenniebrennie

"This tool performs..."

brenniebrennie

I would put this all on the next line.

brenniebrennie

Col: 21 E127 continuation line over-indented for visual indent

reviewbotreviewbot

Perhaps to avoid having to do all these repeated endswith() checks, we could instead get the extension and look it …

AD adriano

This should be infer -- javac path

brenniebrennie

This should be infer -- gcc -c path

brenniebrennie

This should be infer -- clang path

brenniebrennie

Col: 1 W391 blank line at end of file

reviewbotreviewbot

Col: 21 E127 continuation line over-indented for visual indent

reviewbotreviewbot

Col: 1 W391 blank line at end of file

reviewbotreviewbot

'logging' imported but unused

reviewbotreviewbot

Col: 21 E127 continuation line over-indented for visual indent

reviewbotreviewbot

Col: 13 E265 block comment should start with '# '

reviewbotreviewbot

Col: 13 E265 block comment should start with '# '

reviewbotreviewbot

Col: 13 E265 block comment should start with '# '

reviewbotreviewbot

Col: 1 W391 blank line at end of file

reviewbotreviewbot

I think the addition of .idea to your .gitignore file shouldn't be commited to the repository and should instead remain …

AH ahache

Col: 20 W292 no newline at end of file

reviewbotreviewbot

'logging' imported but unused

reviewbotreviewbot

Col: 17 E265 block comment should start with '# '

reviewbotreviewbot

Col: 80 E501 line too long (80 > 79 characters)

reviewbotreviewbot

Col: 17 E265 block comment should start with '# '

reviewbotreviewbot
reviewbot
  1. Tool: PEP8 Style Checker
    Processed Files:
        bot/reviewbot/tools/fbinfer.py
        bot/reviewbot/tools/cppcheck.py
    
    Ignored Files:
        .idea/.name
        .idea/misc.xml
        .idea/ReviewBot.iml
        .idea/modules.xml
        .idea/vcs.xml
        .idea/workspace.xml
    
    
  2. bot/reviewbot/tools/fbinfer.py (Diff revision 1)
     
     
    Show all issues
    Col: 21
     E127 continuation line over-indented for visual indent
    
  3. bot/reviewbot/tools/fbinfer.py (Diff revision 1)
     
     
    Show all issues
    Col: 14
     E251 unexpected spaces around keyword / parameter equals
    
  4. bot/reviewbot/tools/fbinfer.py (Diff revision 1)
     
     
    Show all issues
    Col: 12
     E251 unexpected spaces around keyword / parameter equals
    
  5. bot/reviewbot/tools/fbinfer.py (Diff revision 1)
     
     
    Show all issues
    Col: 5
     E128 continuation line under-indented for visual indent
    
  6. bot/reviewbot/tools/fbinfer.py (Diff revision 1)
     
     
    Show all issues
    Col: 5
     E122 continuation line missing indentation or outdented
    
  7. bot/reviewbot/tools/fbinfer.py (Diff revision 1)
     
     
    Show all issues
    Col: 5
     E122 continuation line missing indentation or outdented
    
  8. bot/reviewbot/tools/fbinfer.py (Diff revision 1)
     
     
    Show all issues
    Col: 13
     E131 continuation line unaligned for hanging indent
    
  9. bot/reviewbot/tools/fbinfer.py (Diff revision 1)
     
     
    Show all issues
    Col: 15
     E251 unexpected spaces around keyword / parameter equals
    
  10. bot/reviewbot/tools/fbinfer.py (Diff revision 1)
     
     
    Show all issues
    Col: 13
     E251 unexpected spaces around keyword / parameter equals
    
  11. bot/reviewbot/tools/fbinfer.py (Diff revision 1)
     
     
    Show all issues
    Col: 17
     E251 unexpected spaces around keyword / parameter equals
    
  12. bot/reviewbot/tools/fbinfer.py (Diff revision 1)
     
     
    Show all issues
    Col: 15
     E251 unexpected spaces around keyword / parameter equals
    
  13. bot/reviewbot/tools/fbinfer.py (Diff revision 1)
     
     
    Show all issues
    Col: 9
     E123 closing bracket does not match indentation of opening bracket's line
    
  14. bot/reviewbot/tools/fbinfer.py (Diff revision 1)
     
     
    Show all issues
    Col: 1
     W391 blank line at end of file
    
  15. bot/reviewbot/tools/fbinfer.py (Diff revision 1)
     
     
    Show all issues
    Col: 1
     W391 blank line at end of file
    
  16. 
      
brennie
  1. 
      
  2. .idea/.name (Diff revision 1)
     
     
    Show all issues

    You are going to want to add .idea to your global git ignore.

  3. 
      
chipx86
  1. Unfortunately, this summary and description is difficult for us to work with, since we have to then look up or remember what your project is, and other students or contributors to Review Board will have no idea.

    You should make sure that you have a detailed, informative review request. See https://www.reviewboard.org/docs/codebase/dev/writing-good-descriptions/

  2. 
      
chipx86
  1. This shouldn't include any of the files under .idea.

  2. bot/reviewbot/tools/fbinfer.py (Diff revision 1)
     
     
    Show all issues

    Needs a docstring.

  3. bot/reviewbot/tools/fbinfer.py (Diff revision 1)
     
     
     
     
     
     
    Show all issues

    endswith can take a tuple of strings to check. I suggest defining a tuple of allowed file types on the class and passing that in. For example:

    class FBINferTool(Tool):
        ...
    
        ALLOWED_EXTENSIONS = ('.java', '.c', '.h', '.m', '.mm')
    
        ...
    
        def handle_file(self, f):
            if not (f.dest_file.endswith(self.ALLOWED_EXTENSIONS)):
                ...
    
  4. bot/reviewbot/tools/fbinfer.py (Diff revision 1)
     
     
     
    Show all issues

    Blank line between these.

  5. 
      
anselina
  1. Looks like you're on the right path! The workers find installed tools through entry points, so you'll need to add a new entry-point for Infer in bot/setup.py before you can test it.

  2. bot/reviewbot/tools/cppcheck.py (Diff revision 1)
     
     
    Show all issues

    Can you revert this change? This typo is actually fixed already in master (but not release-0.2.x, which is why you're seeing this).

  3. bot/reviewbot/tools/fbinfer.py (Diff revision 1)
     
     
    Show all issues

    I believe the executable is actually just infer, instead of fbinfer.

  4. bot/reviewbot/tools/fbinfer.py (Diff revision 1)
     
     
    Show all issues

    infer instead of fbinfer.

  5. 
      
CA
reviewbot
  1. Tool: PEP8 Style Checker
    Processed Files:
        bot/reviewbot/tools/fbinfer.py
    
    Ignored Files:
        .idea/.name
        .gitignore
        .idea/misc.xml
        .idea/ReviewBot.iml
        .idea/modules.xml
        .idea/vcs.xml
        .idea/workspace.xml
    
    
    
    Tool: Pyflakes
    Processed Files:
        bot/reviewbot/tools/fbinfer.py
    
    Ignored Files:
        .idea/.name
        .gitignore
        .idea/misc.xml
        .idea/ReviewBot.iml
        .idea/modules.xml
        .idea/vcs.xml
        .idea/workspace.xml
    
    
  2. bot/reviewbot/tools/fbinfer.py (Diff revision 2)
     
     
    Show all issues
    Col: 21
     E127 continuation line over-indented for visual indent
    
  3. bot/reviewbot/tools/fbinfer.py (Diff revision 2)
     
     
    Show all issues
    Col: 1
     W391 blank line at end of file
    
  4. 
      
CA
chipx86
  1. The summary and description are going into the commit message, so they need to be self-describing and make sense independently of any code or other discussions taking place. You can reference this guide for some examples: https://www.reviewboard.org/docs/codebase/dev/writing-good-descriptions/

  2. 
      
anselina
  1. Looks like you should be ready to test the Infer tool this week!

  2. .gitignore (Diff revision 2)
     
     
    Show all issues

    The PyCharm-specific files should not be included in this review request. To remove the .idea/* files from this RR, you will probably need to do something like:

    git rm .idea/*
    git commit -m "Removed IDEA files."
    rbt post -r 7702
    
    1. Once you do that, you should do the following:

      git config --global core.excludesfile '~/.gitignore_global'
      echo >> .idea/* ~/.gitignore_global
      

      That way, .idea files will never be added.

    2. That second line has a typo!

      It should be:

      echo '.idea/*' >> ~/.gitignore_global
      

      Sorry!

  3. bot/reviewbot/tools/fbinfer.py (Diff revision 2)
     
     
    Show all issues

    Can you remove the extra space between """ and Performs...?

  4. bot/reviewbot/tools/fbinfer.py (Diff revision 2)
     
     
    Show all issues

    Add a period at the end of this sentence.

  5. bot/reviewbot/tools/fbinfer.py (Diff revision 2)
     
     
    Show all issues

    Until you implement options for the infer executable, let's get rid of this variable altogether?

  6. 
      
CA
david
  1. 
      
    1. Oh, also, if you've fixed issues raised in previous reviews, please mark them as "Fixed".

    2. Hi David, do you want me to mark the ReviewBot issues as "Fixed" as well?

    3. Yes. We use the open-issue count as a way of prioritizing when we review things, so if there are a bunch of open issues, we're less likely to look at it. Whenever you fix anything (regardless of the reviewer), please close the issues.

  2. bot/reviewbot/tools/fbinfer.py (Diff revision 2)
     
     
    Show all issues

    You can lose the outer parentheses here.

  3. bot/reviewbot/tools/fbinfer.py (Diff revision 2)
     
     
     
     
     
     
     
    Show all issues

    This can all be on one line.

  4. 
      
david
  1. 
      
  2. bot/reviewbot/tools/fbinfer.py (Diff revision 2)
     
     
     
     
     
    Show all issues

    This can be condensed down to a single statement:

    line_num, col, msg = line.split(':', 3)[1:]
    
  3. 
      
brennie
  1. 
      
  2. bot/reviewbot/tools/fbinfer.py (Diff revision 2)
     
     
    Show all issues

    "Perform" (imperitive mood)

    Also, this should read something like:

    """A ReviewBot tool for FBInfer.
    
    FBInfer is a static analysis tool for mobile apps written in ObjC, Java, and C.
    """
    
  3. bot/reviewbot/tools/fbinfer.py (Diff revision 2)
     
     
     
    Show all issues

    Blank line between these.

  4. bot/reviewbot/tools/fbinfer.py (Diff revision 2)
     
     
    Show all issues

    ... for mobile apps.

  5. bot/reviewbot/tools/fbinfer.py (Diff revision 2)
     
     
    Show all issues

    We don't wan't this running on all java, [obj]c[++] files, so there should probably be per-repository settings for the tool

    (Forgive me if this is already a thing Review Bot does -- I'm not super familiar with it.)

    1. Ah okay, so it should only be running on mobile apps right?

    2. Yes.

  6. bot/reviewbot/tools/fbinfer.py (Diff revision 2)
     
     
     
    Show all issues

    We don't really need to coerce these to integers because we're not doing any processing with them.

    1. Hey Barret, what do you mean by this?

    2. What I mean is, you don't need to call int() here because you're not doing integer-specific things with the values -- you're putting them into a string. It'll be faster if you don't use int()

  7. 
      
CA
reviewbot
  1. Tool: Pyflakes
    Processed Files:
        bot/setup.py
        bot/reviewbot/tools/fbinfer.py
    
    Ignored Files:
        .idea/.name
        .gitignore
    
    
    
    Tool: PEP8 Style Checker
    Processed Files:
        bot/setup.py
        bot/reviewbot/tools/fbinfer.py
    
    Ignored Files:
        .idea/.name
        .gitignore
    
    
  2. bot/reviewbot/tools/fbinfer.py (Diff revision 3)
     
     
    Show all issues
    Col: 21
     E127 continuation line over-indented for visual indent
    
  3. bot/reviewbot/tools/fbinfer.py (Diff revision 3)
     
     
    Show all issues
    Col: 1
     W391 blank line at end of file
    
  4. 
      
AD
  1. 
      
  2. bot/reviewbot/tools/fbinfer.py (Diff revision 3)
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
    Show all issues

    Perhaps to avoid having to do all these repeated endswith() checks, we could instead get the extension and look it up in a precomputed dictionary. For example, something like:

    import os
    
    COMPILER_MAP = {
        '.java': 'javac',
        '.h': 'gcc',
        '.c': 'gcc',
        '.m': 'clang',
        '.mm': 'clang',
    }
    
    # ... other code goes here ...
    
    def handle_file(self, f):
        extension = os.path.splitext(f.dest_file)[1]
        compiler = COMPILER_MAP.get(extension, None)
    
        if not compiler:
            return False
    
        path = f.get_patched_file_path()
    
        if not path:
            return False
    
        output = execute(
            [compiler, path],
            split_lines=True,
            ignore_errors=True
        )
    
        # ... rest of code goes here ...
    
  3. 
      
brennie
  1. 
      
  2. bot/reviewbot/tools/fbinfer.py (Diff revision 3)
     
     
    Show all issues

    "This tool performs..."

  3. bot/reviewbot/tools/fbinfer.py (Diff revision 3)
     
     
     
     
    Show all issues

    I would put this all on the next line.

  4. bot/reviewbot/tools/fbinfer.py (Diff revision 3)
     
     
    Show all issues

    This should be infer -- javac path

  5. bot/reviewbot/tools/fbinfer.py (Diff revision 3)
     
     
    Show all issues

    This should be infer -- gcc -c path

  6. bot/reviewbot/tools/fbinfer.py (Diff revision 3)
     
     
    Show all issues

    This should be infer -- clang path

  7. 
      
brennie
  1. 
      
  2. .gitignore (Diff revision 3)
     
     
    Show all issues

    This should not be in the project's .gitignore. This should be in your ~/.gitignore_global.

  3. .idea/.name (Diff revision 3)
     
     
    Show all issues

    Remove this file.

  4. 
      
CA
reviewbot
  1. Tool: Pyflakes
    Processed Files:
        bot/setup.py
        bot/reviewbot/tools/fbinfer.py
    
    Ignored Files:
        .idea/.name
        .gitignore
    
    
    
    Tool: PEP8 Style Checker
    Processed Files:
        bot/setup.py
        bot/reviewbot/tools/fbinfer.py
    
    Ignored Files:
        .idea/.name
        .gitignore
    
    
  2. bot/reviewbot/tools/fbinfer.py (Diff revision 4)
     
     
    Show all issues
    Col: 21
     E127 continuation line over-indented for visual indent
    
  3. bot/reviewbot/tools/fbinfer.py (Diff revision 4)
     
     
    Show all issues
    Col: 1
     W391 blank line at end of file
    
  4. 
      
CA
reviewbot
  1. Tool: PEP8 Style Checker
    Processed Files:
        bot/setup.py
        bot/reviewbot/tools/fbinfer.py
    
    Ignored Files:
        .idea/.name
        .gitignore
    
    
    
    Tool: Pyflakes
    Processed Files:
        bot/setup.py
        bot/reviewbot/tools/fbinfer.py
    
    Ignored Files:
        .idea/.name
        .gitignore
    
    
  2. bot/reviewbot/tools/fbinfer.py (Diff revision 5)
     
     
    Show all issues
     'logging' imported but unused
    
  3. bot/reviewbot/tools/fbinfer.py (Diff revision 5)
     
     
    Show all issues
    Col: 21
     E127 continuation line over-indented for visual indent
    
  4. bot/reviewbot/tools/fbinfer.py (Diff revision 5)
     
     
    Show all issues
    Col: 13
     E265 block comment should start with '# '
    
  5. bot/reviewbot/tools/fbinfer.py (Diff revision 5)
     
     
    Show all issues
    Col: 13
     E265 block comment should start with '# '
    
  6. bot/reviewbot/tools/fbinfer.py (Diff revision 5)
     
     
    Show all issues
    Col: 13
     E265 block comment should start with '# '
    
  7. bot/reviewbot/tools/fbinfer.py (Diff revision 5)
     
     
    Show all issues
    Col: 1
     W391 blank line at end of file
    
  8. 
      
CA
reviewbot
  1. Tool: Pyflakes
    Processed Files:
        bot/setup.py
        bot/reviewbot/tools/fbinfer.py
    
    Ignored Files:
        .idea/.name
        .gitignore
    
    
    
    Tool: PEP8 Style Checker
    Processed Files:
        bot/setup.py
        bot/reviewbot/tools/fbinfer.py
    
    Ignored Files:
        .idea/.name
        .gitignore
    
    
  2. bot/reviewbot/tools/fbinfer.py (Diff revision 6)
     
     
    Show all issues
    Col: 20
     W292 no newline at end of file
    
  3. 
      
AH
  1. 
      
  2. .gitignore (Diff revision 6)
     
     
    Show all issues

    I think the addition of .idea to your .gitignore file shouldn't be commited to the repository and should instead remain only on your local setup.
    One approach to doing this would be to revert this change, and once it's resolved, you can add both .idea to your ignore file, as well as .gitignore, that way changes done to it won't be tracked.
    There may be a better way of doing this, but this is how I've done it before.

  3. 
      
CA
reviewbot
  1. Tool: Pyflakes
    Processed Files:
        bot/setup.py
        bot/reviewbot/tools/fbinfer.py
    
    Ignored Files:
        .idea/.name
        .gitignore
    
    
    
    Tool: PEP8 Style Checker
    Processed Files:
        bot/setup.py
        bot/reviewbot/tools/fbinfer.py
    
    Ignored Files:
        .idea/.name
        .gitignore
    
    
  2. bot/reviewbot/tools/fbinfer.py (Diff revision 7)
     
     
    Show all issues
     'logging' imported but unused
    
  3. bot/reviewbot/tools/fbinfer.py (Diff revision 7)
     
     
    Show all issues
    Col: 17
     E265 block comment should start with '# '
    
  4. bot/reviewbot/tools/fbinfer.py (Diff revision 7)
     
     
    Show all issues
    Col: 80
     E501 line too long (80 > 79 characters)
    
  5. bot/reviewbot/tools/fbinfer.py (Diff revision 7)
     
     
    Show all issues
    Col: 17
     E265 block comment should start with '# '
    
  6. 
      
david
Review request changed
Status:
Discarded