Showing 42 of 42 total issues
Similar blocks of code found in 3 locations. Consider refactoring. Open
monitor.on("removed", function (f) {
logger.log('Removed file ' + f);
if(!(f.indexOf('deploy/') > -1)) {
wm.projectFileChangeEventHandler(f, callback);
}
- 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 68.
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
Function MinifyFile
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
MinifyFile: function(cb) {
var include;
var includeTitle;
var inPath;
Similar blocks of code found in 2 locations. Consider refactoring. Open
if(type === 'js') {
res.writeHead(200, {
'Content-Type': 'application/javascript',
'cache-control':'no-cache'
});
- 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 66.
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 {
res.writeHead(200, {
'Content-Type': 'text/css',
'cache-control':'no-cache'
});
- 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 66.
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
Function exports
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
module.exports = function (args, settings, callback) {
logger.debug('Entering create...', 6);
logger.debug('Args: ' + JSON.stringify(args));
logger.debug('Settings: ' + JSON.stringify(settings));
- 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 serveLibrary
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
LibraryManager.prototype.serveLibrary = function(uri, res, callback) {
var type = uri.indexOf('js') > 0 ? 'js' : 'css';
getLibraryContents(uri, function(pageText, found) {
if(found) {
if(type === 'js') {
Function exports
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports = function (args, settings, callback) {
logger.debug('Entering create...', 6);
logger.debug('Args: ' + JSON.stringify(args));
logger.debug('Settings: ' + JSON.stringify(settings));
Function walkSync
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
function walkSync (start, callback) {
if(fs.existsSync(start)) {
var stat = fs.statSync(start);
if (stat.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 exports
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports = function () {
var wm = require('./watchManager.js');
var callback = function() {
Function copyStaticFiles
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
View.prototype.copyStaticFiles = function(callback) {
var staticDirectory = 'custom/static';
utils.walkSync(staticDirectory, function(dir, directories, fileNames) {
logger.debug('Directory: ' + dir);
logger.debug('FileNames: ' + JSON.stringify(fileNames));
Function getLibraryContents
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
var getLibraryContents = function(uri, callback) {
logger.debug('Entering getLibraryContents...');
logger.debug(JSON.stringify(Libraries));
if(typeof(Libraries) === 'undefined') {
throw new Error('No libraries defined, did you call LibraryManager.init first?');
- 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
var jsincludes = (script.js.start + '/js/' + this.name + '-' + title + '.js' + script.js.end);
- 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
var cssincludes = (script.css.start + '/css/' + this.name + '-' + title + '.css' + script.css.end);
- 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
Avoid deeply nested control flow statements. Open
for(var l = 0; l < libraries[i][k].fileNames.length; l++) {
if(typeof(libraryContainer[libraries[i][k].fileNames[l]]) === 'undefined') {
libraryContainer[libraries[i][k].fileNames[l]] = {};
libraryContainer[libraries[i][k].fileNames[l]].dir = libraries[i][k].dir;
}
Avoid deeply nested control flow statements. Open
if(typeof(callback) !== 'undefined') {
callback(null, testing.nirodhaManager.notfound);
}
Function handleRequest
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
function handleRequest (req, res, rootDirectory, htmlFiles, callback) {
Function hasDuplicateLibraries
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
Util.prototype.hasDuplicateLibraries = function(libraries) {
logger.debug('Libraries is: ' + JSON.stringify(libraries));
var librariesByName = [];
for(var i = 0; i < libraries.length; i++) {
for(var k = 0; k < libraries[i].length; k++) {
- 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 generateIncludes
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
function generateIncludes(libobject, type) {
var files = libobject.libs[type];
logger.log('Generating includes...', 7);
logger.log('Library lengths: ' + files.length, 7);
- 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 getLibraries
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
function getLibraries(cwd, type, include, callback) {
process.chdir(cwd);
logger.debug('Entering loop to add ' + type + ' libraries');
var files = include.libs[type];
- 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 getDuplicateLibraries
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
Util.prototype.getDuplicateLibraries = function(libraries) {
var librariesByName = [];
for(var i = 0; i < libraries.length; i++) {
for(var k = 0; k < libraries[i].length; k++) {
logger.debug('Libraries in loop: ' + JSON.stringify(libraries[i][k].fileNames));
- 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"