Showing 150 of 273 total issues

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 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 _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 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

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

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 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 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 __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

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

            def __init__(
        Severity: Major
        Found in alot/commands/globals.py - About 1 hr to fix

          Function _parse_accounts has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
          Open

              def _parse_accounts(config):
                  """
                  read accounts information from config
          
                  :param config: valit alot config
          Severity: Minor
          Found in alot/settings/manager.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 get_attachments has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
          Open

              def get_attachments(self):
                  """
                  returns messages attachments
          
                  Derived from the leaves of the email mime tree
          Severity: Minor
          Found in alot/db/message.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 remove_cte has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
          Open

          def remove_cte(part, as_string=False):
              """Interpret MIME-part according to it's Content-Transfer-Encodings.
          
              This returns the payload of `part` as string or bytestring for display, or
              to be passed to an external program. In the raw file the payload may be
          Severity: Minor
          Found in alot/db/utils.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 apply has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
          Open

              def apply(self, ui):
                  try:
                      ui.dbman.flush()
                      if callable(self.callback):
                          self.callback()
          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

          Function get_addressbooks has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
          Open

              def get_addressbooks(self, order=None, append_remaining=True):
                  """returns list of all defined :class:`AddressBook` objects"""
                  order = order or []
                  abooks = []
                  for a in order:
          Severity: Minor
          Found in alot/settings/manager.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 rebuild has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
          Open

              def rebuild(self):
                  self.thread = self.dbman.get_thread(self.tid)
                  self.widgets = []
                  self.structure = settings.get_threadline_theming(self.thread)
          
          
          Severity: Minor
          Found in alot/widgets/search.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 apply has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
          Open

              def apply(self, ui):
                  if self.query:
                      open_searches = ui.get_buffers_of_type(buffers.SearchBuffer)
                      to_be_focused = None
                      for sb in open_searches:
          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

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

              def _expand_config_values(section, key):
                  """
                  Walker function for ConfigObj.walk
          
                  Applies expand_environment_and_home to all configuration values that
          Severity: Minor
          Found in alot/settings/manager.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