lib/coltrane/representation/guitar/chord.rb
Class Chord
has 32 methods (exceeds 20 allowed). Consider refactoring. Open
Open
class Chord
include Comparable
attr_reader :guitar_notes, :guitar, :free_fingers, :target_chord, :barre
MAX_FRET_SPAN = 3
Method find_by_notation
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
Open
def self.find_by_notation(guitar, chord_notation)
chord_notation
.split('-')
.map
.with_index do |n, i|
- 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 fetch_descendant_chords
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
Open
def fetch_descendant_chords
return [self] if guitar_notes.size >= guitar.strings.size
possible_new_notes(notes_available.positive?).reduce([]) do |memo, n|
barre = n.fret if guitar_notes.last == n.fret
fingers_change = n.fret == barre || n.fret.zero? ? 0 : 1
- 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"