astroband/ruby-stellar-sdk

View on GitHub

Showing 306 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

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

                  def path_payment_strict_receive(destination:, amount:, with:, path: [], source_account: nil)
                    raise ArgumentError unless destination.is_a?(KeyPair)
            
                    dest_asset, dest_amount = get_asset_amount(amount)
                    send_asset, send_max = get_asset_amount(with)
            Severity: Major
            Found in base/lib/stellar/operation.rb and 1 other location - About 1 hr to fix
            base/lib/stellar/operation.rb on lines 299..314

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 59.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

                  def path_payment_strict_send(destination:, amount:, with:, path: [], source_account: nil)
                    raise ArgumentError unless destination.is_a?(KeyPair)
            
                    dest_asset, dest_min = get_asset_amount(amount)
                    send_asset, send_amount = get_asset_amount(with)
            Severity: Major
            Found in base/lib/stellar/operation.rb and 1 other location - About 1 hr to fix
            base/lib/stellar/operation.rb on lines 271..286

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 59.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            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

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

                    def manage_buy_offer(buying:, selling:, amount:, price:, offer_id: 0, source_account: nil)
                      buying = Asset.send(*buying) if buying.is_a?(Array)
                      selling = Asset.send(*selling) if selling.is_a?(Array)
              
                      op = ManageBuyOfferOp.new(
              Severity: Major
              Found in base/lib/stellar/operation.rb and 1 other location - About 1 hr to fix
              base/lib/stellar/operation.rb on lines 327..339

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 53.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

                    def manage_sell_offer(selling:, buying:, amount:, price:, offer_id: 0, source_account: nil)
                      selling = Asset.send(*selling) if selling.is_a?(Array)
                      buying = Asset.send(*buying) if buying.is_a?(Array)
              
                      op = ManageSellOfferOp.new(
              Severity: Major
              Found in base/lib/stellar/operation.rb and 1 other location - About 1 hr to fix
              base/lib/stellar/operation.rb on lines 352..364

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 53.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              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