astroband/ruby-stellar-sdk

View on GitHub

Showing 16 of 306 total issues

Class Operation has 26 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Operation
    MAX_INT64 = 2**63 - 1
    TRUST_LINE_FLAGS_MAPPING = {
      full: Stellar::TrustLineFlags.authorized_flag,
      maintain_liabilities: Stellar::TrustLineFlags.authorized_to_maintain_liabilities_flag,
Severity: Minor
Found in base/lib/stellar/operation.rb - About 3 hrs to fix

    Class KeyPair has 26 methods (exceeds 20 allowed). Consider refactoring.
    Open

      class KeyPair
        module FactoryMethods
          def from_seed(seed)
            seed_bytes = Util::StrKey.check_decode(:seed, seed)
            from_raw_seed seed_bytes
    Severity: Minor
    Found in base/lib/stellar/key_pair.rb - About 3 hrs to fix

      File operation.rb has 255 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      require "bigdecimal"
      
      module Stellar
        class Operation
          MAX_INT64 = 2**63 - 1
      Severity: Minor
      Found in base/lib/stellar/operation.rb - About 2 hrs to fix

        Method read_challenge_tx has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
        Open

            def self.read_challenge_tx(server:, challenge_xdr:, **options)
              envelope = Stellar::TransactionEnvelope.from_xdr(challenge_xdr, "base64")
              transaction = envelope.tx
        
              if transaction.seq_num != 0
        Severity: Minor
        Found in sdk/lib/stellar/sep10.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 build_challenge_tx has 48 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def self.build_challenge_tx(server:, client:, domain: nil, timeout: 300, **options)
              if domain.blank? && options.key?(:anchor_name)
                ActiveSupport::Deprecation.new("next release", "stellar-sdk").warn <<~MSG
                  SEP-10 v2.0.0 requires usage of service home domain instead of anchor name in the challenge transaction.
                  Please update your implementation to use `Stellar::SEP10.build_challenge_tx(..., home_domain: 'example.com')`.
        Severity: Minor
        Found in sdk/lib/stellar/sep10.rb - About 1 hr to fix

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

              def check_memo_required(tx_envelope)
                tx = tx_envelope.tx
          
                if tx.is_a?(Stellar::FeeBumpTransaction)
                  tx = tx.inner_tx.v1!.tx
          Severity: Minor
          Found in horizon/lib/stellar/horizon/client.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 read_challenge_tx has 47 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def self.read_challenge_tx(server:, challenge_xdr:, **options)
                envelope = Stellar::TransactionEnvelope.from_xdr(challenge_xdr, "base64")
                transaction = envelope.tx
          
                if transaction.seq_num != 0
          Severity: Minor
          Found in sdk/lib/stellar/sep10.rb - About 1 hr to fix

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

                def check_memo_required(tx_envelope)
                  tx = tx_envelope.tx
            
                  if tx.is_a?(Stellar::FeeBumpTransaction)
                    tx = tx.inner_tx.v1!.tx
            Severity: Minor
            Found in horizon/lib/stellar/horizon/client.rb - About 1 hr to fix

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

                  def initialize(
                    source_account:,
                    sequence_number:,
                    base_fee: 100,
                    time_bounds: nil,
              Severity: Minor
              Found in base/lib/stellar/transaction_builder.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 describe has 27 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  def describe
                    case switch
                    when ClaimPredicateType::UNCONDITIONAL
                      "always"
                    when ClaimPredicateType::BEFORE_RELATIVE_TIME
              Severity: Minor
              Found in base/lib/stellar/claim_predicate.rb - About 1 hr to fix

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

                    def self.verify_challenge_tx_signers(server:, challenge_xdr:, signers:)
                      raise InvalidSep10ChallengeError, "no signers provided" if signers.empty?
                
                      te, _ = read_challenge_tx(server: server, challenge_xdr: challenge_xdr)
                
                
                Severity: Minor
                Found in sdk/lib/stellar/sep10.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 lookup has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                    def self.lookup(federated_name)
                      _, domain = federated_name.split("*")
                      if domain.nil?
                        raise InvalidFederationAddress.new
                      end
                Severity: Minor
                Found in sdk/lib/stellar/federation.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 evaluate has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                    def evaluate(created_at, claiming_at)
                      created_at = created_at.to_time if created_at.respond_to?(:to_time)
                      claiming_at = created_at + claiming_at if claiming_at.is_a?(ActiveSupport::Duration)
                      claiming_at = claiming_at.to_time if claiming_at.respond_to?(:to_time)
                
                
                Severity: Minor
                Found in base/lib/stellar/claim_predicate.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 from has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                    def self.from(number)
                      number = BigDecimal(number, 0) if number.is_a?(String)
                      number = number.to_r if number.respond_to?(:to_r)
                
                      raise ArgumentError, "Couldn't convert #{number.class} to rational number" unless number.is_a?(Rational)
                Severity: Minor
                Found in base/lib/stellar/price.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 make has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                    def make(thresholds = {})
                      # error if any of the needed components are not provided
                      if COMPONENTS.any? { |c| thresholds[c].blank? }
                        raise ArgumentError, "invalid thresholds hash, must have #{COMPONENTS.inspect} keys, had: #{thresholds.keys.inspect}"
                      end
                Severity: Minor
                Found in base/lib/stellar/thresholds.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 build_challenge_tx has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                    def self.build_challenge_tx(server:, client:, domain: nil, timeout: 300, **options)
                      if domain.blank? && options.key?(:anchor_name)
                        ActiveSupport::Deprecation.new("next release", "stellar-sdk").warn <<~MSG
                          SEP-10 v2.0.0 requires usage of service home domain instead of anchor name in the challenge transaction.
                          Please update your implementation to use `Stellar::SEP10.build_challenge_tx(..., home_domain: 'example.com')`.
                Severity: Minor
                Found in sdk/lib/stellar/sep10.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