Showing 39 of 39 total issues
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|
- Read upRead up
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|
- Read upRead up
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?
- Read upRead up
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?
- Read upRead up
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 %q
only for strings that contain both single quotes and double quotes. Open
spec.description = %q{it provides EMS shipping rate calculation for Japan}
- Exclude checks
Line length Open
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
- Read upRead up
- Exclude checks
MD013 - Line length
Tags: line_length
Aliases: line-length Parameters: linelength, codeblocks, tables (number; default 80, boolean; default true)
This rule is triggered when there are lines that are longer than the configured line length (default: 80 characters). To fix this, split the line up into multiple lines.
This rule has an exception where there is no whitespace beyond the configured line length. This allows you to still include items such as long URLs without being forced to break them in the middle.
You also have the option to exclude this rule for code blocks and tables. To
do this, set the code_blocks
and/or tables
parameters to false.
Code blocks are included in this rule by default since it is often a requirement for document readability, and tentatively compatible with code rules. Still, some languages do not lend themselves to short lines.
Code block style Open
$bundle
- Exclude checks
Lists should be surrounded by blank lines Open
* The use of sexualized language or imagery and unwelcome sexual attention or
- Read upRead up
- Exclude checks
MD032 - Lists should be surrounded by blank lines
Tags: bullet, ul, ol, blank_lines
Aliases: blanks-around-lists
This rule is triggered when lists (of any kind) are either not preceded or not followed by a blank line:
Some text
* Some
* List
1. Some
2. List
Some text
To fix this, ensure that all lists have a blank line both before and after (except where the block is at the beginning or end of the document):
Some text
* Some
* List
1. Some
2. List
Some text
Rationale: Aside from aesthetic reasons, some parsers, including kramdown, will not parse lists that don't have blank lines before and after them.
Note: List items without hanging indents are a violation of this rule; list items with hanging indents are okay:
* This is
not okay
* This is
okay
Use %q
only for strings that contain both single quotes and double quotes. Open
spec.summary = %q{A Ruby gem for Japan shipping rate calculation.}
- Exclude checks
Optional arguments should appear at the end of the argument list. Open
def domestic(size = 120, to_state)
- Read upRead up
- Exclude checks
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
Space between { and | missing. Open
git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
- Read upRead up
- Exclude checks
Checks that block braces have or don't have surrounding space inside them on configuration. For blocks taking parameters, it checks that the left brace has or doesn't have trailing space depending on configuration.
Prefer single-quoted strings when you don't need string interpolation or special symbols. Open
require "irb"
- Exclude checks
%q
-literals should be delimited by (
and )
. Open
spec.description = %q{it provides EMS shipping rate calculation for Japan}
- Read upRead up
- Exclude checks
This cop enforces the consistent usage of %
-literal delimiters.
Specify the 'default' key to set all preferred delimiters at once. You can continue to specify individual preferred delimiters to override the default.
Example:
# Style/PercentLiteralDelimiters:
# PreferredDelimiters:
# default: '[]'
# '%i': '()'
# good
%w[alpha beta] + %i(gamma delta)
# bad
%W(alpha #{beta})
# bad
%I(alpha beta)
Prefer single-quoted strings when you don't need string interpolation or special symbols. Open
require "bundler/gem_tasks"
- Exclude checks
Prefer single-quoted strings when you don't need string interpolation or special symbols. Open
require "rspec/core/rake_task"
- Exclude checks
Prefer single-quoted strings when you don't need string interpolation or special symbols. Open
require "bundler/setup"
- Exclude checks
Use the new Ruby 1.9 hash syntax. Open
task :default => :spec
- Read upRead up
- Exclude checks
This cop checks hash literal syntax.
It can enforce either the use of the class hash rocket syntax or the use of the newer Ruby 1.9 syntax (when applicable).
A separate offense is registered for each problematic pair.
The supported styles are:
- ruby19 - forces use of the 1.9 syntax (e.g.
{a: 1}
) when hashes have all symbols for keys - hash_rockets - forces use of hash rockets for all hashes
- nomixedkeys - simply checks for hashes with mixed syntaxes
- ruby19nomixed_keys - forces use of ruby 1.9 syntax and forbids mixed syntax hashes
Example:
"EnforcedStyle => 'ruby19'"
# good
{a: 2, b: 1}
{:c => 2, 'd' => 2} # acceptable since 'd' isn't a symbol
{d: 1, 'e' => 2} # technically not forbidden
# bad
{:a => 2}
{b: 1, :c => 2}
Example:
"EnforcedStyle => 'hash_rockets'"
# good
{:a => 1, :b => 2}
# bad
{a: 1, b: 2}
{c: 1, 'd' => 5}
Example:
"EnforcedStyle => 'no_mixed_keys'"
# good
{:a => 1, :b => 2}
{c: 1, d: 2}
# bad
{:a => 1, b: 2}
{c: 1, 'd' => 2}
Example:
"EnforcedStyle => 'ruby19_no_mixed_keys'"
# good
{a: 1, b: 2}
{:c => 3, 'd' => 4}
# bad
{:a => 1, :b => 2}
{c: 2, 'd' => 3} # should just use hash rockets
Code block style Open
$gem install jp_shipping_rate
- Exclude checks
Prefer single-quoted strings when you don't need string interpolation or special symbols. Open
source "https://rubygems.org"
- Exclude checks
Line length Open
* With domestic (inside Japan) is Yu-Pack fee = domestic rate + extra charges. Only support calculating fee for Kyoto deposite now.
- Read upRead up
- Exclude checks
MD013 - Line length
Tags: line_length
Aliases: line-length Parameters: linelength, codeblocks, tables (number; default 80, boolean; default true)
This rule is triggered when there are lines that are longer than the configured line length (default: 80 characters). To fix this, split the line up into multiple lines.
This rule has an exception where there is no whitespace beyond the configured line length. This allows you to still include items such as long URLs without being forced to break them in the middle.
You also have the option to exclude this rule for code blocks and tables. To
do this, set the code_blocks
and/or tables
parameters to false.
Code blocks are included in this rule by default since it is often a requirement for document readability, and tentatively compatible with code rules. Still, some languages do not lend themselves to short lines.