ripple/ripple-rest

View on GitHub

Showing 105 of 151 total issues

File orders.js has 252 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/* globals Promise: true */
/* eslint-disable valid-jsdoc */
'use strict';
var _ = require('lodash');
var asyncify = require('simple-asyncify');
Severity: Minor
Found in api/orders.js - About 2 hrs to fix

    Function getLineBalances has 49 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      function getLineBalances(prevResult) {
        var isAggregate = options.limit === 'all';
        if (prevResult && (!isAggregate || !prevResult.marker)) {
          return Promise.resolve(prevResult);
        }
    Severity: Minor
    Found in api/balances.js - About 1 hr to fix

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

          var promise = new Promise(function(resolve, reject) {
            var accountLinesRequest;
            var marker;
            var ledger;
            var limit;
      Severity: Minor
      Found in api/trustlines.js - About 1 hr to fix

        Function getOrders has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

        function getOrders(account, options, callback) {
          var self = this;
        
          validate.address(account);
          validate.options(options);
        Severity: Minor
        Found in api/orders.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

        Function getAccountPayments has 47 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function getAccountPayments(account, source_account, destination_account,
            direction, options, callback) {
          var self = this;
        
          function getTransactions(_callback) {
        Severity: Minor
        Found in api/payments.js - About 1 hr to fix

          Function createRemote has 45 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function createRemote(options) {
            var remote = new ripple.Remote(options);
            if (options.mock) {
              return remote;
            }
          Severity: Minor
          Found in api/lib/remote.js - About 1 hr to fix

            Function promise has 42 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                var promise = new Promise(function(resolve, reject) {
                  var accountLinesRequest;
                  var marker;
                  var ledger;
                  var limit;
            Severity: Minor
            Found in api/balances.js - About 1 hr to fix

              Function parsePaymentFromTx has 42 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              function parsePaymentFromTx(account, message, meta) {
                if (!account) {
                  throw new Error('Internal Error. must supply options.account');
                }
              
              
              Severity: Minor
              Found in api/lib/tx-to-rest-converter.js - About 1 hr to fix

                Function getParsedBookOffers has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  function getParsedBookOffers(offers, isAsk) {
                    return offers.reduce(function(orderBook, off) {
                      var price;
                      var order_maker = off.Account;
                      var sequence = off.Sequence;
                Severity: Minor
                Found in api/orders.js - About 1 hr to fix

                  Function submitPayment has 39 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  function submitPayment(account, payment, clientResourceID, secret,
                      urlBase, options, callback) {
                  
                    function formatTransactionResponse(message, meta) {
                      if (meta.state === 'validated') {
                  Severity: Minor
                  Found in api/payments.js - About 1 hr to fix

                    Function validateOptions has 38 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    function validateOptions(options) {
                      if (options.max_fee !== undefined) {
                        validateNonNegativeStringFloat(options.max_fee, 'max_fee');
                      }
                      if (options.fixed_fee !== undefined) {
                    Severity: Minor
                    Found in api/lib/validate.js - About 1 hr to fix

                      Function parsePaymentsFromPathFind has 38 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      function parsePaymentsFromPathFind(pathfindResults) {
                        return pathfindResults.alternatives.map(function(alternative) {
                          return {
                            source_account: pathfindResults.source_account,
                            source_tag: '',
                      Severity: Minor
                      Found in api/lib/tx-to-rest-converter.js - About 1 hr to fix

                        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 createTxJSON has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                          Open

                          function createTxJSON(transaction, remote, instructions, callback) {
                            instructions = instructions || {};
                            validate.options(instructions);
                          
                            transaction.complete();
                          Severity: Minor
                          Found in api/transaction/utils.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

                          Function setTransactionBitFlags has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                          Open

                          function setTransactionBitFlags(transaction, options) {
                            for (var flagName in options.flags) {
                              var flag = options.flags[flagName];
                          
                              // Set transaction flags
                          Severity: Minor
                          Found in api/transaction/utils.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

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

                          DI.getTransaction = function(options, callback) {
                            assert.strictEqual(typeof options, 'object');
                          
                            var txQuery = {};
                          
                          
                          Severity: Minor
                          Found in api/lib/db-interface.js - About 1 hr to fix

                            Function generateIndexPage has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                            function generateIndexPage(request, response, next) {
                              var url_base = '/v' + version.getApiVersion();
                            
                              respond.success(response, {
                                success: true,
                            Severity: Minor
                            Found in server/indexpage.js - About 1 hr to fix

                              Function parseNotifications has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                function parseNotifications(baseTransactions, _callback) {
                                  var numTransactions = baseTransactions.length;
                              
                                  function parseNotification(transaction, __callback) {
                                    var args = {
                              Severity: Minor
                              Found in api/notifications.js - About 1 hr to fix

                                Function getAccountOrders has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                  function getAccountOrders(prevResult) {
                                    var isAggregate = options.limit === 'all';
                                    if (prevResult && (!isAggregate || !prevResult.marker)) {
                                      return Promise.resolve(prevResult);
                                    }
                                Severity: Minor
                                Found in api/orders.js - About 1 hr to fix

                                  Function init has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                  DI.init = function(callback) {
                                    var self = this;
                                  
                                    if (this.initialized) {
                                      self.logger.info('[DB] Warning: Re-initializing');
                                  Severity: Minor
                                  Found in api/lib/db-interface.js - About 1 hr to fix
                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language