Luavis/sherlock

View on GitHub
sherlock/codelib/analyzer/__init__.py

Summary

Maintainability
C
7 hrs
Test Coverage

Function get_type has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

    def get_type(self, node):
        if isinstance(node, ast.BinOp):
            left_type = self.get_type(node.left)
            right_type = self.get_type(node.right)

Severity: Minor
Found in sherlock/codelib/analyzer/__init__.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 get_function_return_type has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    def get_function_return_type(self, function_name, args_type=[]):
        function = self.functions[function_name]
        if is_system_function(function_name):
            return SystemFunction.get_function(function_name).return_type
        if function is not None:
Severity: Minor
Found in sherlock/codelib/analyzer/__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 analysis has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def analysis(self):
        for node in self.module_node.body:
            if isinstance(node, ast.Assign):
                self.analysis_assign_node(self.variables, node)
            elif isinstance(node, ast.Expr):
Severity: Minor
Found in sherlock/codelib/analyzer/__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 analysis_function has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def analysis_function(self, function_node, args_type=[]):
        variables = Variables()
        return_type = Type.VOID

        for node in function_node.body:
Severity: Minor
Found in sherlock/codelib/analyzer/__init__.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

Avoid too many return statements within this function.
Open

            return self.get_function_return_type(node.func.id, args_type)
Severity: Major
Found in sherlock/codelib/analyzer/__init__.py - About 30 mins to fix

    Avoid too many return statements within this function.
    Open

                return self.variables[node.id].var_type
    Severity: Major
    Found in sherlock/codelib/analyzer/__init__.py - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

                  return Type.STRING
      Severity: Major
      Found in sherlock/codelib/analyzer/__init__.py - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

                    return Type.NUMBER
        Severity: Major
        Found in sherlock/codelib/analyzer/__init__.py - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                      return Type.LIST
          Severity: Major
          Found in sherlock/codelib/analyzer/__init__.py - About 30 mins to fix

            There are no issues that match your filters.

            Category
            Status