eagletmt/faml

View on GitHub
lib/faml/stats.rb

Summary

Maintainability
B
7 hrs
Test Coverage

Method collect_attribute_info has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
Open

    def collect_attribute_info(info, ast)
      if ast.object_ref
        info.object_reference_count += 1
        return
      end
Severity: Minor
Found in lib/faml/stats.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 collect_attribute_info has 33 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def collect_attribute_info(info, ast)
      if ast.object_ref
        info.object_reference_count += 1
        return
      end
Severity: Minor
Found in lib/faml/stats.rb - About 1 hr to fix

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

        def walk_ast(info, ast)
          info.ast_types[ast.class.to_s.sub(/\A.*::(.+)\z/, '\1')] += 1
          case ast
          when HamlParser::Ast::Root
            ast.children.each { |c| walk_ast(info, c) }
    Severity: Minor
    Found in lib/faml/stats.rb - About 1 hr to fix

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

          def walk_ast(info, ast)
            info.ast_types[ast.class.to_s.sub(/\A.*::(.+)\z/, '\1')] += 1
            case ast
            when HamlParser::Ast::Root
              ast.children.each { |c| walk_ast(info, c) }
      Severity: Minor
      Found in lib/faml/stats.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

      There are no issues that match your filters.

      Category
      Status