Showing 16 of 20 total issues
Class PitchSet
has 37 methods (exceeds 20 allowed). Consider refactoring. Open
class HeadMusic::PitchSet
TERTIAN_SONORITIES = {
implied_triad: [3],
triad: [3, 5],
seventh_chord: [3, 5, 7],
Class Pitch
has 36 methods (exceeds 20 allowed). Consider refactoring. Open
class HeadMusic::Pitch
include Comparable
attr_reader :spelling, :register
File diatonic_interval.rb
has 307 lines of code (exceeds 250 allowed). Consider refactoring. Open
class HeadMusic::DiatonicInterval
include Comparable
# TODO: include Named module
NUMBER_NAMES = %w[
Class Meter
has 25 methods (exceeds 20 allowed). Consider refactoring. Open
class HeadMusic::Meter
attr_reader :top_number, :bottom_number
NAMED = {
common_time: "4/4",
Class Annotation
has 24 methods (exceeds 20 allowed). Consider refactoring. Open
class HeadMusic::Style::Annotation
MESSAGE = "Write music."
attr_reader :voice
Class ConsonantClimax
has 23 methods (exceeds 20 allowed). Consider refactoring. Open
class HeadMusic::Style::Guidelines::ConsonantClimax < HeadMusic::Style::Annotation
MESSAGE = "Peak on a consonant high or low note one time or twice with a step between."
def marks
HeadMusic::Style::Mark.for_each(highest_notes) unless adherent_climax?
Class Voice
has 23 methods (exceeds 20 allowed). Consider refactoring. Open
class HeadMusic::Content::Voice
include Comparable
attr_reader :composition, :placements, :role
Class DiatonicInterval
has 21 methods (exceeds 20 allowed). Consider refactoring. Open
class HeadMusic::DiatonicInterval
include Comparable
# TODO: include Named module
NUMBER_NAMES = %w[
Method to_s
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def to_s
if sharps.any?
(sharps.length == 1) ? "1 sharp" : "#{sharps.length} sharps"
elsif flats.any?
(flats.length == 1) ? "1 flat" : "#{flats.length} flats"
- 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 marks
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def marks
return if last_melodic_interval.nil?
fitness = 1
fitness *= HeadMusic::PENALTY_FACTOR unless step?
- 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_number
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def self.from_number(identifier)
return nil unless identifier.to_s == identifier.to_i.to_s
return nil unless (-2..12).cover?(identifier.to_i)
@registers ||= {}
- 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 steps_to
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def steps_to(other, direction = :ascending)
other = HeadMusic::LetterName.get(other)
other_position = other.position
if direction == :descending
other_position -= NAMES.length if other_position > position
- 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 marks
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def marks
return if last_melodic_interval.nil?
fitness = 1
fitness *= HeadMusic::PENALTY_FACTOR unless step?
- 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 initialize
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def initialize(interval:, starting_pitch: "C4")
@interval = interval if interval.is_a?(HeadMusic::DiatonicInterval)
@interval ||= interval if interval.is_a?(HeadMusic::ChromaticInterval)
@interval ||= HeadMusic::ChromaticInterval.get(interval) if interval.to_s.match?(/\d/)
@interval ||= HeadMusic::DiatonicInterval.get(interval)
- 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_or_create
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def self.fetch_or_create(spelling, register = nil)
register ||= HeadMusic::Register::DEFAULT
return unless spelling && (-1..9).cover?(register)
@pitches ||= {}
- 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 unrecovered_leap?
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def unrecovered_leap?(first_interval, second_interval, third_interval)
return false unless first_interval.large_leap?
return false if spelling_consonant_triad?(first_interval, second_interval, third_interval)
return false if second_interval.step?
return false if second_interval.repetition?
- 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"