Showing 271 of 275 total issues

Function shorten_author_string has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

def shorten_author_string(authors_string, maxlength):
    """
    Parse a list of authors concatenated as a text string (comma
    separated) and smartly adjust them to maxlength.

Severity: Minor
Found in alot/helper.py - About 2 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

Function get_authors_string has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

    def get_authors_string(self, own_accts=None, replace_own=None):
        """
        returns a string of comma-separated authors
        Depending on settings, it will substitute "me" for author name if
        address is user's own.
Severity: Minor
Found in alot/db/thread.py - About 2 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

Function complete has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

    def complete(self, original, pos):
        pref = original[:pos]

        res = []
        for act in self.actions:
Severity: Minor
Found in alot/completion/argparse.py - About 2 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

SettingsManager has 24 functions (exceeds 20 allowed). Consider refactoring.
Open

class SettingsManager:
    """Organizes user settings"""
    def __init__(self):
        self.hooks = None
        self._mailcaps = mailcap.getcaps()
Severity: Minor
Found in alot/settings/manager.py - About 2 hrs to fix

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

        def __init__(self, address=None, aliases=None, alias_regexp=None,
    Severity: Major
    Found in alot/account.py - About 2 hrs to fix

      Function get_authors has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
      Open

          def get_authors(self):
              """
              returns a list of authors (name, addr) of the messages.
              The authors are ordered by msg date and unique (by name/addr).
      
      
      Severity: Minor
      Found in alot/db/thread.py - About 2 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

      UI has 23 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class UI:
          """
          This class integrates all components of alot and offers
          methods for user interaction like :meth:`prompt`, :meth:`notify` etc.
          It handles the urwid widget tree and mainloop (we use asyncio) and is
      Severity: Minor
      Found in alot/ui.py - About 2 hrs to fix

        Function get_keybindings has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
        Open

            def get_keybindings(self, mode):
                """look up keybindings from `MODE-maps` sections
        
                :param mode: mode identifier
                :type mode: str
        Severity: Minor
        Found in alot/settings/manager.py - About 2 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

        Function render has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
        Open

            def render(self, size, focus=False):
                if self.message_count == 0:
                    return self.body.render(size, focus)
        
                if settings.get('auto_remove_unread'):
        Severity: Minor
        Found in alot/buffers/thread.py - About 2 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

        Function parse_template has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
        Open

            def parse_template(self, raw, reset=False, only_body=False,
                               target_body='plaintext'):
                """Parse a template or user edited string to fills this envelope.
        
                :param raw: the string to parse.
        Severity: Minor
        Found in alot/db/envelope.py - About 2 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

        Function _handle_encrypted has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
        Open

        def _handle_encrypted(original, message, session_keys=None):
            """Handle encrypted messages helper.
        
            RFC 3156 is quite strict:
            * exactly two messages
        Severity: Minor
        Found in alot/db/utils.py - About 2 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

        Function _decrypted_message_from_message has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
        Open

        def _decrypted_message_from_message(original_bytes, m, session_keys=None):
            '''Detect and decrypt OpenPGP encrypted data in an email object. If this
            succeeds, any mime messages found in the recovered plaintext
            message are added to the returned message object.
        
        
        Severity: Minor
        Found in alot/db/utils.py - About 2 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

        Function get_threadline_theming has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
        Open

            def get_threadline_theming(self, thread, colourmode):
                """
                look up how to display a Threadline wiidget in search mode
                for a given thread.
        
        
        Severity: Minor
        Found in alot/settings/theme.py - About 2 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

        Function read_config has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
        Open

            def read_config(self, path):
                """
                parse alot's config file
                :param path: path to alot's config file
                :type path: str
        Severity: Minor
        Found in alot/settings/manager.py - About 2 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 crypto.py has 259 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        # Copyright (C) 2011-2012  Patrick Totzke <patricktotzke@gmail.com>
        # Copyright © 2017-2018 Dylan Baker <dylan@pnwbakers.com>
        # This file is released under the GNU GPL, version 3 or a later revision.
        # For further details see the COPYING file
        import gpg
        Severity: Minor
        Found in alot/crypto.py - About 2 hrs to fix

          File message.py has 259 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          # Copyright (C) 2011-2012  Patrick Totzke <patricktotzke@gmail.com>
          # This file is released under the GNU GPL, version 3 or a later revision.
          # For further details see the COPYING file
          import email
          import email.charset as charset
          Severity: Minor
          Found in alot/db/message.py - About 2 hrs to fix

            Function __init__ has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
            Open

                def __init__(self, message, even=True):
                    """
                    :param message: a message
                    :type message: alot.db.Message
                    :param even: even entry in a pile of messages? Used for theming.
            Severity: Minor
            Found in alot/widgets/thread.py - About 2 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

            Function add_signature_headers has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
            Open

            def add_signature_headers(mail, sigs, error_msg):
                '''Add pseudo headers to the mail indicating whether the signature
                verification was successful.
            
                :param mail: :class:`email.message.Message` the message to entitle
            Severity: Minor
            Found in alot/db/utils.py - About 2 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

            Function __init__ has 52 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                def __init__(self, dbman, initialcmdline):
                    """
                    :param dbman: :class:`~alot.db.DBManager`
                    :param initialcmdline: commandline applied after setting up interface
                    :type initialcmdline: str
            Severity: Major
            Found in alot/ui.py - About 2 hrs to fix

              Function apply has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
              Open

                  def apply(self, ui):
                      logging.debug('HELP')
                      if self.commandname == 'bindings':
                          text_att = settings.get_theming_attribute('help', 'text')
                          title_att = settings.get_theming_attribute('help', 'title')
              Severity: Minor
              Found in alot/commands/globals.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

              Severity
              Category
              Status
              Source
              Language