ripple/ripple-rest

View on GitHub
api/transactions.js

Summary

Maintainability
F
4 days
Test Coverage

File transactions.js has 411 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/* eslint-disable valid-jsdoc */
'use strict';

var _ = require('lodash');
var assert = require('assert');
Severity: Minor
Found in api/transactions.js - About 5 hrs to fix

    Function getTransaction has 108 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function getTransaction(api, account, identifier, requestOptions, callback) {
    
      try {
        assert.strictEqual(typeof requestOptions, 'object');
    
    
    Severity: Major
    Found in api/transactions.js - About 4 hrs to fix

      Function transactionFilter has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
      Open

      function transactionFilter(transactions, options) {
        var filtered_transactions = transactions.filter(function(transaction) {
          if (options.exclude_failed) {
            if (transaction.state === 'failed' || (transaction.meta
                && transaction.meta.TransactionResult !== 'tesSUCCESS')) {
      Severity: Minor
      Found in api/transactions.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 submitTransaction has 98 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function submitTransaction(api, tx, secret, options, callback) {
        function blockDuplicates(transaction, _options, _callback) {
          var transactionOptions = {
            source_account: transaction.tx_json.Account,
            client_resource_id: _options.clientResourceId,
      Severity: Major
      Found in api/transactions.js - About 3 hrs to fix

        Function getTransaction has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
        Open

        function getTransaction(api, account, identifier, requestOptions, callback) {
        
          try {
            assert.strictEqual(typeof requestOptions, 'object');
        
        
        Severity: Minor
        Found in api/transactions.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 getAccountTransactions has 62 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function getAccountTransactions(api, options, callback) {
          try {
            validate.address(options.account);
          } catch(err) {
            return callback(err);
        Severity: Major
        Found in api/transactions.js - About 2 hrs to fix

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

          function getAccountTransactions(api, options, callback) {
            try {
              validate.address(options.account);
            } catch(err) {
              return callback(err);
          Severity: Minor
          Found in api/transactions.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 transactionFilter has 36 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function transactionFilter(transactions, options) {
            var filtered_transactions = transactions.filter(function(transaction) {
              if (options.exclude_failed) {
                if (transaction.state === 'failed' || (transaction.meta
                    && transaction.meta.TransactionResult !== 'tesSUCCESS')) {
          Severity: Minor
          Found in api/transactions.js - About 1 hr to fix

            Function filtered_transactions has 33 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              var filtered_transactions = transactions.filter(function(transaction) {
                if (options.exclude_failed) {
                  if (transaction.state === 'failed' || (transaction.meta
                      && transaction.meta.TransactionResult !== 'tesSUCCESS')) {
                    return false;
            Severity: Minor
            Found in api/transactions.js - About 1 hr to fix

              Function getLocalAndRemoteTransactions has 31 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              function getLocalAndRemoteTransactions(api, options, callback) {
              
                function queryRippled(_callback) {
                  getAccountTx(api, options, function(error, results) {
                    if (error) {
              Severity: Minor
              Found in api/transactions.js - About 1 hr to fix

                Function getAccountTx has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                function getAccountTx(api, options, callback) {
                  var params = {
                    account: options.account,
                    ledger_index_min: options.ledger_index_min || options.ledger_index || -1,
                    ledger_index_max: options.ledger_index_max || options.ledger_index || -1,
                Severity: Minor
                Found in api/transactions.js - About 1 hr to fix

                  Function queryTransaction has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    function queryTransaction(async_callback) {
                      api.db.getTransaction(options, function(error, entry) {
                        if (error) {
                          return async_callback(error);
                        }
                  Severity: Minor
                  Found in api/transactions.js - About 1 hr to fix

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

                    function submitTransaction(api, tx, secret, options, callback) {
                      function blockDuplicates(transaction, _options, _callback) {
                        var transactionOptions = {
                          source_account: transaction.tx_json.Account,
                          client_resource_id: _options.clientResourceId,
                    Severity: Minor
                    Found in api/transactions.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 submitTransaction has 5 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                    function submitTransaction(api, tx, secret, options, callback) {
                    Severity: Minor
                    Found in api/transactions.js - About 35 mins to fix

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

                      function getTransaction(api, account, identifier, requestOptions, callback) {
                      Severity: Minor
                      Found in api/transactions.js - About 35 mins to fix

                        Avoid too many return statements within this function.
                        Open

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

                          Avoid too many return statements within this function.
                          Open

                              return true;
                          Severity: Major
                          Found in api/transactions.js - About 30 mins to fix

                            Avoid too many return statements within this function.
                            Open

                                    return callback(new errors.NotFoundError('Ledger not found'));
                            Severity: Major
                            Found in api/transactions.js - About 30 mins to fix

                              Avoid too many return statements within this function.
                              Open

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

                                There are no issues that match your filters.

                                Category
                                Status