alot/buffers/thread.py

Summary

Maintainability
F
5 days
Test Coverage

ThreadBuffer has 38 functions (exceeds 20 allowed). Consider refactoring.
Open

class ThreadBuffer(Buffer):
    """displays a thread as a tree of messages."""

    modename = 'thread'

Severity: Minor
Found in alot/buffers/thread.py - About 5 hrs to fix

    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

      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 unfold_matching has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def unfold_matching(self, querystring, focus_first=True):
              """
              expand all messages that match a given querystring.
      
              :param querystring: query to match
      Severity: Minor
      Found in alot/buffers/thread.py - About 35 mins 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

          def focus_prev_sibling(self):
              """
              focus previous sibling of currently focussed message in thread tree
              """
              mid = self.get_selected_mid()
      Severity: Major
      Found in alot/buffers/thread.py and 1 other location - About 7 hrs to fix
      alot/buffers/thread.py on lines 256..267

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

      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

          def focus_prev(self):
              """focus previous message in depth first order"""
              mid = self.get_selected_mid()
              localroot = self._sanitize_position((mid,))
              if localroot == self.get_focus()[1]:
      Severity: Major
      Found in alot/buffers/thread.py and 1 other location - About 7 hrs to fix
      alot/buffers/thread.py on lines 233..246

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

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

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

          def focus_next_unfolded(self):
              """focus next unfolded message in depth first order"""
              self.focus_property(lambda x: not x.is_collapsed(x.root),
                                  self._tree.next_position)
      Severity: Major
      Found in alot/buffers/thread.py and 1 other location - About 1 hr to fix
      alot/buffers/thread.py on lines 297..300

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

      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

          def focus_prev_unfolded(self):
              """focus previous unfolded message in depth first order"""
              self.focus_property(lambda x: not x.is_collapsed(x.root),
                                  self._tree.prev_position)
      Severity: Major
      Found in alot/buffers/thread.py and 1 other location - About 1 hr to fix
      alot/buffers/thread.py on lines 292..295

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

      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

          def focus_prev_matching(self, querystring):
              """focus previous matching message in depth first order"""
              self.focus_property(lambda x: x._message.matches(querystring),
                                  self._tree.prev_position)
      Severity: Major
      Found in alot/buffers/thread.py and 1 other location - About 1 hr to fix
      alot/buffers/thread.py on lines 282..285

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

      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

          def focus_next_matching(self, querystring):
              """focus next matching message in depth first order"""
              self.focus_property(lambda x: x._message.matches(querystring),
                                  self._tree.next_position)
      Severity: Major
      Found in alot/buffers/thread.py and 1 other location - About 1 hr to fix
      alot/buffers/thread.py on lines 287..290

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

      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

      There are no issues that match your filters.

      Category
      Status