whoward/cadenza

View on GitHub

Showing 18 of 29 total issues

File racc_parser.rb has 678 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'racc/parser.rb'

# racc_parser.rb : generated by racc

module Cadenza
Severity: Major
Found in lib/cadenza/racc_parser.rb - About 1 day to fix

    Method state= has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

        def state=(new_state)
          # if trying to transition to a new state raise an exception
          raise IllegalStateError, new_state unless VALID_STATES.include?(new_state)
    
          # no special transition for the same state
    Severity: Minor
    Found in lib/cadenza/source_renderer.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 scan_statement has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

        def scan_statement
          # eat any whitespace at the start of the string
          whitespace = @scanner.scan_until(/\S/)
    
          if whitespace
    Severity: Minor
    Found in lib/cadenza/lexer.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 scan_statement has 45 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def scan_statement
          # eat any whitespace at the start of the string
          whitespace = @scanner.scan_until(/\S/)
    
          if whitespace
    Severity: Minor
    Found in lib/cadenza/lexer.rb - About 1 hr to fix

      Method scan_body has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

          def scan_body
            if (text = @scanner.scan(/\{\{/))
              @context = :statement
              token(:VAR_OPEN, text)
      
      
      Severity: Minor
      Found in lib/cadenza/lexer.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 eval has 29 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def eval(context)
            l = @left.eval(context)
            r = @right.eval(context)
      
            case @operator
      Severity: Minor
      Found in lib/cadenza/nodes/operation_node.rb - About 1 hr to fix

        Method render_operation has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            def render_operation(node, context, blocks)
              self.state = :var unless state == :tag
        
              # calculate the operator precedence of the left, right and parent node
              node_precedence  = calculate_precedence(node)
        Severity: Minor
        Found in lib/cadenza/source_renderer.rb - 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

        Method render_filtered_value has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            def render_filtered_value(node, context, blocks)
              state == :var unless state == :tag
        
              render(node.value, context, blocks)
        
        
        Severity: Minor
        Found in lib/cadenza/source_renderer.rb - 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 method.
        Open

                return l || r
        Severity: Major
        Found in lib/cadenza/nodes/operation_node.rb - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

                  return l > r
          Severity: Major
          Found in lib/cadenza/nodes/operation_node.rb - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                    return l < r
            Severity: Major
            Found in lib/cadenza/nodes/operation_node.rb - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                      return l + r
              Severity: Major
              Found in lib/cadenza/nodes/operation_node.rb - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                        return l * r
                Severity: Major
                Found in lib/cadenza/nodes/operation_node.rb - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                          return l && r
                  Severity: Major
                  Found in lib/cadenza/nodes/operation_node.rb - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                            return l - r
                    Severity: Major
                    Found in lib/cadenza/nodes/operation_node.rb - About 30 mins to fix

                      Avoid too many return statements within this method.
                      Open

                              return l / r
                      Severity: Major
                      Found in lib/cadenza/nodes/operation_node.rb - About 30 mins to fix

                        Method lookup_on_object has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                        Open

                            def self.lookup_on_object(identifier, object)
                              sym_identifier = identifier.to_sym
                        
                              # allow looking up array indexes with dot notation, example: alphabet.0 => "a"
                              return object[identifier.to_i] if object.respond_to?(:[]) && object.is_a?(Array) && identifier =~ /\A\d+\z/
                        Severity: Minor
                        Found in lib/cadenza/context.rb - About 25 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

                        Method render_children has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                        Open

                            def render_children(nodes, context, blocks)
                              nodes.each_with_index do |node, idx|
                                is_last_loop = idx == nodes.length - 1
                        
                                output << ("\u2503   " * @level)
                        Severity: Minor
                        Found in lib/cadenza/source_tree_renderer.rb - About 25 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

                        Severity
                        Category
                        Status
                        Source
                        Language