Skip to content

Commit 3647673

Browse files
authoredApr 23, 2020
Minor lint tweaks (#285)
1 parent ff21930 commit 3647673

File tree

4 files changed

+45
-29
lines changed

4 files changed

+45
-29
lines changed
 

‎lib/convertLcovToCoveralls.js

+14-5
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,23 @@ const logger = require('./logger')();
77

88
const detailsToCoverage = (length, details) => {
99
const coverage = new Array(length);
10+
1011
details.forEach(obj => {
1112
coverage[obj.line - 1] = obj.hit;
1213
});
14+
1315
return coverage;
1416
};
1517

1618
const detailsToBranches = details => {
1719
const branches = [];
20+
1821
details.forEach(obj => {
1922
['line', 'block', 'branch', 'taken'].forEach(key => {
2023
branches.push(obj[key] || 0);
2124
});
2225
});
26+
2327
return branches;
2428
};
2529

@@ -67,7 +71,7 @@ const convertLcovToCoveralls = (input, options, cb) => {
6771
if (options.flag_name) {
6872
postJson.flag_name = options.flag_name;
6973
}
70-
74+
7175
if (options.git) {
7276
postJson.git = options.git;
7377
}
@@ -79,11 +83,11 @@ const convertLcovToCoveralls = (input, options, cb) => {
7983
if (options.service_name) {
8084
postJson.service_name = options.service_name;
8185
}
82-
86+
8387
if (options.service_number) {
8488
postJson.service_number = options.service_number;
8589
}
86-
90+
8791
if (options.service_job_id) {
8892
postJson.service_job_id = options.service_job_id;
8993
}
@@ -107,6 +111,7 @@ const convertLcovToCoveralls = (input, options, cb) => {
107111
postJson.source_files.push(convertLcovFileObject(file, filepath));
108112
}
109113
});
114+
110115
return cb(null, postJson);
111116
});
112117
};
@@ -134,7 +139,7 @@ module.exports = convertLcovToCoveralls;
134139
135140
example output from lcov parser:
136141
137-
[
142+
[
138143
{
139144
"file": "index.js",
140145
"lines": {
@@ -156,6 +161,10 @@ example output from lcov parser:
156161
{
157162
"line": 5,
158163
"hit": 1
159-
},
164+
}
165+
]
166+
}
167+
}
168+
]
160169
161170
*/

‎lib/getOptions.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ const getBaseOptions = cb => {
180180
if (coveralls_yaml_conf.repo_token) {
181181
options.repo_token = coveralls_yaml_conf.repo_token;
182182
}
183+
183184
if (coveralls_yaml_conf.service_name) {
184185
options.service_name = coveralls_yaml_conf.service_name;
185186
}
@@ -190,7 +191,7 @@ const getBaseOptions = cb => {
190191
options.repo_token = process.env.COVERALLS_REPO_TOKEN;
191192
}
192193

193-
if ('travis-pro' === options.service_name && !options.repo_token) {
194+
if (options.service_name === 'travis-pro' && !options.repo_token) {
194195
logger.warn('Repo token could not be determined. Continuing without it. ' +
195196
'This is necessary for private repos only, so may not be an issue at all.');
196197
}

‎test/convertLcovToCoveralls.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ describe('convertLcovToCoveralls', () => {
9393
fs.existsSync = originalExistsSync;
9494

9595
should.not.exist(err);
96-
output.source_files[0].name.should.equal(path.posix.join("svgo", "config.js"));
96+
output.source_files[0].name.should.equal(path.posix.join('svgo', 'config.js'));
9797
done();
9898
});
9999
});

‎test/getOptions.js

+28-22
Original file line numberDiff line numberDiff line change
@@ -134,10 +134,10 @@ describe('getOptions', () => {
134134
it('should set service_name if it exists', done => {
135135
testServiceName(getOptions, done);
136136
});
137-
it ("should set service_number if it exists", done => {
137+
it('should set service_number if it exists', done => {
138138
testServiceNumber(getOptions, done);
139139
});
140-
it("should set service_pull_request if it exists", done => {
140+
it('should set service_pull_request if it exists', done => {
141141
testServicePullRequest(getOptions, done);
142142
});
143143
it('should set service_name and service_job_id if it\'s running on travis-ci', done => {
@@ -164,7 +164,7 @@ describe('getOptions', () => {
164164
it('should set service_name and service_job_id if it\'s running on Gitlab', done => {
165165
testGitlab(getOptions, done);
166166
});
167-
it ("should set service_name and service_job_id if it's running on AppVeyor", done => {
167+
it('should set service_name and service_job_id if it\'s running on AppVeyor', done => {
168168
testAppVeyor(getOptions, done);
169169
});
170170
it('should set service_name and service_job_id if it\'s running via Surf', done => {
@@ -565,26 +565,32 @@ const testGitlab = (sut, done) => {
565565
});
566566
};
567567

568-
const testAppVeyor = function(sut, done) {
568+
const testAppVeyor = (sut, done) => {
569569
process.env.APPVEYOR = true;
570-
process.env.APPVEYOR_BUILD_ID = "1234";
571-
process.env.APPVEYOR_BUILD_NUMBER = "5678";
572-
process.env.APPVEYOR_REPO_COMMIT = "e3e3e3e3e3e3e3e3e";
573-
process.env.APPVEYOR_REPO_BRANCH = "feature";
574-
575-
sut(function(err, options){
576-
options.service_name.should.equal("appveyor");
577-
options.service_job_id.should.equal("1234");
578-
options.service_job_number.should.equal("5678");
579-
options.git.should.eql({ head:
580-
{ id: 'e3e3e3e3e3e3e3e3e',
581-
author_name: 'Unknown Author',
582-
author_email: '',
583-
committer_name: 'Unknown Committer',
584-
committer_email: '',
585-
message: 'Unknown Commit Message' },
586-
branch: 'feature',
587-
remotes: [] });
570+
process.env.APPVEYOR_BUILD_ID = '1234';
571+
process.env.APPVEYOR_BUILD_NUMBER = '5678';
572+
process.env.APPVEYOR_REPO_COMMIT = 'e3e3e3e3e3e3e3e3e';
573+
process.env.APPVEYOR_REPO_BRANCH = 'feature';
574+
575+
const git = {
576+
head: {
577+
id: 'e3e3e3e3e3e3e3e3e',
578+
author_name: 'Unknown Author',
579+
author_email: '',
580+
committer_name: 'Unknown Committer',
581+
committer_email: '',
582+
message: 'Unknown Commit Message'
583+
},
584+
branch: 'feature',
585+
remotes: []
586+
};
587+
588+
sut((err, options) => {
589+
should.not.exist(err);
590+
options.service_name.should.equal('appveyor');
591+
options.service_job_id.should.equal('1234');
592+
options.service_job_number.should.equal('5678');
593+
options.git.should.eql(git);
588594
done();
589595
});
590596
};

0 commit comments

Comments
 (0)
Please sign in to comment.