robertgauld/osm

View on GitHub

Showing 146 of 184 total issues

Method get_summary_for_section has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

    def self.get_summary_for_section(api, section, term=nil, options={})
      raise Error, 'This method must NOT be called on one of the subclasses(CoreBadge, ChallengeBadge, StagedBadge or ActivityBadge)' unless type.nil?
      require_ability_to(api, :read, :badge, section, options)
      section = Osm::Section.get(api, section, options) unless section.is_a?(Osm::Section)
      term_id = (term.nil? ? Osm::Term.get_current_term_for_section(api, section, options) : term).to_i
Severity: Minor
Found in lib/osm/badge.rb - About 2 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

Class Model has 25 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Model
    include ActiveModel::MassAssignmentSecurity if ActiveModel::VERSION::MAJOR < 4
    include ActiveAttr::Model

    SORT_BY = [:id]
Severity: Minor
Found in lib/osm/model.rb - About 2 hrs to fix

    Method get_all has 70 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def self.get_all(api, options={})
          cache_key = ['sections', api.user_id]
    
          if !options[:no_cache] && cache_exist?(api, cache_key)
            ids = cache_read(api, cache_key)
    Severity: Major
    Found in lib/osm/section.rb - About 2 hrs to fix

      Method get has 69 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def self.get(api, activity_id, version=nil, options={})
            cache_key = ['activity', activity_id]
      
            if !options[:no_cache] && cache_exist?(api, [*cache_key, version])
              activity = cache_read(api, [*cache_key, version])
      Severity: Major
      Found in lib/osm/activity.rb - About 2 hrs to fix

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

            def update(api, force=false)
              raise Osm::ObjectIsInvalid, 'member is invalid' unless valid?
              require_ability_to(api, :write, :member, section_id)
        
              updated = true
        Severity: Minor
        Found in lib/osm/member.rb - About 2 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

        Method get_data has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
        Open

            def self.get_data(api, section, term=nil, options={})
              Osm::Model.require_ability_to(api, :read, :finance, 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 = ['gift_aid_data', section_id, term_id]
        Severity: Minor
        Found in lib/osm/giftaid.rb - About 2 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

        Method get_badges_for_section has 64 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def self.get_badges_for_section(api, section, section_type=nil, options={})
              raise Error, 'This method must be called on one of the subclasses (CoreBadge, ChallengeBadge, StagedBadge or ActivityBadge)' if type.nil?
              require_ability_to(api, :read, :badge, section, options)
              section = Osm::Section.get(api, section, options) unless section.is_a?(Osm::Section)
              section_type ||= section.type
        Severity: Major
        Found in lib/osm/badge.rb - About 2 hrs to fix

          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

            File invoice.rb has 268 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            module Osm
            
              class Invoice < Osm::Model
                SORT_BY = [:section_id, :name, :date]
            
            
            Severity: Minor
            Found in lib/osm/invoice.rb - About 2 hrs to fix

              Method configure has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
              Open

                  def self.configure(options)
                    unless options[:i_know].eql?(:unsupported)
                      raise Osm::Error, 'The OSM gem is now unsupported. ' \
                                        'To continue using it append "i_know: :unsupported" to your passed options. ' \
                                        "See #{File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'UNSUPPORTED.md'))} for more details."
              Severity: Minor
              Found in lib/osm/api.rb - About 2 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

              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 58 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    def update(api, force=false)
                      raise Osm::ObjectIsInvalid, 'member is invalid' unless valid?
                      require_ability_to(api, :write, :member, section_id)
                
                      updated = true
                Severity: Major
                Found in lib/osm/member.rb - About 2 hrs to fix

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

                      def self.get_for_section(api, section, options={})
                        require_ability_to(api, :read, :events, section, options)
                        section_id = section.to_i
                        cache_key = ['events', section_id]
                        events = nil
                  Severity: Minor
                  Found in lib/osm/event.rb - About 2 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 activity.rb has 255 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

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

                    Method make_datetime has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                    Open

                      def self.make_datetime(date, time, options={})
                        date = nil if date.nil? || date.empty? || (!options[:ignore_epoch] && epoch_date?(date))
                        time = nil if time.nil? || time.empty?
                        if (!date.nil? && !time.nil?)
                          begin
                    Severity: Minor
                    Found in lib/osm.rb - About 2 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

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

                          def update(api)
                            require_ability_to(api, :write, :events, event.section_id)
                    
                            payment_values = {
                              :manual => 'Manual',
                    Severity: Major
                    Found in lib/osm/event.rb - About 2 hrs to fix

                      File myscout.rb has 253 lines of code (exceeds 250 allowed). Consider refactoring.
                      Open

                      module Osm
                      
                        class Myscout
                      
                          class ParentLoginHistory < Osm::Model
                      Severity: Minor
                      Found in lib/osm/myscout.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, 'data is invalid' unless valid?
                                require_ability_to(api, :write, :finance, section_id)
                                term_id = Osm::Term.get_current_term_for_section(api, section_id).id
                        
                        
                        Severity: Minor
                        Found in lib/osm/giftaid.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 validate_each has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                            Open

                              def validate_each(record, attribute, value)
                                record.errors.add(attribute, 'must be an Array') unless value.is_a?(Array)
                                value.each do |value_item|
                                  unless value_item.is_a?(options[:item_type])
                                    record.errors.add(attribute, "items in the Array must be a #{options[:item_type].name}")
                            Severity: Minor
                            Found in lib/array_of_validator.rb - About 1 hr 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

                            Severity
                            Category
                            Status
                            Source
                            Language