Luavis/sherlock

View on GitHub

Showing 31 of 31 total issues

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

@add_generator('If')
def generate_if(self, node, ext_info):
    test = self.dispatch(node.test, ext_info)
    self.code_buffer.append('if [ %s ]; then' % test)
    for x in node.body:
Severity: Major
Found in sherlock/codelib/generator/implements/statement.py and 1 other location - About 3 hrs to fix
sherlock/codelib/generator/implements/statement.py on lines 12..18

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

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

@add_generator('While')
def generate_while(self, node, ext_info):
    test = self.dispatch(node.test, ext_info)
    self.code_buffer.append('while [ %s ]; do' % test)
    for x in node.body:
Severity: Major
Found in sherlock/codelib/generator/implements/statement.py and 1 other location - About 3 hrs to fix
sherlock/codelib/generator/implements/statement.py on lines 4..10

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

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

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

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

@system_function('pipe', Type.VOID, Type.ANY, Type.ANY)
def system_pipe(g, before, after):
    return '%s | %s' % (g.dispatch(before), g.dispatch(after))
Severity: Major
Found in sherlock/codelib/system_function/implements.py and 1 other location - About 1 hr to fix
sherlock/codelib/system_function/implements.py on lines 6..8

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

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

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

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

@system_function('range', Type.LIST, Type.NUMBER, Type.NUMBER)
def system_range(g, start, end):
    return '$(seq %s $(( %s - 1 )))' % (g.dispatch(start), g.dispatch(end))
Severity: Major
Found in sherlock/codelib/system_function/implements.py and 1 other location - About 1 hr to fix
sherlock/codelib/system_function/implements.py on lines 14..16

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

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

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

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

    @add_generator('Print')
    def generate_print(self, node, ext_info):
        return 'echo %s' % ' '.join([self.dispatch(value, ext_info) for value in node.values])
    Severity: Minor
    Found in sherlock/codelib/generator/implements/simple_generator.py and 1 other location - About 30 mins to fix
    sherlock/codelib/generator/implements/simple_generator.py on lines 72..72

    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

    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
          Severity
          Category
          Status
          Source
          Language