Showing 26 of 26 total issues
Function exports
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
module.exports = function(targetPath, exports) {
var modules = [];
var builder;
var exportsIds = {};
exports = exports || [];
- 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 exports
has 72 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports = function(targetPath, exports) {
var modules = [];
var builder;
var exportsIds = {};
exports = exports || [];
Function astRequireFinder
has 51 lines of code (exceeds 25 allowed). Consider refactoring. Open
function astRequireFinder (options){
return function (node) {
//jshint validthis:true
var file = this;
Function end
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
}, function end() {
var stream = this;
if (cachedTemplate) {
applyTemplate(cachedTemplate);
Function repipeRequirement
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
function repipeRequirement(adapter) {
var builder;
return through2.obj(function loadRequired(file, enc, next) {
if (!file.requires) {
this.push(file);
Function createBundle
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
function createBundle(output, sourceFileGlob) {
var outputPath = path.resolve(process.cwd(), output);
winston.info('Reading source files ', sourceFileGlob);
winston.info('Writing result to ', outputPath);
Function loadRequired
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
return through2.obj(function loadRequired(file, enc, next) {
if (!file.requires) {
this.push(file);
return next();
}
Function astVisitor
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
function astVisitor(visitors) {
if (typeof visitors === 'function') {
visitors = [visitors];
}
return through2.obj(function visit(file, enc, next) {
Function repipeRequirement
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
function repipeRequirement(adapter) {
var builder;
return through2.obj(function loadRequired(file, enc, next) {
if (!file.requires) {
this.push(file);
- 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 astParser
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
function astParser(options) {
options = options || {loc:true};
options.loc = 'loc' in options ? options.loc : true;
options.parsers = options.parsers || {
js: parseJs,
- 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 applyTemplate
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
function applyTemplate(template) {
try {
var file = new File({
path: targetPath
});
Function runProgram
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
function runProgram(er, data) {
if (er) {
winston.error('There was an error reading the file ' + packagePath + '\n\n' + er.stack);
return;
}
Function astParser
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
function astParser(options) {
options = options || {loc:true};
options.loc = 'loc' in options ? options.loc : true;
options.parsers = options.parsers || {
js: parseJs,
Function astVisitor
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
function astVisitor(visitors) {
if (typeof visitors === 'function') {
visitors = [visitors];
}
return through2.obj(function visit(file, enc, next) {
- 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 visit
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
return through2.obj(function visit(file, enc, next) {
var _this = this;
winston.verbose('astVisitor -> ', file && file.path);
if (file.isNull()) {
_this.push(file); // pass along
Function visit
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
.pipe(through2.obj(function visit(file, enc, next) {
if (file.isNull()) {
this.push(file); // pass along
return next();
}
Function modulesBuilder
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
function modulesBuilder() {
var builder = {
rootModules:{},
modules:{},
resolved:{},
Function assignModuleId
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
function assignModuleId() {
var id = 0;
var allFiles = [];
return through(function write(file) {
Similar blocks of code found in 2 locations. Consider refactoring. Open
gulp.task('quality', function () {
return gulp.src('./test/*.js')
.pipe(mocha({
ui: 'bdd',
reporter: 'spec',
- 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
gulp.task('only', function () {
return gulp.src('./test/*.js')
.pipe(mocha({
ui: 'bdd',
reporter: 'spec',
- 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