meteor/meteor

View on GitHub
tools/meteor-services/deploy.js

Summary

Maintainability
F
6 days
Test Coverage

File deploy.js has 678 lines of code (exceeds 250 allowed). Consider refactoring.
Open

// URL parsing and validation
// RPC to server (endpoint, arguments)
// see if RPC requires password
// prompt for password
// send RPC with or without password as required
Severity: Major
Found in tools/meteor-services/deploy.js - About 1 day to fix

    Function bundleAndDeploy has 173 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export async function bundleAndDeploy(options) {
      if (options.recordPackageUsage === undefined) {
        options.recordPackageUsage = true;
      }
    
    
    Severity: Major
    Found in tools/meteor-services/deploy.js - About 6 hrs to fix

      Function bundleAndDeploy has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
      Open

      export async function bundleAndDeploy(options) {
        if (options.recordPackageUsage === undefined) {
          options.recordPackageUsage = true;
        }
      
      
      Severity: Minor
      Found in tools/meteor-services/deploy.js - About 4 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 authedRpc has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
      Open

      function authedRpc(options) {
        var rpcOptions = Object.assign({}, options);
        var preflight = rpcOptions.preflight;
        delete rpcOptions.preflight;
      
      
      Severity: Minor
      Found in tools/meteor-services/deploy.js - About 4 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 deployRpc has 77 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function deployRpc(options) {
        options = Object.assign({}, options);
        options.headers = Object.assign({}, options.headers || {});
        if (options.headers.cookie) {
          throw new Error("sorry, can't combine cookie headers yet");
      Severity: Major
      Found in tools/meteor-services/deploy.js - About 3 hrs to fix

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

        function authedRpc(options) {
          var rpcOptions = Object.assign({}, options);
          var preflight = rpcOptions.preflight;
          delete rpcOptions.preflight;
        
        
        Severity: Major
        Found in tools/meteor-services/deploy.js - About 2 hrs to fix

          Function deployRpc has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
          Open

          function deployRpc(options) {
            options = Object.assign({}, options);
            options.headers = Object.assign({}, options.headers || {});
            if (options.headers.cookie) {
              throw new Error("sorry, can't combine cookie headers yet");
          Severity: Minor
          Found in tools/meteor-services/deploy.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 pollForDeploy has 44 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          async function pollForDeploy(pollingState, versionId, site, deployWithTokenProps) {
            const {
              deadline,
              pollIntervalMs,
              currentMessage,
          Severity: Minor
          Found in tools/meteor-services/deploy.js - About 1 hr to fix

            Function checkAuthThenSendRpc has 44 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            function checkAuthThenSendRpc(site, operation, what) {
              var preflight = authedRpc({
                operation: operation,
                site: site,
                preflight: true,
            Severity: Minor
            Found in tools/meteor-services/deploy.js - About 1 hr to fix

              Function pollForDeploy has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
              Open

              async function pollForDeploy(pollingState, versionId, site, deployWithTokenProps) {
                const {
                  deadline,
                  pollIntervalMs,
                  currentMessage,
              Severity: Minor
              Found in tools/meteor-services/deploy.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 listAuthorized has 33 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              export function listAuthorized(site) {
                site = canonicalizeSite(site);
                if (! site) {
                  return 1;
                }
              Severity: Minor
              Found in tools/meteor-services/deploy.js - About 1 hr to fix

                Function checkAuthThenSendRpc has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                Open

                function checkAuthThenSendRpc(site, operation, what) {
                  var preflight = authedRpc({
                    operation: operation,
                    site: site,
                    preflight: true,
                Severity: Minor
                Found in tools/meteor-services/deploy.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

                Consider simplifying this complex logical expression.
                Open

                    if (!buildCache ||
                      !exists(buildCache.buildDir) ||
                      !exists(buildCache.bundlePath) ||
                      !buildCache.gitCommitHash ||
                      !gitCommitHash ||
                Severity: Major
                Found in tools/meteor-services/deploy.js - About 40 mins to fix

                  Function pollForDeploymentSuccess has 5 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                  async function pollForDeploymentSuccess(versionId, deployPollTimeout, result, site, deployWithTokenProps) {
                  Severity: Minor
                  Found in tools/meteor-services/deploy.js - About 35 mins to fix

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

                    export function listAuthorized(site) {
                      site = canonicalizeSite(site);
                      if (! site) {
                        return 1;
                      }
                    Severity: Minor
                    Found in tools/meteor-services/deploy.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

                        return 1;
                    Severity: Major
                    Found in tools/meteor-services/deploy.js - About 30 mins to fix

                      Avoid too many return statements within this function.
                      Open

                          return preflight ? { } : deployRpc(rpcOptions);
                      Severity: Major
                      Found in tools/meteor-services/deploy.js - About 30 mins to fix

                        Avoid too many return statements within this function.
                        Open

                            return infoResult;
                        Severity: Major
                        Found in tools/meteor-services/deploy.js - About 30 mins to fix

                          Avoid too many return statements within this function.
                          Open

                                return {
                                  protection: info.protection,
                                  authorized: info.authorized
                                };
                          Severity: Major
                          Found in tools/meteor-services/deploy.js - About 30 mins to fix

                            Avoid too many return statements within this function.
                            Open

                                  return deployRpc(rpcOptions);
                            Severity: Major
                            Found in tools/meteor-services/deploy.js - About 30 mins to fix

                              Avoid too many return statements within this function.
                              Open

                                return {
                                  statusCode: null,
                                  errorMessage: "You need a newer version of Meteor to work with this site"
                                };
                              Severity: Major
                              Found in tools/meteor-services/deploy.js - About 30 mins to fix

                                Avoid too many return statements within this function.
                                Open

                                        return {
                                          statusCode: null,
                                          errorMessage: isLoggedIn() ?
                                            // XXX better error message (probably need to break out of
                                            // the 'errorMessage printed with brief prefix' pattern)
                                Severity: Major
                                Found in tools/meteor-services/deploy.js - About 30 mins to fix

                                  Avoid too many return statements within this function.
                                  Open

                                    return result;
                                  Severity: Major
                                  Found in tools/meteor-services/deploy.js - About 30 mins to fix

                                    Avoid too many return statements within this function.
                                    Open

                                        return await pollForDeploymentSuccess(
                                          result.payload.newVersionId,
                                          options.deployPollingTimeoutMs,
                                          result,
                                          site,
                                    Severity: Major
                                    Found in tools/meteor-services/deploy.js - About 30 mins to fix

                                      Avoid too many return statements within this function.
                                      Open

                                              return { protection: info.protection };
                                      Severity: Major
                                      Found in tools/meteor-services/deploy.js - About 30 mins to fix

                                        Avoid too many return statements within this function.
                                        Open

                                            return 0;
                                        Severity: Major
                                        Found in tools/meteor-services/deploy.js - About 30 mins to fix

                                          Avoid too many return statements within this function.
                                          Open

                                              return 0;
                                          Severity: Major
                                          Found in tools/meteor-services/deploy.js - About 30 mins to fix

                                            Avoid too many return statements within this function.
                                            Open

                                              return 0;
                                            Severity: Major
                                            Found in tools/meteor-services/deploy.js - About 30 mins to fix

                                              Avoid too many return statements within this function.
                                              Open

                                                  return null;
                                              Severity: Major
                                              Found in tools/meteor-services/deploy.js - About 30 mins to fix

                                                There are no issues that match your filters.

                                                Category
                                                Status