lib/versions/version-info.js
Function getCdnVersion
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
Open
var getCdnVersion = function() {
return _(previousVersions)
.filter(function(tag) {
return semver.satisfies(tag, currentPackage.branchVersion);
})
- 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 getPreviousVersions
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
var getPreviousVersions = function() {
// If we are allowing remote requests then use the remote tags as the local clone might
// not contain all commits when cloned with git clone --depth=...
// Otherwise just use the tags in the local repository
var repo_url = currentPackage.repository.url;
Consider simplifying this complex logical expression. Open
Open
if ((version.major === 1 && version.minor === 0 && version.prerelease.length > 0) || (version.major === 1 && version.minor === 2 && version.prerelease[0] === 'rc1')) {
version.version = [version.major, version.minor, version.patch].join('.') + version.prerelease.join('');
version.raw = 'v' + version.version;
}