Showing 68 of 77 total issues

Avoid too many return statements within this method.
Open

        return push flat_script(line.strip!(2), false) if line.text[1] == FLAT_SCRIPT
Severity: Major
Found in lib/haml/parser.rb - About 30 mins to fix

    Method string_literal? has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

          def string_literal?(code)
            return false if SyntaxChecker.syntax_error?(code)
    
            type, instructions = Ripper.sexp(code)
            return false if type != :program
    Severity: Minor
    Found in lib/haml/string_splitter.rb - About 25 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 compile_text! has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

          def compile_text!(temple, node, prefix)
            text = node.value[:text].rstrip.gsub(/^/, prefix)
            if ::Haml::Util.contains_interpolation?(node.value[:text])
              # original: Haml::Filters#compile
              text = ::Haml::Util.unescape_interpolation(text).gsub(/(\\+)n/) do |s|
    Severity: Minor
    Found in lib/haml/filters/text_base.rb - About 25 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 call has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def call(template, source = nil)
          source ||= template.source
          options = RailsTemplate.options
    
          # Make the filename available in parser etc.
    Severity: Minor
    Found in lib/haml/rails_template.rb - About 25 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 process_indent has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def process_indent(line)
          return unless line.tabs <= @template_tabs && @template_tabs > 0
    
          to_close = @template_tabs - line.tabs
          to_close.times {|i| close unless to_close - 1 - i == 0 && continuation_script?(line.text)}
    Severity: Minor
    Found in lib/haml/parser.rb - About 25 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 find_and_preserve has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def find_and_preserve(input = nil, tags = DEFAULT_PRESERVE_TAGS, &block)
          return find_and_preserve(capture_haml(&block), input || tags) if block
    
          tags = tags.each_with_object('') do |t, s|
            s << '|' unless s.empty?
    Severity: Minor
    Found in lib/haml/rails_helpers.rb - About 25 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 haml_comment has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def haml_comment(text)
          if filter_opened?
            @flat = true
            @filter_buffer = String.new
            @filter_buffer << "#{text}\n" unless text.empty?
    Severity: Minor
    Found in lib/haml/parser.rb - About 25 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 process_load_options has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def process_load_options
          if options[:load_path]
            options[:load_path].split(':').each do |dir|
              $LOAD_PATH.unshift(dir) unless $LOAD_PATH.include?(dir)
            end
    Severity: Minor
    Found in lib/haml/cli.rb - About 25 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

    Severity
    Category
    Status
    Source
    Language