app/helpers/policies_helper.rb
Method submit_or_cancel_policy
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
Open
def submit_or_cancel_policy(form, overwrite = nil, args = {})
args[:cancel_path] ||= send("#{controller_name}_path")
content_tag(:div, :class => "clearfix") do
content_tag(:div, :class => "form-actions") do
text = overwrite ? overwrite : _("Submit")
- 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 scap_content_profile_selector
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
Open
def scap_content_profile_selector(form)
if profiles_selection.length == 1
select_f form, :scap_content_profile_id, profiles_selection, :id, :title,
{ :selected => @policy.scap_content_profile_id },
{ :label => _("XCCDF Profile"),
- 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"