Luavis/sherlock

View on GitHub

Showing 25 of 31 total issues

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

    def generate(self):
        if self.node is None:
            self.node = ast.parse(self.code)
        if isinstance(self.node, ast.Module):
            for x in self.node.body:
Severity: Minor
Found in sherlock/codelib/generator/__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_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_type has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    def get_type(self, node):
        if isinstance(node, ast.Num):
            return Type.NUMBER
        elif isinstance(node, ast.Str):
            return Type.STRING
Severity: Minor
Found in sherlock/codelib/generator/__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 system_function has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

def system_function(name, return_type, *arg_types):
    def decorator(func):
        global SYSTEM_FUNCTION_TABLE
        def wrapper(generator, node):
            func_args = [generator, ]
Severity: Minor
Found in sherlock/codelib/system_function/__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 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 _generate_binop has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

def _generate_binop(self, node, ext_info):
    left_type = self.get_type(node.left)
    right_type = self.get_type(node.right)
    extra_code = ext_info.get('extra_code', '')

Severity: Minor
Found in sherlock/codelib/generator/implements/binop.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 generate_call has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

def generate_call(self, node, ext_info={}):
    if hasattr(node, 'kwargs'):
        if not node.kwargs is None:
            raise SyntaxNotSupportError('Keyword arguments is not support yet.')
    elif not len(node.keywords) == 0:
Severity: Minor
Found in sherlock/codelib/generator/implements/function.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 generate_name has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

def generate_name(self, node, ext_info={'is_arg': False}):
    is_arg = ext_info.get('is_arg', False)
    if isinstance(node.ctx, ast.Store) or isinstance(node.ctx, ast.Param):
        return 'export ' + node.id if self.is_global else 'local ' + node.id
    else:
Severity: Minor
Found in sherlock/codelib/generator/implements/simple_generator.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 __init__ has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def __init__(
Severity: Minor
Found in sherlock/codelib/generator/__init__.py - About 45 mins to fix

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

    def execute_from_command_line():
        args = parser.parse_args()
    
        try:
            script = ''
    Severity: Minor
    Found in sherlock/__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

    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.VOID
        Severity: Major
        Found in sherlock/codelib/generator/__init__.py - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                      return 'Unknown'
          Severity: Major
          Found in sherlock/codelib/analyzer/variable.py - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

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

              Avoid too many return statements within this function.
              Open

                          return 'List'
              Severity: Major
              Found in sherlock/codelib/analyzer/variable.py - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                            return self.functions[node.func.id].return_type
                Severity: Major
                Found in sherlock/codelib/generator/__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
                    Severity
                    Category
                    Status
                    Source
                    Language