Regily/secure-postmate

View on GitHub

Showing 11 of 13 total issues

File postmate.js has 298 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require('json.date-extensions');

/**
 * The type of messages our frames our sending
 * @type {String}
Severity: Minor
Found in src/postmate.js - About 3 hrs to fix

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

    module.exports = function (config) {
      config.set({
        sauceLabs: {
          testName: 'Encrypted Postmate',
          startConnect: false,
    Severity: Minor
    Found in karma.config.js - About 1 hr to fix

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

        sendHandshake(url) {
          const childOrigin = resolveOrigin(url);
          const messageType = this.messageType;
          let attempt = 0;
          let responseInterval;
      Severity: Minor
      Found in src/postmate.js - About 1 hr to fix

        Function constructor has 28 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          constructor(info) {
            this.model = info.model;
            this.parent = info.parent;
            this.parentOrigin = info.parentOrigin;
            this.child = info.child;
        Severity: Minor
        Found in src/postmate.js - About 1 hr to fix

          Function constructor has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

            constructor(info) {
              this.parent = info.parent;
              this.frame = info.frame;
              this.child = info.child;
              this.childOrigin = info.childOrigin;
          Severity: Minor
          Found in src/postmate.js - About 35 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

          Avoid too many return statements within this function.
          Open

            }[message.data.postmate]) return false;
          Severity: Major
          Found in src/postmate.js - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

              return true;
            Severity: Major
            Found in src/postmate.js - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                if (typeof message.data.postmate === 'object') return true;
              Severity: Major
              Found in src/postmate.js - About 30 mins to fix

                Function handleHandshakeData has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                  handleHandshakeData(data) {
                    // Extend model with the one provided by the parent
                    const defaults = data.model;
                
                    if (defaults) {
                Severity: Minor
                Found in src/postmate.js - About 25 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 sanitize has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                function sanitize(message, allowedOrigin, messageType) {
                  if (message.origin !== allowedOrigin) return false;
                  if (typeof message.data !== 'object') return false;
                  if (!('postmate' in message.data)) return false;
                  if (message.data.type !== messageType) return false;
                Severity: Minor
                Found in src/postmate.js - About 25 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 resolveOrigin has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                function resolveOrigin(url) {
                  const a = document.createElement('a');
                
                  a.href = url;
                
                
                Severity: Minor
                Found in src/postmate.js - About 25 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

                Severity
                Category
                Status
                Source
                Language