ripple/ripple-rest

View on GitHub

Showing 151 of 151 total issues

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 validateTrustline has 30 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function validateTrustline(trustline) {
        if (typeof trustline !== 'object') {
          throw error('Invalid parameter: trustline');
        }
        if (_.isUndefined(trustline.limit)) {
      Severity: Minor
      Found in api/lib/validate.js - About 1 hr to fix

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

            function parseNotification(transaction, __callback) {
              var args = {
                account: account,
                identifier: transaction.hash,
                transaction: transaction
        Severity: Minor
        Found in api/notifications.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

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

                  } else {
                    price = {
                      currency: taker_gets_total.currency,
                      counterparty: taker_gets_total.counterparty,
                      value: bignum(taker_gets_total.value).div(
            Severity: Major
            Found in api/orders.js and 1 other location - About 1 hr to fix
            api/orders.js on lines 295..302

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

            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 (isAsk) {
                    price = {
                      currency: taker_pays_total.currency,
                      counterparty: taker_pays_total.counterparty,
                      value: bignum(taker_pays_total.value).div(
            Severity: Major
            Found in api/orders.js and 1 other location - About 1 hr to fix
            api/orders.js on lines 302..309

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

            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 exports has 28 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            module.exports = (function() {
              var validator = new JaySchema();
              var validate = validator.validate;
            
              // If schema is valid, return true. Otherwise
            Severity: Minor
            Found in api/lib/schema-validator.js - About 1 hr to fix

              Function validateTrustline has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
              Open

              function validateTrustline(trustline) {
                if (typeof trustline !== 'object') {
                  throw error('Invalid parameter: trustline');
                }
                if (_.isUndefined(trustline.limit)) {
              Severity: Minor
              Found in api/lib/validate.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 promise has 27 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

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

                Function findPreviousAndNextTransactions has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  function findPreviousAndNextTransactions(txns, callback) {
                
                    // Find the index in the array of the baseTransaction
                    var baseTransactionIndex = _.findIndex(txns, function(possibility) {
                      if (possibility.hash === notificationDetails.transaction.hash) {
                Severity: Minor
                Found in api/notifications.js - About 1 hr to fix

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

                    for (var flagName in constants.AccountSetIntFlags) {
                      var flag = constants.AccountSetIntFlags[flagName];
                      _settings[flag.name] = settings[flag.name];
                    }
                  Severity: Major
                  Found in api/lib/tx-to-rest-converter.js and 1 other location - About 1 hr to fix
                  api/lib/tx-to-rest-converter.js on lines 352..355

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

                  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

                    for (var fieldName in constants.AccountRootFields) {
                      var field = constants.AccountRootFields[fieldName];
                      _settings[field.name] = settings[field.name];
                    }
                  Severity: Major
                  Found in api/lib/tx-to-rest-converter.js and 1 other location - About 1 hr to fix
                  api/lib/tx-to-rest-converter.js on lines 347..350

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

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

                  function validatePaymentMemos(memos) {
                    if (!Array.isArray(memos)) {
                      throw error(
                        'Invalid parameter: memos. Must be an array with memo objects');
                    }
                  Severity: Minor
                  Found in api/lib/validate.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 parseCurrencyQuery has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                  Open

                  function parseCurrencyQuery(query) {
                    var params = query.split('+');
                  
                    if (!isNaN(params[0])) {
                      return {
                  Severity: Minor
                  Found in api/lib/utils.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

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

                    if (payment.destination_amount
                        && payment.destination_amount.currency.toUpperCase() === 'XRP'
                        && payment.destination_amount.issuer) {
                      throw error(
                        'Invalid parameter: destination_amount. XRP cannot have issuer');
                  Severity: Minor
                  Found in api/lib/validate.js and 1 other location - About 55 mins to fix
                  api/lib/validate.js on lines 283..288

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

                  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 (payment.source_amount
                        && payment.source_amount.currency.toUpperCase() === 'XRP'
                        && payment.source_amount.issuer) {
                      throw error(
                        'Invalid parameter: source_amount. XRP cannot have issuer');
                  Severity: Minor
                  Found in api/lib/validate.js and 1 other location - About 55 mins to fix
                  api/lib/validate.js on lines 277..282

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

                  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

                  function getPayment(request, callback) {
                    var account = request.params.account;
                    var identifier = request.params.identifier;
                    api.getPayment(account, identifier, callback);
                  }
                  Severity: Minor
                  Found in server/routes.js and 1 other location - About 55 mins to fix
                  server/routes.js on lines 147..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 53.

                  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

                  function getOrder(request, callback) {
                    var account = request.params.account;
                    var identifier = request.params.identifier;
                    api.getOrder(account, identifier, callback);
                  }
                  Severity: Minor
                  Found in server/routes.js and 1 other location - About 55 mins to fix
                  server/routes.js on lines 110..114

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

                  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

                  Severity
                  Category
                  Status
                  Source
                  Language