robertgauld/osm

View on GitHub

Showing 146 of 184 total issues

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

Avoid too many return statements within this method.
Open

            return false unless total_gained >= badge.min_requirements_required
Severity: Major
Found in lib/osm/badge.rb - About 30 mins to fix

    Avoid too many return statements within this method.
    Open

                return this_level if (done < this_level && done > previous_level) # this_level has been started (and not finished)
    Severity: Major
    Found in lib/osm/badge.rb - About 30 mins to fix

      Avoid too many return statements within this method.
      Open

                return 0 # No reason we should ever get here
      Severity: Major
      Found in lib/osm/badge.rb - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

                    return false if requires.include?(false) # Only earnt if all combinations are met
        Severity: Major
        Found in lib/osm/badge.rb - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

                    return true
          Severity: Major
          Found in lib/osm/badge.rb - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                      return 0 if levels.include?(done)        # Has achieved a level (and not started next )
            Severity: Major
            Found in lib/osm/badge.rb - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                        return true
              Severity: Major
              Found in lib/osm/online_payment.rb - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                      return nil
                Severity: Major
                Found in lib/osm.rb - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                                return false unless requirement_met?(c[:id])
                  Severity: Major
                  Found in lib/osm/badge.rb - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                                  return false if requirements[c[:id]].to_i < c[:min]
                    Severity: Major
                    Found in lib/osm/badge.rb - About 30 mins to fix

                      Avoid too many return statements within this method.
                      Open

                                return 0 if done >= levels[-1]           # No more levels to do
                      Severity: Major
                      Found in lib/osm/badge.rb - About 30 mins to fix

                        Method create has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                        Open

                            def create(api)
                              raise Osm::Error, 'the invoice already exists in OSM' unless id.nil?
                              raise Osm::ObjectIsInvalid, 'invoice is invalid' unless valid?
                              Osm::Model.require_ability_to(api, :write, :finance, section_id)
                        
                        
                        Severity: Minor
                        Found in lib/osm/invoice.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 delete has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                        Open

                              def delete(api)
                                require_ability_to(api, :write, :events, event.section_id)
                        
                                data = api.perform_query("events.php?action=deleteColumn&sectionid=#{event.section_id}&eventid=#{event.id}", {
                                  'columnId' => id
                        Severity: Minor
                        Found in lib/osm/event.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 update has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                        Open

                            def update(api, section, secret_update=false)
                              raise Osm::ObjectIsInvalid, 'activity is invalid' unless valid?
                              raise Osm::Forbidden, "You are not allowed to update this activity" unless self.editable
                        
                              data = api.perform_query("programme.php?action=update", {
                        Severity: Minor
                        Found in lib/osm/activity.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 get has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                        Open

                            def self.get(api, section_id, options={})
                              cache_key = ['section', section_id]
                        
                              if !options[:no_cache] && cache_exist?(api, cache_key) && can_access_section?(api, section_id)
                                return cache_read(api, cache_key)
                        Severity: Minor
                        Found in lib/osm/section.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 get_notepad has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                        Open

                            def get_notepad(api, options={})
                              require_access_to_section(api, self, options)
                              cache_key = ['notepad', id]
                        
                              if !options[:no_cache] && cache_exist?(api, cache_key) && can_access_section?(api, self.id)
                        Severity: Minor
                        Found in lib/osm/section.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 require_permission has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                        Open

                            def self.require_permission(api, to, on, section, options={})
                              section = Osm::Section.get(api, section.to_i, options) unless section.is_a?(Osm::Section)
                              section_name = section.try(:name)
                              unless user_has_permission?(api, to, on, section, options)
                                raise Osm::Forbidden, "Your OSM user does not have permission to #{to} on #{on} for #{section_name}."
                        Severity: Minor
                        Found in lib/osm/model.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 module_completion_data has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                        Open

                            def self.module_completion_data(api, badge, options={})
                              fetched_this_time = @module_completion_data.nil? # Flag to ensure we only get the data once (at most) per invocation
                              @module_completion_data = get_module_completion_data(api, options) if fetched_this_time
                        
                              if @module_completion_data[badge.id].nil? && !fetched_this_time
                        Severity: Minor
                        Found in lib/osm/badge.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 unblock_address has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                        Open

                                def unblock_address(api)
                                  return true unless bounced?
                        
                                  data = api.perform_query('ext/settings/emails/?action=unBlockEmail', {
                                    'section_id' => delivery_report.section_id,
                        Severity: Minor
                        Found in lib/osm/email.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

                        Severity
                        Category
                        Status
                        Source
                        Language