whitequark/parser

View on GitHub
lib/parser/lexer/literal.rb

Summary

Maintainability
C
7 hrs
Test Coverage

Class Literal has 24 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Lexer::Literal
    DELIMITERS = { '(' => ')', '[' => ']', '{' => '}', '<' => '>' }
    SPACE = ' '.ord
    TAB = "\t".ord

Severity: Minor
Found in lib/parser/lexer/literal.rb - About 2 hrs to fix

    Method nest_and_try_closing has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

        def nest_and_try_closing(delimiter, ts, te, lookahead=nil)
          delimiter = coerce_encoding(delimiter)
    
          if @start_delim && @start_delim == delimiter
            @nesting += 1
    Severity: Minor
    Found in lib/parser/lexer/literal.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 initialize has 26 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def initialize(lexer, str_type, delimiter, str_s, heredoc_e = nil,
                       indent = false, dedent_body = false, label_allowed = false)
          @lexer       = lexer
          @nesting     = 1
    
    
    Severity: Minor
    Found in lib/parser/lexer/literal.rb - About 1 hr to fix

      Method initialize has 8 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def initialize(lexer, str_type, delimiter, str_s, heredoc_e = nil,
                         indent = false, dedent_body = false, label_allowed = false)
      Severity: Major
      Found in lib/parser/lexer/literal.rb - About 1 hr to fix

        Method infer_indent_level has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            def infer_indent_level(line)
              return if !@dedent_body
        
              indent_level = 0
              line.each_char do |char|
        Severity: Minor
        Found in lib/parser/lexer/literal.rb - 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

        Method initialize has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            def initialize(lexer, str_type, delimiter, str_s, heredoc_e = nil,
                           indent = false, dedent_body = false, label_allowed = false)
              @lexer       = lexer
              @nesting     = 1
        
        
        Severity: Minor
        Found in lib/parser/lexer/literal.rb - 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

        There are no issues that match your filters.

        Category
        Status