Showing 107 of 107 total issues
Function sendTestUpdate
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
var sendTestUpdate = function (scope, name, info) {
if (!checkTaskExecutionId(scope, name)) {
return false;
}
if (!info) {
Similar blocks of code found in 2 locations. Consider refactoring. Open
ConsoleReport.prototype.addResult = function (event) {
var eventName = event.event;
var eventHandler = eventTypes[eventName];
if (eventHandler) {
eventHandler.call(this, event);
- 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 62.
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
JsonReport.prototype.addResult = function (event) {
var eventName = event.event;
var eventHandler = eventTypes[eventName];
if (eventHandler) {
eventHandler.call(this, event);
- 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 62.
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 processFile
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
var processFile = function processFile(out, fileName, fileInfos) {
fileName = fileName.replace(/\\/g, '/'); // use only forward slashes
out.push('SF:' + fileName);
var statements = fileInfos.code.src;
var execCount;
Function buildTask
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
var buildTask = function (testType, test, browser) {
var taskId = this.tasks.length;
var task = {
taskId: taskId,
testType: testType,
Function exports
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports = function (ipv4Only) {
var categories = {
IPv4: [],
internalIPv4: [],
IPv6: [],
Function taskFinished
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
taskFinished: function (event) {
var taskId = event.taskId;
var task = this.campaign.jsonReport.tasks[taskId];
var taskName = task.name;
Function tag
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
function tag(name, defaults, description, scope, attributesGenerator) {
var config = defaults || {};
var data = scope || {};
merge(config, description);
- 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 buildTasksForTest
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
var buildTasksForTest = function (testType, test) {
var subTests = test.subTests;
var testResults = test.results;
if (!subTests && !test.url && !testResults) {
// something is wrong with this test!!
- 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 resolvePath
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
Resources.prototype.resolvePath = function (path, callback) {
var rootsArray = this._rootsArray;
var checkFileExistence = function (pathInContext, currentIndex) {
var entry = rootsArray[currentIndex];
var absolutePath = pathUtils.join(entry.root, pathInContext);
Function optimizeNumberOfParallelInstances
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
var optimizeNumberOfParallelInstances = function (cfg, logger) {
if (cfg.maxInstances === 0) { // explicitly asking for no PhantomJS
logger.logInfo("No PhantomJS instances launched.");
return 0;
}
Function create
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
exports.create = function (callback) {
testServer = new TestServer({
predictableUrls: config["predictable-urls"],
shutdownOnCampaignEnd: config["shutdown-on-campaign-end"],
frozen: config["server-only"],
Function routeCoverage
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
var routeCoverage = function (req, res, next) {
var testServer = this;
var match = /\/([0-9]+)\/([0-9]+)/.exec(req.path);
var campaignId;
var taskId;
Function _addResult
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
TestEnumerator.prototype._addResult = function (testInfo, res) {
var classpath = testInfo.name;
var testSuite = res.testSuite;
var error = res.error;
if (error) {
Function exports
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports = function (req, res, next) {
var model = this.data;
var page = this.page;
if (page.charAt(0) !== "/") {
page = "/" + page;
Function walker
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
var walker = new UglifyJS.TreeWalker(function (node) {
var isAssignment = node instanceof UglifyJS.AST_Assign && node.operator == "=";
if (!isAssignment) return;
var moduleExports = node.left;
var isDotExports = moduleExports instanceof UglifyJS.AST_Dot && moduleExports.property == "exports";
Function processFile
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
var processFile = function processFile(out, fileName, fileInfos) {
fileName = fileName.replace(/\\/g, '/'); // use only forward slashes
out.push('SF:' + fileName);
var statements = fileInfos.code.src;
var execCount;
- 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 init
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
AllTests.prototype.init = function (callback) {
var expectedCallbacks = 1;
var testTypes = this.testTypes;
var decrementExpectedCallbacks = function () {
expectedCallbacks--;
- 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 require
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
exports.require = function (name, config) {
// Do it here so that it's available for the plugin even before it gets called
var pluginConfig = exports.config(name, config);
var pending = 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 readRequire
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
function readRequire(expression) {
if (expression instanceof UglifyJS.AST_Call && expression.args.length == 1) {
var requireVar = expression.expression;
if (requireVar instanceof UglifyJS.AST_SymbolRef && requireVar.name == "require" && requireVar.thedef.undeclared) {
var param = expression.args[0];
- 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"