Showing 68 of 77 total issues

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

require 'ripper'
require 'strscan'
require 'haml/error'
require 'haml/util'

Severity: Major
Found in lib/haml/parser.rb - About 1 day to fix

    Class Parser has 53 methods (exceeds 20 allowed). Consider refactoring.
    Open

      class Parser
        include Haml::Util
    
        attr_reader :root
    
    
    Severity: Major
    Found in lib/haml/parser.rb - About 7 hrs to fix

      Method tag has a Cognitive Complexity of 44 (exceeds 5 allowed). Consider refactoring.
      Open

          def tag(line)
            tag_name, attributes, attributes_hashes, object_ref, nuke_outer_whitespace,
              nuke_inner_whitespace, action, value, last_line = parse_tag(line.text)
      
            preserve_tag = @options.preserve.include?(tag_name)
      Severity: Minor
      Found in lib/haml/parser.rb - About 6 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 call has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
      Open

          def call(template)
            template = Haml::Util.check_haml_encoding(template) do |msg, line|
              raise Haml::Error.new(msg, line)
            end
      
      
      Severity: Minor
      Found in lib/haml/parser.rb - About 5 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 a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
      Open

          def parse_tag(text)
            match = text.scan(/%([-:\w]+)([-:\w.#\@]*)(.+)?/)[0]
            raise SyntaxError.new(Error.message(:invalid_tag, text)) unless match
      
            tag_name, attributes, rest = match
      Severity: Minor
      Found in lib/haml/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 process_line has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
      Open

          def process_line(line)
            case line.text[0]
            when DIV_CLASS; push div(line)
            when DIV_ID
              return push plain(line) if %w[{ @ $].include?(line.text[1])
      Severity: Minor
      Found in lib/haml/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 merge_value has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
      Open

            def merge_value(key, to, from)
              if from.kind_of?(Hash) || to.kind_of?(Hash)
                from = { nil => from } if !from.is_a?(Hash)
                to   = { nil => to }   if !to.is_a?(Hash)
                to.merge(from)
      Severity: Minor
      Found in lib/haml/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_new_attribute has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
      Open

          def parse_new_attribute(scanner)
            unless (name = scanner.scan(/[-:\w]+/))
              return if scanner.scan(/\)/)
              return false
            end
      Severity: Minor
      Found in lib/haml/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 tag has 68 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def tag(line)
            tag_name, attributes, attributes_hashes, object_ref, nuke_outer_whitespace,
              nuke_inner_whitespace, action, value, last_line = parse_tag(line.text)
      
            preserve_tag = @options.preserve.include?(tag_name)
      Severity: Major
      Found in lib/haml/parser.rb - About 2 hrs to fix

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

              def rstrip_whitespace!(temple)
                return if temple.size == 1
        
                case temple[0]
                when :multi
        Severity: Minor
        Found in lib/haml/compiler/children_compiler.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_new_attributes has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

            def parse_new_attributes(text)
              scanner = StringScanner.new(text)
              last_line = @line.index + 1
              attributes = {}
        
        
        Severity: Minor
        Found in lib/haml/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_static_hash has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

            def parse_static_hash(text)
              attributes = {}
              return attributes if text.empty?
        
              text = text[1...-1] # strip brackets
        Severity: Minor
        Found in lib/haml/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 unescape_interpolation has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

            def unescape_interpolation(str, escape_html = nil)
              res = ''.dup
              rest = Haml::Util.handle_interpolation str.dump do |scan|
                escapes = (scan[2].size - 1) / 2
                char = scan[3] # '{', '@' or '$'
        Severity: Minor
        Found in lib/haml/util.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_tag has 43 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def parse_tag(text)
              match = text.scan(/%([-:\w]+)([-:\w.#\@]*)(.+)?/)[0]
              raise SyntaxError.new(Error.message(:invalid_tag, text)) unless match
        
              tag_name, attributes, rest = match
        Severity: Minor
        Found in lib/haml/parser.rb - About 1 hr to fix

          Method call has 42 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def call(template)
                template = Haml::Util.check_haml_encoding(template) do |msg, line|
                  raise Haml::Error.new(msg, line)
                end
          
          
          Severity: Minor
          Found in lib/haml/parser.rb - About 1 hr to fix

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

                    def shift_balanced_embexpr(tokens)
                      String.new.tap do |embedded|
                        embexpr_open = 1
            
                        until tokens.empty?
            Severity: Minor
            Found in lib/haml/string_splitter.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 each_attr has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
            Open

                def each_attr(tokens)
                  attr_tokens = []
                  open_tokens = Hash.new { |h, k| h[k] = 0 }
            
                  tokens.each do |token|
            Severity: Minor
            Found in lib/haml/attribute_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 handle_multiline has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
            Open

                def handle_multiline(line)
                  return unless is_multiline?(line.text)
                  line.text.slice!(-1)
                  loop do
                    new_line = @template.first
            Severity: Minor
            Found in lib/haml/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 silent_script has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
            Open

                def silent_script(line)
                  raise SyntaxError.new(Error.message(:no_end), line.index) if line.text[1..-1].strip == 'end'
            
                  line = handle_ruby_multiline(line)
                  keyword = block_keyword(line.text)
            Severity: Minor
            Found in lib/haml/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 compile_contents has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
            Open

                  def compile_contents(node, &block)
                    case
                    when !node.children.empty?
                      yield(node)
                    when node.value[:value].nil? && self_closing?(node)
            Severity: Minor
            Found in lib/haml/compiler/tag_compiler.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

            Severity
            Category
            Status
            Source
            Language