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');
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;
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;
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)
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;
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
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");
}
- Read upRead up
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;
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;
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;
- Read upRead up
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)
- Read upRead up
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"