robertgauld/osm

View on GitHub
lib/osm/online_payment.rb

Summary

Maintainability
C
1 day
Test Coverage

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_payments_for_members has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

          def get_payments_for_members(api, term=nil, options={})
            require_ability_to(api, :read, :finance, section_id, options)
    
            if term.nil?
              section = Osm::Section.get(api, section_id, options)
    Severity: Minor
    Found in lib/osm/online_payment.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 has 34 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def self.get(api, section, schedule, options={})
            require_ability_to(api, :read, :finance, section, options)
            section_id = section.to_i
            schedule_id = schedule.to_i
            cache_key = ['online_payments', 'schedule', schedule_id]
    Severity: Minor
    Found in lib/osm/online_payment.rb - About 1 hr to fix

      Method get_payments_for_members has 32 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            def get_payments_for_members(api, term=nil, options={})
              require_ability_to(api, :read, :finance, section_id, options)
      
              if term.nil?
                section = Osm::Section.get(api, section_id, options)
      Severity: Minor
      Found in lib/osm/online_payment.rb - About 1 hr to fix

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

                def update_payment_status(api, payment, status, gift_aid=false)
                  payment_id = payment.to_i
                  fail ArgumentError, "#{payment_id} is not a valid payment for the schedule." unless schedule.payments.map(&:id).include?(payment_id)
                  fail ArgumentError, "status must be either :required, :not_required or :paid_manually. You passed in #{status.inspect}" unless [:required, :not_required, :paid_manually].include?(status)
        
        
        Severity: Minor
        Found in lib/osm/online_payment.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

        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

          There are no issues that match your filters.

          Category
          Status