File bundler.js
has 2127 lines of code (exceeds 250 allowed). Consider refactoring. Open
// == Site Archive (*.star) file layout (subject to rapid change) ==
//
// /star.json
//
// - format: "site-archive-pre1" for this version
Function load
has 169 lines of code (exceeds 25 allowed). Consider refactoring. Open
load(bindings) {
var self = this;
var ret = new PackageRegistry();
// XXX This is mostly duplicated from
Function _emitResources
has 161 lines of code (exceeds 25 allowed). Consider refactoring. Open
_emitResources(sourceBatches, onJsOutputFiles = () => {}) {
buildmessage.assertInJob();
const isWeb = archinfo.matches(this.arch, 'web');
const isOs = archinfo.matches(this.arch, 'os');
Function write
has 132 lines of code (exceeds 25 allowed). Consider refactoring. Open
write(builder, {
buildMode,
// falsy or 'symlink', documented on exports.bundle
includeNodeModules,
} = {}) {
Function write
has 122 lines of code (exceeds 25 allowed). Consider refactoring. Open
write(builder, {minifyMode, buildMode}) {
builder.reserve("program.json");
// Helper to iterate over all resources that we serve over HTTP.
const eachResource = function (f) {
Function getProdPackagePredicate
has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring. Open
getProdPackagePredicate() {
if (this._prodPackagePredicate) {
return this._prodPackagePredicate;
}
- 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 minifyJs
has 91 lines of code (exceeds 25 allowed). Consider refactoring. Open
minifyJs(minifierDef, minifyMode) {
const staticFiles = [];
const dynamicFiles = [];
const { arch } = this;
const inputHashesByJsFile = new Map;
Function _determineLoadOrder
has 87 lines of code (exceeds 25 allowed). Consider refactoring. Open
_determineLoadOrder({packages}) {
buildmessage.assertInCapture();
const isopackCache = this.isopackCache;
Function write
has 71 lines of code (exceeds 25 allowed). Consider refactoring. Open
write(builder, {
buildMode,
// falsy or 'symlink', documented in exports.bundle
includeNodeModules,
}) {
Function _makeNpmRequire
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
_makeNpmRequire(nodeModulesDirsByPackageName) {
function npmRequire(id) {
return require(npmResolve(id));
}
- 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 getProdPackagePredicate
has 59 lines of code (exceeds 25 allowed). Consider refactoring. Open
getProdPackagePredicate() {
if (this._prodPackagePredicate) {
return this._prodPackagePredicate;
}
Function getPreferredBundlePath
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
getPreferredBundlePath(kind) {
assert.ok(kind === "bundle" ||
kind === "isopack",
kind);
- 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 handle
has 56 lines of code (exceeds 25 allowed). Consider refactoring. Open
function handle(source, dynamic) {
// Allows minifiers to be compatible with HMR without being
// updated to support it.
// In development most minifiers add the file to itself with no
// modifications, and we can safely assume that the file
Function readDirsFromJSON
has 55 lines of code (exceeds 25 allowed). Consider refactoring. Open
static readDirsFromJSON(node_modules, {
rebuildBinaries = false,
// Options consumed by readDirsFromJSON are listed above. Any other
// options will be passed on to NodeModulesDirectory constructor via
// this callerInfo object:
Function readDirsFromJSON
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
static readDirsFromJSON(node_modules, {
rebuildBinaries = false,
// Options consumed by readDirsFromJSON are listed above. Any other
// options will be passed on to NodeModulesDirectory constructor via
// this callerInfo object:
- 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 load
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
load(bindings) {
var self = this;
var ret = new PackageRegistry();
// XXX This is mostly duplicated from
- 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 _runCompilerPlugins
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
_runCompilerPlugins({
minifiers = [],
minifyMode = "development",
}) {
buildmessage.assertInJob();
Function _makeNpmRequire
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
_makeNpmRequire(nodeModulesDirsByPackageName) {
function npmRequire(id) {
return require(npmResolve(id));
}
Function make
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
make({packages, minifyMode, addCacheBusters, minifiers, onJsOutputFiles = () => {}}) {
buildmessage.assertInCapture();
buildmessage.enterJob("building for " + this.arch, () => {
// Populate the list of unibuilds to load
Function readFromDisk
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
static readFromDisk (controlFilePath) {
var ret = new JsImage;
var json = JSON.parse(files.readFile(controlFilePath));
var dir = files.pathDirname(controlFilePath);
Function npmResolve
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
function npmResolve(id) {
if (id in resolveCache) {
return resolveCache[id];
}
Function add
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
function add(moreInfo, path) {
const info = {
...callerInfo,
...moreInfo,
};
Function _addCordovaDependency
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
_addCordovaDependency(name, version, override) {
if (! this.cordovaDependencies) {
return;
}
const scoped = name[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 getPreferredBundlePath
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
getPreferredBundlePath(kind) {
assert.ok(kind === "bundle" ||
kind === "isopack",
kind);
Function isWithinProdPackage
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
return this._prodPackagePredicate = function isWithinProdPackage(path) {
const parts = files.pathRelative(sourcePath, path)
.split(files.pathSep);
// Normalize away trailing files.pathSep characters.
Function buildJsImage
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
exports.buildJsImage = Profile("bundler.buildJsImage", function (options) {
buildmessage.assertInCapture();
if (options.npmDependencies && ! options.npmDir) {
throw new Error("Must indicate .npm directory to use");
}
Function constructor
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
constructor (options) {
if (options.data && ! (options.data instanceof Buffer)) {
throw new Error('File contents must be provided as a Buffer');
}
if (! options.sourcePath && ! options.data) {
Function add
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
const add = function (unibuild) {
// If this has already been added, there's nothing to do.
if (!_.has(needed, unibuild.id)) {
return;
}
Function bundle
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
function bundle({
projectContext,
outputPath,
includeNodeModules,
buildOptions,
- 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 rewriteSourceMaps
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
rewriteSourceMaps() {
const rewriteSourceMap = function (sm) {
sm.sources = sm.sources.map(function (path) {
const prefix = SOURCE_URL_PREFIX;
if (path.slice(0, prefix.length) === prefix) {
- 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 constructor
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
constructor (options) {
if (options.data && ! (options.data instanceof Buffer)) {
throw new Error('File contents must be provided as a Buffer');
}
if (! options.sourcePath && ! options.data) {
- 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 true;
Avoid too many return
statements within this function. Open
return false;
Avoid too many return
statements within this function. Open
return;
Function _runCompilerPlugins
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
_runCompilerPlugins({
minifiers = [],
minifyMode = "development",
}) {
buildmessage.assertInJob();
- 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 writeFile
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
var writeFile = Profile("bundler writeFile", function (file, builder, options) {
if (! file.targetPath) {
throw new Error("No targetPath?");
}
- 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 (this.js) {
this.js.forEach(function (js) {
if (js.sourceMap) {
js.sourceMap = rewriteSourceMap(js.sourceMap);
}
- 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 62.
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 (this.css) {
this.css.forEach(function (css) {
if (css.sourceMap) {
css.sourceMap = rewriteSourceMap(css.sourceMap);
}
- 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 62.
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
[
'load',
'write'
].forEach((method) => {
JsImage.prototype[method] = Profile(`JsImage#${method}`, JsImage.prototype[method]);
- 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 56.
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
[
'minifyCss',
'write'
].forEach((method) => {
ClientTarget.prototype[method] = Profile(`ClientTarget#${method}`, ClientTarget.prototype[method]);
- 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 56.
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
Identical blocks of code found in 2 locations. Consider refactoring. Open
if (resource.data && resource.sourceRoot && resource.sourcePath) {
sourcePath = files.pathJoin(resource.sourceRoot, resource.sourcePath);
}
- 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
Identical blocks of code found in 2 locations. Consider refactoring. Open
if (resource.data && resource.sourceRoot && resource.sourcePath) {
sourcePath = files.pathJoin(resource.sourceRoot, resource.sourcePath);
}
- 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
buildmessage.enterJob('minifying app stylesheet', function () {
try {
Promise.await(markedMinifier(sources, { minifyMode }));
} catch (e) {
buildmessage.exception(e);
- 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