utils/color.rb
Method from_hsl
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
Open
def from_hsl(hue, sat, lum, ignored = nil)
return set([0.0,0.0,0.0]) if lum == 0.0 # if luminosity is zero, the colour is always black
return set([1.0,1.0,1.0]) if lum == 1.0 # if luminosity is one, the colour is always white
return set([lum, lum, lum]) if sat <= 1e-5 # if saturation is zero, the colour is always a greyscale colour
- 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 to_hsl
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
Open
def to_hsl
min = [@red, @green, @blue].min
max = [@red, @green, @blue].max
delta = (max - min).to_f
lum = (max + min) / 2.0
- 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 from_hsl
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def from_hsl(hue, sat, lum, ignored = nil)
return set([0.0,0.0,0.0]) if lum == 0.0 # if luminosity is zero, the colour is always black
return set([1.0,1.0,1.0]) if lum == 1.0 # if luminosity is one, the colour is always white
return set([lum, lum, lum]) if sat <= 1e-5 # if saturation is zero, the colour is always a greyscale colour