robertgauld/osm

View on GitHub
lib/osm/event.rb

Summary

Maintainability
F
6 days
Test Coverage

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

        def update(api)
          require_ability_to(api, :write, :events, section_id)
           updated = true
    
          # Update main attributes
    Severity: Major
    Found in lib/osm/event.rb - About 3 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

      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

        Method get_attendance has 39 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def get_attendance(api, term=nil, options={})
              require_ability_to(api, :read, :events, section_id, options)
              term_id = term.nil? ? Osm::Term.get_current_term_for_section(api, section_id).id : term.to_i
              cache_key = ['event_attendance', id, term_id]
        
        
        Severity: Minor
        Found in lib/osm/event.rb - About 1 hr to fix

          Method get_audit_trail has 38 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                def get_audit_trail(api, options={})
                  require_ability_to(api, :read, :events, event.section_id, options)
                  cache_key = ['event\_attendance\_audit', event.id, member_id]
          
                  if !options[:no_cache] && cache_exist?(api, cache_key)
          Severity: Minor
          Found in lib/osm/event.rb - About 1 hr to fix

            Method create has 36 lines of code (exceeds 25 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 1 hr to fix

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

                    def update(api)
                      require_ability_to(api, :write, :events, event.section_id)
              
                      payment_values = {
                        :manual => 'Manual',
              Severity: Minor
              Found in lib/osm/event.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

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

                  def get_attendance(api, term=nil, options={})
                    require_ability_to(api, :read, :events, section_id, options)
                    term_id = term.nil? ? Osm::Term.get_current_term_for_section(api, section_id).id : term.to_i
                    cache_key = ['event_attendance', id, term_id]
              
              
              Severity: Minor
              Found in lib/osm/event.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

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

                    def update(api)
                      require_ability_to(api, :write, :events, event.section_id)
              
                      data = api.perform_query("events.php?action=renameColumn&sectionid=#{event.section_id}&eventid=#{event.id}", {
                        'columnId' => id,
              Severity: Minor
              Found in lib/osm/event.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

              Method get_for_section has 31 lines of code (exceeds 25 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 1 hr to fix

                Method get_list has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    def self.get_list(api, section, options={})
                      require_ability_to(api, :read, :events, section, options)
                      section_id = section.to_i
                      cache_key = ['events_list', section_id]
                      events_cache_key = ['events', section_id]
                Severity: Minor
                Found in lib/osm/event.rb - About 1 hr to fix

                  Method new_event_from_data has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      def self.new_event_from_data(event_data)
                        event = Osm::Event.new(attributes_from_data(event_data))
                        event.notepad = event_data['notepad']
                  
                        columns = []
                  Severity: Minor
                  Found in lib/osm/event.rb - About 1 hr to fix

                    Method get_list has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def self.get_list(api, section, options={})
                          require_ability_to(api, :read, :events, section, options)
                          section_id = section.to_i
                          cache_key = ['events_list', section_id]
                          events_cache_key = ['events', section_id]
                    Severity: Minor
                    Found in lib/osm/event.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

                    Method add_badge_link has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def add_badge_link(api, link)
                          raise Osm::ObjectIsInvalid, 'link is invalid' unless link.valid?
                    
                          data = api.perform_query("ext/badges/records/index.php?action=linkBadgeToItem&sectionid=#{section_id}", {
                            'section' => link.badge_section,
                    Severity: Minor
                    Found in lib/osm/event.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_audit_trail has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                    Open

                          def get_audit_trail(api, options={})
                            require_ability_to(api, :read, :events, event.section_id, options)
                            cache_key = ['event\_attendance\_audit', event.id, member_id]
                    
                            if !options[:no_cache] && cache_exist?(api, cache_key)
                    Severity: Minor
                    Found in lib/osm/event.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 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

                    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

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

                        def self.get(api, section, event_id, options={})
                          require_ability_to(api, :read, :events, section, options)
                          section_id = section.to_i
                          event_id = event_id.to_i
                          cache_key = ['event', event_id]
                    Severity: Minor
                    Found in lib/osm/event.rb and 1 other location - About 1 hr to fix
                    lib/osm/invoice.rb on lines 91..102

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

                    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

                            if changed_attributes.include?('attending')
                              data = api.perform_query("events.php?action=updateScout", {
                                'scoutid' => member_id,
                                'column' => 'attending',
                                'value' => attending_values[attending],
                    Severity: Minor
                    Found in lib/osm/event.rb and 1 other location - About 30 mins to fix
                    lib/osm/event.rb on lines 823..832

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

                    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

                            if changed_attributes.include?('payment_control')
                              data = api.perform_query("events.php?action=updateScout", {
                                'scoutid' => member_id,
                                'column' => 'payment',
                                'value' => payment_values[payment_control],
                    Severity: Minor
                    Found in lib/osm/event.rb and 1 other location - About 30 mins to fix
                    lib/osm/event.rb on lines 834..843

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

                    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