alot/commands/thread.py

Summary

Maintainability
F
4 days
Test Coverage

File thread.py has 947 lines of code (exceeds 250 allowed). Consider refactoring.
Open

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

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

        def apply(self, ui):
            tbuffer = ui.current_buffer
    
            # set message/reply indentation if changed
            if self.indent is not None:
    Severity: Minor
    Found in alot/commands/thread.py - About 5 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 determine_sender has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
    Open

    def determine_sender(mail, action='reply'):
        """
        Inspect a given mail to reply/forward/bounce and find the most appropriate
        account to act from and construct a suitable From-Header to use.
    
    
    Severity: Minor
    Found in alot/commands/thread.py - About 3 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 apply has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

        def apply(self, ui):
            logging.debug(self.movement)
            original_focus = ui.get_deep_focus()
            tbuffer = ui.current_buffer
            if self.movement == 'parent':
    Severity: Minor
    Found in alot/commands/thread.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, cmd, all=False, separately=False, background=False,
    Severity: Major
    Found in alot/commands/thread.py - About 1 hr to fix

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

          def __init__(self, query=None, visible=None, raw=None, all_headers=None,
      Severity: Major
      Found in alot/commands/thread.py - About 1 hr to fix

        Avoid deeply nested control flow statements.
        Open

                                if name:
                                    ui.notify('saved %s as: %s' % (name, dest))
                                else:
                                    ui.notify('saved attachment as: %s' % dest)
                        else:
        Severity: Major
        Found in alot/commands/thread.py - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                              if settings.get(action + '_force_realname'):
                                  realname = account.realname
                              else:
                                  realname = seen_name
                              if settings.get(action + '_force_address'):
          Severity: Major
          Found in alot/commands/thread.py - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                if settings.get(action + '_force_address'):
                                    address = str(account.address)
                                else:
                                    address = seen_address
            
            
            Severity: Major
            Found in alot/commands/thread.py - About 45 mins to fix

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

                  def __init__(self, tags='', action='add', all=False, flush=True,
              Severity: Minor
              Found in alot/commands/thread.py - About 35 mins to fix

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

                    def __init__(self, message=None, all=False, listreply=None, spawn=None,
                Severity: Minor
                Found in alot/commands/thread.py - About 35 mins to fix

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

                      def __init__(self, all=False, separately=False, raw=False, add_tags=False,
                  Severity: Minor
                  Found in alot/commands/thread.py - About 35 mins to fix

                    TODO found
                    Open

                            # TODO: add next by date..
                    Severity: Minor
                    Found in alot/commands/thread.py by fixme

                    TODO found
                    Open

                            # TODO add 'next matching' if threadbuffer stores the original query
                    Severity: Minor
                    Found in alot/commands/thread.py by fixme

                    XXX found
                    Open

                                # XXX: could this be repalced with "'needsterminal' not in entry"?
                    Severity: Minor
                    Found in alot/commands/thread.py by fixme

                    There are no issues that match your filters.

                    Category
                    Status