File commands-packages.js
has 2086 lines of code (exceeds 250 allowed). Consider refactoring. Open
var main = require('./main.js');
var _ = require('underscore');
var files = require('../fs/files');
var buildmessage = require('../utils/buildmessage.js');
var auth = require('../meteor-services/auth.js');
Function maybeUpdateRelease
has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring. Open
var maybeUpdateRelease = function (options) {
// We are only updating packages, so we are not updating the release.
if (options["packages-only"]) {
return 0;
}
- 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 maybeUpdateRelease
has 141 lines of code (exceeds 25 allowed). Consider refactoring. Open
var maybeUpdateRelease = function (options) {
// We are only updating packages, so we are not updating the release.
if (options["packages-only"]) {
return 0;
}
Function messages
has 65 lines of code (exceeds 25 allowed). Consider refactoring. Open
var messages = buildmessage.capture(function () {
_.each(packagesToAdd, function (packageReq) {
buildmessage.enterJob("adding package " + packageReq, function () {
var constraint = utils.parsePackageConstraint(packageReq, {
useBuildmessage: true
Function updatePackageMetadata
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
var updatePackageMetadata = function (packageSource, conn) {
var name = packageSource.name;
var version = packageSource.version;
// You can't change the metadata of a record that doesn't exist.
Consider simplifying this complex logical expression. Open
if (showTree || showJson) {
const jsonOut = showJson && {};
const showWeak = !!options['weak'];
const showDetails = !!options['details'];
// Load package details of all used packages (inc. dependencies)
Avoid too many return
statements within this function. Open
return 0;
Avoid too many return
statements within this function. Open
return 0;
Avoid too many return
statements within this function. Open
return 0;
Avoid too many return
statements within this function. Open
return 1;
Avoid too many return
statements within this function. Open
return 1;
Avoid too many return
statements within this function. Open
return 0;
Avoid too many return
statements within this function. Open
return 1;
Avoid too many return
statements within this function. Open
return 1;
Avoid too many return
statements within this function. Open
return 1;
Avoid too many return
statements within this function. Open
return 0;
Avoid too many return
statements within this function. Open
return 0;
Avoid too many return
statements within this function. Open
return 1;
Avoid too many return
statements within this function. Open
return 1;
Avoid too many return
statements within this function. Open
return 0;
Avoid too many return
statements within this function. Open
return 2;
Avoid too many return
statements within this function. Open
return 1;
Avoid too many return
statements within this function. Open
return 1;
Avoid too many return
statements within this function. Open
return 2;
Avoid too many return
statements within this function. Open
return 0;
Avoid too many return
statements within this function. Open
return updatePackageMetadata(packageSource, conn);
Avoid too many return
statements within this function. Open
return 0;
Avoid too many return
statements within this function. Open
return 1;
Avoid too many return
statements within this function. Open
return 0;
Avoid too many return
statements within this function. Open
return 0;
Avoid too many return
statements within this function. Open
return 1;
Avoid too many return
statements within this function. Open
return 0;
Avoid too many return
statements within this function. Open
return 0;
Avoid too many return
statements within this function. Open
return 1;
Avoid too many return
statements within this function. Open
return 0;
Avoid too many return
statements within this function. Open
return 0;
Function getNewerVersion
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
var getNewerVersion = function (packageName, curVersion, whichCatalog) {
// Check to see if there are later versions available, returning the
// latest version if there are.
//
// If we are not using an rc for this package, then we are not going to
- 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
Similar blocks of code found in 2 locations. Consider refactoring. Open
if (messages.hasMessages()) {
Console.arrowError("Errors while adding packages:", 1);
Console.printMessages(messages);
catalogUtils.explainIfRefreshFailed(); // this is why we're not using captureAndExit
return 1;
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 54.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
if (messages.hasMessages()) {
Console.arrowError("Errors while parsing arguments:", 1);
Console.printMessages(messages);
catalogUtils.explainIfRefreshFailed(); // this is why we're not using captureAndExit
return 1;
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 54.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
if (fullRecord.release) {
packageClient.callPackageServer(
conn, 'addReleaseMaintainer', name, options.add);
} else {
packageClient.callPackageServer(
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 51.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
if (fullRecord.release) {
packageClient.callPackageServer(
conn, 'removeReleaseMaintainer', name, options.remove);
} else {
packageClient.callPackageServer(
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 51.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
Console.info(" * " + rec.name + " " + rec.selectedVersion +
" (" + rec.latestVersion + " is available)");
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 46.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
} else {
plugins[id] = version;
Console.info(`Added Cordova plugin ${id}@${version}.`);
changed = true;
}
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 45.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
} else if (newId) {
plugins[newId] = version;
Console.info(`Added Cordova plugin ${newId}@${version} \
(plugin has been renamed as part of moving to npm).`);
changed = true;
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 45.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76