sds/haml-lint

View on GitHub
lib/haml_lint/ruby_extraction/script_chunk.rb

Summary

Maintainability
C
1 day
Test Coverage

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

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

      There are no issues that match your filters.

      Category
      Status