ripple/ripple-rest

View on GitHub

Showing 151 of 151 total issues

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

var AccountSetResponseFlags = {
  RequireDestTag: {name: 'require_destination_tag',
    value: ripple.Transaction.flags.AccountSet.RequireDestTag},
  RequireAuth: {name: 'require_authorization',
    value: ripple.Transaction.flags.AccountSet.RequireAuth},
Severity: Major
Found in api/lib/constants.js and 2 other locations - About 3 hrs to fix
api/lib/constants.js on lines 51..58
api/lib/constants.js on lines 87..94

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

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 3 locations. Consider refactoring.
Open

var TrustSetResponseFlags = {
  NoRipple: {name: 'prevent_rippling',
    value: ripple.Transaction.flags.TrustSet.NoRipple},
  SetFreeze: {name: 'account_trustline_frozen',
    value: ripple.Transaction.flags.TrustSet.SetFreeze},
Severity: Major
Found in api/lib/constants.js and 2 other locations - About 3 hrs to fix
api/lib/constants.js on lines 51..58
api/lib/constants.js on lines 68..75

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

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 3 locations. Consider refactoring.
Open

var AccountSetIntFlags = {
  NoFreeze: {name: 'no_freeze',
    value: ripple.Transaction.set_clear_flags.AccountSet.asfNoFreeze},
  GlobalFreeze: {name: 'global_freeze',
    value: ripple.Transaction.set_clear_flags.AccountSet.asfGlobalFreeze},
Severity: Major
Found in api/lib/constants.js and 2 other locations - About 3 hrs to fix
api/lib/constants.js on lines 68..75
api/lib/constants.js on lines 87..94

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

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

function handleError(error, req, res, next) {
  // If in debug mode, print errors
  if (config.get('debug')) {
    if (error && error.remote) {
      logger.error(error.remote);
Severity: Minor
Found in server/error-handler.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 getTrustLines has 81 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function getTrustLines(account, options, callback) {
  validate.address(account);
  validate.currency(options.currency, true);
  validate.counterparty(options.counterparty, true);
  validate.options(options);
Severity: Major
Found in api/trustlines.js - About 3 hrs to fix

    Function validatePayment has 81 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function validatePayment(payment) {
      if (!isValidAddress(payment.source_account)) {
        throw error('Invalid parameter: source_account. '
          + 'Must be a valid Ripple address');
      }
    Severity: Major
    Found in api/lib/validate.js - About 3 hrs to fix

      Function attachPreviousAndNextTransactionIdentifiers has 77 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function attachPreviousAndNextTransactionIdentifiers(api,
          notificationDetails, topCallback) {
      
        // Get all of the transactions affecting the specified
        // account in the given ledger. This is done so that
      Severity: Major
      Found in api/notifications.js - About 3 hrs to fix

        File payments.js has 292 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        /* eslint-disable valid-jsdoc */
        'use strict';
        
        var _ = require('lodash');
        var async = require('async');
        Severity: Minor
        Found in api/payments.js - About 3 hrs to fix

          Function createPaymentTransaction has 75 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function createPaymentTransaction(account, payment) {
            validate.address(account);
            validate.payment(payment);
          
            // Convert blank issuer to sender's address
          Severity: Major
          Found in api/transaction/payment.js - About 3 hrs to fix

            Function getOrders has 73 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            function getOrders(account, options, callback) {
              var self = this;
            
              validate.address(account);
              validate.options(options);
            Severity: Major
            Found in api/orders.js - About 2 hrs to fix

              File tx-to-rest-converter.js has 278 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              /* eslint-disable valid-jsdoc */
              'use strict';
              var ripple = require('ripple-lib');
              var utils = require('./utils');
              var _ = require('lodash');
              Severity: Minor
              Found in api/lib/tx-to-rest-converter.js - About 2 hrs to fix

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

                function changeSettings(request, callback) {
                  validateRequest(request);
                  var account = request.params.account;
                  var settings = request.body.settings;
                  var secret = request.body.secret;
                Severity: Major
                Found in server/routes.js and 3 other locations - About 2 hrs to fix
                server/routes.js on lines 228..235
                server/routes.js on lines 246..253
                server/routes.js on lines 255..262

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

                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 4 locations. Consider refactoring.
                Open

                function cancelOrder(request, callback) {
                  validateRequest(request);
                  var account = request.params.account;
                  var sequence = request.params.sequence;
                  var secret = request.body.secret;
                Severity: Major
                Found in server/routes.js and 3 other locations - About 2 hrs to fix
                server/routes.js on lines 228..235
                server/routes.js on lines 237..244
                server/routes.js on lines 246..253

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

                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 4 locations. Consider refactoring.
                Open

                function addTrustLine(request, callback) {
                  validateRequest(request);
                  var account = request.params.account;
                  var trustline = request.body.trustline;
                  var secret = request.body.secret;
                Severity: Major
                Found in server/routes.js and 3 other locations - About 2 hrs to fix
                server/routes.js on lines 228..235
                server/routes.js on lines 237..244
                server/routes.js on lines 255..262

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

                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 4 locations. Consider refactoring.
                Open

                function submitOrder(request, callback) {
                  validateRequest(request);
                  var account = request.params.account;
                  var order = request.body.order;
                  var secret = request.body.secret;
                Severity: Major
                Found in server/routes.js and 3 other locations - About 2 hrs to fix
                server/routes.js on lines 237..244
                server/routes.js on lines 246..253
                server/routes.js on lines 255..262

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

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

                DI.saveTransaction = function(transaction, callback) {
                  assert.strictEqual(typeof transaction, 'object');
                  assert(transaction.state, 'Transaction missing property: state');
                  assert(transaction.tx_json, 'Transaction missing property: tx_json');
                  assert(transaction.tx_json.TransactionType,
                Severity: Major
                Found in api/lib/db-interface.js - About 2 hrs to fix

                  Function parse has 65 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  NotificationParser.prototype.parse = function(notification_details, urlBase) {
                    var transaction = notification_details.transaction;
                    var account = notification_details.account;
                    var previous_transaction_identifier =
                      notification_details.previous_transaction_identifier;
                  Severity: Major
                  Found in api/lib/notification_parser.js - About 2 hrs to fix

                    Function validateSettings has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
                    Open

                    function validateSettings(settings) {
                      if (typeof settings !== 'object') {
                        throw error('Invalid parameter: settings');
                      }
                      if (!/(undefined|string)/.test(typeof settings.domain)) {
                    Severity: Minor
                    Found in api/lib/validate.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 getTrustLines has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
                    Open

                    function getTrustLines(account, options, callback) {
                      validate.address(account);
                      validate.currency(options.currency, true);
                      validate.counterparty(options.counterparty, true);
                      validate.options(options);
                    Severity: Minor
                    Found in api/trustlines.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 parseOrderFromTx has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
                    Open

                    function parseOrderFromTx(tx, options) {
                      if (!options.account) {
                        throw new Error('Internal Error. must supply options.account');
                      }
                      if (tx.TransactionType !== 'OfferCreate'
                    Severity: Minor
                    Found in api/lib/tx-to-rest-converter.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

                    Severity
                    Category
                    Status
                    Source
                    Language