Showing 2 of 99 total issues
Method country_options_for
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
Open
def country_options_for(country_codes, sorted=true)
I18n.with_locale(locale) do
country_list = country_codes.map do |code_or_name|
if country = ISO3166::Country.new(code_or_name)
code = country.alpha2
- 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 country_option_tags
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
Open
def country_option_tags
# In Rails 5.2+, `value` accepts no arguments and must also be called
# with parens to avoid the local variable of the same name
# https://github.com/rails/rails/pull/29791
selected_option = @options.fetch(:selected) do
- 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"