Showing 13 of 17 total issues
Class Color
has 28 methods (exceeds 20 allowed). Consider refactoring. Open
class Color
include Math
attr_reader :red, :green, :blue, :hue, :saturation, :lightness, :hex
Class Palette
has 28 methods (exceeds 20 allowed). Consider refactoring. Open
class Palette
include Math
include Enumerable
attr_accessor :colors
Method initialize
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def initialize(*args)
if args.length == 1 && args[0].is_a?(Color)
args[0].instance_variables.each do |key|
self.send("#{key[1..key.length]}=".to_sym, args[0].send("#{key[1..key.length]}"))
end
- 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 update_hsl
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def update_hsl
r = @red / 255.0 rescue 0.0
g = @green / 255.0 rescue 0.0
b = @blue / 255.0 rescue 0.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 add_monochromatic_in_hues_of_color
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def self.add_monochromatic_in_hues_of_color(palette, color, size)
raise(ArgumentError, "Second argument is not a Color") unless color.is_a?(Color)
hues = palette.map { |c| c.hue }
step = ugap = dgap = 100 / size
i = j = 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 multiple_regression
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def multiple_regression(dx, dy, dz)
regression = {}
regression[:slope], regression[:offset] = {}, {}
size = dx.size
Method generate
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def self.generate(opts = {})
size = opts[:size] || 5
if !opts[:type].nil? && opts[:type].to_sym == :random
- 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_monochromatic_from_color
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def self.generate_monochromatic_from_color(color, size)
raise(ArgumentError, "Passed argument is not a Color") unless color.is_a?(Color)
palette = self.new(color)
step = (100 / size)
saturation = color.saturation
- 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_shades_from_color
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def self.generate_shades_from_color(color, size)
raise(ArgumentError, "Passed argument is not a Color") unless color.is_a?(Color)
palette = self.new(color)
step = (100 / size)
lightness = color.lightness
- 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_analogous_from_color
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def self.generate_analogous_from_color(color, size)
raise(ArgumentError, "Passed argument is not a Color") unless color.is_a?(Color)
palette = self.new(color)
step = 20
below = (size / 2)
- 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
Consider simplifying this complex logical expression. Open
unless (a.is_a?(Hash) && b.is_a?(Hash) && a.keys == b.keys) || (a.is_a?(Array) && b.is_a?(Array) && a.size == b.size)
raise ArgumentError, "Arguments must be Hashes with identical keys or Arrays of the same size"
end
Method distance
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def distance(a, b)
unless (a.is_a?(Hash) && b.is_a?(Hash) && a.keys == b.keys) || (a.is_a?(Array) && b.is_a?(Array) && a.size == b.size)
raise ArgumentError, "Arguments must be Hashes with identical keys or Arrays of the same size"
end
sum = 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 update_hex
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def update_hex
r = @red.to_i.to_s(16) rescue "00"
g = @green.to_i.to_s(16) rescue "00"
b = @blue.to_i.to_s(16) rescue "00"
r = "0#{r}" if r.length < 2
- 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"