Showing 71 of 71 total issues
Function serviceFunction
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
var serviceFunction = function(logFile) {
if(logFileHandlers[logFile])
return logFileHandlers[logFile];
var watch;
Function serverForPortConfig
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
function serverForPortConfig(host, portNumber, portConfig) {
var self = this;
var server;
self.cachedServers = self.cachedServers || {};
- 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 checkPathForReq
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
DispatchTable.prototype.checkPathForReq = function(req, entry) {
if(!entry.path)
return true;
var m;
- 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
Identical blocks of code found in 2 locations. Consider refactoring. Open
entryParser: function(config) {
if(!config.match(/\s*=\s*/)) {
throw new Error('Bad format, should be key=value');
}
var m = config.match(/^(.*?)\s*=\s*(.*$)/);
- 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 63.
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
entryParser: function(config) {
if(!config.match(/\s*=\s*/)) {
throw new Error('Bad format, should be key=value');
}
var m = config.match(/^(.*?)\s*=\s*(.*$)/);
- 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 63.
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 bindTypeGeneric
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
function bindTypeGeneric(doCache, name, type) {
// implicit name from function name
if(typeof name === 'function') {
type = name;
var constructorName = functionName(type);
Function processDirectory
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
let processDirectory = (dirName, cb) => {
fs.readdir(dirName, (err, files) => {
if(err) return cb(err);
Function createHandlers
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
function createHandlers(portNumber, portConfig) {
var self = this;
var di = this.di.makeChild();
di.bindInstance('di', di);
- 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 dropPrivileges
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
function dropPrivileges() {
var strInfo;
if (process.setgid) {
var group = config.group;
if (typeof group === 'string') {
- 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 WebsockifyMiddleware
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports = function WebsockifyMiddleware() {
return {
requestHandler: function(req, res, next, parsedEntry) {
if(req.upgrade) {
var socket = new net.Socket();
Function Logging
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports = function Logging(logFileService, master, moduleConfig) {
var appStream;
if(!master)
return;
Function requestHandler
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
requestHandler: function(req, res, next, dispatchTarget) {
req.next = next;
// workaround for node-http-proxy/#591
if(!req.headers.host) {
req.headers.host = '';
Function patchSslConfig
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
function patchSslConfig(portEntrySslConfig) {
if (nodeVersion >= 0.11) { // use fancy cipher settings only for 0.11
if (portEntrySslConfig.honorCipherOrder !== false) {
// prefer server ciphers over clients - prevents BEAST attack
portEntrySslConfig.honorCipherOrder = true;
- 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 lazyGetTcpServer
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
function lazyGetTcpServer(port, host, cb) {
var tcpServers = this.tcpServers;
var entry = (host ? host + ':' + port : port);
if (tcpServers[entry]) {
- 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 resolve
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
DI.prototype.resolve = function(obj, overrides) {
var dependencyMap = extend({}, this.mapping, overrides);
var args;
var resolved;
Function processMatch
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
function processMatch(target, m) {
var keyWithOffset;
if (m) {
for(var key in m) {
var replaceFrom = key;
- 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 WebsockifyMiddleware
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
module.exports = function WebsockifyMiddleware() {
return {
requestHandler: function(req, res, next, parsedEntry) {
if(req.upgrade) {
var socket = new net.Socket();
- 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 loadConfig
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
HttpMasterWorker.prototype.loadConfig = function(config, configLoaded) {
var self = this;
var events = new EventEmitter();
- 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 a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
module.exports = function(argv, data, cb) {
var oldWarn = console.warn;
console.warn = function() {};
- 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 reload
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
HttpMaster.prototype.reload = function(config, reloadDone) {
var self = this;
this.emit('reload');
function actualReload(config) {
- 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"