Skip to content

Commit b3dcf92

Browse files
committed
Name the assertion label separately from the value
SonarQube read `assert.equal(String(args[0]), nr, nr)` as a likely copy-paste slip, which is fair: the same variable served as both the expected value and the failure message. Each loop now builds a label once and uses it for the messages, leaving the value argument on its own.
1 parent 98f9a81 commit b3dcf92

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

‎tests/unit/ParseCommandLine.test.js‎

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -257,24 +257,26 @@ describe("Unittests for ParseCommandLine.js", () => {
257257
"9007199254740993"
258258
];
259259
for (const nr of tooLargeIntegers) {
260+
const label = "value " + nr;
260261
args = [];
261262
params = {};
262263
result = ParseCommandLine.parseCommandLine(nr, args, params);
263-
assert.equal(result, "Integer argument is too large to be sent exactly", nr);
264-
assert.equal(args.length, 0, nr);
264+
assert.equal(result, "Integer argument is too large to be sent exactly", label);
265+
assert.equal(args.length, 0, label);
265266
}
266267

267268
// The largest exact integer is still accepted, and a real jobid is matched
268269
// as a string before the integer branch, so it round-trips unchanged.
269270
const exactValues = ["9007199254740991", "20180814033130818988"];
270271
for (const nr of exactValues) {
272+
const label = "value " + nr;
271273
args = [];
272274
params = {};
273275
result = ParseCommandLine.parseCommandLine(nr, args, params);
274-
assert.isNull(result, nr);
275-
assert.equal(args.length, 1, nr);
276-
assert.equal(String(args[0]), nr, nr);
277-
assert.equal(Object.keys(params).length, 0, nr);
276+
assert.isNull(result, label);
277+
assert.equal(args.length, 1, label);
278+
assert.equal(String(args[0]), nr, label);
279+
assert.equal(Object.keys(params).length, 0, label);
278280
}
279281

280282
// FLOAT

0 commit comments

Comments
 (0)