catarse/catarse_pagarme

View on GitHub

Showing 10 of 10 total issues

Method af_metadata has 119 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def af_metadata
      project = contribution.project
      user = contribution.user

      {
Severity: Major
Found in app/controllers/catarse_pagarme/credit_cards_controller.rb - About 4 hrs to fix

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

        def change_status_by_transaction(transaction_status)
          case transaction_status
          when 'pending_review' then
            self.payment.try(:notify_about_pending_review)
          when 'paid' then
    Severity: Minor
    Found in app/models/catarse_pagarme/payment_delegator.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 credit_card_attributes has 41 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def credit_card_attributes
          contribution.reload
          hash = {
            payment_method: 'credit_card',
            amount: delegator.value_with_installment_tax(get_installment),
    Severity: Minor
    Found in app/controllers/catarse_pagarme/credit_cards_controller.rb - About 1 hr to fix

      Method process! has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          def process!
            authorize!
            if self.transaction.status == 'authorized'
              if was_credit_card_used_before?
                self.transaction.capture
      Severity: Minor
      Found in app/models/catarse_pagarme/credit_card_transaction.rb - About 55 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 transfer_funds has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def transfer_funds
            ActiveRecord::Base.transaction do
              raise "unable to create transfer, need to be authorized" if !balance_transfer.authorized?
      
              bank_account = PagarMe::BankAccount.new(bank_account_attributes.delete(:bank_account))
      Severity: Minor
      Found in app/models/catarse_pagarme/balance_transfer_delegator.rb - About 45 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 transaction has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def transaction
            gateway_id = self.payment.gateway_id
            return nil unless gateway_id.present?
      
            @transaction ||= ::PagarMe::Transaction.find_by_id(gateway_id)
      Severity: Minor
      Found in app/models/catarse_pagarme/payment_delegator.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 authenticate_user! has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def authenticate_user!
            unless defined?(current_user) && current_user
              raise Exception.new('invalid user')
            end
      
      
      Severity: Minor
      Found in app/controllers/catarse_pagarme/application_controller.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 create has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def create
            transaction = CreditCardTransaction.new(credit_card_attributes, payment).process!
      
            render json: { payment_status: transaction.status }
          rescue PagarMe::PagarMeError, PagarMe::ValidationError => e
      Severity: Minor
      Found in app/controllers/catarse_pagarme/credit_cards_controller.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 installments_for_json has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def installments_for_json
            if contribution.value.to_f >= CatarsePagarme.configuration.minimum_value_for_installment.to_f
              project = payment.project
              installments = payment.pagarme_delegator.get_installments['installments']
              collection = installments.map do |installment|
      Severity: Minor
      Found in app/controllers/catarse_pagarme/credit_cards_controller.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 installments_for_select has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def installments_for_select(payment)
            installments = payment.pagarme_delegator.get_installments['installments']
            project = payment.project
      
            collection = installments.map do |installment|
      Severity: Minor
      Found in app/helpers/catarse_pagarme/application_helper.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