meteor/meteor

View on GitHub
tools/isobuild/meteor-npm.js

Summary

Maintainability
F
5 days
Test Coverage

File meteor-npm.js has 775 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/// Implements the process of managing a package's .npm directory,
/// in which we call `npm install` to install npm dependencies,
/// and a variety of related commands. Notably, we use `npm shrinkwrap`
/// to ensure we get consistent versions of npm sub-dependencies.

Severity: Major
Found in tools/isobuild/meteor-npm.js - About 1 day to fix

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

    var updateExistingNpmDirectory = function (packageName, newPackageNpmDir,
                                               packageNpmDir, npmDependencies,
                                               quiet) {
      // sanity check on contents of .npm directory
      if (!files.stat(packageNpmDir).isDirectory()) {
    Severity: Major
    Found in tools/isobuild/meteor-npm.js - About 3 hrs to fix

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

      Profile("meteorNpm.rebuildIfNonPortable", function (nodeModulesDir) {
        const dirsToRebuild = [];
      
        function scan(dir, scoped) {
          if (! isDirectory(dir)) {
      Severity: Major
      Found in tools/isobuild/meteor-npm.js - About 2 hrs to fix

        Function updateExistingNpmDirectory has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
        Open

        var updateExistingNpmDirectory = function (packageName, newPackageNpmDir,
                                                   packageNpmDir, npmDependencies,
                                                   quiet) {
          // sanity check on contents of .npm directory
          if (!files.stat(packageNpmDir).isDirectory()) {
        Severity: Minor
        Found in tools/isobuild/meteor-npm.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 getInstalledDependenciesTree has 59 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function getInstalledDependenciesTree(dir) {
          function ls(nodeModulesDir) {
            let contents;
            try {
              contents = files.readdir(nodeModulesDir).sort();
        Severity: Major
        Found in tools/isobuild/meteor-npm.js - About 2 hrs to fix

          Function ls has 53 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            function ls(nodeModulesDir) {
              let contents;
              try {
                contents = files.readdir(nodeModulesDir).sort();
              } finally {
          Severity: Major
          Found in tools/isobuild/meteor-npm.js - About 2 hrs to fix

            Function getProdPackageNames has 50 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            export const getProdPackageNames = wrapOptimistic(nodeModulesDir => {
              const names = Object.create(null);
              const dirs = Object.create(null);
              const nodeModulesDirStack = [];
            
            
            Severity: Minor
            Found in tools/isobuild/meteor-npm.js - About 2 hrs to fix

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

              meteorNpm.updateDependencies = function (packageName,
                                                       packageNpmDir,
                                                       npmDependencies,
                                                       quiet) {
                // we make sure to put it beside the original package dir so that
              Severity: Minor
              Found in tools/isobuild/meteor-npm.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 isPortable has 47 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              const isPortable = Profile("meteorNpm.isPortable", dir => {
                const lstat = optimisticLStat(dir);
                if (! lstat.isDirectory()) {
                  // Non-directory files are portable unless they end with .node.
                  return ! dir.endsWith(".node");
              Severity: Minor
              Found in tools/isobuild/meteor-npm.js - About 1 hr to fix

                Function runNpmCommand has 43 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                Profile("meteorNpm.runNpmCommand", function (args, cwd) {
                  import { getEnv } from "../cli/dev-bundle-bin-helpers.js";
                
                  const devBundleDir = files.getDevBundle();
                  const isWindows = process.platform === "win32";
                Severity: Minor
                Found in tools/isobuild/meteor-npm.js - About 1 hr to fix

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

                  const installNpmModule = meteorNpm.installNpmModule = (name, version, dir) => {
                    const installArg = utils.isNpmUrl(version)
                      ? version
                      : `${name}@${version}`;
                  
                  
                  Severity: Minor
                  Found in tools/isobuild/meteor-npm.js - About 1 hr to fix

                    Function installNpmModule has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                    Open

                    const installNpmModule = meteorNpm.installNpmModule = (name, version, dir) => {
                      const installArg = utils.isNpmUrl(version)
                        ? version
                        : `${name}@${version}`;
                    
                    
                    Severity: Minor
                    Found in tools/isobuild/meteor-npm.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 updateDependencies has 38 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    meteorNpm.updateDependencies = function (packageName,
                                                             packageNpmDir,
                                                             npmDependencies,
                                                             quiet) {
                      // we make sure to put it beside the original package dir so that
                    Severity: Minor
                    Found in tools/isobuild/meteor-npm.js - About 1 hr to fix

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

                      function copyNpmPackageWithSymlinkedNodeModules(fromPkgDir, toPkgDir) {
                        files.mkdir_p(toPkgDir);
                      
                        let needToHandleNodeModules = false;
                      
                      
                      Severity: Minor
                      Found in tools/isobuild/meteor-npm.js - About 1 hr to fix

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

                        const isPortable = Profile("meteorNpm.isPortable", dir => {
                          const lstat = optimisticLStat(dir);
                          if (! lstat.isDirectory()) {
                            // Non-directory files are portable unless they end with .node.
                            return ! dir.endsWith(".node");
                        Severity: Minor
                        Found in tools/isobuild/meteor-npm.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 getProdPackageNames has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                        Open

                        export const getProdPackageNames = wrapOptimistic(nodeModulesDir => {
                          const names = Object.create(null);
                          const dirs = Object.create(null);
                          const nodeModulesDirStack = [];
                        
                        
                        Severity: Minor
                        Found in tools/isobuild/meteor-npm.js - About 55 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 createFreshNpmDirectory has 5 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                        var createFreshNpmDirectory = function (packageName, newPackageNpmDir,
                                                                packageNpmDir, npmDependencies, quiet) {
                        Severity: Minor
                        Found in tools/isobuild/meteor-npm.js - About 35 mins to fix

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

                          var updateExistingNpmDirectory = function (packageName, newPackageNpmDir,
                                                                     packageNpmDir, npmDependencies,
                                                                     quiet) {
                          Severity: Minor
                          Found in tools/isobuild/meteor-npm.js - About 35 mins to fix

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

                            function minimizeDependencyTree(tree) {
                              function minimizeModule(module) {
                                var version;
                                if (module.resolved && ! isUrlFromRegistry(module.resolved)) {
                                  version = module.resolved;
                            Severity: Minor
                            Found in tools/isobuild/meteor-npm.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;
                            Severity: Major
                            Found in tools/isobuild/meteor-npm.js - About 30 mins to fix

                              There are no issues that match your filters.

                              Category
                              Status