jacquev6/ActionTree

View on GitHub
ActionTree/__init__.py

Summary

Maintainability
F
1 wk
Test Coverage

File __init__.py has 775 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# coding: utf8

# Copyright 2012-2018 Vincent Jacques <vincent@vincent-jacques.net>
# Copyright 2017 Nelo-T. Wallus <nelo@wallus.de>

Severity: Major
Found in ActionTree/__init__.py - About 1 day to fix

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

        def run(self, root_action):
            now = datetime.datetime.now()
    
            # Pre-process actions
            self._check_picklability(root_action)
    Severity: Minor
    Found in ActionTree/__init__.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 a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        def __init__(self, report):
            self.__actions = {
                id(action): self.__make_action(action, status)
                for (action, status) in report.get_actions_and_statuses()
            }
    Severity: Minor
    Found in ActionTree/__init__.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 _cancel_action has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        def _cancel_action(self, action, now):
            self.report.get_action_status(action)._set_cancel_time(now)
            self.hooks.action_canceled(now, action)
    
            if action in self.pending:
    Severity: Minor
    Found in ActionTree/__init__.py - About 55 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

    Function _allocate_resources has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def _allocate_resources(self, action):
            for (resource, quantity) in action.resources_required:
                used = self.resources_used.setdefault(resource, 0)
                if used == 0:
                    # Allow actions requiring more than available to run when they are alone requiring this resource
    Severity: Minor
    Found in ActionTree/__init__.py - About 45 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

    Function __nearest has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def __nearest(v, values):
            for i, value in enumerate(values):
                if v < value:
                    break
            if i == 0:
    Severity: Minor
    Found in ActionTree/__init__.py - About 45 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

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

    def execute(action, cpu_cores=None, keep_going=False, do_raise=True, hooks=None):
    Severity: Minor
    Found in ActionTree/__init__.py - About 35 mins to fix

      Function __init__ has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def __init__(self, action):
              import graphviz
              self.__graphviz_graph = graphviz.Digraph("action", node_attr={"shape": "box"})
              nodes = {}
              for (i, action) in enumerate(action.get_possible_execution_order()):
      Severity: Minor
      Found in ActionTree/__init__.py - About 25 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

          class FailedAction(object):
              def __init__(self, action, status):
                  self.__label = action.label
                  self.__id = id(action)
                  self.__dependencies = set(id(d) for d in action.dependencies)
      Severity: Major
      Found in ActionTree/__init__.py and 1 other location - About 2 days to fix
      ActionTree/__init__.py on lines 588..619

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

      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

          class SuccessfulAction(object):
              def __init__(self, action, status):
                  self.__label = action.label
                  self.__id = id(action)
                  self.__dependencies = set(id(d) for d in action.dependencies)
      Severity: Major
      Found in ActionTree/__init__.py and 1 other location - About 2 days to fix
      ActionTree/__init__.py on lines 621..651

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

      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

      try:
          stderr = ctypes.c_void_p.in_dll(libc, "stderr")
      except ValueError:  # pragma no cover: specific to macOS
          stderr = ctypes.c_void_p.in_dll(libc, "__stderrp")
      Severity: Minor
      Found in ActionTree/__init__.py and 1 other location - About 45 mins to fix
      ActionTree/__init__.py on lines 16..19

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

      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

      try:
          stdout = ctypes.c_void_p.in_dll(libc, "stdout")
      except ValueError:  # pragma no cover: specific to macOS
          stdout = ctypes.c_void_p.in_dll(libc, "__stdoutp")
      Severity: Minor
      Found in ActionTree/__init__.py and 1 other location - About 45 mins to fix
      ActionTree/__init__.py on lines 20..23

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

      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