autotelik/datashift

View on GitHub
lib/datashift/loaders/loader_base.rb

Summary

Maintainability
A
35 mins
Test Coverage

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

    def bind_headers( headers )

      logger.info("Binding #{headers.size} inbound headers to #{load_object_class.name}")

      begin
Severity: Minor
Found in lib/datashift/loaders/loader_base.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

Avoid the use of double negation (!!).
Open

      !! DataShift::Configuration.call.abort_on_failure

This cop checks for uses of double negation (!!) to convert something to a boolean value. As this is both cryptic and usually redundant, it should be avoided.

Example:

# bad
!!something

# good
!something.nil?

Please, note that when something is a boolean value !!something and !something.nil? are not the same thing. As you're unlikely to write code that can accept values of any type this is rarely a problem in practice.

Do not prefix writer method names with set_.
Open

    def set_headers(headings)

This cop makes sure that accessor methods are named properly.

Example:

# bad
def set_attribute(value)
end

# good
def attribute=(value)
end

# bad
def get_attribute
end

# good
def attribute
end

There are no issues that match your filters.

Category
Status