mechanicles/set_as_primary

View on GitHub

Showing 4 of 4 total issues

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

      def index_on
        if owner_key.present?
          klass = table_name.classify.constantize
          owner_association = klass.reflect_on_association(owner_key.to_sym)

Severity: Minor
Found in lib/generators/set_as_primary/set_as_primary_generator.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

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

        def _handle_setup_errors(primary_flag_attribute, configuration)
          if !primary_flag_attribute.is_a?(Symbol)
            raise SetAsPrimary::Error, "wrong argument type (expected Symbol)"
          end

Severity: Minor
Found in lib/set_as_primary.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

Method set_as_primary has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

        def set_as_primary(primary_flag_attribute = :primary, options = {})
          if primary_flag_attribute.is_a?(Hash)
            options = primary_flag_attribute; primary_flag_attribute = :primary
          end

Severity: Minor
Found in lib/set_as_primary.rb - About 25 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 force_primary has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def force_primary
      scope = _klass
      scope = scope.where(_scope_options) if _scope_options.present?
      count = scope.count

Severity: Minor
Found in lib/set_as_primary.rb - About 25 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

Severity
Category
Status
Source
Language