sds/haml-lint

View on GitHub

Showing 58 of 58 total issues

Method visit_tag_attributes has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def visit_tag_attributes(node, indent:)
      final_line_index = node.line - 1
      additional_attributes = node.dynamic_attributes_sources

      attributes_code = additional_attributes.first
Severity: Minor
Found in lib/haml_lint/ruby_extraction/chunk_extractor.rb - About 1 hr to fix

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

        def contains_class_attribute?(attributes_sources)
          attributes_sources.each do |code|
            ast_root = parse_ruby(surrounded_by_braces?(code) ? code : "{#{code}}")
            next unless ast_root # RuboCop linter will report syntax errors
    
    
    Severity: Minor
    Found in lib/haml_lint/linter/class_attribute_with_static_value.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 extract_raw_tag_attributes_ruby_lines has 27 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def extract_raw_tag_attributes_ruby_lines(haml_processed_ruby_code, first_line_index)
          haml_processed_ruby_code = haml_processed_ruby_code.strip
          first_line = @original_haml_lines[first_line_index]
    
          char_index = first_line.index(haml_processed_ruby_code)
    Severity: Minor
    Found in lib/haml_lint/ruby_extraction/chunk_extractor.rb - About 1 hr to fix

      Method transfer_correction_logic has 27 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def transfer_correction_logic(_coordinator, to_ruby_lines, haml_lines) # rubocop:disable Metrics
            return if @ruby_lines == to_ruby_lines
      
            affected_haml_lines = haml_lines[@haml_line_index..haml_end_line_index]
      
      
      Severity: Minor
      Found in lib/haml_lint/ruby_extraction/tag_attributes_chunk.rb - About 1 hr to fix

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

            def for_consecutive_items(items, satisfies, min_consecutive = 2)
              current_index = -1
        
              while (current_index += 1) < items.count
                next unless satisfies[items[current_index]]
        Severity: Minor
        Found in lib/haml_lint/utils.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 finish_visit_any_script has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            def finish_visit_any_script(node, lines, raw_code: nil, must_start_chunk: false, first_output_prefix: '=')
              raw_code ||= lines.join("\n")
              start_nesting = self.class.start_nesting_after?(raw_code)
        
              lines = add_following_empty_lines(node, lines)
        Severity: Minor
        Found in lib/haml_lint/ruby_extraction/chunk_extractor.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 rubocop_autocorrect_flags has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            def rubocop_autocorrect_flags
              return [] unless @autocorrect
        
              rubocop_version = Gem::Version.new(::RuboCop::Version::STRING)
        
        
        Severity: Minor
        Found in lib/haml_lint/linter/rubocop.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 parsed_script has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            def parsed_script
              statement =
                case keyword = @value[:keyword]
                when 'else', 'elsif'
                  'if 0;' + script + ';end'
        Severity: Minor
        Found in lib/haml_lint/tree/silent_script_node.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 visit has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            def visit(node)
              # Keep track of whether this block was consumed by the visitor. This
              # allows us to visit all nodes by default, but can override the behavior
              # by specifying `yield false` in a visit method, indicating that no
              # further visiting should occur for the current node's children.
        Severity: Minor
        Found in lib/haml_lint/haml_visitor.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 new_haml_validity_checks has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            def new_haml_validity_checks(new_haml_string)
              new_haml_error = HamlLint::Utils.check_error_when_compiling_haml(new_haml_string)
              return true unless new_haml_error
        
              error_message = if new_haml_error.is_a?(::SyntaxError)
        Severity: Minor
        Found in lib/haml_lint/linter/rubocop.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 visit_tag_attributes has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            def visit_tag_attributes(node, indent:)
              final_line_index = node.line - 1
              additional_attributes = node.dynamic_attributes_sources
        
              attributes_code = additional_attributes.first
        Severity: Minor
        Found in lib/haml_lint/ruby_extraction/chunk_extractor.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 visit_tag has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            def visit_tag(node)
              return unless node.hash_attributes?
        
              style = STYLE[config['style'] == 'no_space' ? 'no_space' : 'space']
              source = node.hash_attributes_source
        Severity: Minor
        Found in lib/haml_lint/linter/space_inside_hash_attributes.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 act_on_options has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            def act_on_options(options) # rubocop:disable Metrics
              configure_logger(options)
              if options[:debug]
                ENV['HAML_LINT_DEBUG'] = 'true'
              end
        Severity: Minor
        Found in lib/haml_lint/cli.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 visit_tag has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            def visit_tag(node) # rubocop:disable Metrics/CyclomaticComplexity
              # If this tag has inline script
              return unless node.contains_script?
        
              text = node.script.strip
        Severity: Minor
        Found in lib/haml_lint/linter/space_before_script.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 check_character has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            def check_character(character, root)
              wrong_characters = character == :space ? 'tabs' : 'spaces'
              regex = INDENT_REGEX[character]
              dummy_node = Struct.new(:line)
        
        
        Severity: Minor
        Found in lib/haml_lint/linter/indentation.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 extract_raw_ruby_lines has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            def extract_raw_ruby_lines(haml_processed_ruby_code, first_line_index)
              haml_processed_ruby_code = haml_processed_ruby_code.strip
              first_line = @original_haml_lines[first_line_index]
        
              char_index = first_line.index(haml_processed_ruby_code)
        Severity: Minor
        Found in lib/haml_lint/ruby_extraction/chunk_extractor.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 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def initialize(linter, filename, line, message, severity = :warning, corrected: false) # rubocop:disable Metrics/ParameterLists
        Severity: Minor
        Found in lib/haml_lint/lint.rb - About 35 mins to fix

          Method visit_script has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              def visit_script(node, &block)
                raw_first_line = @original_haml_lines[node.line - 1]
          
                # ==, !, !==, &, &== means interpolation (was needed before HAML 2.2... it's still supported)
                # =, !=, &= mean actual ruby code is coming
          Severity: Minor
          Found in lib/haml_lint/ruby_extraction/chunk_extractor.rb - About 35 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 node_for_line has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              def node_for_line(line) # rubocop:disable Metrics
                each do |node|
                  return node if node.line_numbers.cover?(line) && node != self
                end
          
          
          Severity: Minor
          Found in lib/haml_lint/tree/root_node.rb - About 35 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 visit_tag_script has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              def visit_tag_script(node, line_index:, indent:)
                return if node.script.nil? || node.script.empty?
                # We ignore scripts which are just a comment
                return if node.script[/\S/] == '#'
          
          
          Severity: Minor
          Found in lib/haml_lint/ruby_extraction/chunk_extractor.rb - About 35 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