astroband/ruby-stellar-sdk

View on GitHub
base/lib/stellar/operation.rb

Summary

Maintainability
C
1 day
Test Coverage
B
81%

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

    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

      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

      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

      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

      There are no issues that match your filters.

      Category