voucherifyio/voucherify-ruby-sdk

View on GitHub
lib/VoucherifySdk/models/voucher_transaction_details_balance.rb

Summary

Maintainability
D
2 days
Test Coverage

File voucher_transaction_details_balance.rb has 260 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'date'
require 'time'

module VoucherifySdk
  # Contains information on how the balance was affected by the transaction.
Severity: Minor
Found in lib/VoucherifySdk/models/voucher_transaction_details_balance.rb - About 2 hrs to fix

    Method initialize has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

        def initialize(attributes = {})
          if (!attributes.is_a?(Hash))
            fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::VoucherTransactionDetailsBalance` initialize method"
          end
    
    
    Severity: Minor
    Found in lib/VoucherifySdk/models/voucher_transaction_details_balance.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 39 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def initialize(attributes = {})
          if (!attributes.is_a?(Hash))
            fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::VoucherTransactionDetailsBalance` initialize method"
          end
    
    
    Severity: Minor
    Found in lib/VoucherifySdk/models/voucher_transaction_details_balance.rb - About 1 hr to fix

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

          def valid?
            warn '[DEPRECATED] the `valid?` method is obsolete'
            return false if @type.nil?
            type_validator = EnumAttributeValidator.new('String', ["loyalty_card"])
            return false unless type_validator.valid?(@type)
      Severity: Minor
      Found in lib/VoucherifySdk/models/voucher_transaction_details_balance.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 _deserialize has 34 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def self._deserialize(type, value)
            case type.to_sym
            when :Time
              Time.parse(value)
            when :Date
      Severity: Minor
      Found in lib/VoucherifySdk/models/voucher_transaction_details_balance.rb - About 1 hr to fix

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

            def list_invalid_properties
              warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
              invalid_properties = Array.new
              if @type.nil?
                invalid_properties.push('invalid value for "type", type cannot be nil.')
        Severity: Minor
        Found in lib/VoucherifySdk/models/voucher_transaction_details_balance.rb - About 1 hr to fix

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

              def self._deserialize(type, value)
                case type.to_sym
                when :Time
                  Time.parse(value)
                when :Date
          Severity: Minor
          Found in lib/VoucherifySdk/models/voucher_transaction_details_balance.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 build_from_hash has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

              def self.build_from_hash(attributes)
                return nil unless attributes.is_a?(Hash)
                attributes = attributes.transform_keys(&:to_sym)
                transformed_hash = {}
                openapi_types.each_pair do |key, type|
          Severity: Minor
          Found in lib/VoucherifySdk/models/voucher_transaction_details_balance.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 to_hash has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              def to_hash
                hash = {}
                self.class.attribute_map.each_pair do |attr, param|
                  value = self.send(attr)
                  if value.nil?
          Severity: Minor
          Found in lib/VoucherifySdk/models/voucher_transaction_details_balance.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 list_invalid_properties has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              def list_invalid_properties
                warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
                invalid_properties = Array.new
                if @type.nil?
                  invalid_properties.push('invalid value for "type", type cannot be nil.')
          Severity: Minor
          Found in lib/VoucherifySdk/models/voucher_transaction_details_balance.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

          Avoid too many return statements within this method.
          Open

                return false if @object.nil?
          Severity: Major
          Found in lib/VoucherifySdk/models/voucher_transaction_details_balance.rb - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                  return false unless object_validator.valid?(@object)
            Severity: Major
            Found in lib/VoucherifySdk/models/voucher_transaction_details_balance.rb - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                    return false if @balance.nil?
              Severity: Major
              Found in lib/VoucherifySdk/models/voucher_transaction_details_balance.rb - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                      return false if @related_object.nil?
                Severity: Major
                Found in lib/VoucherifySdk/models/voucher_transaction_details_balance.rb - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                        return false if @object !~ Regexp.new(/balance/)
                  Severity: Major
                  Found in lib/VoucherifySdk/models/voucher_transaction_details_balance.rb - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                          return false if @points.nil?
                    Severity: Major
                    Found in lib/VoucherifySdk/models/voucher_transaction_details_balance.rb - About 30 mins to fix

                      Method _to_hash has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                      Open

                          def _to_hash(value)
                            if value.is_a?(Array)
                              value.compact.map { |v| _to_hash(v) }
                            elsif value.is_a?(Hash)
                              {}.tap do |hash|
                      Severity: Minor
                      Found in lib/VoucherifySdk/models/voucher_transaction_details_balance.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

                      There are no issues that match your filters.

                      Category
                      Status