newmen/versatile-diamond

View on GitHub
analyzer/lib/interpreter/reaction.rb

Summary

Maintainability
C
1 day
Test Coverage

Method extends_if_possible has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

      def extends_if_possible(type, source, products, bonds_sum_limit, deep, &block)
        specs = eval(type.to_s)
        combinations(specs).each do |combination|
          bonds_sum = specs.reduce(0) do |acc, spec|
            acc +
Severity: Minor
Found in analyzer/lib/interpreter/reaction.rb - 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

Method equation has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

      def equation(str)
        sides = Matcher.equation(str)
        syntax_error('.invalid') unless sides

        names_and_specs = {}
Severity: Minor
Found in analyzer/lib/interpreter/reaction.rb - 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

Method equation has 36 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def equation(str)
        sides = Matcher.equation(str)
        syntax_error('.invalid') unless sides

        names_and_specs = {}
Severity: Minor
Found in analyzer/lib/interpreter/reaction.rb - About 1 hr to fix

    Method check_balance has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

          def check_balance(source, products, deep = 2, &block)
            ebs = external_bonds_sum(source)
            ebp = external_bonds_sum(products)
    
            if ebs == ebp
    Severity: Minor
    Found in analyzer/lib/interpreter/reaction.rb - 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

    Method detect_name_and_spec has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

          def detect_name_and_spec(spec_str)
            if Matcher.active_bond(spec_str)
              ['*', Concepts::ActiveBond.new]
            elsif (atom_name = Matcher.atom(spec_str))
              atom = get(:atom, atom_name)
    Severity: Minor
    Found in analyzer/lib/interpreter/reaction.rb - 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

    Method extends_if_possible has 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

          def extends_if_possible(type, source, products, bonds_sum_limit, deep, &block)
    Severity: Minor
    Found in analyzer/lib/interpreter/reaction.rb - About 45 mins to fix

      There are no issues that match your filters.

      Category
      Status