Showing 268 of 272 total issues

Similar blocks of code found in 2 locations. Consider refactoring.
Open

    def count_messages(self, querystring):
        """returns number of messages that match `querystring`"""
        db = Database(path=self.path, mode=Database.MODE.READ_ONLY,
                      config=self.config)
        return db.count_messages(querystring,
Severity: Major
Found in alot/db/manager.py and 1 other location - About 2 hrs to fix
alot/db/manager.py on lines 272..277

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 50.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

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

    Identical blocks of code found in 2 locations. Consider refactoring.
    Open

            def myafterwards():
                if remove_rest:
                    self._tags = set(tags)
                else:
                    self._tags = self._tags.union(tags)
    Severity: Major
    Found in alot/db/message.py and 1 other location - About 1 hr to fix
    alot/db/thread.py on lines 116..122

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 48.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Identical blocks of code found in 2 locations. Consider refactoring.
    Open

            def myafterwards():
                if remove_rest:
                    self._tags = set(tags)
                else:
                    self._tags = self._tags.union(tags)
    Severity: Major
    Found in alot/db/thread.py and 1 other location - About 1 hr to fix
    alot/db/message.py on lines 195..201

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 48.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

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

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

    def pretty_datetime(d):
        """
        translates :class:`datetime` `d` to a "sup-style" human readable string.
    
        >>> now = datetime.now()
    Severity: Minor
    Found in alot/helper.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

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

          if encrypt and not key.can_encrypt:
              raise GPGProblem(
                  'The key "{}" cannot be used to encrypt'.format(key.uids[0].uid),
                  code=GPGCode.KEY_CANNOT_ENCRYPT)
      Severity: Major
      Found in alot/crypto.py and 1 other location - About 1 hr to fix
      alot/crypto.py on lines 300..303

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 44.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

          if sign and not key.can_sign:
              raise GPGProblem(
                  'The key "{}" cannot be used to sign'.format(key.uids[0].uid),
                  code=GPGCode.KEY_CANNOT_SIGN)
      Severity: Major
      Found in alot/crypto.py and 1 other location - About 1 hr to fix
      alot/crypto.py on lines 296..299

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 44.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

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

      def main():
          """The main entry point to alot.  It parses the command line and prepares
          for the user interface main loop to run."""
          options, command = parser()
      
      
      Severity: Minor
      Found in alot/__main__.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_tagstring_representation has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

          def get_tagstring_representation(self, tag, onebelow_normal=None,
                                           onebelow_focus=None):
              """
              looks up user's preferred way to represent a given tagstring.
      
      
      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