lyang/braintree-rails

View on GitHub

Showing 5 of 5 total issues

Method with_update_braintree has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

      def with_update_braintree(context)
        raise RecordInvalid.new(self) unless valid?(context)
        run_callbacks context do
          case result = yield
          when Braintree::ErrorResult
Severity: Minor
Found in lib/braintree_rails/persistence.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 first_billing_date_must_be_valid_future_date has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def first_billing_date_must_be_valid_future_date(subscription)
      subscription.instance_eval do
        begin
          if new_record? && first_billing_date.present?
            errors.add(:first_billing_date, "cannot be in the past") if DateTime.parse(first_billing_date.to_s) < Date.today
Severity: Minor
Found in lib/braintree_rails/subscription_validator.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 credit_card_attributes has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def credit_card_attributes
      if credit_card.present?
        if credit_card.persisted?
          {:payment_method_token => credit_card.token}
        else
Severity: Minor
Found in lib/braintree_rails/transaction.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 number_of_billing_cycles_must_be_greater_than_current_billing_cycle has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def number_of_billing_cycles_must_be_greater_than_current_billing_cycle(subscription)
      subscription.instance_eval do
        if number_of_billing_cycles.present? && current_billing_cycle.present?
          errors.add(:number_of_billing_cycles, "is too small") if number_of_billing_cycles < current_billing_cycle
        end
Severity: Minor
Found in lib/braintree_rails/subscription_validator.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 attributes has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

      def attributes
        self.class.attributes.inject({}) do |hash, attribute|
          if (value = self.send(attribute)).present?
            hash[attribute] = value.respond_to?(:attributes_for) ? value.attributes_for(:as_association) : value
          end
Severity: Minor
Found in lib/braintree_rails/attributes.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