robertgauld/osm

View on GitHub

Showing 184 of 184 total issues

File badge.rb has 619 lines of code (exceeds 250 allowed). Consider refactoring.
Open

module Osm

  class Badge < Osm::Model
    class Requirement; end # Ensure the constant exists for the validators
    class RequirementModule; end # Ensure the constant exists for the validators
Severity: Major
Found in lib/osm/badge.rb - About 1 day to fix

    File event.rb has 614 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    module Osm
    
      class Event < Osm::Model
        class BadgeLink < Osm::Model; end # Ensure the constant exists for the validators
        class Column < Osm::Model; end # Ensure the constant exists for the validators
    Severity: Major
    Found in lib/osm/event.rb - About 1 day to fix

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

          def self.get_for_section(api, section, term=nil, options={})
            require_ability_to(api, :read, :member, section, options)
            if term.nil?
              section = Osm::Section.get(api, section) if section.is_a?(Fixnum)
              term = section.waiting? ? -1 : Osm::Term.get_current_term_for_section(api, section)
      Severity: Minor
      Found in lib/osm/member.rb - About 1 day 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 member.rb has 550 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      module Osm
      
        class Member < Osm::Model
          # Constants for group id
          GID_PRIMARY_CONTACT = 1
      Severity: Major
      Found in lib/osm/member.rb - About 1 day to fix

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

            def update(api)
              require_ability_to(api, :write, :events, section_id)
               updated = true
        
              # Update main attributes
        Severity: Minor
        Found in lib/osm/event.rb - About 7 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 144 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def self.get_for_section(api, section, term=nil, options={})
              require_ability_to(api, :read, :member, section, options)
              if term.nil?
                section = Osm::Section.get(api, section) if section.is_a?(Fixnum)
                term = section.waiting? ? -1 : Osm::Term.get_current_term_for_section(api, section)
        Severity: Major
        Found in lib/osm/member.rb - About 5 hrs to fix

          Method earnt? has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
          Open

                def earnt?
                  if badge.has_levels?
                    return earnt > awarded
                  else
                    return false if (due.eql?(1) && awarded.eql?(1))
          Severity: Minor
          Found in lib/osm/badge.rb - About 5 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 a Cognitive Complexity of 35 (exceeds 5 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 5 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_all has a Cognitive Complexity of 33 (exceeds 5 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: Minor
          Found in lib/osm/section.rb - About 4 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 28 (exceeds 5 allowed). Consider refactoring.
          Open

              def get_data(api, term=nil, options={})
                require_ability_to(api, :read, :flexi, section_id, options)
                section = Osm::Section.get(api, self.section_id)
                term_id = term.nil? ? Osm::Term.get_current_term_for_section(api, section).id : term.to_i
                cache_key = ['flexi_record_data', id, term_id]
          Severity: Minor
          Found in lib/osm/flexi_record.rb - About 4 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 started has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
          Open

                def started
                  unless badge.has_levels?
                    return started? ? 1 : 0
                  end
                  unless badge.show_level_letters
          Severity: Minor
          Found in lib/osm/badge.rb - About 4 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 create has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
          Open

              def self.create(api, parameters)
                require_ability_to(api, :write, :events, parameters[:section_id])
                event = new(parameters)
                raise Osm::ObjectIsInvalid, 'event is invalid' unless event.valid?
          
          
          Severity: Minor
          Found in lib/osm/event.rb - About 4 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 validate_each has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
          Open

            def validate_each(record, attribute, value)
              record.errors.add(attribute, 'must be a Hash') unless value.is_a?(Hash)
          
              value.each do |k, v|
                if options[:key_type]
          Severity: Minor
          Found in lib/hash_validator.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

          Method perform_query has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
          Open

              def self.perform_query(site, url, api_data={}, raw=false)
                raise ArgumentError, 'site is invalid, this should be set to either :osm or :ogm' unless Osm::Api::BASE_URLS.keys.include?(site)
           
                data = api_data.merge({
                  'apiid' => @@api_details[site][:id],
          Severity: Minor
          Found in lib/osm/api.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

          Method get_attendance has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
          Open

              def self.get_attendance(api, section, term=nil, options={})
                Osm::Model.require_ability_to(api, :read, :register, 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 = ['register_attendance', section_id, term_id]
          Severity: Minor
          Found in lib/osm/register.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

          Method get has a Cognitive Complexity of 24 (exceeds 5 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: Minor
          Found in lib/osm/activity.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

          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/event.rb and 1 other location - About 3 hrs to fix
          lib/osm/meeting.rb on lines 374..417

          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

              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

          File online_payment.rb has 305 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          module Osm
          
            class OnlinePayment
          
              class Schedule < Osm::Model
          Severity: Minor
          Found in lib/osm/online_payment.rb - About 3 hrs to fix

            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

            Severity
            Category
            Status
            Source
            Language