meteor/meteor

View on GitHub
packages/constraint-solver/solver.js

Summary

Maintainability
F
4 days
Test Coverage

File solver.js has 772 lines of code (exceeds 250 allowed). Consider refactoring.
Open

const has = Npm.require('lodash.has');
const zip = Npm.require('lodash.zip');
const memoize = Npm.require('lodash.memoize');
const groupBy = Npm.require('lodash.groupby');

Severity: Major
Found in packages/constraint-solver/solver.js - About 1 day to fix

    Function _getAnswer has 220 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    CS.Solver.prototype._getAnswer = function (options) {
      var self = this;
      var input = self.input;
      var analysis = self.analysis;
      var cache = input.catalogCache;
    Severity: Major
    Found in packages/constraint-solver/solver.js - About 1 day to fix

      Function analyze has 145 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      CS.Solver.prototype.analyze = function () {
        var self = this;
        var analysis = self.analysis;
        var input = self.input;
        var cache = input.catalogCache;
      Severity: Major
      Found in packages/constraint-solver/solver.js - About 5 hrs to fix

        Function minimize has 62 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        CS.Solver.prototype.minimize = function (step, options) {
          var self = this;
        
          if (Array.isArray(step)) {
            // minimize([steps...], options)
        Severity: Major
        Found in packages/constraint-solver/solver.js - About 2 hrs to fix

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

          CS.Solver.prototype.getPathsToPackageVersion = function (packageAndVersion) {
            check(packageAndVersion, CS.PackageAndVersion);
            var self = this;
            var input = self.input;
            var cache = input.catalogCache;
          Severity: Minor
          Found in packages/constraint-solver/solver.js - About 1 hr to fix

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

            var groupMutuallyExclusiveTerms = function (costTerms, costWeights) {
              // Return a key for a term, such that terms with the same key are
              // guaranteed to be mutually exclusive.  We assume each term is
              // a variable representing either a package or a package version.
              // We take a prefix of the variable name up to and including the
            Severity: Minor
            Found in packages/constraint-solver/solver.js - About 1 hr to fix

              Function addTerm has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
              Open

              CS.Solver.Step.prototype.addTerm = function (term, weight) {
                if (weight == null) {
                  if (typeof this.weights !== 'number') {
                    throw new Error("Must specify a weight");
                  }
              Severity: Minor
              Found in packages/constraint-solver/solver.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 throwConflicts has 26 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              CS.Solver.prototype.throwConflicts = function () {
                var self = this;
              
                var solution = self.solution;
                var constraints = self.analysis.constraints;
              Severity: Minor
              Found in packages/constraint-solver/solver.js - About 1 hr to fix

                Function getPaths has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  var getPaths = function (pv, _ignorePackageSet) {
                    if (!solution.evaluate(pv.toString())) {
                      return [];
                    }
                    var pkg = pv.package;
                Severity: Minor
                Found in packages/constraint-solver/solver.js - About 1 hr to fix

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

                  CS.Solver.prototype._getAnswer = function (options) {
                    var self = this;
                    var input = self.input;
                    var analysis = self.analysis;
                    var cache = input.catalogCache;
                  Severity: Minor
                  Found in packages/constraint-solver/solver.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 minimize has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                  CS.Solver.prototype.minimize = function (step, options) {
                    var self = this;
                  
                    if (Array.isArray(step)) {
                      // minimize([steps...], options)
                  Severity: Minor
                  Found in packages/constraint-solver/solver.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

                  There are no issues that match your filters.

                  Category
                  Status