Showing 107 of 107 total issues
Function getReportContent
has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring. Open
function getReportContent(jsonReport, fixedLevels) {
var res = ['<?xml version="1.0" encoding="UTF-8" ?>\n'];
function processError(error) {
var tagName = error.failure ? "failure" : "error";
- 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
File test-server.js
has 382 lines of code (exceeds 250 allowed). Consider refactoring. Open
/*
* Copyright 2012 Amadeus s.a.s.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
Function writeReports
has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring. Open
var writeReports = function (config, results, callback) {
var mkdirsCache = {};
var expectedCallbacks = 1;
var errors = null;
var decreaseCallbacks = function (err) {
- 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
File slave-client.js
has 342 lines of code (exceeds 250 allowed). Consider refactoring. Open
/* global SockJS */
/*
* Copyright 2012 Amadeus s.a.s.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Function exports
has 100 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports = function (attester) {
var BaseTestType = attester.classes.BaseTestType;
var FileSet = attester.classes.FileSet;
var BrowserExcludesFileSet = attester.classes.BrowserExcludesFileSet;
Function writeReports
has 94 lines of code (exceeds 25 allowed). Consider refactoring. Open
var writeReports = function (config, results, callback) {
var mkdirsCache = {};
var expectedCallbacks = 1;
var errors = null;
var decreaseCallbacks = function (err) {
Function exports
has 94 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports = function (attesterServer, serverRoot) {
var listsPossibleReports = function () {
var list = [];
attesterServer.campaigns.forEach(function (campaign) {
var result = campaign.getCoverageResult();
Function iterate
has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring. Open
FileSet.prototype.iterate = function (entryCallback, endCallback) {
var self = this;
var root = this._root || "";
var waitingCallbacks = 0;
var decreaseCallbacks = 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 exports
has 86 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports = function (attester) {
var BaseTestType = attester.classes.BaseTestType;
var TestsEnumerator = require('./at-tests-enumerator.js');
var url = attester.utils.url;
Function readATNewFileContent
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
function readATNewFileContent(res, fileContent, fileName) {
var foundClassDef = null;
var walker = new UglifyJS.TreeWalker(function (node) {
var isAssignment = node instanceof UglifyJS.AST_Assign && node.operator == "=";
if (!isAssignment) return;
- 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
File slave-server.js
has 281 lines of code (exceeds 250 allowed). Consider refactoring. Open
/*
* Copyright 2012 Amadeus s.a.s.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
Function readATNewFileContent
has 68 lines of code (exceeds 25 allowed). Consider refactoring. Open
function readATNewFileContent(res, fileContent, fileName) {
var foundClassDef = null;
var walker = new UglifyJS.TreeWalker(function (node) {
var isAssignment = node instanceof UglifyJS.AST_Assign && node.operator == "=";
if (!isAssignment) return;
Function getReportContent
has 65 lines of code (exceeds 25 allowed). Consider refactoring. Open
function getReportContent(jsonReport, fixedLevels) {
var res = ['<?xml version="1.0" encoding="UTF-8" ?>\n'];
function processError(error) {
var tagName = error.failure ? "failure" : "error";
Similar blocks of code found in 2 locations. Consider refactoring. Open
} else if (/chai(\.js)?/.test(assertion)) {
assertionDescription.src = this.getBaseURL() + "/assertion/chai.js";
this.use(staticFile.bind({
page: "/assertion/chai.js",
path: path.join(path.dirname(require.resolve("chai")), "chai.js")
- 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 81.
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
if (/^expect([\.\-]?js)?$/.test(assertion)) {
assertionDescription.src = this.getBaseURL() + "/assertion/expect.js";
this.use(staticFile.bind({
page: "/assertion/expect.js",
path: path.join(path.dirname(require.resolve("expect.js")), "index.js")
- 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 81.
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 createPhantomExitCb
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
createPhantomExitCb: function (cfg, state, n) {
// Node 0.8 and 0.10 differently handle spawning errors ('exit' vs 'error'), but errors that happened after
// launching the command are both handled in 'exit' callback
return function (code, signal) {
// See http://tldp.org/LDP/abs/html/exitcodes.html and http://stackoverflow.com/a/1535733/
- 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 taskFinished
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
taskFinished: function (event) {
var taskId = event.taskId;
var task = this.campaign.jsonReport.tasks[taskId];
var taskName = task.name;
- 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 readATClasspath
has 52 lines of code (exceeds 25 allowed). Consider refactoring. Open
ATEnvironment.prototype.readATClasspath = function (classpath, callback) {
var classpathInfo = this._classpaths[classpath];
var self = this;
var filePath = null;
if (!classpathInfo) {
Function MochaTestType
has 52 lines of code (exceeds 25 allowed). Consider refactoring. Open
var MochaTestType = function (campaign, inputConfig) {
// Default values for the configuration object
var testConfig = {
files: {
rootDirectory: process.cwd(),
Function TestCampaign
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
var TestCampaign = function (config, parentLogger) {
this.results = config.liveResults ? [] : null;
this.startTime = new Date();
this.campaignNumber = config.campaignNumber;
this.id = createCampaignId(this.startTime);