whoward/cadenza

View on GitHub

Showing 29 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

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

    racc_action_table = [
        37,    37,     3,    90,     4,     3,     3,   116,    46,    65,
        66,    56,    57,    89,    37,    65,    66,   107,     9,    37,
       121,     9,     9,   106,    33,    33,    34,    34,    78,    79,
        35,    35,    37,    36,    36,    85,    38,    38,    33,   110,
    Severity: Major
    Found in lib/cadenza/racc_parser.rb and 1 other location - About 1 day to fix
    lib/cadenza/racc_parser.rb on lines 49..77

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

    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

    racc_action_check = [
       116,    46,     0,    53,     0,   118,     7,   118,     7,    70,
        70,    99,    99,    73,    43,    69,    69,    70,     0,    87,
        85,   118,     7,    69,   116,    46,   116,    46,   116,   116,
       116,    46,    39,   116,    46,    46,   116,    46,    43,    73,
    Severity: Major
    Found in lib/cadenza/racc_parser.rb and 1 other location - About 1 day to fix
    lib/cadenza/racc_parser.rb on lines 19..47

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

    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

    racc_goto_check = [
        28,    16,    27,     6,    11,     3,     4,    12,     2,    25,
        22,     5,     5,     2,     2,     2,     2,    19,    15,     4,
         4,     9,     3,     4,     6,     8,     8,     8,     8,     8,
         8,     7,     7,    10,    10,     1,   nil,    16,   nil,    28,
    Severity: Major
    Found in lib/cadenza/racc_parser.rb and 1 other location - About 3 hrs to fix
    lib/cadenza/racc_parser.rb on lines 111..123

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

    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

    racc_goto_table = [
        18,    40,    19,    32,   104,    52,    51,   105,     2,    88,
        47,    91,    92,    41,    45,    48,    49,    44,    42,    69,
        70,    64,    73,    51,    53,    95,    96,    97,    98,    99,
       100,    93,    94,   101,   102,     1,   nil,    80,   nil,    18,
    Severity: Major
    Found in lib/cadenza/racc_parser.rb and 1 other location - About 3 hrs to fix
    lib/cadenza/racc_parser.rb on lines 125..137

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

    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

    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_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

        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

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