stellar/js-stellar-base

View on GitHub

Showing 57 of 111 total issues

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

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

            Function nativeToScVal has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
            Open

            export function nativeToScVal(val, opts = {}) {
              switch (typeof val) {
                case 'object':
                  if (val === null) {
                    return xdr.ScVal.scvVoid();
            Severity: Minor
            Found in src/scval.js - About 4 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 setOptions has 110 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            export function setOptions(opts) {
              const attributes = {};
            
              if (opts.inflationDest) {
                if (!StrKey.isValidEd25519PublicKey(opts.inflationDest)) {
            Severity: Major
            Found in src/operations/set_options.js - About 4 hrs to fix

              Function nativeToScVal has 95 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              export function nativeToScVal(val, opts = {}) {
                switch (typeof val) {
                  case 'object':
                    if (val === null) {
                      return xdr.ScVal.scvVoid();
              Severity: Major
              Found in src/scval.js - About 3 hrs to fix

                File test.ts has 303 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                import * as StellarSdk from 'stellar-base';
                
                const masterKey = StellarSdk.Keypair.master(StellarSdk.Networks.TESTNET); // $ExpectType Keypair
                const sourceKey = StellarSdk.Keypair.random(); // $ExpectType Keypair
                const destKey = StellarSdk.Keypair.random();
                Severity: Minor
                Found in types/test.ts - About 3 hrs 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 constructor has 79 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    constructor(envelope, networkPassphrase) {
                      if (typeof envelope === 'string') {
                        const buffer = Buffer.from(envelope, 'base64');
                        envelope = xdr.TransactionEnvelope.fromXDR(buffer);
                      }
                  Severity: Major
                  Found in src/transaction.js - About 3 hrs to fix

                    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

                      Transaction has 24 functions (exceeds 20 allowed). Consider refactoring.
                      Open

                      export class Transaction extends TransactionBase {
                        constructor(envelope, networkPassphrase) {
                          if (typeof envelope === 'string') {
                            const buffer = Buffer.from(envelope, 'base64');
                            envelope = xdr.TransactionEnvelope.fromXDR(buffer);
                      Severity: Minor
                      Found in src/transaction.js - About 2 hrs to fix

                        Function revokeSignerSponsorship has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
                        Open

                        export function revokeSignerSponsorship(opts = {}) {
                          if (!StrKey.isValidEd25519PublicKey(opts.account)) {
                            throw new Error('account is invalid');
                          }
                          let key;
                        Severity: Minor
                        Found in src/operations/revoke_sponsorship.js - About 2 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 scValToNative has 60 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                        export function scValToNative(scv) {
                          // we use the verbose xdr.ScValType.<type>.value form here because it's faster
                          // than string comparisons and the underlying constants never need to be
                          // updated
                          switch (scv.switch().value) {
                        Severity: Major
                        Found in src/scval.js - About 2 hrs to fix

                          Function buildInvocationTree has 52 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                          export function buildInvocationTree(root) {
                            const fn = root.function();
                          
                            /** @type {InvocationTree} */
                            const output = {};
                          Severity: Major
                          Found in src/invocation.js - About 2 hrs to fix

                            Function isValid has 48 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                            function isValid(versionByteName, encoded) {
                              if (typeof encoded !== 'string') {
                                return false;
                              }
                            
                            
                            Severity: Minor
                            Found in src/strkey.js - About 1 hr to fix

                              Function revokeSignerSponsorship has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                              export function revokeSignerSponsorship(opts = {}) {
                                if (!StrKey.isValidEd25519PublicKey(opts.account)) {
                                  throw new Error('account is invalid');
                                }
                                let key;
                              Severity: Minor
                              Found in src/operations/revoke_sponsorship.js - About 1 hr to fix

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

                                  constructor(envelope, networkPassphrase) {
                                    if (typeof envelope === 'string') {
                                      const buffer = Buffer.from(envelope, 'base64');
                                      envelope = xdr.TransactionEnvelope.fromXDR(buffer);
                                    }
                                Severity: Minor
                                Found in src/transaction.js - 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

                                Severity
                                Category
                                Status
                                Source
                                Language