Showing 258 of 258 total issues
Function 11
has 82 lines of code (exceeds 25 allowed). Consider refactoring. Open
},{}],11:[function(require,module,exports){
'use strict';
var hasOwn = Object.prototype.hasOwnProperty;
var toStr = Object.prototype.toString;
Function 7
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
},{"custom-event":5,"ent/encode":7,"extend":9,"void-elements":11}],7:[function(require,module,exports){
var punycode = require('punycode');
var revEntities = require('./reversed.json');
module.exports = encode;
- 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 9
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
},{"custom-event":7,"ent/encode":9,"extend":11,"void-elements":13}],9:[function(require,module,exports){
var punycode = require('punycode');
var revEntities = require('./reversed.json');
module.exports = encode;
- 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 ProcessLauncher
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
function ProcessLauncher (spawn, tempDir, timer, processKillTimeout) {
const self = this
let onExitCallback
const killTimeout = processKillTimeout || 2000
// Will hold output from the spawned child process
- 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 stringify
has 76 lines of code (exceeds 25 allowed). Consider refactoring. Open
function stringify (obj, depth) {
if (depth === 0) {
return '...'
}
Function stringify
has 76 lines of code (exceeds 25 allowed). Consider refactoring. Open
function stringify (obj, depth) {
if (depth === 0) {
return '...'
}
Function stringify
has 76 lines of code (exceeds 25 allowed). Consider refactoring. Open
function stringify (obj, depth) {
if (depth === 0) {
return '...'
}
Function createRunnerMiddleware
has 76 lines of code (exceeds 25 allowed). Consider refactoring. Open
function createRunnerMiddleware (emitter, fileList, capturedBrowsers, reporter, executor,
/* config.protocol */ protocol, /* config.hostname */ hostname, /* config.port */
port, /* config.urlRoot */ urlRoot, config) {
helper.saveOriginalArgs(config)
return function (request, response, next) {
Function constructor
has 72 lines of code (exceeds 25 allowed). Consider refactoring. Open
constructor (cliOptionsOrConfig, done) {
super()
cliOptionsOrConfig = cliOptionsOrConfig || {}
this.log = logger.create('karma-server')
done = helper.isFunction(done) ? done : process.exit
Function encode
has 71 lines of code (exceeds 25 allowed). Consider refactoring. Open
function encode(input) {
var n,
delta,
handledCPCount,
basicLength,
Function encode
has 71 lines of code (exceeds 25 allowed). Consider refactoring. Open
function encode(input) {
var n,
delta,
handledCPCount,
basicLength,
File cli.js
has 285 lines of code (exceeds 250 allowed). Consider refactoring. Open
'use strict'
const path = require('path')
const yargs = require('yargs')
const fs = require('graceful-fs')
Function 4
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
},{"../common/util":6,"./constants":1,"./karma":2,"./updater":4}],4:[function(require,module,exports){
var VERSION = require('./constants').VERSION
function StatusUpdater (socket, titleElement, bannerElement, browsersElement) {
function updateBrowsersInfo (browsers) {
- 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 4
has 68 lines of code (exceeds 25 allowed). Consider refactoring. Open
},{"../common/util":6,"./constants":1,"./karma":2,"./updater":4}],4:[function(require,module,exports){
var VERSION = require('./constants').VERSION
function StatusUpdater (socket, titleElement, bannerElement, browsersElement) {
function updateBrowsersInfo (browsers) {
Function run
has 66 lines of code (exceeds 25 allowed). Consider refactoring. Open
function run (cliOptionsOrConfig, done) {
cliOptionsOrConfig = cliOptionsOrConfig || {}
done = helper.isFunction(done) ? done : process.exit
let config
Function StatusUpdater
has 64 lines of code (exceeds 25 allowed). Consider refactoring. Open
function StatusUpdater (socket, titleElement, bannerElement, browsersElement) {
function updateBrowsersInfo (browsers) {
if (!browsersElement) {
return
}
Function StatusUpdater
has 64 lines of code (exceeds 25 allowed). Consider refactoring. Open
function StatusUpdater (socket, titleElement, bannerElement, browsersElement) {
function updateBrowsersInfo (browsers) {
if (!browsersElement) {
return
}
Function createServeFile
has 62 lines of code (exceeds 25 allowed). Consider refactoring. Open
function createServeFile (fs, directory, config) {
const cache = Object.create(null)
return function (filepath, rangeHeader, response, transform, content, doNotCache) {
let responseData
Function constructor
has 62 lines of code (exceeds 25 allowed). Consider refactoring. Open
constructor () {
this.LOG_DISABLE = constant.LOG_DISABLE
this.LOG_ERROR = constant.LOG_ERROR
this.LOG_WARN = constant.LOG_WARN
this.LOG_INFO = constant.LOG_INFO
Similar blocks of code found in 3 locations. Consider refactoring. Open
if (helper.isArray(data.changedFiles)) {
await Promise.all(data.changedFiles.map(async function (filepath) {
await fileList.changeFile(path.resolve(config.basePath, filepath))
fullRefresh = false
}))
- 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 83.
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