aromajoin/jp-shipping-rate

View on GitHub
lib/jp_shipping_rate.rb

Summary

Maintainability
A
2 hrs
Test Coverage

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

  def international_rate(weight, region)
    rate = 0
    @rates['international_ems'].each do |w, r|
      next if w.to_i < weight
      r.each do |r_rate|
Severity: Minor
Found in lib/jp_shipping_rate.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 domestic_rate has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def domestic_rate(size = 100, area = 'okinawa')
    rate = 0
    @rates['domestic_parcel'].each do |w, r|
      next if w.to_i < size
      r.each do |r_rate|
Severity: Minor
Found in lib/jp_shipping_rate.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 region_of_country has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def region_of_country(country_code = 'JP')
    result = @regions['asia'].to_s
    @regions.each do |region, countries|
      countries.each do |country|
        return result = region.to_s unless country[country_code].nil?
Severity: Minor
Found in lib/jp_shipping_rate.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 area_of_prefecture has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def area_of_prefecture(state_name = 'kyoto')
    result = 'okinawa'
    @jp_areas.each do |area, states|
      states.each do |state|
        return result = area.to_s unless state[state_name].nil?
Severity: Minor
Found in lib/jp_shipping_rate.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

Line is too long. [83/80]
Open

  # 1. default size = 120 for now, parcel size is total of length, width and height
Severity: Minor
Found in lib/jp_shipping_rate.rb by rubocop

Line is too long. [81/80]
Open

  # 4. plus base extra charges for internaltional shipping and insurrance charge?
Severity: Minor
Found in lib/jp_shipping_rate.rb by rubocop

Optional arguments should appear at the end of the argument list.
Open

  def domestic(size = 120, to_state)
Severity: Minor
Found in lib/jp_shipping_rate.rb by rubocop

This cop checks for optional arguments to methods that do not come at the end of the argument list

Example:

# bad
def foo(a = 1, b, c)
end

# good
def baz(a, b, c = 1)
end

def foobar(a = 1, b = 2, c = 3)
end

There are no issues that match your filters.

Category
Status