rorkjop/klarna-checkout-ruby

View on GitHub

Showing 7 of 7 total issues

Cyclomatic complexity for handle_status_code is too high. [11/6]
Open

      def handle_status_code(code, msg = nil)
        case Integer(code)
          when 200, 201
            yield if block_given?
          when 400
Severity: Minor
Found in lib/klarna/checkout/client.rb by rubocop

This cop checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.

An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one.

Cyclomatic complexity for as_json is too high. [8/6]
Open

      def as_json
        json = json_sanitize({
          :merchant_reference => (@merchant_reference && @merchant_reference.as_json),
          :purchase_country => @purchase_country,
          :purchase_currency => @purchase_currency,
Severity: Minor
Found in lib/klarna/checkout/order.rb by rubocop

This cop checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.

An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one.

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

      def as_json
        json = json_sanitize({
          :merchant_reference => (@merchant_reference && @merchant_reference.as_json),
          :purchase_country => @purchase_country,
          :purchase_currency => @purchase_currency,
Severity: Minor
Found in lib/klarna/checkout/order.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 defaults= has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

        def defaults=(hash)
          if hash
            raise ArgumentError.new unless hash.is_a? Hash

            @defaults ||= {}
Severity: Minor
Found in lib/klarna/checkout/resource.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 Klarna::Checkout::Client#environment is defined at both lib/klarna/checkout/client.rb:10 and lib/klarna/checkout/client.rb:21.
Open

      def environment
Severity: Minor
Found in lib/klarna/checkout/client.rb by rubocop

This cop checks for duplicated instance (or singleton) method definitions.

Example:

# bad

def duplicated
  1
end

def duplicated
  2
end

Example:

# bad

def duplicated
  1
end

alias duplicated other_duplicated

Example:

# good

def duplicated
  1
end

def other_duplicated
  2
end

Method Klarna::Checkout::Client#environment= is defined at both lib/klarna/checkout/client.rb:10 and lib/klarna/checkout/client.rb:25.
Open

      def environment=(new_env)
Severity: Minor
Found in lib/klarna/checkout/client.rb by rubocop

This cop checks for duplicated instance (or singleton) method definitions.

Example:

# bad

def duplicated
  1
end

def duplicated
  2
end

Example:

# bad

def duplicated
  1
end

alias duplicated other_duplicated

Example:

# good

def duplicated
  1
end

def other_duplicated
  2
end

TODO found
Open

## TODO
Severity: Minor
Found in README.md by fixme
Severity
Category
Status
Source
Language