tristanlatr/WPWatcher

View on GitHub
wpwatcher/cli.py

Summary

Maintainability
B
5 hrs
Test Coverage

File cli.py has 293 lines of code (exceeds 250 allowed). Consider refactoring.
Open

"""
Command line arguments and specific options. 
"""

# Main program, parse the args, read config and launch scans
Severity: Minor
Found in wpwatcher/cli.py - About 3 hrs to fix

    Cyclomatic complexity is too high in function main. (9)
    Open

    def main(_args: Optional[Sequence[Text]] = None) -> None:
        """Main program entrypoint"""
        # Parse arguments
        args: argparse.Namespace = get_arg_parser().parse_args(_args)
    
    
    Severity: Minor
    Found in wpwatcher/cli.py by radon

    Cyclomatic Complexity

    Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

    Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

    Construct Effect on CC Reasoning
    if +1 An if statement is a single decision.
    elif +1 The elif statement adds another decision.
    else +0 The else statement does not cause a new decision. The decision is at the if.
    for +1 There is a decision at the start of the loop.
    while +1 There is a decision at the while statement.
    except +1 Each except branch adds a new conditional path of execution.
    finally +0 The finally block is unconditionally executed.
    with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
    assert +1 The assert statement internally roughly equals a conditional statement.
    Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
    Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

    Source: http://radon.readthedocs.org/en/latest/intro.html

    Cyclomatic complexity is too high in function show. (8)
    Open

    def show(urlpart: str, filepath: Optional[str] = None, daemon: bool = False, format:str='cli') -> None:
        """Inspect a report in database"""
        db = DataBase(filepath, daemon=daemon)
        matching_reports = [r for r in db._data if urlpart in r["site"]]
        eq_reports = [r for r in db._data if urlpart == r["site"]]
    Severity: Minor
    Found in wpwatcher/cli.py by radon

    Cyclomatic Complexity

    Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

    Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

    Construct Effect on CC Reasoning
    if +1 An if statement is a single decision.
    elif +1 The elif statement adds another decision.
    else +0 The else statement does not cause a new decision. The decision is at the if.
    for +1 There is a decision at the start of the loop.
    while +1 There is a decision at the while statement.
    except +1 Each except branch adds a new conditional path of execution.
    finally +0 The finally block is unconditionally executed.
    with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
    assert +1 The assert statement internally roughly equals a conditional statement.
    Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
    Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

    Source: http://radon.readthedocs.org/en/latest/intro.html

    Function get_arg_parser has 35 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    def get_arg_parser() -> argparse.ArgumentParser:
        """Parse CLI arguments, arguments can overwrite config file values"""
    
        parser = argparse.ArgumentParser(
            description=f"""WordPress Watcher is a Python wrapper for WPScan that manages scans on multiple sites and reports by email.
    Severity: Minor
    Found in wpwatcher/cli.py - About 1 hr to fix

      Function main has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

      def main(_args: Optional[Sequence[Text]] = None) -> None:
          """Main program entrypoint"""
          # Parse arguments
          args: argparse.Namespace = get_arg_parser().parse_args(_args)
      
      
      Severity: Minor
      Found in wpwatcher/cli.py - About 55 mins to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Trailing whitespace
      Open

      Command line arguments and specific options. 
      Severity: Minor
      Found in wpwatcher/cli.py by pep8

      Trailing whitespace is superfluous.

      The warning returned varies on whether the line itself is blank,
      for easier filtering for those who want to indent their blank lines.
      
      Okay: spam(1)\n#
      W291: spam(1) \n#
      W293: class Foo(object):\n    \n    bang = 12

      Line too long (125 > 79 characters)
      Open

      If not specified, will try to load config from file `~/.wpwatcher/wpwatcher.conf`, `~/wpwatcher.conf` and `./wpwatcher.conf`.
      Severity: Minor
      Found in wpwatcher/cli.py by pep8

      Limit all lines to a maximum of 79 characters.

      There are still many devices around that are limited to 80 character
      lines; plus, limiting windows to 80 characters makes it possible to
      have several windows side-by-side.  The default wrapping on such
      devices looks ugly.  Therefore, please limit all lines to a maximum
      of 79 characters. For flowing long blocks of text (docstrings or
      comments), limiting the length to 72 characters is recommended.
      
      Reports error E501.

      Line too long (87 > 79 characters)
      Open

          parser.add_argument("--daemon", help="Loop and scan for ever", action="store_true")
      Severity: Minor
      Found in wpwatcher/cli.py by pep8

      Limit all lines to a maximum of 79 characters.

      There are still many devices around that are limited to 80 character
      lines; plus, limiting windows to 80 characters makes it possible to
      have several windows side-by-side.  The default wrapping on such
      devices looks ugly.  Therefore, please limit all lines to a maximum
      of 79 characters. For flowing long blocks of text (docstrings or
      comments), limiting the length to 72 characters is recommended.
      
      Reports error E501.

      Line too long (99 > 79 characters)
      Open

              help="Sends syslog testing packets of all possible sorts to the configured syslog server.",
      Severity: Minor
      Found in wpwatcher/cli.py by pep8

      Limit all lines to a maximum of 79 characters.

      There are still many devices around that are limited to 80 character
      lines; plus, limiting windows to 80 characters makes it possible to
      have several windows side-by-side.  The default wrapping on such
      devices looks ugly.  Therefore, please limit all lines to a maximum
      of 79 characters. For flowing long blocks of text (docstrings or
      comments), limiting the length to 72 characters is recommended.
      
      Reports error E501.

      Line too long (103 > 79 characters)
      Open

      def show(urlpart: str, filepath: Optional[str] = None, daemon: bool = False, format:str='cli') -> None:
      Severity: Minor
      Found in wpwatcher/cli.py by pep8

      Limit all lines to a maximum of 79 characters.

      There are still many devices around that are limited to 80 character
      lines; plus, limiting windows to 80 characters makes it possible to
      have several windows side-by-side.  The default wrapping on such
      devices looks ugly.  Therefore, please limit all lines to a maximum
      of 79 characters. For flowing long blocks of text (docstrings or
      comments), limiting the length to 72 characters is recommended.
      
      Reports error E501.

      Line too long (140 > 79 characters)
      Open

              help="Print all reports summary. Leave path blank to find default file. Can be used with --daemon to print default daemon databse.",
      Severity: Minor
      Found in wpwatcher/cli.py by pep8

      Limit all lines to a maximum of 79 characters.

      There are still many devices around that are limited to 80 character
      lines; plus, limiting windows to 80 characters makes it possible to
      have several windows side-by-side.  The default wrapping on such
      devices looks ugly.  Therefore, please limit all lines to a maximum
      of 79 characters. For flowing long blocks of text (docstrings or
      comments), limiting the length to 72 characters is recommended.
      
      Reports error E501.

      Line too long (122 > 79 characters)
      Open

              help="""Configuration file. You can specify multiple files, it will overwrites the keys with each successive file.
      Severity: Minor
      Found in wpwatcher/cli.py by pep8

      Limit all lines to a maximum of 79 characters.

      There are still many devices around that are limited to 80 character
      lines; plus, limiting windows to 80 characters makes it possible to
      have several windows side-by-side.  The default wrapping on such
      devices looks ugly.  Therefore, please limit all lines to a maximum
      of 79 characters. For flowing long blocks of text (docstrings or
      comments), limiting the length to 72 characters is recommended.
      
      Reports error E501.

      Line too long (81 > 79 characters)
      Open

              "--send_infos", "--infos", help="Email INFO reports", action="store_true"
      Severity: Minor
      Found in wpwatcher/cli.py by pep8

      Limit all lines to a maximum of 79 characters.

      There are still many devices around that are limited to 80 character
      lines; plus, limiting windows to 80 characters makes it possible to
      have several windows side-by-side.  The default wrapping on such
      devices looks ugly.  Therefore, please limit all lines to a maximum
      of 79 characters. For flowing long blocks of text (docstrings or
      comments), limiting the length to 72 characters is recommended.
      
      Reports error E501.

      Line too long (98 > 79 characters)
      Open

              help="Write all WPScan results in sub directories 'info', 'warning', 'alert' and 'error'",
      Severity: Minor
      Found in wpwatcher/cli.py by pep8

      Limit all lines to a maximum of 79 characters.

      There are still many devices around that are limited to 80 character
      lines; plus, limiting windows to 80 characters makes it possible to
      have several windows side-by-side.  The default wrapping on such
      devices looks ugly.  Therefore, please limit all lines to a maximum
      of 79 characters. For flowing long blocks of text (docstrings or
      comments), limiting the length to 72 characters is recommended.
      
      Reports error E501.

      Missing whitespace after ':'
      Open

      def show(urlpart: str, filepath: Optional[str] = None, daemon: bool = False, format:str='cli') -> None:
      Severity: Minor
      Found in wpwatcher/cli.py by pep8

      Each comma, semicolon or colon should be followed by whitespace.

      Okay: [a, b]
      Okay: (3,)
      Okay: a[1:4]
      Okay: a[:4]
      Okay: a[1:]
      Okay: a[1:4:2]
      E231: ['a','b']
      E231: foo(bar,baz)
      E231: [{'a':'b'}]

      Line too long (131 > 79 characters)
      Open

              description=f"""WordPress Watcher is a Python wrapper for WPScan that manages scans on multiple sites and reports by email.
      Severity: Minor
      Found in wpwatcher/cli.py by pep8

      Limit all lines to a maximum of 79 characters.

      There are still many devices around that are limited to 80 character
      lines; plus, limiting windows to 80 characters makes it possible to
      have several windows side-by-side.  The default wrapping on such
      devices looks ugly.  Therefore, please limit all lines to a maximum
      of 79 characters. For flowing long blocks of text (docstrings or
      comments), limiting the length to 72 characters is recommended.
      
      Reports error E501.

      Line too long (82 > 79 characters)
      Open

              help="Verbose output, print WPScan raw output and parsed WPScan results.",
      Severity: Minor
      Found in wpwatcher/cli.py by pep8

      Limit all lines to a maximum of 79 characters.

      There are still many devices around that are limited to 80 character
      lines; plus, limiting windows to 80 characters makes it possible to
      have several windows side-by-side.  The default wrapping on such
      devices looks ugly.  Therefore, please limit all lines to a maximum
      of 79 characters. For flowing long blocks of text (docstrings or
      comments), limiting the length to 72 characters is recommended.
      
      Reports error E501.

      Missing whitespace around parameter equals
      Open

      def show(urlpart: str, filepath: Optional[str] = None, daemon: bool = False, format:str='cli') -> None:
      Severity: Minor
      Found in wpwatcher/cli.py by pep8

      Don't use spaces around the '=' sign in function arguments.

      Don't use spaces around the '=' sign when used to indicate a
      keyword argument or a default parameter value, except when
      using a type annotation.
      
      Okay: def complex(real, imag=0.0):
      Okay: return magic(r=real, i=imag)
      Okay: boolean(a == b)
      Okay: boolean(a != b)
      Okay: boolean(a <= b)
      Okay: boolean(a >= b)
      Okay: def foo(arg: int = 42):
      Okay: async def foo(arg: int = 42):
      
      E251: def complex(real, imag = 0.0):
      E251: return magic(r = real, i = imag)
      E252: def complex(real, image: float=0.0):

      Missing whitespace around parameter equals
      Open

      def show(urlpart: str, filepath: Optional[str] = None, daemon: bool = False, format:str='cli') -> None:
      Severity: Minor
      Found in wpwatcher/cli.py by pep8

      Don't use spaces around the '=' sign in function arguments.

      Don't use spaces around the '=' sign when used to indicate a
      keyword argument or a default parameter value, except when
      using a type annotation.
      
      Okay: def complex(real, imag=0.0):
      Okay: return magic(r=real, i=imag)
      Okay: boolean(a == b)
      Okay: boolean(a != b)
      Okay: boolean(a <= b)
      Okay: boolean(a >= b)
      Okay: def foo(arg: int = 42):
      Okay: async def foo(arg: int = 42):
      
      E251: def complex(real, imag = 0.0):
      E251: return magic(r = real, i = imag)
      E252: def complex(real, image: float=0.0):

      Line too long (84 > 79 characters)
      Open

              "--send_errors", "--errors", help="Email ERROR reports", action="store_true"
      Severity: Minor
      Found in wpwatcher/cli.py by pep8

      Limit all lines to a maximum of 79 characters.

      There are still many devices around that are limited to 80 character
      lines; plus, limiting windows to 80 characters makes it possible to
      have several windows side-by-side.  The default wrapping on such
      devices looks ugly.  Therefore, please limit all lines to a maximum
      of 79 characters. For flowing long blocks of text (docstrings or
      comments), limiting the length to 72 characters is recommended.
      
      Reports error E501.

      Line too long (87 > 79 characters)
      Open

              "--show", metavar="Site", help="Print a report in the Database in text format."
      Severity: Minor
      Found in wpwatcher/cli.py by pep8

      Limit all lines to a maximum of 79 characters.

      There are still many devices around that are limited to 80 character
      lines; plus, limiting windows to 80 characters makes it possible to
      have several windows side-by-side.  The default wrapping on such
      devices looks ugly.  Therefore, please limit all lines to a maximum
      of 79 characters. For flowing long blocks of text (docstrings or
      comments), limiting the length to 72 characters is recommended.
      
      Reports error E501.

      Line too long (137 > 79 characters)
      Open

              "--show_html", metavar="Site", help="Print a report in the Database in HTML format, use with --quiet to print only HTML content."
      Severity: Minor
      Found in wpwatcher/cli.py by pep8

      Limit all lines to a maximum of 79 characters.

      There are still many devices around that are limited to 80 character
      lines; plus, limiting windows to 80 characters makes it possible to
      have several windows side-by-side.  The default wrapping on such
      devices looks ugly.  Therefore, please limit all lines to a maximum
      of 79 characters. For flowing long blocks of text (docstrings or
      comments), limiting the length to 72 characters is recommended.
      
      Reports error E501.

      Line too long (85 > 79 characters)
      Open

              "WPWatcher - Automating WPscan to scan and report vulnerable Wordpress sites"
      Severity: Minor
      Found in wpwatcher/cli.py by pep8

      Limit all lines to a maximum of 79 characters.

      There are still many devices around that are limited to 80 character
      lines; plus, limiting windows to 80 characters makes it possible to
      have several windows side-by-side.  The default wrapping on such
      devices looks ugly.  Therefore, please limit all lines to a maximum
      of 79 characters. For flowing long blocks of text (docstrings or
      comments), limiting the length to 72 characters is recommended.
      
      Reports error E501.

      Comparison to false should be 'if cond is not false:' or 'if cond:'
      Open

          if args.wprs != False:
      Severity: Minor
      Found in wpwatcher/cli.py by pep8

      Comparison to singletons should use "is" or "is not".

      Comparisons to singletons like None should always be done
      with "is" or "is not", never the equality operators.
      
      Okay: if arg is not None:
      E711: if arg != None:
      E711: if None == arg:
      E712: if arg == True:
      E712: if False == arg:
      
      Also, beware of writing if x when you really mean if x is not None
      -- e.g. when testing whether a variable or argument that defaults to
      None was set to some other value.  The other value might have a type
      (such as a container) that could be false in a boolean context!

      Line too long (137 > 79 characters)
      Open

              "--show_json", metavar="Site", help="Print a report in the Database in JSON format, use with --quiet to print only JSON content."
      Severity: Minor
      Found in wpwatcher/cli.py by pep8

      Limit all lines to a maximum of 79 characters.

      There are still many devices around that are limited to 80 character
      lines; plus, limiting windows to 80 characters makes it possible to
      have several windows side-by-side.  The default wrapping on such
      devices looks ugly.  Therefore, please limit all lines to a maximum
      of 79 characters. For flowing long blocks of text (docstrings or
      comments), limiting the length to 72 characters is recommended.
      
      Reports error E501.

      There are no issues that match your filters.

      Category
      Status