python-security/pyt

View on GitHub
pyt/cfg/stmt_visitor.py

Summary

Maintainability
F
1 wk
Test Coverage

File stmt_visitor.py has 932 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import ast
import itertools
import logging
import os.path
from pkgutil import iter_modules
Severity: Major
Found in pyt/cfg/stmt_visitor.py - About 2 days to fix

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

        def add_module(  # noqa: C901
            self,
            module,
            module_or_package_name,
            local_names,
    Severity: Minor
    Found in pyt/cfg/stmt_visitor.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

    StmtVisitor has 40 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class StmtVisitor(ast.NodeVisitor):
        def __init__(self, allow_local_directory_imports=True):
            self._allow_local_modules = allow_local_directory_imports
            super().__init__()
    
    
    Severity: Minor
    Found in pyt/cfg/stmt_visitor.py - About 5 hrs to fix

      Function add_blackbox_or_builtin_call has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
      Open

          def add_blackbox_or_builtin_call(self, node, blackbox):  # noqa: C901
              """Processes a blackbox or builtin function when it is called.
              Nothing gets assigned to ret_func_foo in the builtin/blackbox case.
      
              Increments self.function_call_index each time it is called, we can refer to it as N in the comments.
      Severity: Minor
      Found in pyt/cfg/stmt_visitor.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 visit_Import has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
      Open

          def visit_Import(self, node):
              for name in node.names:
                  for module in self.local_modules:
                      if name.name == module[0]:
                          if os.path.isdir(module[1]):
      Severity: Minor
      Found in pyt/cfg/stmt_visitor.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 stmt_star_handler has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
      Open

          def stmt_star_handler(
              self,
              stmts,
              prev_node_to_avoid=None
          ):
      Severity: Minor
      Found in pyt/cfg/stmt_visitor.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

      Cyclomatic complexity is too high in method add_module. (13)
      Open

          def add_module(  # noqa: C901
              self,
              module,
              module_or_package_name,
              local_names,
      Severity: Minor
      Found in pyt/cfg/stmt_visitor.py by radon

      Cyclomatic Complexity

      Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

      Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

      Construct Effect on CC Reasoning
      if +1 An if statement is a single decision.
      elif +1 The elif statement adds another decision.
      else +0 The else statement does not cause a new decision. The decision is at the if.
      for +1 There is a decision at the start of the loop.
      while +1 There is a decision at the while statement.
      except +1 Each except branch adds a new conditional path of execution.
      finally +0 The finally block is unconditionally executed.
      with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
      assert +1 The assert statement internally roughly equals a conditional statement.
      Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
      Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

      Source: http://radon.readthedocs.org/en/latest/intro.html

      Cyclomatic complexity is too high in method add_blackbox_or_builtin_call. (13)
      Open

          def add_blackbox_or_builtin_call(self, node, blackbox):  # noqa: C901
              """Processes a blackbox or builtin function when it is called.
              Nothing gets assigned to ret_func_foo in the builtin/blackbox case.
      
              Increments self.function_call_index each time it is called, we can refer to it as N in the comments.
      Severity: Minor
      Found in pyt/cfg/stmt_visitor.py by radon

      Cyclomatic Complexity

      Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

      Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

      Construct Effect on CC Reasoning
      if +1 An if statement is a single decision.
      elif +1 The elif statement adds another decision.
      else +0 The else statement does not cause a new decision. The decision is at the if.
      for +1 There is a decision at the start of the loop.
      while +1 There is a decision at the while statement.
      except +1 Each except branch adds a new conditional path of execution.
      finally +0 The finally block is unconditionally executed.
      with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
      assert +1 The assert statement internally roughly equals a conditional statement.
      Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
      Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

      Source: http://radon.readthedocs.org/en/latest/intro.html

      Cyclomatic complexity is too high in method visit_Import. (12)
      Open

          def visit_Import(self, node):
              for name in node.names:
                  for module in self.local_modules:
                      if name.name == module[0]:
                          if os.path.isdir(module[1]):
      Severity: Minor
      Found in pyt/cfg/stmt_visitor.py by radon

      Cyclomatic Complexity

      Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

      Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

      Construct Effect on CC Reasoning
      if +1 An if statement is a single decision.
      elif +1 The elif statement adds another decision.
      else +0 The else statement does not cause a new decision. The decision is at the if.
      for +1 There is a decision at the start of the loop.
      while +1 There is a decision at the while statement.
      except +1 Each except branch adds a new conditional path of execution.
      finally +0 The finally block is unconditionally executed.
      with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
      assert +1 The assert statement internally roughly equals a conditional statement.
      Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
      Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

      Source: http://radon.readthedocs.org/en/latest/intro.html

      Function handle_relative_import has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
      Open

          def handle_relative_import(self, node):
              """
                  from A means node.level == 0
                  from . import B means node.level == 1
                  from .A means node.level == 1
      Severity: Minor
      Found in pyt/cfg/stmt_visitor.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

      Cyclomatic complexity is too high in method stmt_star_handler. (11)
      Open

          def stmt_star_handler(
              self,
              stmts,
              prev_node_to_avoid=None
          ):
      Severity: Minor
      Found in pyt/cfg/stmt_visitor.py by radon

      Cyclomatic Complexity

      Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

      Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

      Construct Effect on CC Reasoning
      if +1 An if statement is a single decision.
      elif +1 The elif statement adds another decision.
      else +0 The else statement does not cause a new decision. The decision is at the if.
      for +1 There is a decision at the start of the loop.
      while +1 There is a decision at the while statement.
      except +1 Each except branch adds a new conditional path of execution.
      finally +0 The finally block is unconditionally executed.
      with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
      assert +1 The assert statement internally roughly equals a conditional statement.
      Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
      Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

      Source: http://radon.readthedocs.org/en/latest/intro.html

      Cyclomatic complexity is too high in method visit_ImportFrom. (11)
      Open

          def visit_ImportFrom(self, node):
              # Is it relative?
              if node.level > 0:
                  return self.handle_relative_import(node)
              # not relative
      Severity: Minor
      Found in pyt/cfg/stmt_visitor.py by radon

      Cyclomatic Complexity

      Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

      Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

      Construct Effect on CC Reasoning
      if +1 An if statement is a single decision.
      elif +1 The elif statement adds another decision.
      else +0 The else statement does not cause a new decision. The decision is at the if.
      for +1 There is a decision at the start of the loop.
      while +1 There is a decision at the while statement.
      except +1 Each except branch adds a new conditional path of execution.
      finally +0 The finally block is unconditionally executed.
      with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
      assert +1 The assert statement internally roughly equals a conditional statement.
      Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
      Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

      Source: http://radon.readthedocs.org/en/latest/intro.html

      Cyclomatic complexity is too high in method handle_relative_import. (9)
      Open

          def handle_relative_import(self, node):
              """
                  from A means node.level == 0
                  from . import B means node.level == 1
                  from .A means node.level == 1
      Severity: Minor
      Found in pyt/cfg/stmt_visitor.py by radon

      Cyclomatic Complexity

      Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

      Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

      Construct Effect on CC Reasoning
      if +1 An if statement is a single decision.
      elif +1 The elif statement adds another decision.
      else +0 The else statement does not cause a new decision. The decision is at the if.
      for +1 There is a decision at the start of the loop.
      while +1 There is a decision at the while statement.
      except +1 Each except branch adds a new conditional path of execution.
      finally +0 The finally block is unconditionally executed.
      with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
      assert +1 The assert statement internally roughly equals a conditional statement.
      Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
      Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

      Source: http://radon.readthedocs.org/en/latest/intro.html

      Cyclomatic complexity is too high in method assign_tuple_target. (9)
      Open

          def assign_tuple_target(self, target_nodes, value_nodes, right_hand_side_variables):
              new_assignment_nodes = []
              remaining_variables = list(right_hand_side_variables)
              remaining_targets = list(target_nodes)
              remaining_values = list(value_nodes)  # May contain duplicates
      Severity: Minor
      Found in pyt/cfg/stmt_visitor.py by radon

      Cyclomatic Complexity

      Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

      Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

      Construct Effect on CC Reasoning
      if +1 An if statement is a single decision.
      elif +1 The elif statement adds another decision.
      else +0 The else statement does not cause a new decision. The decision is at the if.
      for +1 There is a decision at the start of the loop.
      while +1 There is a decision at the while statement.
      except +1 Each except branch adds a new conditional path of execution.
      finally +0 The finally block is unconditionally executed.
      with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
      assert +1 The assert statement internally roughly equals a conditional statement.
      Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
      Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

      Source: http://radon.readthedocs.org/en/latest/intro.html

      Cyclomatic complexity is too high in method visit_Assign. (8)
      Open

          def visit_Assign(self, node):
              rhs_visitor = RHSVisitor()
              rhs_visitor.visit(node.value)
              if isinstance(node.targets[0], (ast.Tuple, ast.List)):  # x,y = [1,2]
                  if isinstance(node.value, (ast.Tuple, ast.List)):
      Severity: Minor
      Found in pyt/cfg/stmt_visitor.py by radon

      Cyclomatic Complexity

      Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

      Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

      Construct Effect on CC Reasoning
      if +1 An if statement is a single decision.
      elif +1 The elif statement adds another decision.
      else +0 The else statement does not cause a new decision. The decision is at the if.
      for +1 There is a decision at the start of the loop.
      while +1 There is a decision at the while statement.
      except +1 Each except branch adds a new conditional path of execution.
      finally +0 The finally block is unconditionally executed.
      with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
      assert +1 The assert statement internally roughly equals a conditional statement.
      Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
      Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

      Source: http://radon.readthedocs.org/en/latest/intro.html

      Cyclomatic complexity is too high in method visit_Try. (8)
      Open

          def visit_Try(self, node):
              try_node = self.append_node(TryNode(
                  node,
                  path=self.filenames[-1]
              ))
      Severity: Minor
      Found in pyt/cfg/stmt_visitor.py by radon

      Cyclomatic Complexity

      Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

      Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

      Construct Effect on CC Reasoning
      if +1 An if statement is a single decision.
      elif +1 The elif statement adds another decision.
      else +0 The else statement does not cause a new decision. The decision is at the if.
      for +1 There is a decision at the start of the loop.
      while +1 There is a decision at the while statement.
      except +1 Each except branch adds a new conditional path of execution.
      finally +0 The finally block is unconditionally executed.
      with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
      assert +1 The assert statement internally roughly equals a conditional statement.
      Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
      Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

      Source: http://radon.readthedocs.org/en/latest/intro.html

      Function visit_ImportFrom has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

          def visit_ImportFrom(self, node):
              # Is it relative?
              if node.level > 0:
                  return self.handle_relative_import(node)
              # not relative
      Severity: Minor
      Found in pyt/cfg/stmt_visitor.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 assign_tuple_target has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

          def assign_tuple_target(self, target_nodes, value_nodes, right_hand_side_variables):
              new_assignment_nodes = []
              remaining_variables = list(right_hand_side_variables)
              remaining_targets = list(target_nodes)
              remaining_values = list(value_nodes)  # May contain duplicates
      Severity: Minor
      Found in pyt/cfg/stmt_visitor.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

      Cyclomatic complexity is too high in method from_directory_import. (6)
      Open

          def from_directory_import(
              self,
              module,
              real_names,
              local_names,
      Severity: Minor
      Found in pyt/cfg/stmt_visitor.py by radon

      Cyclomatic Complexity

      Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

      Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

      Construct Effect on CC Reasoning
      if +1 An if statement is a single decision.
      elif +1 The elif statement adds another decision.
      else +0 The else statement does not cause a new decision. The decision is at the if.
      for +1 There is a decision at the start of the loop.
      while +1 There is a decision at the while statement.
      except +1 Each except branch adds a new conditional path of execution.
      finally +0 The finally block is unconditionally executed.
      with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
      assert +1 The assert statement internally roughly equals a conditional statement.
      Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
      Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

      Source: http://radon.readthedocs.org/en/latest/intro.html

      Function visit_Assign has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

          def visit_Assign(self, node):
              rhs_visitor = RHSVisitor()
              rhs_visitor.visit(node.value)
              if isinstance(node.targets[0], (ast.Tuple, ast.List)):  # x,y = [1,2]
                  if isinstance(node.value, (ast.Tuple, ast.List)):
      Severity: Minor
      Found in pyt/cfg/stmt_visitor.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 visit_Try has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

          def visit_Try(self, node):
              try_node = self.append_node(TryNode(
                  node,
                  path=self.filenames[-1]
              ))
      Severity: Minor
      Found in pyt/cfg/stmt_visitor.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 add_module has 8 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def add_module(  # noqa: C901
      Severity: Major
      Found in pyt/cfg/stmt_visitor.py - About 1 hr to fix

        Function from_directory_import has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            def from_directory_import(
                self,
                module,
                real_names,
                local_names,
        Severity: Minor
        Found in pyt/cfg/stmt_visitor.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

        Avoid deeply nested control flow statements.
        Open

                                if from_fdid:
                                    alias = handle_fdid_aliases(module_or_package_name, import_alias_mapping)
                                    if alias:
                                        module_or_package_name = alias
                                    parent_definition = ModuleDefinition(
        Severity: Major
        Found in pyt/cfg/stmt_visitor.py - About 45 mins to fix

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

              def from_directory_import(
          Severity: Minor
          Found in pyt/cfg/stmt_visitor.py - About 35 mins to fix

            Avoid too many return statements within this function.
            Open

                        return self.assign_multi_target(node, rhs_visitor.result)
            Severity: Major
            Found in pyt/cfg/stmt_visitor.py - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                              return self.append_node(AssignmentNode(
              Severity: Major
              Found in pyt/cfg/stmt_visitor.py - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                        return IgnoredNode()
                Severity: Major
                Found in pyt/cfg/stmt_visitor.py - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                                  return self.add_module(
                  Severity: Major
                  Found in pyt/cfg/stmt_visitor.py - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                                    return self.assignment_call_node(label.result, node)
                    Severity: Major
                    Found in pyt/cfg/stmt_visitor.py - About 30 mins to fix

                      Avoid too many return statements within this function.
                      Open

                              return IgnoredNode()
                      Severity: Major
                      Found in pyt/cfg/stmt_visitor.py - About 30 mins to fix

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

                                    for module in self.project_modules:
                                        if name.name == module[0]:
                                            if os.path.isdir(module[1]):
                                                return self.import_package(
                                                    module,
                        Severity: Major
                        Found in pyt/cfg/stmt_visitor.py and 1 other location - About 5 hrs to fix
                        pyt/cfg/stmt_visitor.py on lines 1030..1043

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

                        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

                                    for module in self.local_modules:
                                        if name.name == module[0]:
                                            if os.path.isdir(module[1]):
                                                return self.import_package(
                                                    module,
                        Severity: Major
                        Found in pyt/cfg/stmt_visitor.py and 1 other location - About 5 hrs to fix
                        pyt/cfg/stmt_visitor.py on lines 1045..1058

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

                        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 node.module:
                                        name_with_dir = os.path.join(no_file, node.module.replace('.', '/'))
                                        if not os.path.isdir(name_with_dir):
                                            name_with_dir = name_with_dir + '.py'
                        Severity: Major
                        Found in pyt/cfg/stmt_visitor.py and 1 other location - About 2 hrs to fix
                        pyt/cfg/stmt_visitor.py on lines 1003..1006

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

                        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 node.module:
                                        name_with_dir = os.path.join(parent, node.module.replace('.', '/'))
                                        if not os.path.isdir(name_with_dir):
                                            name_with_dir = name_with_dir + '.py'
                        Severity: Major
                        Found in pyt/cfg/stmt_visitor.py and 1 other location - About 2 hrs to fix
                        pyt/cfg/stmt_visitor.py on lines 988..991

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

                        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 alias.name not in uninspectable_modules:
                                        log.warning("Cannot inspect module %s", alias.name)
                                        uninspectable_modules.add(alias.name)  # Don't repeatedly warn about this
                        Severity: Minor
                        Found in pyt/cfg/stmt_visitor.py and 1 other location - About 45 mins to fix
                        pyt/cfg/stmt_visitor.py on lines 1117..1119

                        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

                                if node.module not in uninspectable_modules:
                                    log.warning("Cannot inspect module %s", node.module)
                                    uninspectable_modules.add(node.module)
                        Severity: Minor
                        Found in pyt/cfg/stmt_visitor.py and 1 other location - About 45 mins to fix
                        pyt/cfg/stmt_visitor.py on lines 1067..1069

                        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

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

                                        return self.add_module(
                                            module=module,
                                            module_or_package_name=None,
                                            local_names=as_alias_handler(node.names),
                                            import_alias_mapping=retrieve_import_alias_mapping(node.names),
                        Severity: Minor
                        Found in pyt/cfg/stmt_visitor.py and 1 other location - About 45 mins to fix
                        pyt/cfg/stmt_visitor.py on lines 1102..1106

                        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

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

                                        return self.add_module(
                                            module=module,
                                            module_or_package_name=None,
                                            local_names=as_alias_handler(node.names),
                                            import_alias_mapping=retrieve_import_alias_mapping(node.names),
                        Severity: Minor
                        Found in pyt/cfg/stmt_visitor.py and 1 other location - About 45 mins to fix
                        pyt/cfg/stmt_visitor.py on lines 1085..1089

                        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

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

                                for target, value in zip(reversed(list(remaining_targets)), reversed(list(remaining_values))):
                                    if isinstance(target, ast.Starred) or isinstance(value, ast.Starred):
                                        break
                                    visit(target, value)
                        Severity: Minor
                        Found in pyt/cfg/stmt_visitor.py and 1 other location - About 35 mins to fix
                        pyt/cfg/stmt_visitor.py on lines 368..371

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

                        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

                                for target, value in zip(target_nodes, value_nodes):
                                    if isinstance(target, ast.Starred) or isinstance(value, ast.Starred):
                                        break
                                    visit(target, value)
                        Severity: Minor
                        Found in pyt/cfg/stmt_visitor.py and 1 other location - About 35 mins to fix
                        pyt/cfg/stmt_visitor.py on lines 374..377

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

                        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 visit_Break(self, node):
                                return self.append_node(BreakNode(
                                    node,
                                    path=self.filenames[-1]
                        Severity: Minor
                        Found in pyt/cfg/stmt_visitor.py and 1 other location - About 30 mins to fix
                        pyt/cfg/stmt_visitor.py on lines 244..247

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

                        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 visit_Raise(self, node):
                                return self.append_node(RaiseNode(
                                    node,
                                    path=self.filenames[-1]
                        Severity: Minor
                        Found in pyt/cfg/stmt_visitor.py and 1 other location - About 30 mins to fix
                        pyt/cfg/stmt_visitor.py on lines 733..736

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

                        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