LivePersonInc/chronosjs

View on GitHub
src/courier/PostMessageCourier.js

Summary

Maintainability
F
4 days
Test Coverage

Function prototype has 328 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        PostMessageCourier.prototype = (function () {
            /**
             * Method for initialization
             * @param {Object} options - the configuration options for the instance
             * @param {Object} options.target - the target iframe or iframe configuration
Severity: Major
Found in src/courier/PostMessageCourier.js - About 1 day to fix

    File PostMessageCourier.js has 375 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    /**
     * LIMITATIONS:
     * 1) Only supports browsers which implements postMessage API and have native JSON implementation (IE8+, Chrome, FF, Safari, Opera, IOS, Opera Mini, Android)
     * 2) IE9-, FF & Opera Mini does not support MessageChannel and therefore we fallback to using basic postMessage.
     *    This makes the communication opened to any handler registered for messages on the same origin.
    Severity: Minor
    Found in src/courier/PostMessageCourier.js - About 5 hrs to fix

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

                  function _createMessageHandler(mapping) {
                      return function(message) {
                          var handler;
                          var result;
                          var params;
      Severity: Minor
      Found in src/courier/PostMessageCourier.js - About 1 hr to fix

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

                    function _handleResult(id, name, result, message) {
                        var retMsg;
                        var params;
        
                        // If the result is async (promise) we need to defer the execution of the results data
        Severity: Minor
        Found in src/courier/PostMessageCourier.js - About 1 hr to fix

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

                              result.then(function (data) {
                                  params = [id, ACTION_TYPE.RETURN, null];
          
                                  if (ACTION_TYPE.REQUEST === name) {
                                      params.push(data);
          Severity: Major
          Found in src/courier/PostMessageCourier.js and 1 other location - About 3 hrs to fix
          src/courier/PostMessageCourier.js on lines 688..700

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

          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

                              else if ("undefined" !== typeof result) {
                                  params = [id, ACTION_TYPE.RETURN, null];
          
                                  if (ACTION_TYPE.REQUEST === name) {
                                      params.push(result);
          Severity: Major
          Found in src/courier/PostMessageCourier.js and 1 other location - About 3 hrs to fix
          src/courier/PostMessageCourier.js on lines 656..668

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

          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 (result && result.error) {
                                  params = [id, ACTION_TYPE.RETURN, result];
          
                                  // Call the mapping method to receive the message structure
                                  retMsg = this.mapper.toMessage.apply(this.mapper, params);
          Severity: Major
          Found in src/courier/PostMessageCourier.js and 1 other location - About 1 hr to fix
          src/courier/PostMessageCourier.js on lines 668..676

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

          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

                              }.bind(this), function (data) {
                                  params = [id, ACTION_TYPE.RETURN, data];
          
                                  // Call the mapping method to receive the message structure
                                  retMsg = this.mapper.toMessage.apply(this.mapper, params);
          Severity: Major
          Found in src/courier/PostMessageCourier.js and 1 other location - About 1 hr to fix
          src/courier/PostMessageCourier.js on lines 679..687

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

          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 command() {
                          if (!this.disposed) {
                              var args = Array.prototype.slice.apply(arguments);
                              return _postMessage.call(this, args, ACTION_TYPE.COMMAND);
                          }
          Severity: Major
          Found in src/courier/PostMessageCourier.js and 1 other location - About 1 hr to fix
          src/courier/PostMessageCourier.js on lines 317..322

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

          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 request() {
                          if (!this.disposed) {
                              var args = Array.prototype.slice.apply(arguments);
                              return _postMessage.call(this, args, ACTION_TYPE.REQUEST);
                          }
          Severity: Major
          Found in src/courier/PostMessageCourier.js and 1 other location - About 1 hr to fix
          src/courier/PostMessageCourier.js on lines 285..290

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

          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 PostMessageCourier(options) {
                      // For forcing new keyword
                      /* istanbul ignore if  */
                      if (false === (this instanceof PostMessageCourier)) {
                          return new PostMessageCourier(options);
          Severity: Minor
          Found in src/courier/PostMessageCourier.js and 1 other location - About 35 mins to fix
          src/courier/PostMessagePromise.js on lines 35..43

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

          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

          There are no issues that match your filters.

          Category
          Status