slim-template/slim

View on GitHub
lib/slim/parser.rb

Summary

Maintainability
F
4 days
Test Coverage
F
50%

File parser.rb has 403 lines of code (exceeds 250 allowed). Consider refactoring.
Open

module Slim
  # Parses Slim code and transforms it to a Temple expression
  # @api private
  class Parser < Temple::Parser
    define_options :file,
Severity: Minor
Found in lib/slim/parser.rb - About 5 hrs to fix

    Method parse_tag has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
    Open

        def parse_tag(tag)
          if @tag_shortcut[tag]
            @line.slice!(0, tag.size) unless @attr_shortcut[tag]
            tag = @tag_shortcut[tag]
          end
    Severity: Minor
    Found in lib/slim/parser.rb - About 4 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 parse_text_block has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
    Open

        def parse_text_block(first_line = nil, text_indent = nil)
          result = [:multi]
          if !first_line || first_line.empty?
            text_indent = nil
          else
    Severity: Minor
    Found in lib/slim/parser.rb - About 4 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 parse_attributes has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
    Open

        def parse_attributes(attributes = [:html, :attrs])
          # Check to see if there is a delimiter right after the tag name
          delimiter = nil
          if @line =~ @attr_list_delims_re
            delimiter = @attr_list_delims[$1]
    Severity: Minor
    Found in lib/slim/parser.rb - About 3 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 parse_tag has 67 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def parse_tag(tag)
          if @tag_shortcut[tag]
            @line.slice!(0, tag.size) unless @attr_shortcut[tag]
            tag = @tag_shortcut[tag]
          end
    Severity: Major
    Found in lib/slim/parser.rb - About 2 hrs to fix

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

          def initialize(opts = {})
            super
            @attr_list_delims = options[:attr_list_delims]
            @code_attr_delims = options[:code_attr_delims]
            tabsize = options[:tabsize]
      Severity: Minor
      Found in lib/slim/parser.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 parse_ruby_code has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

          def parse_ruby_code(outer_delimiter)
            code, count, delimiter, close_delimiter = '', 0, nil, nil
      
            # Attribute ends with space or attribute delimiter
            end_re = /\A[\s#{Regexp.escape outer_delimiter.to_s}]/
      Severity: Minor
      Found in lib/slim/parser.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 parse_line_indicators has 47 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def parse_line_indicators
            case @line
            when /\A\/!( ?)/
              # HTML comment
              @stacks.last << [:html, :comment, [:slim, :text, :verbatim, parse_text_block($', @indents.last + $1.size + 2)]]
      Severity: Minor
      Found in lib/slim/parser.rb - About 1 hr to fix

        Method parse_attributes has 44 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def parse_attributes(attributes = [:html, :attrs])
              # Check to see if there is a delimiter right after the tag name
              delimiter = nil
              if @line =~ @attr_list_delims_re
                delimiter = @attr_list_delims[$1]
        Severity: Minor
        Found in lib/slim/parser.rb - About 1 hr to fix

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

              def parse_line
                if @line =~ /\A\s*\Z/
                  @stacks.last << [:newline]
                  return
                end
          Severity: Minor
          Found in lib/slim/parser.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 41 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def initialize(opts = {})
                super
                @attr_list_delims = options[:attr_list_delims]
                @code_attr_delims = options[:code_attr_delims]
                tabsize = options[:tabsize]
          Severity: Minor
          Found in lib/slim/parser.rb - About 1 hr to fix

            Method parse_quoted_attribute has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
            Open

                def parse_quoted_attribute(quote)
                  value, count = '', 0
            
                  until count == 0 && @line[0] == quote[0]
                    if @line =~ /\A(\\)?\Z/
            Severity: Minor
            Found in lib/slim/parser.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 parse_line_indicators has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

                def parse_line_indicators
                  case @line
                  when /\A\/!( ?)/
                    # HTML comment
                    @stacks.last << [:html, :comment, [:slim, :text, :verbatim, parse_text_block($', @indents.last + $1.size + 2)]]
            Severity: Minor
            Found in lib/slim/parser.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 parse_text_block has 31 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                def parse_text_block(first_line = nil, text_indent = nil)
                  result = [:multi]
                  if !first_line || first_line.empty?
                    text_indent = nil
                  else
            Severity: Minor
            Found in lib/slim/parser.rb - About 1 hr to fix

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

                    def initialize(error, file, line, lineno, column)
              Severity: Minor
              Found in lib/slim/parser.rb - About 35 mins to fix

                There are no issues that match your filters.

                Category
                Status