packages/constraint-solver/version-pricer.js
Function priceVersions
has a Cognitive Complexity of 44 (exceeds 5 allowed). Consider refactoring. Open
Open
CS.VersionPricer.prototype.priceVersions = function (versions, mode, options) {
var self = this;
var getMajorMinorPatch = function (v) {
var vInfo = self.getVersionInfo(v);
- 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 priceVersions
has 72 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
CS.VersionPricer.prototype.priceVersions = function (versions, mode, options) {
var self = this;
var getMajorMinorPatch = function (v) {
var vInfo = self.getVersionInfo(v);
Function priceVersionsWithPrevious
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
CS.VersionPricer.prototype.priceVersionsWithPrevious = function (
versions, target, takePatches) {
var self = this;
var parts = self.partitionVersions(versions, target);
Avoid deeply nested control flow statements. Open
Open
for (var m = k+1; m <= REST; m++) {
if (gravity[m]) {
// if we should actually be counting "newness" instead of
// oldness, flip the count. Instead of [0, 1, 1, 2, 3],
// for example, make it [3, 2, 2, 1, 0]. This is the place
Function partitionVersions
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
Open
CS.VersionPricer.prototype.partitionVersions = function (versions, target) {
var self = this;
var firstGteIndex = versions.length;
var higherMajorIndex = versions.length;
var targetVInfo = self.getVersionInfo(target);
- 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"