File compiler-plugin.js
has 1196 lines of code (exceeds 250 allowed). Consider refactoring. Open
var archinfo = require('../utils/archinfo');
var buildmessage = require('../utils/buildmessage.js');
var buildPluginModule = require('./build-plugin.js');
var colonConverter = require('../utils/colon-converter.js');
var files = require('../fs/files');
Function computeJsOutputFilesMap
has 160 lines of code (exceeds 25 allowed). Consider refactoring. Open
static computeJsOutputFilesMap(sourceBatches) {
const map = new Map;
sourceBatches.forEach(batch => {
const name = batch.unibuild.pkg.name || null;
Function _linkJS
has 115 lines of code (exceeds 25 allowed). Consider refactoring. Open
_linkJS(jsResources, onCacheKey = () => {}) {
const self = this;
buildmessage.assertInJob();
var bundleArch = self.processor.arch;
Function _linkJS
has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring. Open
_linkJS(jsResources, onCacheKey = () => {}) {
const self = this;
buildmessage.assertInJob();
var bundleArch = self.processor.arch;
- 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 _warnAboutMissingModules
has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring. Open
static _warnAboutMissingModules(missingModules) {
const topLevelMissingIDs = {};
const warnings = [];
Object.keys(missingModules).forEach(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
InputFile
has 28 functions (exceeds 20 allowed). Consider refactoring. Open
class InputFile extends buildPluginModule.InputFile {
constructor(resourceSlot) {
super();
// We use underscored attributes here because this is user-visible
// code and we don't want users to be accessing anything that we don't
Function runCompilerPlugins
has 61 lines of code (exceeds 25 allowed). Consider refactoring. Open
runCompilerPlugins() {
const self = this;
buildmessage.assertInJob();
// plugin id -> {sourceProcessor, resourceSlots}
Function _isLazy
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
_isLazy(options, isJavaScript) {
let lazy = this._getOption("lazy", options);
if (typeof lazy === "boolean") {
return lazy;
- 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 _warnAboutMissingModules
has 54 lines of code (exceeds 25 allowed). Consider refactoring. Open
static _warnAboutMissingModules(missingModules) {
const topLevelMissingIDs = {};
const warnings = [];
Object.keys(missingModules).forEach(id => {
Function constructor
has 52 lines of code (exceeds 25 allowed). Consider refactoring. Open
constructor(unibuild, processor, {
sourceRoot,
linkerCacheDir,
scannerCacheDir,
}) {
Function handleMissing
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
function handleMissing(missingModules) {
const missingMap = new Map;
_.each(missingModules, (importInfoList, id) => {
const parts = id.split("/");
Function addStylesheet
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
addStylesheet(options, lazyFinalizer) {
if (! this.sourceProcessor) {
throw Error("addStylesheet on non-source ResourceSlot?");
}
Function addStylesheet
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
addStylesheet(options, lazyFinalizer) {
if (! this.sourceProcessor) {
throw Error("addStylesheet on non-source ResourceSlot?");
}
- 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 _isLazy
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
_isLazy(options, isJavaScript) {
let lazy = this._getOption("lazy", options);
if (typeof lazy === "boolean") {
return lazy;
Function _get
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
_get(name) {
if (hasOwn.call(this, name)) {
return this[name];
}
- 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 compileOneJsResource
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
compileOneJsResource(resource) {
const slot = this.makeResourceSlot({
type: "source",
extension: "js",
// Need { data, path, hash } here, at least.
- 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 maybeWarn
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
function maybeWarn(id, info) {
if (info.packageName) {
// Silence warnings generated by Meteor packages, since package
// authors can be trusted to test their packages, and may have
// different/better approaches to ensuring their dependencies are
Function _get
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
_get(name) {
if (hasOwn.call(this, name)) {
return this[name];
}
Function compileOneJsResource
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
compileOneJsResource(resource) {
const slot = this.makeResourceSlot({
type: "source",
extension: "js",
// Need { data, path, hash } here, at least.
Function findControlFile
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
findControlFile(basename) {
let absPath = this._controlFileCache[basename];
if (typeof absPath === "string") {
return absPath;
}
- 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 10 (exceeds 5 allowed). Consider refactoring. Open
constructor(unibuildResourceInfo,
sourceProcessor,
packageSourceBatch) {
const self = this;
// XXX ideally this should be an classy object, but it's not.
- 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 makeResourceSlot
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
makeResourceSlot(resource) {
let sourceProcessor = null;
if (resource.type === "source") {
var extension = resource.extension;
if (extension === null) {
- 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 makeResourceSlot
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
makeResourceSlot(resource) {
let sourceProcessor = null;
if (resource.type === "source") {
var extension = resource.extension;
if (extension === null) {
Avoid too many return
statements within this function. Open
return true;
Avoid too many return
statements within this function. Open
return isInImports;
Avoid too many return
statements within this function. Open
return this[name] = this._initialOptions[name];
Avoid too many return
statements within this function. Open
return this._controlFileCache[basename] = null;
Avoid too many return
statements within this function. Open
return true;
Avoid too many return
statements within this function. Open
return ! mainModule;
Avoid too many return
statements within this function. Open
return;
Avoid too many return
statements within this function. Open
return;
Function finalize
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
finalize() {
if (this._finalizerPromise) {
this._finalizerPromise.await();
} else if (this._lazyFinalizer) {
const finalize = this._lazyFinalizer;
- 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
return {
meteorInstallOptions: inputFile.meteorInstallOptions,
absModuleId: inputFile.absModuleId,
sourceMap: !! inputFile.sourceMap,
mainModule: inputFile.mainModule,
- 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 78.
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 (! sourceProcessor) {
buildmessage.error(
`no plugin found for ${ resource.path } in ` +
`${ this.unibuild.pkg.displayName() }; a plugin for ${ filename } ` +
`was active when it was published but none is now`);
- 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 74.
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 (! sourceProcessor && extension !== 'js') {
buildmessage.error(
`no plugin found for ${ resource.path } in ` +
`${ this.unibuild.pkg.displayName() }; a plugin for *.${ extension } ` +
`was active when it was published but none is now`);
- 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 74.
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