robertgauld/osm

View on GitHub
lib/osm/meeting.rb

Summary

Maintainability
D
2 days
Test Coverage

Method get_for_section has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
Open

    def self.get_for_section(api, section, term=nil, options={})
      require_ability_to(api, :read, :programme, section, options)
      section_id = section.to_i
      term_id = term.nil? ? Osm::Term.get_current_term_for_section(api, section).id : term.to_i
      cache_key = ['programme', section_id, term_id]
Severity: Minor
Found in lib/osm/meeting.rb - About 3 hrs 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

File meeting.rb has 270 lines of code (exceeds 250 allowed). Consider refactoring.
Open

module Osm

  class Meeting < Osm::Model
    class Activity; end # Ensure the constant exists for the validators
    class BadgeLink; end # Ensure the constant exists for the validators
Severity: Minor
Found in lib/osm/meeting.rb - About 2 hrs to fix

    Method get_for_section has 60 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def self.get_for_section(api, section, term=nil, options={})
          require_ability_to(api, :read, :programme, section, options)
          section_id = section.to_i
          term_id = term.nil? ? Osm::Term.get_current_term_for_section(api, section).id : term.to_i
          cache_key = ['programme', section_id, term_id]
    Severity: Major
    Found in lib/osm/meeting.rb - About 2 hrs to fix

      Method update has 50 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def update(api)
            raise Osm::ObjectIsInvalid, 'meeting is invalid' unless valid?
            require_ability_to(api, :write, :programme, section_id)
      
            activities_data = Array.new
      Severity: Minor
      Found in lib/osm/meeting.rb - About 2 hrs to fix

        Method get_badge_requirements has 37 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def get_badge_requirements(api, options={})
              section = Osm::Section.get(api, section_id)
              cache_key = ['badge_requirements', section.id, id]
              if !options[:no_cache] && cache_exist?(api, cache_key)
                return cache_read(api, cache_key)
        Severity: Minor
        Found in lib/osm/meeting.rb - About 1 hr to fix

          Method update has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              def update(api)
                raise Osm::ObjectIsInvalid, 'meeting is invalid' unless valid?
                require_ability_to(api, :write, :programme, section_id)
          
                activities_data = Array.new
          Severity: Minor
          Found in lib/osm/meeting.rb - About 45 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 <=> has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              def <=>(another)
                result = self.section_id <=> another.try(:section_id)
                result = self.date <=> another.try(:date) if result == 0
                if result == 0
                  my_start_time = self.start_time.split(':').map{ |i| i.to_i }
          Severity: Minor
          Found in lib/osm/meeting.rb - About 35 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 get_badge_requirements has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              def get_badge_requirements(api, options={})
                section = Osm::Section.get(api, section_id)
                cache_key = ['badge_requirements', section.id, id]
                if !options[:no_cache] && cache_exist?(api, cache_key)
                  return cache_read(api, cache_key)
          Severity: Minor
          Found in lib/osm/meeting.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

          Identical blocks of code found in 2 locations. Consider refactoring.
          Open

              class BadgeLink
                include ActiveModel::MassAssignmentSecurity if ActiveModel::VERSION::MAJOR < 4
                include ActiveAttr::Model
          
                SORT_BY = [:badge_section, :badge_type, :badge_name, :requirement_label]
          Severity: Major
          Found in lib/osm/meeting.rb and 1 other location - About 3 hrs to fix
          lib/osm/event.rb on lines 581..624

          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 118.

          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

          Identical blocks of code found in 2 locations. Consider refactoring.
          Open

                        :badge_type => badge_data['badgetype'].to_sym,
                        :badge_section => badge_data['section'].to_sym,
                        :badge_name => badge_data['badgeLongName'],
                        :badge_id => Osm::to_i_or_nil(badge_data['badge_id']),
                        :badge_version => Osm::to_i_or_nil(badge_data['badge_version']),
          Severity: Minor
          Found in lib/osm/meeting.rb and 1 other location - About 45 mins to fix
          lib/osm/activity.rb on lines 161..168

          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 41.

          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

          There are no issues that match your filters.

          Category
          Status