analyzer/lib/tools/dimension.rb
Method convert_rate
has a Cognitive Complexity of 43 (exceeds 5 allowed). Consider refactoring. Open
Open
def convert_rate(value, gases_num, dimension = nil)
return 0 if value == 0
dimension ||= @rate
syntax_error('.is_not_set') unless dimension
- 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 convert_rate
has 63 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def convert_rate(value, gases_num, dimension = nil)
return 0 if value == 0
dimension ||= @rate
syntax_error('.is_not_set') unless dimension
Consider simplifying this complex logical expression. Open
Open
if gases_num > 0 || dimension != DEFAULT_RATE
_, dividend, _, divisor =
dimension.gsub(/\(|\)/, '|').gsub(/\s/, '').
scan(%r{\A(\|)?([^\/]+)\1?/(\|)?(.+?)\3?\Z}).first
Method convert
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
Open
def convert(var, value, convertable_dimension = nil)
convertable_dimension && convertable_dimension.strip!
current_dimension = instance_variable_get("@#{var}".to_sym)
unless current_dimension || convertable_dimension
- 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"