stellar/js-stellar-base

View on GitHub

Showing 111 of 111 total issues

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

export namespace xdr {
  export import Operation = xdrHidden.Operation2; // tslint:disable-line:strict-export-declare-modifiers

  type Hash = Opaque[]; // workaround, cause unknown

Severity: Major
Found in types/curr.d.ts and 1 other location - About 2 yrs to fix
types/next.d.ts on lines 41..14078

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

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

export namespace xdr {
  export import Operation = xdrHidden.Operation2; // tslint:disable-line:strict-export-declare-modifiers

  type Hash = Opaque[]; // workaround, cause unknown

Severity: Major
Found in types/next.d.ts and 1 other location - About 2 yrs to fix
types/curr.d.ts on lines 41..14078

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

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

File next.d.ts has 8514 lines of code (exceeds 250 allowed). Consider refactoring.
Open

// Automatically generated on 2023-10-16T10:48:00-08:00
import { Operation } from './index';

export {};

Severity: Major
Found in types/next.d.ts - About 3 wks to fix

    File curr.d.ts has 8514 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    // Automatically generated on 2023-10-16T10:48:00-08:00
    import { Operation } from './index';
    
    export {};
    
    
    Severity: Major
    Found in types/curr.d.ts - About 3 wks to fix

      File index.d.ts has 1129 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      // TypeScript Version: 2.9
      
      /// <reference types="node" />
      import { xdr } from './xdr';
      
      
      Severity: Major
      Found in types/index.d.ts - About 2 days to fix

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

        export function pathPaymentStrictSend(opts) {
          switch (true) {
            case !opts.sendAsset:
              throw new Error('Must specify a send asset');
            case !this.isValidAmount(opts.sendAmount):
        Severity: Major
        Found in src/operations/path_payment_strict_send.js and 1 other location - About 2 days to fix
        src/operations/path_payment_strict_receive.js on lines 30..66

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

        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

        export function pathPaymentStrictReceive(opts) {
          switch (true) {
            case !opts.sendAsset:
              throw new Error('Must specify a send asset');
            case !this.isValidAmount(opts.sendMax):
        Severity: Major
        Found in src/operations/path_payment_strict_receive.js and 1 other location - About 2 days to fix
        src/operations/path_payment_strict_send.js on lines 30..65

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

        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

        declare namespace xdrHidden {
          // tslint:disable-line:strict-export-declare-modifiers
          class Operation2<T extends Operation = Operation> {
            constructor(attributes: {
              sourceAccount: null | xdr.MuxedAccount;
        Severity: Major
        Found in types/curr.d.ts and 1 other location - About 1 day to fix
        types/next.d.ts on lines 7..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 353.

        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

        declare namespace xdrHidden {
          // tslint:disable-line:strict-export-declare-modifiers
          class Operation2<T extends Operation = Operation> {
            constructor(attributes: {
              sourceAccount: null | xdr.MuxedAccount;
        Severity: Major
        Found in types/next.d.ts and 1 other location - About 1 day to fix
        types/curr.d.ts on lines 7..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 353.

        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

        export function manageBuyOffer(opts) {
          const attributes = {};
          attributes.selling = opts.selling.toXDRObject();
          attributes.buying = opts.buying.toXDRObject();
          if (!this.isValidAmount(opts.buyAmount, true)) {
        Severity: Major
        Found in src/operations/manage_buy_offer.js and 1 other location - About 1 day to fix
        src/operations/manage_sell_offer.js on lines 20..47

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

        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

        export function manageSellOffer(opts) {
          const attributes = {};
          attributes.selling = opts.selling.toXDRObject();
          attributes.buying = opts.buying.toXDRObject();
          if (!this.isValidAmount(opts.amount, true)) {
        Severity: Major
        Found in src/operations/manage_sell_offer.js and 1 other location - About 1 day to fix
        src/operations/manage_buy_offer.js on lines 20..47

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

        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

        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

          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

          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

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

                if (opts.signer.sha256Hash) {
                  if (typeof opts.signer.sha256Hash === 'string') {
                    opts.signer.sha256Hash = Buffer.from(opts.signer.sha256Hash, 'hex');
                  }
            
            
            Severity: Major
            Found in src/operations/set_options.js and 1 other location - About 6 hrs to fix
            src/operations/set_options.js on lines 115..132

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

            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

                if (opts.signer.preAuthTx) {
                  if (typeof opts.signer.preAuthTx === 'string') {
                    opts.signer.preAuthTx = Buffer.from(opts.signer.preAuthTx, 'hex');
                  }
            
            
            Severity: Major
            Found in src/operations/set_options.js and 1 other location - About 6 hrs to fix
            src/operations/set_options.js on lines 134..151

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

            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 '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

            Function setOptions has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
            Open

            export function setOptions(opts) {
              const attributes = {};
            
              if (opts.inflationDest) {
                if (!StrKey.isValidEd25519PublicKey(opts.inflationDest)) {
            Severity: Minor
            Found in src/operations/set_options.js - About 5 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

            Severity
            Category
            Status
            Source
            Language