sds/haml-lint

View on GitHub

Showing 58 of 58 total issues

File chunk_extractor.rb has 414 lines of code (exceeds 250 allowed). Consider refactoring.
Open

module HamlLint::RubyExtraction
  # Extracts "chunks" of the haml file into instances of subclasses of HamlLint::RubyExtraction::BaseChunk.
  #
  # This is the first step of generating Ruby code from a HAML file to then be processed by RuboCop.
  # See HamlLint::RubyExtraction::BaseChunk for more details.
Severity: Minor
Found in lib/haml_lint/ruby_extraction/chunk_extractor.rb - About 5 hrs to fix

    Method format_ruby_lines_to_haml_lines has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
    Open

        def self.format_ruby_lines_to_haml_lines(to_ruby_lines, script_output_ruby_prefix:, first_output_haml_prefix: '=') # rubocop:disable Metrics
          to_ruby_lines.reject! { |l| l.strip == 'end' }
          return [] if to_ruby_lines.empty?
    
          statement_start_line_indexes = find_statement_start_line_indexes(to_ruby_lines)
    Severity: Minor
    Found in lib/haml_lint/ruby_extraction/script_chunk.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 find_statement_start_line_indexes has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
    Open

        def self.find_statement_start_line_indexes(to_ruby_lines) # rubocop:disable Metrics
          if to_ruby_lines.size == 1
            if to_ruby_lines.first[/\S/]
              return [0]
            else
    Severity: Minor
    Found in lib/haml_lint/ruby_extraction/script_chunk.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

    Class ChunkExtractor has 28 methods (exceeds 20 allowed). Consider refactoring.
    Open

      class ChunkExtractor
        include HamlLint::HamlVisitor
    
        attr_reader :script_output_prefix
    
    
    Severity: Minor
    Found in lib/haml_lint/ruby_extraction/chunk_extractor.rb - About 3 hrs to fix

      File rubocop.rb has 278 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      require 'rubocop'
      require 'tempfile'
      
      module HamlLint
        # Runs RuboCop on the Ruby code contained within HAML templates.
      Severity: Minor
      Found in lib/haml_lint/linter/rubocop.rb - About 2 hrs to fix

        Class TagNode has 22 methods (exceeds 20 allowed). Consider refactoring.
        Open

          class TagNode < Node
            # Computed set of attribute hashes code.
            #
            # This is a combination of all dynamically calculated attributes from the
            # different attribute setting syntaxes (`{...}`/`(...)`), converted into
        Severity: Minor
        Found in lib/haml_lint/tree/tag_node.rb - About 2 hrs to fix

          Method find_statement_start_line_indexes has 53 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def self.find_statement_start_line_indexes(to_ruby_lines) # rubocop:disable Metrics
                if to_ruby_lines.size == 1
                  if to_ruby_lines.first[/\S/]
                    return [0]
                  else
          Severity: Major
          Found in lib/haml_lint/ruby_extraction/script_chunk.rb - About 2 hrs to fix

            Method add_interpolation_chunks has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
            Open

                def add_interpolation_chunks(node, code, haml_line_index, indent:, line_start_index: 0)
                  HamlLint::Utils.handle_interpolation_with_indexes(code) do |scanner, line_index, line_char_index|
                    escapes = scanner[2].size
                    next if escapes.odd?
                    char = scanner[3] # '{', '@' or '$'
            Severity: Minor
            Found in lib/haml_lint/ruby_extraction/chunk_extractor.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 format_ruby_lines_to_haml_lines has 51 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                def self.format_ruby_lines_to_haml_lines(to_ruby_lines, script_output_ruby_prefix:, first_output_haml_prefix: '=') # rubocop:disable Metrics
                  to_ruby_lines.reject! { |l| l.strip == 'end' }
                  return [] if to_ruby_lines.empty?
            
                  statement_start_line_indexes = find_statement_start_line_indexes(to_ruby_lines)
            Severity: Major
            Found in lib/haml_lint/ruby_extraction/script_chunk.rb - About 2 hrs to fix

              Method extract_files_from has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
              Open

                  def extract_files_from(patterns) # rubocop:disable Metrics
                    files = []
              
                    patterns.each do |pattern|
                      if File.file?(pattern)
              Severity: Minor
              Found in lib/haml_lint/file_finder.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 check_width has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
              Open

                  def check_width(width, root)
                    dummy_node = Struct.new(:line)
              
                    root.children.each do |top_node|
                      # once we've found one line with leading space, there's no need to check any more lines
              Severity: Minor
              Found in lib/haml_lint/linter/indentation.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 run_rubocop has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
              Open

                  def run_rubocop(rubocop_cli, ruby_code, path) # rubocop:disable Metrics
                    rubocop_status = nil
                    stdout_str, stderr_str = HamlLint::Utils.with_captured_streams(ruby_code) do
                      rubocop_cli.config_store.instance_variable_set(:@options_config, rubocop_config_for(path))
                      rubocop_status = rubocop_cli.run(rubocop_flags + ['--stdin', path])
              Severity: Minor
              Found in lib/haml_lint/linter/rubocop.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 transfer_correction_logic has a Cognitive Complexity of 13 (exceeds 5 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

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

                  def extract_lints_from_offenses(offenses, source_map) # rubocop:disable Metrics
                    offenses.each do |offense|
                      next if Array(config['ignored_cops']).include?(offense.cop_name)
                      autocorrected = offense.status == :corrected
              
              
              Severity: Minor
              Found in lib/haml_lint/linter/rubocop.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 run_rubocop has 38 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  def run_rubocop(rubocop_cli, ruby_code, path) # rubocop:disable Metrics
                    rubocop_status = nil
                    stdout_str, stderr_str = HamlLint::Utils.with_captured_streams(ruby_code) do
                      rubocop_cli.config_store.instance_variable_set(:@options_config, rubocop_config_for(path))
                      rubocop_status = rubocop_cli.run(rubocop_flags + ['--stdin', path])
              Severity: Minor
              Found in lib/haml_lint/linter/rubocop.rb - About 1 hr to fix

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

                  Method add_linter_options has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      def add_linter_options(parser) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
                        parser.on('--auto-gen-config', 'Generate a configuration file acting as a TODO list') do
                          @options[:auto_gen_config] = true
                        end
                  
                  
                  Severity: Minor
                  Found in lib/haml_lint/options.rb - About 1 hr to fix

                    Method visit_root has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        def visit_root(_node) # rubocop:disable Metrics
                          # Need to call the received block to avoid Linter automatically visiting children
                          # Only important thing is that the argument is not ":children"
                          yield :skip_children
                    
                    
                    Severity: Minor
                    Found in lib/haml_lint/linter/rubocop.rb - About 1 hr to fix

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

                        Method add_interpolation_chunks has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            def add_interpolation_chunks(node, code, haml_line_index, indent:, line_start_index: 0)
                              HamlLint::Utils.handle_interpolation_with_indexes(code) do |scanner, line_index, line_char_index|
                                escapes = scanner[2].size
                                next if escapes.odd?
                                char = scanner[3] # '{', '@' or '$'
                        Severity: Minor
                        Found in lib/haml_lint/ruby_extraction/chunk_extractor.rb - About 1 hr to fix
                          Severity
                          Category
                          Status
                          Source
                          Language