tansengming/stripe-rails

View on GitHub
lib/stripe/configuration_builder.rb

Summary

Maintainability
A
45 mins
Test Coverage
A
100%

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

      def put!
        if exists?
          puts "[EXISTS] - #{@stripe_class}:#{@id}" unless Stripe::Engine.testing
        else
          object = @stripe_class.create({:id => @id}.merge compact_create_options)
Severity: Minor
Found in lib/stripe/configuration_builder.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

Use == if you meant to do a comparison or wrap the expression in parentheses to indicate you meant to assign in a condition.
Open

        if object = exists?
Severity: Minor
Found in lib/stripe/configuration_builder.rb by rubocop

This cop checks for assignments in the conditions of if/while/until.

Example:

# bad

if some_var = true
  do_something
end

Example:

# good

if some_var == true
  do_something
end

Shadowing outer local variable - block.
Open

          send(:define_method, class_id) do |id, &block|
Severity: Minor
Found in lib/stripe/configuration_builder.rb by rubocop

This cop looks for use of the same name as outer local variables for block arguments or block local variables. This is a mimic of the warning "shadowing outer local variable - foo" from ruby -cw.

Example:

# bad

def some_method
  foo = 1

  2.times do |foo| # shadowing outer `foo`
    do_something(foo)
  end
end

Example:

# good

def some_method
  foo = 1

  2.times do |bar|
    do_something(bar)
  end
end

There are no issues that match your filters.

Category
Status