Showing 268 of 272 total issues

Function parse_escapes_to_urwid has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
Open

def parse_escapes_to_urwid(text, default_attr=None, default_attr_focus=None,
                           parse_background=True):
    """This function converts a text with ANSI escape for terminal
    attributes and returns a list containing each part of text and its
    corresponding Urwid Attributes object, it also returns a dictionary which
Severity: Minor
Found in alot/widgets/ansi.py - About 4 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

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

        elif key == 'meta d':
            start_pos = self.edit_pos
            end_pos = self.move_to_next_word(forward=True)
            if end_pos is not None:
                self.edit_text = (self.edit_text[:start_pos] +
Severity: Major
Found in alot/widgets/globals.py and 1 other location - About 3 hrs to fix
alot/widgets/globals.py on lines 206..212

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 69.

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

        elif key in ('meta delete', 'meta backspace', 'ctrl w'):
            end_pos = self.edit_pos
            start_pos = self.move_to_next_word(forward=False)
            if start_pos is not None:
                self.edit_text = (self.edit_text[:start_pos] +
Severity: Major
Found in alot/widgets/globals.py and 1 other location - About 3 hrs to fix
alot/widgets/globals.py on lines 199..205

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 69.

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

Message has 29 functions (exceeds 20 allowed). Consider refactoring.
Open

class Message:
    """
    a persistent notmuch message object.
    It it uses a :class:`~alot.db.DBManager` for cached manipulation
    and lazy lookups.
Severity: Minor
Found in alot/db/message.py - About 3 hrs to fix

    Function rebuild has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
    Open

        def rebuild(self):
            displayed_widgets = []
            hidden = settings.get('envelope_headers_blacklist')
            # build lines
            lines = []
    Severity: Minor
    Found in alot/buffers/envelope.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 rewrite_entries has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
    Open

    def rewrite_entries(config, path, specpath, sec=None):
        file = open(path, 'w')
        file.write(NOTE % specpath)
    
        if sec is None:
    Severity: Minor
    Found in docs/source/generate_configs.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

    File globals.py has 307 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
    
    """
    Severity: Minor
    Found in alot/widgets/globals.py - About 3 hrs to fix

      Function get_key has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
      Open

      def get_key(keyid, validate=False, encrypt=False, sign=False,
                  signed_only=False):
          """
          Gets a key from the keyring by filtering for the specified keyid, but
          only if the given keyid is specific enough (if it matches multiple
      Severity: Minor
      Found in alot/crypto.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

      File account.py has 300 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

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

        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

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

            def focus_next_sibling(self):
                """focus next sibling of currently focussed message in thread tree"""
                mid = self.get_selected_mid()
                newpos = self._tree.next_sibling_position(mid)
                if newpos is not None:
        Severity: Major
        Found in alot/buffers/thread.py and 4 other locations - About 3 hrs to fix
        alot/buffers/thread.py on lines 201..207
        alot/buffers/thread.py on lines 209..215
        alot/buffers/thread.py on lines 217..223
        alot/buffers/thread.py on lines 248..254

        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 63.

        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 5 locations. Consider refactoring.
        Open

            def focus_first_reply(self):
                """move focus to first reply to currently focussed message"""
                mid = self.get_selected_mid()
                newpos = self._tree.first_child_position(mid)
                if newpos is not None:
        Severity: Major
        Found in alot/buffers/thread.py and 4 other locations - About 3 hrs to fix
        alot/buffers/thread.py on lines 201..207
        alot/buffers/thread.py on lines 217..223
        alot/buffers/thread.py on lines 225..231
        alot/buffers/thread.py on lines 248..254

        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 63.

        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 5 locations. Consider refactoring.
        Open

            def focus_parent(self):
                """move focus to parent of currently focussed message"""
                mid = self.get_selected_mid()
                newpos = self._tree.parent_position(mid)
                if newpos is not None:
        Severity: Major
        Found in alot/buffers/thread.py and 4 other locations - About 3 hrs to fix
        alot/buffers/thread.py on lines 209..215
        alot/buffers/thread.py on lines 217..223
        alot/buffers/thread.py on lines 225..231
        alot/buffers/thread.py on lines 248..254

        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 63.

        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 5 locations. Consider refactoring.
        Open

            def focus_last_reply(self):
                """move focus to last reply to currently focussed message"""
                mid = self.get_selected_mid()
                newpos = self._tree.last_child_position(mid)
                if newpos is not None:
        Severity: Major
        Found in alot/buffers/thread.py and 4 other locations - About 3 hrs to fix
        alot/buffers/thread.py on lines 201..207
        alot/buffers/thread.py on lines 209..215
        alot/buffers/thread.py on lines 225..231
        alot/buffers/thread.py on lines 248..254

        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 63.

        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 5 locations. Consider refactoring.
        Open

            def focus_next(self):
                """focus next message in depth first order"""
                mid = self.get_selected_mid()
                newpos = self._tree.next_position(mid)
                if newpos is not None:
        Severity: Major
        Found in alot/buffers/thread.py and 4 other locations - About 3 hrs to fix
        alot/buffers/thread.py on lines 201..207
        alot/buffers/thread.py on lines 209..215
        alot/buffers/thread.py on lines 217..223
        alot/buffers/thread.py on lines 225..231

        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 63.

        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

        File envelope.py has 293 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 glob
        import logging
        Severity: Minor
        Found in alot/db/envelope.py - About 3 hrs to fix

          Consider simplifying this complex logical expression.
          Open

                          if all_optionals:
                              myarg = arguments_until_now[-1]
                              start_myarg = params.rindex(myarg)
                              beforeme = params[:start_myarg]
                              # set up local stringlist completer
          Severity: Critical
          Found in alot/completion/command.py - About 3 hrs to fix

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

                def apply(self, ui):
                    sign = None
                    envelope = ui.current_buffer.envelope
                    # sign status
                    if self.action == 'sign':
            Severity: Minor
            Found in alot/commands/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 rstify_parser has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
            Open

            def rstify_parser(parser):
                parser.formatter_class = HF
            
                formatter = parser._get_formatter()
                out = ""
            Severity: Minor
            Found in docs/source/generate_commands.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 thread.py has 284 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            # Copyright (C) 2011-2018  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 asyncio
            Severity: Minor
            Found in alot/buffers/thread.py - About 2 hrs to fix
              Severity
              Category
              Status
              Source
              Language