stellar/js-stellar-base

View on GitHub

Showing 57 of 111 total issues

Function allowTrust has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

export function allowTrust(opts) {
  if (!StrKey.isValidEd25519PublicKey(opts.trustor)) {
    throw new Error('trustor is invalid');
  }
  const attributes = {};
Severity: Minor
Found in src/operations/allow_trust.js - 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

Function compare has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  static compare(assetA, assetB) {
    if (!assetA || !(assetA instanceof Asset)) {
      throw new Error('assetA is invalid');
    }
    if (!assetB || !(assetB instanceof Asset)) {
Severity: Minor
Found in src/asset.js - 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

Function changeTrust has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

export function changeTrust(opts) {
  const attributes = {};

  if (opts.asset instanceof Asset) {
    attributes.line = opts.asset.toChangeTrustXDRObject();
Severity: Minor
Found in src/operations/change_trust.js - 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

Function constructor has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  constructor(value, opts) {
    const signed = value < 0;
    let type = opts?.type ?? '';
    if (type.startsWith('u') && signed) {
      throw TypeError(`specified type ${opts.type} yet negative (${value})`);
Severity: Minor
Found in src/numbers/sc_int.js - 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

Function authorizeInvocation has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

  signer,
  validUntilLedgerSeq,
  invocation,
  publicKey = '',
  networkPassphrase = Networks.FUTURENET
Severity: Minor
Found in src/auth.js - About 35 mins to fix

    Function manageData has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

    export function manageData(opts) {
      const attributes = {};
    
      if (!(typeof opts.name === 'string' && opts.name.length <= 64)) {
        throw new Error('name must be a string, up to 64 characters');
    Severity: Minor
    Found in src/operations/manage_data.js - 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

    Function getLiquidityPoolId has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

    export function getLiquidityPoolId(
      liquidityPoolType,
      liquidityPoolParameters = {}
    ) {
      if (liquidityPoolType !== 'constant_product') {
    Severity: Minor
    Found in src/get_liquidity_pool_id.js - 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

    Function constructor has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

      constructor(code, issuer) {
        if (!/^[a-zA-Z0-9]{1,12}$/.test(code)) {
          throw new Error(
            'Asset code is invalid (maximum alphanumeric, 12 characters at max)'
          );
    Severity: Minor
    Found in src/asset.js - 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

    Avoid too many return statements within this function.
    Open

          return new ScInt(val, { type: opts?.type }).toScVal();
    Severity: Major
    Found in src/scval.js - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

                  return new XdrLargeInt(optType, val).toScVal();
      Severity: Major
      Found in src/scval.js - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

                return xdr.ScVal.scvVec(val.map((v) => nativeToScVal(v, opts)));
        Severity: Major
        Found in src/scval.js - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                return xdr.ScVal.scvMap(
                  Object.entries(val)
                    // The Soroban runtime expects maps to have their keys in sorted
                    // order, so let's do that here as part of the conversion to prevent
                    // confusing error messages on execution.
          Severity: Major
          Found in src/scval.js - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                return false;
            Severity: Major
            Found in src/strkey.js - About 30 mins to fix

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

                addSignature(publicKey = '', signature = '') {
                  if (!signature || typeof signature !== 'string') {
                    throw new Error('Invalid signature');
                  }
              
              
              Severity: Minor
              Found in src/transaction_base.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

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

              export function buildInvocationTree(root) {
                const fn = root.function();
              
                /** @type {InvocationTree} */
                const output = {};
              Severity: Minor
              Found in src/invocation.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

              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

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

                constructor(assetA, assetB, fee) {
                  if (!assetA || !(assetA instanceof Asset)) {
                    throw new Error('assetA is invalid');
                  }
                  if (!assetB || !(assetB instanceof Asset)) {
              Severity: Minor
              Found in src/liquidity_pool_asset.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

              Severity
              Category
              Status
              Source
              Language