app/helpers/studied_factors_helper.rb
Method uniq_fs_or_ec
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
Open
def uniq_fs_or_ec fs_or_ec_array=[]
result = []
uniq_fs_or_ec_field_array = []
link_table_name = (!fs_or_ec_array.empty? && fs_or_ec_array.first.class.name == 'StudiedFactor') ? 'studied_factor_links' : 'experimental_condition_links'
fs_or_ec_array.each do |fs_or_ec|
- 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 tagged_substances
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
Open
def tagged_substances resource
tagged_substances = []
link_table_name = (resource.class.name == 'StudiedFactor') ? 'studied_factor_links' : 'experimental_condition_links'
if !resource.nil?
(resource.send link_table_name).each do |ltn|
- 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"