Showing 5 of 5 total issues

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

        def verify!
          raise TBK::Webpay::PaymentError, "Commerce required" if self.commerce.nil?
          raise TBK::Webpay::PaymentError, "Invalid amount (#{self.amount.inspect})" unless self.amount && self.amount > 0
          raise TBK::Webpay::PaymentError, "Order ID required" if self.order_id.nil?
          raise TBK::Webpay::PaymentError, "Success URL required" if self.success_url.nil?
Severity: Minor
Found in lib/tbk/webpay/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 initialize has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    def initialize(attributes)
      @environment = (attributes[:environment] || :production).to_sym
      raise TBK::CommerceError, "Invalid commerce environment" unless [:production,:test].include? @environment

      @id = attributes[:id]
Severity: Minor
Found in lib/tbk/commerce.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 fetch_token has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        def fetch_token
          uri = URI.parse( self.validation_url )

          response = nil
          until response && response['location'].nil?
Severity: Minor
Found in lib/tbk/webpay/payment.rb - About 1 hr to fix

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

            def payment(payment)
              events_log_file do |file|
                file.write PAYMENT_FORMAT % {
                  date: now.strftime(LOG_DATE_FORMAT),
                  time: now.strftime(LOG_TIME_FORMAT),
    Severity: Minor
    Found in lib/tbk/webpay/logger/official_logger.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 fetch_token has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

            def fetch_token
              uri = URI.parse( self.validation_url )
    
              response = nil
              until response && response['location'].nil?
    Severity: Minor
    Found in lib/tbk/webpay/payment.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

    Severity
    Category
    Status
    Source
    Language