roberthead/head_music

View on GitHub

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],
Severity: Minor
Found in lib/head_music/pitch_set.rb - About 4 hrs to fix

    Class Pitch has 36 methods (exceeds 20 allowed). Consider refactoring.
    Open

    class HeadMusic::Pitch
      include Comparable
    
      attr_reader :spelling, :register
    
    
    Severity: Minor
    Found in lib/head_music/pitch.rb - About 4 hrs to fix

      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[
      Severity: Minor
      Found in lib/head_music/diatonic_interval.rb - About 3 hrs to fix

        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",
        Severity: Minor
        Found in lib/head_music/meter.rb - About 2 hrs to fix

          Class Annotation has 24 methods (exceeds 20 allowed). Consider refactoring.
          Open

          class HeadMusic::Style::Annotation
            MESSAGE = "Write music."
          
            attr_reader :voice
          
          
          Severity: Minor
          Found in lib/head_music/style/annotation.rb - About 2 hrs to fix

            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?
            Severity: Minor
            Found in lib/head_music/style/guidelines/consonant_climax.rb - About 2 hrs to fix

              Class Voice has 23 methods (exceeds 20 allowed). Consider refactoring.
              Open

              class HeadMusic::Content::Voice
                include Comparable
              
                attr_reader :composition, :placements, :role
              
              
              Severity: Minor
              Found in lib/head_music/content/voice.rb - About 2 hrs to fix

                Class DiatonicInterval has 21 methods (exceeds 20 allowed). Consider refactoring.
                Open

                class HeadMusic::DiatonicInterval
                  include Comparable
                
                  # TODO: include Named module
                  NUMBER_NAMES = %w[
                Severity: Minor
                Found in lib/head_music/diatonic_interval.rb - About 2 hrs to fix

                  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"
                  Severity: Minor
                  Found in lib/head_music/key_signature.rb - About 55 mins to fix

                  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
                  Severity: Minor
                  Found in lib/head_music/style/guidelines/prepare_octave_leaps.rb and 1 other location - About 25 mins to fix
                  lib/head_music/style/guidelines/prepare_octave_leaps.rb on lines 25..29

                  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

                  Further Reading

                  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
                  Severity: Minor
                  Found in lib/head_music/style/guidelines/prepare_octave_leaps.rb and 1 other location - About 25 mins to fix
                  lib/head_music/style/guidelines/prepare_octave_leaps.rb on lines 18..22

                  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

                  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?
                  Severity: Minor
                  Found in lib/head_music/style/guidelines/step_up_to_final_note.rb - About 25 mins to fix

                  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 ||= {}
                  Severity: Minor
                  Found in lib/head_music/register.rb - About 25 mins to fix

                  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
                  Severity: Minor
                  Found in lib/head_music/letter_name.rb - About 25 mins to fix

                  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?
                  Severity: Minor
                  Found in lib/head_music/style/guidelines/step_down_to_final_note.rb - About 25 mins to fix

                  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)
                  Severity: Minor
                  Found in lib/head_music/interval_cycle.rb - About 25 mins to fix

                  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 ||= {}
                  Severity: Minor
                  Found in lib/head_music/pitch.rb - About 25 mins to fix

                  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?
                  Severity: Minor
                  Found in lib/head_music/style/guidelines/single_large_leaps.rb - About 25 mins to fix

                  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)
                  Severity: Minor
                  Found in lib/head_music/reference_pitch.rb and 1 other location - About 15 mins to fix
                  lib/head_music/clef.rb on lines 77..80

                  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

                  Further Reading

                  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)
                  Severity: Minor
                  Found in lib/head_music/clef.rb and 1 other location - About 15 mins to fix
                  lib/head_music/reference_pitch.rb on lines 138..141

                  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

                  Further Reading

                  Severity
                  Category
                  Status
                  Source
                  Language