stellar/js-stellar-base

View on GitHub
src/operation.js

Summary

Maintainability
F
1 wk
Test Coverage

Function fromXDRObject has 257 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  static fromXDRObject(operation) {
    const result = {};
    if (operation.sourceAccount()) {
      result.source = encodeMuxedAccountToAddress(operation.sourceAccount());
    }
Severity: Major
Found in src/operation.js - About 1 day to fix

    File operation.js has 499 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    /* eslint-disable no-bitwise */
    
    import { Hyper } from '@stellar/js-xdr';
    import BigNumber from './util/bignumber';
    import { trimEnd } from './util/util';
    Severity: Minor
    Found in src/operation.js - About 1 day to fix

      Function fromXDRObject has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
      Open

        static fromXDRObject(operation) {
          const result = {};
          if (operation.sourceAccount()) {
            result.source = encodeMuxedAccountToAddress(operation.sourceAccount());
          }
      Severity: Minor
      Found in src/operation.js - About 3 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

      Function extractRevokeSponshipDetails has 69 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function extractRevokeSponshipDetails(attrs, result) {
        switch (attrs.switch().name) {
          case 'revokeSponsorshipLedgerEntry': {
            const ledgerKey = attrs.ledgerKey();
            switch (ledgerKey.switch().name) {
      Severity: Major
      Found in src/operation.js - About 2 hrs to fix

        Consider simplifying this complex logical expression.
        Open

            if (
              // == 0
              (!allowZero && amount.isZero()) ||
              // < 0
              amount.isNegative() ||
        Severity: Major
        Found in src/operation.js - About 1 hr to fix

          Function extractRevokeSponshipDetails has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

          function extractRevokeSponshipDetails(attrs, result) {
            switch (attrs.switch().name) {
              case 'revokeSponsorshipLedgerEntry': {
                const ledgerKey = attrs.ledgerKey();
                switch (ledgerKey.switch().name) {
          Severity: Minor
          Found in src/operation.js - 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

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

                case 'pathPaymentStrictReceive': {
                  result.type = 'pathPaymentStrictReceive';
                  result.sendAsset = Asset.fromOperation(attrs.sendAsset());
                  result.sendMax = this._fromXDRAmount(attrs.sendMax());
                  result.destination = encodeMuxedAccountToAddress(attrs.destination());
          Severity: Major
          Found in src/operation.js and 1 other location - About 1 day to fix
          src/operation.js on lines 158..174

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

          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

                case 'pathPaymentStrictSend': {
                  result.type = 'pathPaymentStrictSend';
                  result.sendAsset = Asset.fromOperation(attrs.sendAsset());
                  result.sendAmount = this._fromXDRAmount(attrs.sendAmount());
                  result.destination = encodeMuxedAccountToAddress(attrs.destination());
          Severity: Major
          Found in src/operation.js and 1 other location - About 1 day to fix
          src/operation.js on lines 141..157

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

          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

                case 'manageBuyOffer': {
                  result.type = 'manageBuyOffer';
                  result.selling = Asset.fromOperation(attrs.selling());
                  result.buying = Asset.fromOperation(attrs.buying());
                  result.buyAmount = this._fromXDRAmount(attrs.buyAmount());
          Severity: Major
          Found in src/operation.js and 1 other location - About 5 hrs to fix
          src/operation.js on lines 237..245

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

          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

                case 'manageSellOffer': {
                  result.type = 'manageSellOffer';
                  result.selling = Asset.fromOperation(attrs.selling());
                  result.buying = Asset.fromOperation(attrs.buying());
                  result.amount = this._fromXDRAmount(attrs.amount());
          Severity: Major
          Found in src/operation.js and 1 other location - About 5 hrs to fix
          src/operation.js on lines 246..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 145.

          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

                  case xdr.LedgerEntryType.liquidityPool().name: {
                    result.type = 'revokeLiquidityPoolSponsorship';
                    result.liquidityPoolId = ledgerKey
                      .liquidityPool()
                      .liquidityPoolId()
          Severity: Major
          Found in src/operation.js and 1 other location - About 1 hr to fix
          src/operation.js on lines 579..586

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

          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

                  case xdr.LedgerEntryType.claimableBalance().name: {
                    result.type = 'revokeClaimableBalanceSponsorship';
                    result.balanceId = ledgerKey
                      .claimableBalance()
                      .balanceId()
          Severity: Major
          Found in src/operation.js and 1 other location - About 1 hr to fix
          src/operation.js on lines 587..594

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

          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

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

                  const mapping = {
                    authorized: xdr.TrustLineFlags.authorizedFlag(),
                    authorizedToMaintainLiabilities:
                      xdr.TrustLineFlags.authorizedToMaintainLiabilitiesFlag(),
                    clawbackEnabled: xdr.TrustLineFlags.trustlineClawbackEnabledFlag()
          Severity: Major
          Found in src/operation.js and 1 other location - About 1 hr to fix
          src/operations/set_trustline_flags.js on lines 48..53

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

          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

              case xdr.SignerKeyType.signerKeyTypePreAuthTx().name: {
                attrs.preAuthTx = signerKey.preAuthTx().toString('hex');
                break;
              }
          Severity: Minor
          Found in src/operation.js and 1 other location - About 40 mins to fix
          src/operation.js on lines 626..629

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

          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

              case xdr.SignerKeyType.signerKeyTypeHashX().name: {
                attrs.sha256Hash = signerKey.hashX().toString('hex');
                break;
              }
          Severity: Minor
          Found in src/operation.js and 1 other location - About 40 mins to fix
          src/operation.js on lines 622..625

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

          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
          Status