mbroadst/amqp10-rpc

View on GitHub

Showing 23 of 23 total issues

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

  if (arguments.length > 2) {
    var args = new Array(arguments.length);
    for (var i = 0, ii = args.length; i < ii; ++i) args[i] = arguments[i];
    request.body.params = args.slice(1);
  } else if (!!params) {
Severity: Major
Found in lib/rpc-client.js and 1 other location - About 5 hrs to fix
lib/rpc-client.js on lines 79..85

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

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

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

  if (arguments.length > 2) {
    var args = new Array(arguments.length);
    for (var i = 0, ii = args.length; i < ii; ++i) args[i] = arguments[i];
    request.body.params = args.slice(1);
  } else if (!!params) {
Severity: Major
Found in lib/rpc-client.js and 1 other location - About 5 hrs to fix
lib/rpc-client.js on lines 112..118

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

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

RpcServer.prototype._processMessage = function(receiver, message) {
  if (!u.assertProperties(message, this._logger, ['body']))
    return receiver.modify(message, { undeliverableHere: true });

  var self = this;
Severity: Major
Found in lib/rpc-server.js - About 2 hrs to fix

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

    RpcServer.prototype.bind = function(methodNameOrDef, method) {
      var methodName, methodFunc, methodValidations, interceptor;
      if (typeof methodNameOrDef === 'function') {
        if (methodNameOrDef.name === undefined ||
            methodNameOrDef.name === null || methodNameOrDef.name === '')
    Severity: Minor
    Found in lib/rpc-server.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 bind has 48 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    RpcServer.prototype.bind = function(methodNameOrDef, method) {
      var methodName, methodFunc, methodValidations, interceptor;
      if (typeof methodNameOrDef === 'function') {
        if (methodNameOrDef.name === undefined ||
            methodNameOrDef.name === null || methodNameOrDef.name === '')
    Severity: Minor
    Found in lib/rpc-server.js - About 1 hr to fix

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

      RpcClient.prototype._processMessage = function(message) {
        var correlationId = message.properties.correlationId;
        if (correlationId === undefined || correlationId === null) {
          this._logger.error({
            message: 'message lacks correlation-id',
      Severity: Minor
      Found in lib/rpc-client.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 _processMessage has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

      RpcServer.prototype._processMessage = function(receiver, message) {
        if (!u.assertProperties(message, this._logger, ['body']))
          return receiver.modify(message, { undeliverableHere: true });
      
        var self = this;
      Severity: Minor
      Found in lib/rpc-server.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 notify has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

      RpcClient.prototype.notify = function(method, params) {
        // support call with raw request objects { method: 'method', params: [] }
        if (u.isPlainObject(method) && method.hasOwnProperty('method') ||
            Array.isArray(method)) {
          var notification = {};
      Severity: Minor
      Found in lib/rpc-client.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 exports has 42 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      module.exports = function(options) {
        options = options || {};
        var logger = options.logger || console;
      
        return function(Client) {
      Severity: Minor
      Found in lib/index.js - About 1 hr to fix

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

        RpcClient.prototype._processMessage = function(message) {
          var correlationId = message.properties.correlationId;
          if (correlationId === undefined || correlationId === null) {
            this._logger.error({
              message: 'message lacks correlation-id',
        Severity: Minor
        Found in lib/rpc-client.js - About 1 hr to fix

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

          RpcServer.prototype._processRequest = function(replyTo, correlationId, request) {
            if (!request.hasOwnProperty('method')) {
              throw new errors.InvalidRequestError('Missing required property: method', {
                source: { replyTo: replyTo, request: request }
              });
          Severity: Minor
          Found in lib/rpc-server.js - About 1 hr to fix

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

            RpcClient.prototype.call = function(method, params) {
              var correlator = uuid.v4().replace(/-/g, '');
              var request = {
                properties: {
                  replyTo: this._receiver.remote.attach.source.address,
            Severity: Minor
            Found in lib/rpc-client.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 _respond has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

            RpcServer.prototype._respond = function(replyTo, correlationId, response) {
              if (response === null || response === undefined) return;
              if (response.hasOwnProperty('error') &&
                  response.error.code === ErrorCode.MethodNotFound && !!this._ignoreUnknownMethods) {
                return;
            Severity: Minor
            Found in lib/rpc-server.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 call has 27 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            RpcClient.prototype.call = function(method, params) {
              var correlator = uuid.v4().replace(/-/g, '');
              var request = {
                properties: {
                  replyTo: this._receiver.remote.attach.source.address,
            Severity: Minor
            Found in lib/rpc-client.js - About 1 hr to fix

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

              errors.BadRequestError = function(message) {
                errors.BaseError.call(this, message || 'Bad request');
                this.name = 'AmqpRpcBadRequestError';
              };
              Severity: Minor
              Found in lib/errors.js and 1 other location - About 45 mins to fix
              lib/errors.js on lines 79..82

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

              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

              errors.DuplicateMethodError = function(method) {
                errors.BaseError.call(this, 'Duplicate method bound: ' + method);
                this.name = 'AmqpRpcDuplicateMethodError';
              };
              Severity: Major
              Found in lib/errors.js and 3 other locations - About 45 mins to fix
              lib/errors.js on lines 41..44
              lib/errors.js on lines 54..57
              lib/errors.js on lines 67..70

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

              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

              errors.InvalidMethodNameError = function(name) {
                errors.BaseError.call(this, 'Invalid method name: ' + name);
                this.name = 'AmqpRpcInvalidMethodNameError';
              };
              Severity: Major
              Found in lib/errors.js and 3 other locations - About 45 mins to fix
              lib/errors.js on lines 28..31
              lib/errors.js on lines 54..57
              lib/errors.js on lines 67..70

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

              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

              errors.InvalidValidationDefinitionError = function(message) {
                errors.BaseError.call(this, 'Invalid validation definiton: ' + message);
                this.name = 'AmqpRpcInvalidValidationDefinitionError';
              };
              Severity: Major
              Found in lib/errors.js and 3 other locations - About 45 mins to fix
              lib/errors.js on lines 28..31
              lib/errors.js on lines 41..44
              lib/errors.js on lines 54..57

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

              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

              errors.InvalidMethodDefinitionError = function(message) {
                errors.BaseError.call(this, 'Invalid method definiton: ' + message);
                this.name = 'AmqpRpcInvalidMethodDefinitionError';
              };
              Severity: Major
              Found in lib/errors.js and 3 other locations - About 45 mins to fix
              lib/errors.js on lines 28..31
              lib/errors.js on lines 41..44
              lib/errors.js on lines 67..70

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

              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

              errors.RequestTimeoutError = function(message) {
                errors.BaseError.call(this, message || 'Request timed out');
                this.name = 'AmqpRpcRequestTimeoutError';
              };
              Severity: Minor
              Found in lib/errors.js and 1 other location - About 45 mins to fix
              lib/errors.js on lines 91..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 50.

              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