Method generate_sql_as_normal
has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring. Open
def generate_sql_as_normal(thesource)
result = "1 = 0"
result_hash = thesource.sql_codes(current_user)
sql_text = result_hash[:text]
- 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 generate_sql_as_normal
has 54 lines of code (exceeds 25 allowed). Consider refactoring. Open
def generate_sql_as_normal(thesource)
result = "1 = 0"
result_hash = thesource.sql_codes(current_user)
sql_text = result_hash[:text]
Method construct_conditions
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def construct_conditions
if criterium.mapping and criterium.mapping.source != source
# This is get Age at SHHS2 against SHHS1 (linked search)
# GENERATE LINKED SQL
# 1) Get the Source Join between criterium.mapping.source and source
- 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
Avoid deeply nested control flow statements. Open
if left_token.blank? and right_token.blank?
all_conditions << "#{numeric_string} BETWEEN #{range[0]} and #{range[1]}"
else
all_conditions << "#{numeric_string} #{left_token} #{range[0]} and #{numeric_string} #{right_token} #{range[1]}"
end
Consider simplifying this complex logical expression. Open
elsif val == '1 = 0' or (range.size == 1 and range[0].blank?) or (range.size == 2 and range[0].blank? and range[1].blank?)
all_conditions << '1 = 0'
elsif val == '1 = 1'
all_conditions << '1 = 1'
elsif criterium.variable.variable_type == 'date'
Method generate_sql_through_link
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def generate_sql_through_link(source_identifer_mapping, criterium_source_identifer_mapping)
result_hash = criterium.mapping.source.sql_codes(current_user)
sql_open = result_hash[:open]
sql_close = result_hash[:close]
- 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"