File meteor-npm.js
has 775 lines of code (exceeds 250 allowed). Consider refactoring. Open
/// Implements the process of managing a package's .npm directory,
/// in which we call `npm install` to install npm dependencies,
/// and a variety of related commands. Notably, we use `npm shrinkwrap`
/// to ensure we get consistent versions of npm sub-dependencies.
Function updateExistingNpmDirectory
has 81 lines of code (exceeds 25 allowed). Consider refactoring. Open
var updateExistingNpmDirectory = function (packageName, newPackageNpmDir,
packageNpmDir, npmDependencies,
quiet) {
// sanity check on contents of .npm directory
if (!files.stat(packageNpmDir).isDirectory()) {
Function rebuildIfNonPortable
has 73 lines of code (exceeds 25 allowed). Consider refactoring. Open
Profile("meteorNpm.rebuildIfNonPortable", function (nodeModulesDir) {
const dirsToRebuild = [];
function scan(dir, scoped) {
if (! isDirectory(dir)) {
Function updateExistingNpmDirectory
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
var updateExistingNpmDirectory = function (packageName, newPackageNpmDir,
packageNpmDir, npmDependencies,
quiet) {
// sanity check on contents of .npm directory
if (!files.stat(packageNpmDir).isDirectory()) {
- 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 getInstalledDependenciesTree
has 59 lines of code (exceeds 25 allowed). Consider refactoring. Open
function getInstalledDependenciesTree(dir) {
function ls(nodeModulesDir) {
let contents;
try {
contents = files.readdir(nodeModulesDir).sort();
Function ls
has 53 lines of code (exceeds 25 allowed). Consider refactoring. Open
function ls(nodeModulesDir) {
let contents;
try {
contents = files.readdir(nodeModulesDir).sort();
} finally {
Function getProdPackageNames
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
export const getProdPackageNames = wrapOptimistic(nodeModulesDir => {
const names = Object.create(null);
const dirs = Object.create(null);
const nodeModulesDirStack = [];
Function updateDependencies
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
meteorNpm.updateDependencies = function (packageName,
packageNpmDir,
npmDependencies,
quiet) {
// we make sure to put it beside the original package dir so that
- 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 isPortable
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
const isPortable = Profile("meteorNpm.isPortable", dir => {
const lstat = optimisticLStat(dir);
if (! lstat.isDirectory()) {
// Non-directory files are portable unless they end with .node.
return ! dir.endsWith(".node");
Function runNpmCommand
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
Profile("meteorNpm.runNpmCommand", function (args, cwd) {
import { getEnv } from "../cli/dev-bundle-bin-helpers.js";
const devBundleDir = files.getDevBundle();
const isWindows = process.platform === "win32";
Function installNpmModule
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
const installNpmModule = meteorNpm.installNpmModule = (name, version, dir) => {
const installArg = utils.isNpmUrl(version)
? version
: `${name}@${version}`;
Function installNpmModule
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
const installNpmModule = meteorNpm.installNpmModule = (name, version, dir) => {
const installArg = utils.isNpmUrl(version)
? version
: `${name}@${version}`;
- 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 updateDependencies
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
meteorNpm.updateDependencies = function (packageName,
packageNpmDir,
npmDependencies,
quiet) {
// we make sure to put it beside the original package dir so that
Function copyNpmPackageWithSymlinkedNodeModules
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
function copyNpmPackageWithSymlinkedNodeModules(fromPkgDir, toPkgDir) {
files.mkdir_p(toPkgDir);
let needToHandleNodeModules = false;
Function isPortable
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
const isPortable = Profile("meteorNpm.isPortable", dir => {
const lstat = optimisticLStat(dir);
if (! lstat.isDirectory()) {
// Non-directory files are portable unless they end with .node.
return ! dir.endsWith(".node");
- 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 getProdPackageNames
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
export const getProdPackageNames = wrapOptimistic(nodeModulesDir => {
const names = Object.create(null);
const dirs = Object.create(null);
const nodeModulesDirStack = [];
- 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 createFreshNpmDirectory
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
var createFreshNpmDirectory = function (packageName, newPackageNpmDir,
packageNpmDir, npmDependencies, quiet) {
Function updateExistingNpmDirectory
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
var updateExistingNpmDirectory = function (packageName, newPackageNpmDir,
packageNpmDir, npmDependencies,
quiet) {
Function minimizeDependencyTree
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
function minimizeDependencyTree(tree) {
function minimizeModule(module) {
var version;
if (module.resolved && ! isUrlFromRegistry(module.resolved)) {
version = module.resolved;
- 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
Avoid too many return
statements within this function. Open
return;