flant/superhosting

View on GitHub
lib/superhosting/mapper_inheritance/model.rb

Summary

Maintainability
A
45 mins
Test Coverage

Method set_inheritance has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

        def set_inheritance(model_mapper, mapper = model_mapper)
          @models_mapper ||= model_mapper.parent
          @muxs_mapper ||= @models_mapper.parent.muxs
          inheritors = get_or_collect(model_mapper)

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

Line is too long. [166/150]
Open

              raise NetStatus::Exception, error: :logical_error, code: :base_model_should_not_be_abstract, data: { name: model_mapper.name } if model_mapper.abstract?

Line is too long. [151/150]
Open

              raise NetStatus::Exception, error: :input_error, code: :model_does_not_exists, data: { name: model_mapper.name } unless model_mapper.dir?

end at 21, 10 is not aligned with case at 12, 17.
Open

          end

This cop checks whether the end keywords are aligned properly.

Three modes are supported through the EnforcedStyleAlignWith configuration parameter:

If it's set to keyword (which is the default), the end shall be aligned with the start of the keyword (if, class, etc.).

If it's set to variable the end shall be aligned with the left-hand-side of the variable assignment, if there is one.

If it's set to start_of_line, the end shall be aligned with the start of the line where the matching keyword appears.

Example: EnforcedStyleAlignWith: keyword (default)

# bad

variable = if true
    end

# good

variable = if true
           end

Example: EnforcedStyleAlignWith: variable

# bad

variable = if true
    end

# good

variable = if true
end

Example: EnforcedStyleAlignWith: startofline

# bad

variable = if true
    end

# good

puts(if true
end)

There are no issues that match your filters.

Category
Status