stellar/ruby-stellar-base

View on GitHub

Showing 29 of 29 total issues

Class Transaction has 27 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Transaction

    #
    # @see  Stellar::Operation.payment
    def self.payment(attributes={})
Severity: Minor
Found in lib/stellar/transaction.rb - About 3 hrs to fix

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

    require 'bigdecimal'
    
    module Stellar
      class Operation
    
    
    Severity: Minor
    Found in lib/stellar/operation.rb - About 2 hrs to fix

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

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

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

            def self.path_payment_strict_receive(attributes={})
              destination             = attributes[:destination]
              asset, amount           = get_asset_amount(attributes[:amount])
              send_asset, send_max    = get_asset_amount(attributes[:with])
              path                    = (attributes[:path] || []).map{
        Severity: Major
        Found in lib/stellar/operation.rb and 1 other location - About 2 hrs to fix
        lib/stellar/operation.rb on lines 135..155

        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 83.

        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 self.path_payment_strict_send(attributes={})
              destination             = attributes[:destination]
              asset, dest_min         = get_asset_amount(attributes[:amount])
              send_asset, send_amount = get_asset_amount(attributes[:with])
              path                    = (attributes[:path] || []).map{
        Severity: Major
        Found in lib/stellar/operation.rb and 1 other location - About 2 hrs to fix
        lib/stellar/operation.rb on lines 97..117

        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 83.

        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 self.manage_buy_offer(attributes={})
              buying = attributes[:buying]
              if buying.is_a?(Array)
                buying = Asset.send(*buying)
              end
        Severity: Major
        Found in lib/stellar/operation.rb and 1 other location - About 1 hr to fix
        lib/stellar/operation.rb on lines 205..228

        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 70.

        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 self.manage_sell_offer(attributes={})
              buying = attributes[:buying]
              if buying.is_a?(Array)
                buying = Asset.send(*buying)
              end
        Severity: Major
        Found in lib/stellar/operation.rb and 1 other location - About 1 hr to fix
        lib/stellar/operation.rb on lines 231..254

        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 70.

        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 11 (exceeds 5 allowed). Consider refactoring.
        Open

            def initialize(
              source_account:, 
              sequence_number:, 
              base_fee: 100, 
              time_bounds: nil, 
        Severity: Minor
        Found in 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

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

        module Stellar
          class PathPaymentStrictSendResultCode < XDR::Enum
            member :path_payment_strict_send_success,            0
            member :path_payment_strict_send_malformed,          -1
            member :path_payment_strict_send_underfunded,        -2
        Severity: Major
        Found in generated/stellar/path_payment_strict_send_result_code.rb and 3 other locations - About 55 mins to fix
        generated/stellar/manage_buy_offer_result_code.rb on lines 32..48
        generated/stellar/manage_sell_offer_result_code.rb on lines 32..48
        generated/stellar/path_payment_strict_receive_result_code.rb on lines 29..45

        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 44.

        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 4 locations. Consider refactoring.
        Open

        module Stellar
          class ManageBuyOfferResultCode < XDR::Enum
            member :manage_buy_offer_success,             0
            member :manage_buy_offer_malformed,           -1
            member :manage_buy_offer_sell_no_trust,       -2
        Severity: Major
        Found in generated/stellar/manage_buy_offer_result_code.rb and 3 other locations - About 55 mins to fix
        generated/stellar/manage_sell_offer_result_code.rb on lines 32..48
        generated/stellar/path_payment_strict_receive_result_code.rb on lines 29..45
        generated/stellar/path_payment_strict_send_result_code.rb on lines 29..45

        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 44.

        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 4 locations. Consider refactoring.
        Open

        module Stellar
          class ManageSellOfferResultCode < XDR::Enum
            member :manage_sell_offer_success,             0
            member :manage_sell_offer_malformed,           -1
            member :manage_sell_offer_sell_no_trust,       -2
        Severity: Major
        Found in generated/stellar/manage_sell_offer_result_code.rb and 3 other locations - About 55 mins to fix
        generated/stellar/manage_buy_offer_result_code.rb on lines 32..48
        generated/stellar/path_payment_strict_receive_result_code.rb on lines 29..45
        generated/stellar/path_payment_strict_send_result_code.rb on lines 29..45

        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 44.

        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 4 locations. Consider refactoring.
        Open

        module Stellar
          class PathPaymentStrictReceiveResultCode < XDR::Enum
            member :path_payment_strict_receive_success,            0
            member :path_payment_strict_receive_malformed,          -1
            member :path_payment_strict_receive_underfunded,        -2
        Severity: Major
        Found in generated/stellar/path_payment_strict_receive_result_code.rb and 3 other locations - About 55 mins to fix
        generated/stellar/manage_buy_offer_result_code.rb on lines 32..48
        generated/stellar/manage_sell_offer_result_code.rb on lines 32..48
        generated/stellar/path_payment_strict_send_result_code.rb on lines 29..45

        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 44.

        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 manage_data has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            def self.manage_data(attributes={})
              op = ManageDataOp.new()
        
              name  = attributes[:name]
              value = attributes[:value]
        Severity: Minor
        Found in lib/stellar/operation.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

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

        module Stellar
          class SetOptionsResultCode < XDR::Enum
            member :set_options_success,                0
            member :set_options_low_reserve,            -1
            member :set_options_too_many_signers,       -2
        Severity: Minor
        Found in generated/stellar/set_options_result_code.rb and 1 other location - About 35 mins to fix
        generated/stellar/payment_result_code.rb on lines 26..39

        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 35.

        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

        module Stellar
          class PaymentResultCode < XDR::Enum
            member :payment_success,            0
            member :payment_malformed,          -1
            member :payment_underfunded,        -2
        Severity: Minor
        Found in generated/stellar/payment_result_code.rb and 1 other location - About 35 mins to fix
        generated/stellar/set_options_result_code.rb on lines 25..38

        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 35.

        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 allow_trust has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            def self.allow_trust(attributes={})
              op = AllowTrustOp.new()
        
              trustor = attributes[:trustor]
              authorize = attributes[:authorize]
        Severity: Minor
        Found in lib/stellar/operation.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 change_trust has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            def self.change_trust(attributes={})
              line = attributes[:line]
              if !line.is_a?(Asset)
                if !Asset::TYPES.include?(line[0])
                  fail ArgumentError, "must be one of #{Asset::TYPES}"
        Severity: Minor
        Found in lib/stellar/operation.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

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

        module Stellar
          class LedgerEntryChange < XDR::Union
            switch_on LedgerEntryChangeType, :type
        
            switch :ledger_entry_created, :created
        Severity: Minor
        Found in generated/stellar/ledger_entry_change.rb and 1 other location - About 25 mins to fix
        generated/stellar/ledger_upgrade.rb on lines 21..33

        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 31.

        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

        module Stellar
          class LedgerUpgrade < XDR::Union
            switch_on LedgerUpgradeType, :type
        
            switch :ledger_upgrade_version,         :new_ledger_version
        Severity: Minor
        Found in generated/stellar/ledger_upgrade.rb and 1 other location - About 25 mins to fix
        generated/stellar/ledger_entry_change.rb on lines 21..33

        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 31.

        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 path_payment_strict_send has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def self.path_payment_strict_send(attributes={})
              destination             = attributes[:destination]
              asset, dest_min         = get_asset_amount(attributes[:amount])
              send_asset, send_amount = get_asset_amount(attributes[:with])
              path                    = (attributes[:path] || []).map{
        Severity: Minor
        Found in lib/stellar/operation.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