Skip to content
This repository was archived by the owner on Sep 16, 2021. It is now read-only.

Commit d9e950d

Browse files
committed
Configure Code Climate
I added the eslintrc from the ESLint engine and addressed the simple ESLint issues.
1 parent 68dce39 commit d9e950d

9 files changed

+453
-26
lines changed

.codeclimate.yml

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
engines:
3+
requiresafe:
4+
enabled: true
5+
duplication:
6+
enabled: true
7+
config:
8+
languages:
9+
- javascript
10+
eslint:
11+
enabled: true
12+
fixme:
13+
enabled: true
14+
ratings:
15+
paths:
16+
- "**.js"
17+
- "npm-shrinkwrap.json"
18+
exclude_paths:
19+
- node_modules/**/*
20+
- test/**/*

.eslintignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
**/*{.,-}min.js

.eslintrc

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"env": {
3+
"node": true
4+
},
5+
"rules": {
6+
"brace-style": [2, "1tbs", { "allowSingleLine": true }],
7+
"comma-dangle": [2, "never"],
8+
"comma-style": [2, "first", { exceptions: {ArrayExpression: true, ObjectExpression: true} }],
9+
"complexity": [2, 6],
10+
"curly": 2,
11+
"eqeqeq": [2, "allow-null"],
12+
"max-statements": [2, 30],
13+
"no-shadow-restricted-names": 2,
14+
"no-undef": 2,
15+
"no-use-before-define": 2,
16+
"radix": 2,
17+
"semi": 2,
18+
"space-infix-ops": 2,
19+
"strict": 0
20+
},
21+
"globals": {
22+
}
23+
}

bin/codeclimate.js

+5-4
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,22 @@ process.stdin.on("data", function(chunk) {
1414

1515
var repo_token = process.env.CODECLIMATE_REPO_TOKEN;
1616

17-
if(repo_token == undefined || repo_token.trim() == "") {
17+
if(repo_token === undefined || repo_token.trim() === "") {
1818
console.error("No CODECLIMATE_REPO_TOKEN found. A CODECLIMATE_REPO_TOKEN must be specified as an environment variable.");
1919
process.exit(1);
2020
}
2121

2222
process.stdin.on("end", function() {
23-
formatter = new Formatter()
23+
var formatter = new Formatter();
24+
2425
formatter.format(input, function(err, json) {
2526
if (err) {
2627
console.error("A problem occurred parsing the lcov data", err);
2728
} else {
28-
if (process.env.CC_OUTPUT == "stdout") {
29+
if (process.env.CC_OUTPUT === "stdout") {
2930
console.log(json);
3031
} else {
31-
json['repo_token'] = repo_token
32+
json['repo_token'] = repo_token;
3233
client.postJson(json);
3334
}
3435
}

ci_info.js

+9-9
Original file line numberDiff line numberDiff line change
@@ -29,47 +29,47 @@ module.exports = {
2929
build_url: env.BUILD_URL,
3030
branch: env.GIT_BRANCH,
3131
commit_sha: env.GIT_COMMIT
32-
}
32+
};
3333
} else if (env.TDDIUM) {
3434
return {
3535
name: "tddium",
3636
build_identifier: env.TDDIUM_SESSION_ID,
3737
worker_id: env.TDDIUM_TID
38-
}
38+
};
3939
} else if (env.WERCKER) {
4040
return {
4141
name: "wercker",
4242
build_identifier: env.WERCKER_BUILD_ID,
4343
build_url: env.WERCKER_BUILD_URL,
4444
branch: env.WERCKER_GIT_BRANCH,
4545
commit_sha: env.WERCKER_GIT_COMMIT
46-
}
46+
};
4747
} else if (env.CI_NAME && env.CI_NAME.match(/codeship/i)) {
4848
return {
4949
name: "codeship",
5050
build_identifier: env.CI_BUILD_NUMBER,
5151
build_url: env.CI_BUILD_URL,
5252
branch: env.CI_BRANCH,
53-
commit_sha: env.CI_COMMIT_ID,
54-
}
53+
commit_sha: env.CI_COMMIT_ID
54+
};
5555
} else if (env.APPVEYOR) {
5656
return {
5757
name: "appveyor",
5858
build_identifier: env.APPVEYOR_BUILD_NUMBER,
5959
branch: env.APPVEYOR_REPO_BRANCH,
6060
commit_sha: env.APPVEYOR_REPO_COMMIT,
61-
pull_request: env.APPVEYOR_PULL_REQUEST_NUMBER,
62-
}
61+
pull_request: env.APPVEYOR_PULL_REQUEST_NUMBER
62+
};
6363
} else if (env.BUILDKITE) {
6464
return {
6565
name: "buildkite",
6666
build_identifier: env.BUILDKITE_BUILD_ID,
6767
build_url: env.BUILDKITE_BUILD_URL,
6868
branch: env.BUILDKITE_BRANCH,
6969
commit_sha: env.BUILDKITE_COMMIT
70-
}
70+
};
7171
} else {
7272
return {};
7373
}
7474
}
75-
}
75+
};

formatter.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ function Formatter(options) {
1212

1313
Formatter.prototype.rootDirectory = function() {
1414
return this.options.rootDirectory || process.cwd();
15-
}
15+
};
1616

1717
Formatter.prototype.format = function(lcovData, callback) {
1818
var self = this;
@@ -27,7 +27,7 @@ Formatter.prototype.format = function(lcovData, callback) {
2727
package_version: pjson.version
2828
},
2929
ci_service: ci.getInfo()
30-
}
30+
};
3131
async.parallel({
3232
head: git.head,
3333
branch: git.branch,
@@ -41,11 +41,11 @@ Formatter.prototype.format = function(lcovData, callback) {
4141
head: results.head,
4242
branch: results.branch,
4343
committed_at: results.committed_at
44-
}
44+
};
4545
return callback(parseError, result);
4646
});
4747
});
48-
}
48+
};
4949

5050
Formatter.prototype.sourceFiles = function(data) {
5151
var source_files = [];
@@ -62,14 +62,14 @@ Formatter.prototype.sourceFiles = function(data) {
6262
throw e;
6363
}
6464
}
65-
var numLines = content.split("\n").size
65+
var numLines = content.split("\n").size;
6666

6767
var coverage = new Array(numLines);
6868
coverage.forEach(function(elem, index, arr) {
6969
arr[index] = null;
7070
});
7171
elem.lines.details.forEach(function(lineDetail) {
72-
coverage[lineDetail.line - 1] = lineDetail.hit
72+
coverage[lineDetail.line - 1] = lineDetail.hit;
7373
});
7474

7575
var fileName = path.relative(self.rootDirectory(), elem.file);
@@ -84,6 +84,6 @@ Formatter.prototype.sourceFiles = function(data) {
8484
});
8585
});
8686
return source_files;
87-
}
87+
};
8888

8989
module.exports = Formatter;

git_info.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ module.exports = {
1414
var result = null;
1515
var timestamp = null;
1616
if (stdout) {
17-
timestamp = parseInt(stdout);
18-
if (!isNaN(timestamp) && timestamp != 0) {
17+
timestamp = parseInt(stdout, 10);
18+
if (!isNaN(timestamp) && timestamp !== 0) {
1919
result = timestamp;
2020
}
2121
}
@@ -29,7 +29,7 @@ module.exports = {
2929
if (stdout) {
3030
var branches = stdout.split("\n");
3131
branches.forEach(function(val) {
32-
if(val.charAt(0) == "*") {
32+
if(val.charAt(0) === "*") {
3333
returnBranch = val;
3434
}
3535
});
@@ -49,4 +49,4 @@ module.exports = {
4949
return shasum.digest("hex");
5050
}
5151

52-
}
52+
};

http_client.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ if (proxy) {
2222

2323
var postJson = function(data) {
2424

25-
parts = url.parse(options.url);
25+
var parts = url.parse(options.url);
2626

2727
options.body = JSON.stringify(data);
2828
console.log("Sending test coverage results to " + parts.host + " ...");
@@ -33,7 +33,7 @@ var postJson = function(data) {
3333
if (response) {
3434
if (response.statusCode >= 200 && response.statusCode < 300) {
3535
console.log("Test coverage data sent.");
36-
} else if (response.statusCode == 401) {
36+
} else if (response.statusCode === 401) {
3737
console.log("An invalid CODECLIMATE_REPO_TOKEN repo token was specified.");
3838
} else {
3939
console.log("Status code: " + response.statusCode);

0 commit comments

Comments
 (0)