meteor/meteor

View on GitHub
tools/project-context.js

Summary

Maintainability
F
1 wk
Test Coverage

File project-context.js has 1257 lines of code (exceeds 250 allowed). Consider refactoring.
Open


var assert = require("assert");
var _ = require('underscore');

var archinfo = require('./utils/archinfo');
Severity: Major
Found in tools/project-context.js - About 3 days to fix

    `` has 35 functions (exceeds 20 allowed). Consider refactoring.
    Open

    Object.assign(ProjectContext.prototype, {
      reset: function (moreOptions, resetOptions) {
        var self = this;
        // Allow overriding some options until the next call to reset;
        var options = Object.assign({}, self.originalOptions, moreOptions);
    Severity: Minor
    Found in tools/project-context.js - About 4 hrs to fix

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

        reset: function (moreOptions, resetOptions) {
          var self = this;
          // Allow overriding some options until the next call to reset;
          var options = Object.assign({}, self.originalOptions, moreOptions);
          // This is options that are actually directed at reset itself.
      Severity: Major
      Found in tools/project-context.js - About 2 hrs to fix

        Function _resolveConstraints has 70 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          _resolveConstraints: Profile('_resolveConstraints', function () {
            var self = this;
            buildmessage.assertInJob();
        
            var depsAndConstraints = self._getRootDepsAndConstraints();
        Severity: Major
        Found in tools/project-context.js - About 2 hrs to fix

          Function _readFile has 60 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            _readFile: function () {
              var self = this;
              buildmessage.assertInCapture();
          
              self.watchSet = new watch.WatchSet;
          Severity: Major
          Found in tools/project-context.js - About 2 hrs to fix

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

              _readProjectMetadata: Profile('_readProjectMetadata', function () {
                var self = this;
                buildmessage.assertInCapture();
            
                buildmessage.enterJob('reading project metadata', function () {
            Severity: Minor
            Found in tools/project-context.js - About 1 hr to fix

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

                reset: function (moreOptions, resetOptions) {
                  var self = this;
                  // Allow overriding some options until the next call to reset;
                  var options = Object.assign({}, self.originalOptions, moreOptions);
                  // This is options that are actually directed at reset itself.
              Severity: Minor
              Found in tools/project-context.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 getNodeModulesToRecompileByArch has 32 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                getNodeModulesToRecompileByArch() {
                  const packageNamesByArch = Object.create(null);
                  const recompile = this.get("nodeModules", "recompile");
              
                  if (recompile && typeof recompile === "object") {
              Severity: Minor
              Found in tools/project-context.js - About 1 hr to fix

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

                  _getEntryModule(
                    arch,
                    entryModulesByArch,
                  ) {
                    const entryMatch = archinfo.mostSpecificMatch(
                Severity: Minor
                Found in tools/project-context.js - About 1 hr to fix

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

                    _localPackageSearchDirs: function () {
                      const self = this;
                      let searchDirs = [
                        files.pathJoin(self._projectDirForLocalPackages, 'packages'),
                      ];
                  Severity: Minor
                  Found in tools/project-context.js - About 1 hr to fix

                    Function _initializeCatalog has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      _initializeCatalog: Profile('_initializeCatalog', function () {
                        var self = this;
                        buildmessage.assertInJob();
                    
                        catalog.runAndRetryWithRefreshIfHelpful(function () {
                    Severity: Minor
                    Found in tools/project-context.js - About 1 hr to fix

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

                        _readFile: function () {
                          var self = this;
                          buildmessage.assertInCapture();
                      
                          self.watchSet = new watch.WatchSet;
                      Severity: Minor
                      Found in tools/project-context.js - About 1 hr to fix

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

                          ensureDevBundleLink() {
                            import { makeLink, readLink } from "./cli/dev-bundle-links.js";
                        
                            const dotMeteorDir = files.pathDirname(this.filename);
                            const localDir = files.pathJoin(dotMeteorDir, "local");
                        Severity: Minor
                        Found in tools/project-context.js - About 1 hr to fix

                          Function _buildLocalPackages has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                            _buildLocalPackages: Profile('_buildLocalPackages', function () {
                              var self = this;
                              buildmessage.assertInCapture();
                          
                          
                          
                          Severity: Minor
                          Found in tools/project-context.js - About 1 hr to fix

                            Function _write has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                            Open

                              _write: function () {
                                var self = this;
                                var lines = _.map(self._constraintLines, function (lineRecord) {
                                  // Don't write packages that were not loaded from .meteor/packages
                                  if (lineRecord.skipOnWrite)
                            Severity: Minor
                            Found in tools/project-context.js - About 45 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 _getEntryModule has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                            Open

                              _getEntryModule(
                                arch,
                                entryModulesByArch,
                              ) {
                                const entryMatch = archinfo.mostSpecificMatch(
                            Severity: Minor
                            Found in tools/project-context.js - About 45 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 getNodeModulesToRecompileByArch has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                            Open

                              getNodeModulesToRecompileByArch() {
                                const packageNamesByArch = Object.create(null);
                                const recompile = this.get("nodeModules", "recompile");
                            
                                if (recompile && typeof recompile === "object") {
                            Severity: Minor
                            Found in tools/project-context.js - About 45 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

                            Consider simplifying this complex logical expression.
                            Open

                                if (! self._neverWritePackageMap &&
                                    (self._alwaysWritePackageMap ||
                                     (release.current.isCheckout() && self.releaseFile.isCheckout()) ||
                                     (! release.current.isCheckout() &&
                                      release.current.name === self.releaseFile.fullReleaseName))) {
                            Severity: Major
                            Found in tools/project-context.js - About 40 mins to fix

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

                                ensureDevBundleLink() {
                                  import { makeLink, readLink } from "./cli/dev-bundle-links.js";
                              
                                  const dotMeteorDir = files.pathDirname(this.filename);
                                  const localDir = files.pathJoin(dotMeteorDir, "local");
                              Severity: Minor
                              Found in tools/project-context.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

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

                                _saveChangedMetadata: Profile('_saveChangedMetadata', function () {
                                  var self = this;
                              
                                  // Save any changes to .meteor/packages.
                                  if (! self._neverWriteProjectConstraintsFile)
                              Severity: Minor
                              Found in tools/project-context.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/project-context.js - About 30 mins to fix

                                Avoid too many return statements within this function.
                                Open

                                        return;
                                Severity: Major
                                Found in tools/project-context.js - About 30 mins to fix

                                  Avoid too many return statements within this function.
                                  Open

                                          return;
                                  Severity: Major
                                  Found in tools/project-context.js - About 30 mins to fix

                                    Avoid too many return statements within this function.
                                    Open

                                            return;
                                    Severity: Major
                                    Found in tools/project-context.js - About 30 mins to fix

                                      Avoid too many return statements within this function.
                                      Open

                                              return;
                                      Severity: Major
                                      Found in tools/project-context.js - About 30 mins to fix

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

                                          appendUpgraders: function (upgraders) {
                                            var self = this;
                                        
                                            var current = null;
                                            try {
                                        Severity: Minor
                                        Found in tools/project-context.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 _readResolverResultCache has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                        Open

                                          _readResolverResultCache() {
                                            if (! this._resolverResultCache) {
                                              try {
                                                this._resolverResultCache =
                                                  JSON.parse(files.readFile(files.pathJoin(
                                        Severity: Minor
                                        Found in tools/project-context.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 getDevBundle has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                        Open

                                          getDevBundle() {
                                            let devBundle = files.getDevBundle();
                                            const devBundleParts = devBundle.split(files.pathSep);
                                            const meteorToolIndex = devBundleParts.lastIndexOf("meteor-tool");
                                        
                                        
                                        Severity: Minor
                                        Found in tools/project-context.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

                                        There are no issues that match your filters.

                                        Category
                                        Status