knipknap/exscript

View on GitHub
Exscript/interpreter/expression.py

Summary

Maintainability
F
3 days
Test Coverage

Function value has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring.
Open

    def value(self, context):
        # Special behavior where we only have one term.
        if self.op is None:
            return self.lft.value(context)
        elif self.op == 'not':
Severity: Minor
Found in Exscript/interpreter/expression.py - About 6 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 priority has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    def priority(self):
        if self.op is None:
            return 8
        elif self.op_type == 'arithmetic_operator' and self.op == '%':
            return 7
Severity: Minor
Found in Exscript/interpreter/expression.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 prioritize has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def prioritize(self, start, prio=1):
        # print("Prioritizing from", start.op, "with prio", prio, (start.lft,)
        # start.rgt)
        if prio == 6:
            return
Severity: Minor
Found in Exscript/interpreter/expression.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 too many return statements within this function.
Open

            return 4
Severity: Major
Found in Exscript/interpreter/expression.py - About 30 mins to fix

    Avoid too many return statements within this function.
    Open

                return [int(lft) // int(rgt)]
    Severity: Major
    Found in Exscript/interpreter/expression.py - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

                  return [int(lft) % int(rgt)]
      Severity: Major
      Found in Exscript/interpreter/expression.py - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

                    return 5
        Severity: Major
        Found in Exscript/interpreter/expression.py - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                      return 1
          Severity: Major
          Found in Exscript/interpreter/expression.py - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                        return [0]
            Severity: Major
            Found in Exscript/interpreter/expression.py - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                          return [int(lft) + int(rgt)]
              Severity: Major
              Found in Exscript/interpreter/expression.py - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                            return [lft != rgt]
                Severity: Major
                Found in Exscript/interpreter/expression.py - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                              return 2
                  Severity: Major
                  Found in Exscript/interpreter/expression.py - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                                return [lft not in rgt_lst]
                    Severity: Major
                    Found in Exscript/interpreter/expression.py - About 30 mins to fix

                      Avoid too many return statements within this function.
                      Open

                                  return [int(lft) >= int(rgt)]
                      Severity: Major
                      Found in Exscript/interpreter/expression.py - About 30 mins to fix

                        Avoid too many return statements within this function.
                        Open

                                    return [int(lft) <= int(rgt)]
                        Severity: Major
                        Found in Exscript/interpreter/expression.py - About 30 mins to fix

                          Avoid too many return statements within this function.
                          Open

                                      return [str(lft) + str(rgt)]
                          Severity: Major
                          Found in Exscript/interpreter/expression.py - About 30 mins to fix

                            Avoid too many return statements within this function.
                            Open

                                        return [lft in rgt_lst]
                            Severity: Major
                            Found in Exscript/interpreter/expression.py - About 30 mins to fix

                              Avoid too many return statements within this function.
                              Open

                                          return [int(lft) < int(rgt)]
                              Severity: Major
                              Found in Exscript/interpreter/expression.py - About 30 mins to fix

                                Avoid too many return statements within this function.
                                Open

                                            return 3
                                Severity: Major
                                Found in Exscript/interpreter/expression.py - About 30 mins to fix

                                  Avoid too many return statements within this function.
                                  Open

                                              return [lft and rgt]
                                  Severity: Major
                                  Found in Exscript/interpreter/expression.py - About 30 mins to fix

                                    Avoid too many return statements within this function.
                                    Open

                                                return [int(lft) - int(rgt)]
                                    Severity: Major
                                    Found in Exscript/interpreter/expression.py - About 30 mins to fix

                                      Avoid too many return statements within this function.
                                      Open

                                                  return [int(lft) > int(rgt)]
                                      Severity: Major
                                      Found in Exscript/interpreter/expression.py - About 30 mins to fix

                                        Avoid too many return statements within this function.
                                        Open

                                                    return [lft or rgt]
                                        Severity: Major
                                        Found in Exscript/interpreter/expression.py - About 30 mins to fix

                                          Avoid too many return statements within this function.
                                          Open

                                                      return [int(lft) * int(rgt)]
                                          Severity: Major
                                          Found in Exscript/interpreter/expression.py - About 30 mins to fix

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

                                                def dump(self, indent=0):
                                                    print((' ' * indent) + self.name, 'start')
                                                    self.root.dump(indent + 1)
                                                    print((' ' * indent) + self.name, 'end.')
                                            Severity: Major
                                            Found in Exscript/interpreter/expression.py and 1 other location - About 3 hrs to fix
                                            Exscript/interpreter/trying.py on lines 46..49

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

                                            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 type(rgt_lst) == type([]):
                                                        if len(rgt_lst) > 0:
                                                            rgt = rgt_lst[0]
                                                        else:
                                                            rgt = ''
                                            Severity: Major
                                            Found in Exscript/interpreter/expression.py and 1 other location - About 1 hr to fix
                                            Exscript/interpreter/expression.py on lines 105..109

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

                                            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 type(lft_lst) == type([]):
                                                        if len(lft_lst) > 0:
                                                            lft = lft_lst[0]
                                                        else:
                                                            lft = ''
                                            Severity: Major
                                            Found in Exscript/interpreter/expression.py and 1 other location - About 1 hr to fix
                                            Exscript/interpreter/expression.py on lines 111..115

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

                                            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 not lexer.current_is('arithmetic_operator') and \
                                                           not lexer.current_is('logical_operator') and \
                                                           not lexer.current_is('comparison') and \
                                                           not lexer.current_is('regex_delimiter'):
                                            Severity: Major
                                            Found in Exscript/interpreter/expression.py and 1 other location - About 1 hr to fix
                                            Exscript/interpreter/expression.py on lines 61..64

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

                                            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 not lexer.next_if('arithmetic_operator') and \
                                                       not lexer.next_if('logical_operator') and \
                                                       not lexer.next_if('comparison') and \
                                                       not lexer.next_if('regex_delimiter'):
                                            Severity: Major
                                            Found in Exscript/interpreter/expression.py and 1 other location - About 1 hr to fix
                                            Exscript/interpreter/expression.py on lines 52..55

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

                                            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