
When an include is not surrounded by empty lines, its content is inlined on the same line as the adjacent content. That can lead to broken tags and other display issues. This PR fixes all such includes and introduces a validation step that forbids introducing the same problem again.
83 lines
1.9 KiB
Plaintext
83 lines
1.9 KiB
Plaintext
== Why is this an issue?
|
|
|
|
Many assertions compare two objects or properties of these objects. Passing twice the same argument is likely to be a bug due to developer's carelessness.
|
|
|
|
|
|
This rule raises an issue when a Chai assertion is given twice the same argument.
|
|
|
|
=== Noncompliant code example
|
|
|
|
[source,javascript]
|
|
----
|
|
const assert = require('chai').assert;
|
|
|
|
describe("test the same object", function() {
|
|
it("uses chai 'assert'", function() {
|
|
const expected = '1'
|
|
const actual = (1).toString()
|
|
assert.equal(actual, actual); // Noncompliant
|
|
});
|
|
});
|
|
----
|
|
|
|
=== Compliant solution
|
|
|
|
[source,javascript]
|
|
----
|
|
const assert = require('chai').assert;
|
|
|
|
describe("test the same object", function() {
|
|
it("uses chai 'assert'", function() {
|
|
const expected = '1'
|
|
const actual = (1).toString()
|
|
assert.equal(actual, expected);
|
|
});
|
|
});
|
|
----
|
|
|
|
ifdef::env-github,rspecator-view[]
|
|
|
|
'''
|
|
== Implementation Specification
|
|
(visible only on this page)
|
|
|
|
=== Message
|
|
|
|
Replace this argument or its duplicate at position [X].
|
|
|
|
|
|
=== Highlighting
|
|
|
|
If the same argument is passed twice to the same function
|
|
|
|
* Primary: the first expression occurence
|
|
message: 'Refactor this assertion to not pass the same argument twice.'
|
|
|
|
* Secondary: the second expression occurence
|
|
message: 'Argument [POSITION] has the same value.'
|
|
|
|
|
|
If the assertion is of the form ``++expect(obj).a(obj, other1)++``
|
|
|
|
* Primary: the duplicate argument.
|
|
message: 'Refactor this assertion to not pass the same value as in "expect()".'
|
|
|
|
* Secondary: the argument of "expect".
|
|
|
|
If the assertion is of the form ``++obj.should.be.closeTo(obj, other1, other2)++``
|
|
|
|
* Primary: the duplicate argument.
|
|
message: Refactor this assertion to not use the same value as the one asserted by "should".
|
|
|
|
* Secondary: the variable on which "should" is called.
|
|
no message
|
|
|
|
|
|
'''
|
|
== Comments And Links
|
|
(visible only on this page)
|
|
|
|
include::../comments-and-links.adoc[]
|
|
|
|
endif::env-github,rspecator-view[]
|