Method account_nav_sections
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Wontfix
def account_nav_sections
sections = []
sections << {id: :overview, title: 'Overview', path: provider_admin_account_path} if can?(:manage, current_account)
sections << {id: :personal, title: 'Personal', items: account_personal_items} if can?(:manage, current_user)
- 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 audience_portal_items
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Wontfix
def audience_portal_items # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity
items = []
if can?(:manage, :portal)
items << {id: :content, title: 'Content', path: provider_admin_cms_templates_path}
- 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 audience_portal_items
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Wontfix
def audience_portal_items # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity
items = []
if can?(:manage, :portal)
items << {id: :content, title: 'Content', path: provider_admin_cms_templates_path}
Method service_nav_sections
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Wontfix
def service_nav_sections
sections = []
return sections unless @service
sections << {id: :overview, title: 'Product Overview', path: admin_service_path(@service)} if can? :manage, :plans
- 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
VerticalNavHelper#service_analytics has approx 9 statements Open
def service_analytics
- Read upRead up
- Exclude checks
A method with Too Many Statements
is any method that has a large number of lines.
Too Many Statements
warns about any method that has more than 5 statements. Reek's smell detector for Too Many Statements
counts +1 for every simple statement in a method and +1 for every statement within a control structure (if
, else
, case
, when
, for
, while
, until
, begin
, rescue
) but it doesn't count the control structure itself.
So the following method would score +6 in Reek's statement-counting algorithm:
def parse(arg, argv, &error)
if !(val = arg) and (argv.empty? or /\A-/ =~ (val = argv[0]))
return nil, block, nil # +1
end
opt = (val = parse_arg(val, &error))[1] # +2
val = conv_arg(*val) # +3
if opt and !arg
argv.shift # +4
else
val[0] = nil # +5
end
val # +6
end
(You might argue that the two assigments within the first @if@ should count as statements, and that perhaps the nested assignment should count as +2.)
VerticalNavHelper#audience_portal_items has approx 19 statements Open
def audience_portal_items # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity
- Read upRead up
- Exclude checks
A method with Too Many Statements
is any method that has a large number of lines.
Too Many Statements
warns about any method that has more than 5 statements. Reek's smell detector for Too Many Statements
counts +1 for every simple statement in a method and +1 for every statement within a control structure (if
, else
, case
, when
, for
, while
, until
, begin
, rescue
) but it doesn't count the control structure itself.
So the following method would score +6 in Reek's statement-counting algorithm:
def parse(arg, argv, &error)
if !(val = arg) and (argv.empty? or /\A-/ =~ (val = argv[0]))
return nil, block, nil # +1
end
opt = (val = parse_arg(val, &error))[1] # +2
val = conv_arg(*val) # +3
if opt and !arg
argv.shift # +4
else
val[0] = nil # +5
end
val # +6
end
(You might argue that the two assigments within the first @if@ should count as statements, and that perhaps the nested assignment should count as +2.)
VerticalNavHelper#account_nav_sections has approx 10 statements Open
def account_nav_sections
- Read upRead up
- Exclude checks
A method with Too Many Statements
is any method that has a large number of lines.
Too Many Statements
warns about any method that has more than 5 statements. Reek's smell detector for Too Many Statements
counts +1 for every simple statement in a method and +1 for every statement within a control structure (if
, else
, case
, when
, for
, while
, until
, begin
, rescue
) but it doesn't count the control structure itself.
So the following method would score +6 in Reek's statement-counting algorithm:
def parse(arg, argv, &error)
if !(val = arg) and (argv.empty? or /\A-/ =~ (val = argv[0]))
return nil, block, nil # +1
end
opt = (val = parse_arg(val, &error))[1] # +2
val = conv_arg(*val) # +3
if opt and !arg
argv.shift # +4
else
val[0] = nil # +5
end
val # +6
end
(You might argue that the two assigments within the first @if@ should count as statements, and that perhaps the nested assignment should count as +2.)
VerticalNavHelper#audience_billing_items has approx 9 statements Open
def audience_billing_items
- Read upRead up
- Exclude checks
A method with Too Many Statements
is any method that has a large number of lines.
Too Many Statements
warns about any method that has more than 5 statements. Reek's smell detector for Too Many Statements
counts +1 for every simple statement in a method and +1 for every statement within a control structure (if
, else
, case
, when
, for
, while
, until
, begin
, rescue
) but it doesn't count the control structure itself.
So the following method would score +6 in Reek's statement-counting algorithm:
def parse(arg, argv, &error)
if !(val = arg) and (argv.empty? or /\A-/ =~ (val = argv[0]))
return nil, block, nil # +1
end
opt = (val = parse_arg(val, &error))[1] # +2
val = conv_arg(*val) # +3
if opt and !arg
argv.shift # +4
else
val[0] = nil # +5
end
val # +6
end
(You might argue that the two assigments within the first @if@ should count as statements, and that perhaps the nested assignment should count as +2.)
VerticalNavHelper#service_nav_sections has approx 9 statements Open
def service_nav_sections
- Read upRead up
- Exclude checks
A method with Too Many Statements
is any method that has a large number of lines.
Too Many Statements
warns about any method that has more than 5 statements. Reek's smell detector for Too Many Statements
counts +1 for every simple statement in a method and +1 for every statement within a control structure (if
, else
, case
, when
, for
, while
, until
, begin
, rescue
) but it doesn't count the control structure itself.
So the following method would score +6 in Reek's statement-counting algorithm:
def parse(arg, argv, &error)
if !(val = arg) and (argv.empty? or /\A-/ =~ (val = argv[0]))
return nil, block, nil # +1
end
opt = (val = parse_arg(val, &error))[1] # +2
val = conv_arg(*val) # +3
if opt and !arg
argv.shift # +4
else
val[0] = nil # +5
end
val # +6
end
(You might argue that the two assigments within the first @if@ should count as statements, and that perhaps the nested assignment should count as +2.)
Method audience_nav_sections
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Wontfix
def audience_nav_sections
sections = []
sections << {id: :accounts, title: 'Accounts', items: audience_accounts_items} if can?(:manage, :partners) || can?(:manage, :settings)
sections << {id: :applications, title: 'Applications', items: audience_applications_items} if can?(:manage, :applications)
sections << {id: :finance, title: 'Billing', items: audience_billing_items} if can?(:see, :finance) && (can?(:manage, :finance) || can?(:manage, :settings))
- 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
VerticalNavHelper#account_billing_items calls '!ThreeScale.config.onpremises' 2 times Open
items << {id: :invoices, title: '3scale Invoices', path: provider_admin_account_invoices_path} if can?(:read, Invoice) && !ThreeScale.config.onpremises
items << {id: :payment_details, title: 'Payment Details', path: provider_admin_account_braintree_blue_path} if can?(:manage, :credit_card) && !ThreeScale.config.onpremises
- Read upRead up
- Exclude checks
Duplication occurs when two fragments of code look nearly identical, or when two fragments of code have nearly identical effects at some conceptual level.
Reek implements a check for Duplicate Method Call.
Example
Here's a very much simplified and contrived example. The following method will report a warning:
def double_thing()
@other.thing + @other.thing
end
One quick approach to silence Reek would be to refactor the code thus:
def double_thing()
thing = @other.thing
thing + thing
end
A slightly different approach would be to replace all calls of double_thing
by calls to @other.double_thing
:
class Other
def double_thing()
thing + thing
end
end
The approach you take will depend on balancing other factors in your code.
VerticalNavHelper#audience_billing_items calls 'can?(:manage, :finance)' 2 times Open
if can?(:manage, :finance)
items << {id: :earnings, title: 'Earnings by Month', path: admin_finance_root_path}
items << {id: :invoices, title: 'Invoices', path: admin_finance_invoices_path}
items << {id: :log_entries, title: 'Finance Log', path: admin_finance_log_entries_path} if current_user.impersonation_admin?
end
- Read upRead up
- Exclude checks
Duplication occurs when two fragments of code look nearly identical, or when two fragments of code have nearly identical effects at some conceptual level.
Reek implements a check for Duplicate Method Call.
Example
Here's a very much simplified and contrived example. The following method will report a warning:
def double_thing()
@other.thing + @other.thing
end
One quick approach to silence Reek would be to refactor the code thus:
def double_thing()
thing = @other.thing
thing + thing
end
A slightly different approach would be to replace all calls of double_thing
by calls to @other.double_thing
:
class Other
def double_thing()
thing + thing
end
end
The approach you take will depend on balancing other factors in your code.
VerticalNavHelper#account_nav_sections calls 'current_account.master?' 2 times Open
sections << {id: :billing, title: 'Billing', items: account_billing_items} if ThreeScale.master_billing_enabled? && !current_account.master?
end
sections << {id: :integrate, title: 'Integrate', items: account_itegrate_items}
sections << {id: :email_configurations, title: 'Email configurations', path: provider_admin_account_email_configurations_path} if current_account.master? && Features::EmailConfigurationConfig.enabled?
- Read upRead up
- Exclude checks
Duplication occurs when two fragments of code look nearly identical, or when two fragments of code have nearly identical effects at some conceptual level.
Reek implements a check for Duplicate Method Call.
Example
Here's a very much simplified and contrived example. The following method will report a warning:
def double_thing()
@other.thing + @other.thing
end
One quick approach to silence Reek would be to refactor the code thus:
def double_thing()
thing = @other.thing
thing + thing
end
A slightly different approach would be to replace all calls of double_thing
by calls to @other.double_thing
:
class Other
def double_thing()
thing + thing
end
end
The approach you take will depend on balancing other factors in your code.
VerticalNavHelper#account_nav_sections calls 'can?(:manage, current_account)' 2 times Open
sections << {id: :overview, title: 'Overview', path: provider_admin_account_path} if can?(:manage, current_account)
sections << {id: :personal, title: 'Personal', items: account_personal_items} if can?(:manage, current_user)
if can? :manage, current_account
- Read upRead up
- Exclude checks
Duplication occurs when two fragments of code look nearly identical, or when two fragments of code have nearly identical effects at some conceptual level.
Reek implements a check for Duplicate Method Call.
Example
Here's a very much simplified and contrived example. The following method will report a warning:
def double_thing()
@other.thing + @other.thing
end
One quick approach to silence Reek would be to refactor the code thus:
def double_thing()
thing = @other.thing
thing + thing
end
A slightly different approach would be to replace all calls of double_thing
by calls to @other.double_thing
:
class Other
def double_thing()
thing + thing
end
end
The approach you take will depend on balancing other factors in your code.
VerticalNavHelper#audience_portal_items calls 'can?(:manage, :portal)' 2 times Open
if can?(:manage, :portal)
items << {id: :content, title: 'Content', path: provider_admin_cms_templates_path}
items << {id: :changes, title: 'Drafts', path: provider_admin_cms_changes_path}
items << {id: :redirects, title: 'Redirects', path: provider_admin_cms_redirects_path}
items << {id: :groups, title: 'Groups', path: provider_admin_cms_groups_path} if can?(:see, :groups)
- Read upRead up
- Exclude checks
Duplication occurs when two fragments of code look nearly identical, or when two fragments of code have nearly identical effects at some conceptual level.
Reek implements a check for Duplicate Method Call.
Example
Here's a very much simplified and contrived example. The following method will report a warning:
def double_thing()
@other.thing + @other.thing
end
One quick approach to silence Reek would be to refactor the code thus:
def double_thing()
thing = @other.thing
thing + thing
end
A slightly different approach would be to replace all calls of double_thing
by calls to @other.double_thing
:
class Other
def double_thing()
thing + thing
end
end
The approach you take will depend on balancing other factors in your code.
VerticalNavHelper#audience_nav_sections calls 'can?(:manage, :settings)' 3 times Open
sections << {id: :accounts, title: 'Accounts', items: audience_accounts_items} if can?(:manage, :partners) || can?(:manage, :settings)
sections << {id: :applications, title: 'Applications', items: audience_applications_items} if can?(:manage, :applications)
sections << {id: :finance, title: 'Billing', items: audience_billing_items} if can?(:see, :finance) && (can?(:manage, :finance) || can?(:manage, :settings))
sections << {id: :cms, title: 'Developer Portal', items: audience_portal_items} if (can?(:manage, :portal) || can?(:manage, :settings) || can?(:manage, :plans)) && !master_on_premises?
- Read upRead up
- Exclude checks
Duplication occurs when two fragments of code look nearly identical, or when two fragments of code have nearly identical effects at some conceptual level.
Reek implements a check for Duplicate Method Call.
Example
Here's a very much simplified and contrived example. The following method will report a warning:
def double_thing()
@other.thing + @other.thing
end
One quick approach to silence Reek would be to refactor the code thus:
def double_thing()
thing = @other.thing
thing + thing
end
A slightly different approach would be to replace all calls of double_thing
by calls to @other.double_thing
:
class Other
def double_thing()
thing + thing
end
end
The approach you take will depend on balancing other factors in your code.
VerticalNavHelper#account_billing_items calls 'ThreeScale.config' 2 times Open
items << {id: :invoices, title: '3scale Invoices', path: provider_admin_account_invoices_path} if can?(:read, Invoice) && !ThreeScale.config.onpremises
items << {id: :payment_details, title: 'Payment Details', path: provider_admin_account_braintree_blue_path} if can?(:manage, :credit_card) && !ThreeScale.config.onpremises
- Read upRead up
- Exclude checks
Duplication occurs when two fragments of code look nearly identical, or when two fragments of code have nearly identical effects at some conceptual level.
Reek implements a check for Duplicate Method Call.
Example
Here's a very much simplified and contrived example. The following method will report a warning:
def double_thing()
@other.thing + @other.thing
end
One quick approach to silence Reek would be to refactor the code thus:
def double_thing()
thing = @other.thing
thing + thing
end
A slightly different approach would be to replace all calls of double_thing
by calls to @other.double_thing
:
class Other
def double_thing()
thing + thing
end
end
The approach you take will depend on balancing other factors in your code.
VerticalNavHelper#backend_api_nav_sections calls 'can? :edit, BackendApi' 2 times Open
sections << {id: :methods_metrics, title: 'Methods and Metrics', path: provider_admin_backend_api_metrics_path(@backend_api)} if can? :edit, BackendApi
sections << {id: :mapping_rules, title: 'Mapping Rules', path: provider_admin_backend_api_mapping_rules_path(@backend_api)} if can? :edit, BackendApi
- Read upRead up
- Exclude checks
Duplication occurs when two fragments of code look nearly identical, or when two fragments of code have nearly identical effects at some conceptual level.
Reek implements a check for Duplicate Method Call.
Example
Here's a very much simplified and contrived example. The following method will report a warning:
def double_thing()
@other.thing + @other.thing
end
One quick approach to silence Reek would be to refactor the code thus:
def double_thing()
thing = @other.thing
thing + thing
end
A slightly different approach would be to replace all calls of double_thing
by calls to @other.double_thing
:
class Other
def double_thing()
thing + thing
end
end
The approach you take will depend on balancing other factors in your code.
VerticalNavHelper#account_billing_items calls 'ThreeScale.config.onpremises' 2 times Open
items << {id: :invoices, title: '3scale Invoices', path: provider_admin_account_invoices_path} if can?(:read, Invoice) && !ThreeScale.config.onpremises
items << {id: :payment_details, title: 'Payment Details', path: provider_admin_account_braintree_blue_path} if can?(:manage, :credit_card) && !ThreeScale.config.onpremises
- Read upRead up
- Exclude checks
Duplication occurs when two fragments of code look nearly identical, or when two fragments of code have nearly identical effects at some conceptual level.
Reek implements a check for Duplicate Method Call.
Example
Here's a very much simplified and contrived example. The following method will report a warning:
def double_thing()
@other.thing + @other.thing
end
One quick approach to silence Reek would be to refactor the code thus:
def double_thing()
thing = @other.thing
thing + thing
end
A slightly different approach would be to replace all calls of double_thing
by calls to @other.double_thing
:
class Other
def double_thing()
thing + thing
end
end
The approach you take will depend on balancing other factors in your code.
VerticalNavHelper#service_nav_sections calls 'can? :manage, :plans' 3 times Open
sections << {id: :overview, title: 'Product Overview', path: admin_service_path(@service)} if can? :manage, :plans
sections << {id: :monitoring, title: 'Analytics', items: service_analytics} if can? :manage, :monitoring
sections << {id: :applications, title: 'Applications', items: service_applications} if (can? :manage, :plans) || (can? :manage, :applications)
sections << {id: :subscriptions, title: 'Subscriptions', items: service_subscriptions} if can?(:manage, :service_plans) && current_account.settings.service_plans_ui_visible?
- Read upRead up
- Exclude checks
Duplication occurs when two fragments of code look nearly identical, or when two fragments of code have nearly identical effects at some conceptual level.
Reek implements a check for Duplicate Method Call.
Example
Here's a very much simplified and contrived example. The following method will report a warning:
def double_thing()
@other.thing + @other.thing
end
One quick approach to silence Reek would be to refactor the code thus:
def double_thing()
thing = @other.thing
thing + thing
end
A slightly different approach would be to replace all calls of double_thing
by calls to @other.double_thing
:
class Other
def double_thing()
thing + thing
end
end
The approach you take will depend on balancing other factors in your code.
Method audience_billing_items
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Wontfix
def audience_billing_items
items = []
if can?(:manage, :finance)
items << {id: :earnings, title: 'Earnings by Month', path: admin_finance_root_path}
- 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"