sds/haml-lint

View on GitHub
lib/haml_lint/linter/rubocop.rb

Summary

Maintainability
C
1 day
Test Coverage

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

    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 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 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 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 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_root has a Cognitive Complexity of 7 (exceeds 5 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 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

        There are no issues that match your filters.

        Category
        Status