Showing 77 of 77 total issues

Method process_line has 34 lines of code (exceeds 25 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 1 hr to fix

    Method parse_new_attributes has 33 lines of code (exceeds 25 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

      Method each_attr has 33 lines of code (exceeds 25 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

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

              def filter_and_join(value, separator)
                return '' if (value.respond_to?(:empty?) && value.empty?)
        
                if value.is_a?(Array)
                  value = value.flatten
        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 flatten_attributes has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

            def flatten_attributes(attributes)
              flattened = {}
        
              attributes.each do |key, value|
                case value
        Severity: Minor
        Found in lib/haml/attribute_builder.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

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

          class Filters
            class Css < TextBase
              def compile(node)
                case @format
                when :xhtml
        Severity: Major
        Found in lib/haml/filters/css.rb and 1 other location - About 1 hr to fix
        lib/haml/filters/javascript.rb on lines 3..29

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

        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

          class Filters
            class Javascript < TextBase
              def compile(node)
                case @format
                when :xhtml
        Severity: Major
        Found in lib/haml/filters/javascript.rb and 1 other location - About 1 hr to fix
        lib/haml/filters/css.rb on lines 3..29

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

        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 compile_boolean! has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

            def compile_boolean!(temple, key, values)
              exp = literal_for(values.last)
        
              if Temple::StaticAnalyzer.static?(exp)
                value = eval(exp)
        Severity: Minor
        Found in lib/haml/attribute_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

        Method on_multi has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            def on_multi(*exps)
              exps = exps.dup
              result = [:multi]
              buffer = []
        
        
        Severity: Minor
        Found in lib/haml/dynamic_merger.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 next_line has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            def next_line
              line = @template.shift || raise(StopIteration)
        
              # `flat?' here is a little outdated,
              # so we have to manually check if either the previous or current line
        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_tokens! has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

                def compile_tokens!(exps, tokens)
                  beg_str, end_str = strip_quotes!(tokens)
        
                  until tokens.empty?
                    _, type, str = tokens.shift
        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 compute_tabs has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            def compute_tabs(line)
              return 0 if line.text.empty? || !line.whitespace
        
              if @indentation.nil?
                @indentation = line.whitespace
        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 rstrip_whitespace! has 26 lines of code (exceeds 25 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 1 hr to fix

          Method on_dynamic has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

                def on_dynamic(code)
                  return [:dynamic, code] unless string_literal?(code)
                  return [:dynamic, code] if code.include?("\n")
          
                  temple = [:multi]
          Severity: Minor
          Found in lib/haml/string_splitter.rb - About 55 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 close_silent_script has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

              def close_silent_script(node)
                @script_level_stack.pop if ["if", "case", "unless"].include? node.value[:keyword]
          
                # Post-process case statements to normalize the nesting of "when" clauses
                return unless node.value[:keyword] == "case"
          Severity: Minor
          Found in lib/haml/parser.rb - About 55 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 balance has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

              def balance(scanner, start, finish, count = 0)
                str = ''.dup
                scanner = StringScanner.new(scanner) unless scanner.is_a? StringScanner
                regexp = Regexp.new("(.*?)[\\#{start.chr}\\#{finish.chr}]", Regexp::MULTILINE)
                while scanner.scan(regexp)
          Severity: Minor
          Found in lib/haml/util.rb - About 55 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 count_lines has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

              def self.count_lines(exp)
                type, *args = exp
                case type
                when :multi
                  args.map { |a| count_lines(a) }.reduce(:+) || 0
          Severity: Minor
          Found in lib/haml/temple_line_counter.rb - About 55 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

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

                def compile_interpolated_plain(node)
                  temple = [:multi]
                  StringSplitter.compile(node.value[:text]).each do |type, value|
                    case type
                    when :static
          Severity: Minor
          Found in lib/haml/compiler/script_compiler.rb and 1 other location - About 50 mins to fix
          lib/haml/compiler/tag_compiler.rb on lines 57..67

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

          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

                def compile_interpolated_plain(node)
                  temple = [:multi]
                  StringSplitter.compile(node.value[:value]).each do |type, value|
                    case type
                    when :static
          Severity: Minor
          Found in lib/haml/compiler/tag_compiler.rb and 1 other location - About 50 mins to fix
          lib/haml/compiler/script_compiler.rb on lines 45..55

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

          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 build_boolean! has 6 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              def build_boolean!(escape_attrs, quote, format, buf, key, value)
          Severity: Minor
          Found in lib/haml/attribute_builder.rb - About 45 mins to fix
            Severity
            Category
            Status
            Source
            Language