Showing 20 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
Similar blocks of code found in 2 locations. Consider refactoring. Open
def external_entries
melodic_intervals.each_cons(2).map do |pair|
first, second = *pair
pair.map(&:notes).uniq if second.octave? && !second.spans?(first.first_note.pitch)
end.compact
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 31.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
def external_exits
melodic_intervals.each_cons(2).map do |pair|
first, second = *pair
pair.map(&:notes).uniq if first.octave? && !first.spans?(second.second_note.pitch)
end.compact
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 31.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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"
Further reading
Similar blocks of code found in 2 locations. Consider refactoring. Open
def name_and_alias_translations_for_keys(name_keys)
name_keys.map do |name_key|
I18n.config.available_locales.map do |locale_code|
I18n.translate(name_key, scope: :reference_pitches, locale: locale_code)
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 26.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
def name_key_translations(name_keys)
name_keys.map do |name_key|
I18n.config.available_locales.map do |locale_code|
I18n.translate(name_key, scope: :clefs, locale: locale_code)
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 26.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76