akissa/spamc

View on GitHub

Showing 11 of 13 total issues

Function perform has a Cognitive Complexity of 54 (exceeds 5 allowed). Consider refactoring.
Open

    def perform(self, cmd, msg='', extra_headers=None):
        """Perform the call"""
        tries = 0
        while 1:
            conn = None
Severity: Minor
Found in spamc/client.py - About 1 day 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

Function get_response has a Cognitive Complexity of 49 (exceeds 5 allowed). Consider refactoring.
Open

def get_response(cmd, conn):
    """Return a response"""
    resp = conn.socket().makefile('rb', -1)
    resp_dict = dict(
        code=0,
Severity: Minor
Found in spamc/client.py - About 7 hrs 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

File client.py has 273 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# -*- coding: utf-8 -*-
# vim: ai ts=4 sts=4 et sw=4
# spamc - Python spamassassin spamc client library
# Copyright (C) 2015  Andrew Colin Kissa <andrew@topdog.za.net>
#
Severity: Minor
Found in spamc/client.py - About 2 hrs to fix

    Function sendfile has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

        def sendfile(self, data, zlib_compress=None, compress_level=6):
            """Send data from a file object"""
            if hasattr(data, 'seek'):
                data.seek(0)
    
    
    Severity: Minor
    Found in spamc/conn.py - About 1 hr 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

    Function __init__ has 12 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def __init__(self,
    Severity: Major
    Found in spamc/client.py - About 1 hr to fix

      Function tell has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def tell(self, msg, action, learnas=''):
              """Tell what type of we are to process and what should be done
              with that message. This includes setting or removing a local
              or a remote database (learning, reporting, forgetting, revoking)."""
              action = _check_action(action)
      Severity: Minor
      Found in spamc/client.py - About 45 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

      Avoid deeply nested control flow statements.
      Open

                          for part in match:
                              resp_dict['symbols'].append(part)
                  if not match and cmd != 'PROCESS':
      Severity: Major
      Found in spamc/client.py - About 45 mins to fix

        Function get_headers has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            def get_headers(self, cmd, msg_length, extra_headers):
                """Returns the headers string based on command to execute"""
                cmd_header = "%s %s" % (cmd, PROTOCOL_VERSION)
                len_header = "Content-length: %s" % msg_length
                headers = [cmd_header, len_header]
        Severity: Minor
        Found in spamc/client.py - About 45 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

        Function get_readme has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

        def get_readme():
            """Generate long description"""
            pandoc = None
            for path in os.environ["PATH"].split(os.pathsep):
                path = path.strip('"')
        Severity: Minor
        Found in setup.py - About 45 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

        Avoid deeply nested control flow statements.
        Open

                            for part in match:
                                score = part[0] + part[1]
                                score = score.strip()
                                resp_dict['report'].append(
                                    dict(score=score,
        Severity: Major
        Found in spamc/client.py - About 45 mins to fix

          Function __init__ has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              def __init__(self, host, port, backend_mod, is_ssl=False, **ssl_args):
          Severity: Minor
          Found in spamc/conn.py - About 35 mins to fix
            Severity
            Category
            Status
            Source
            Language