k0kubun/hamlit

View on GitHub
lib/hamlit/parser/haml_attribute_builder.rb

Summary

Maintainability
C
1 day
Test Coverage

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

      def build_attributes(is_html, attr_wrapper, escape_attrs, hyphenate_data_attrs, attributes = {})
        # @TODO this is an absolutely ridiculous amount of arguments. At least
        # some of this needs to be moved into an instance method.
        join_char = hyphenate_data_attrs ? '-' : '_'

Severity: Minor
Found in lib/hamlit/parser/haml_attribute_builder.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 merge_value has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

      def merge_value(key, to, from)
        if from.kind_of?(Hash) || to.kind_of?(Hash)
          from = { nil => from } if !from.is_a?(Hash)
          to   = { nil => to }   if !to.is_a?(Hash)
          to.merge(from)
Severity: Minor
Found in lib/hamlit/parser/haml_attribute_builder.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 filter_and_join has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

      def filter_and_join(value, separator)
        return '' if (value.respond_to?(:empty?) && value.empty?)

        if value.is_a?(Array)
          value = value.flatten
Severity: Minor
Found in lib/hamlit/parser/haml_attribute_builder.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 build_attributes has 33 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def build_attributes(is_html, attr_wrapper, escape_attrs, hyphenate_data_attrs, attributes = {})
        # @TODO this is an absolutely ridiculous amount of arguments. At least
        # some of this needs to be moved into an instance method.
        join_char = hyphenate_data_attrs ? '-' : '_'

Severity: Minor
Found in lib/hamlit/parser/haml_attribute_builder.rb - About 1 hr to fix

    Method build_attributes has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

          def build_attributes(is_html, attr_wrapper, escape_attrs, hyphenate_data_attrs, attributes = {})
    Severity: Minor
    Found in lib/hamlit/parser/haml_attribute_builder.rb - About 35 mins to fix

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

            def flatten_data_attributes(data, key, join_char, seen = [])
              return {key => data} unless data.is_a?(Hash)
      
              return {key => nil} if seen.include? data.object_id
              seen << data.object_id
      Severity: Minor
      Found in lib/hamlit/parser/haml_attribute_builder.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