Skip to content
This repository has been archived by the owner on Mar 23, 2024. It is now read-only.

disallowTrailingWhitespace: Fix autofixing whitespace on last line #1978

Closed
wants to merge 1 commit into from

Conversation

lukeapage
Copy link
Contributor

No description provided.

@lukeapage
Copy link
Contributor Author

I'm not sure how coverage is setup because I added lines to a function that clearly is tested, but coveralls is reporting the whole function untested ..
https://coveralls.io/builds/4154698/source?filename=lib%2Ftoken-assert.js#L518

@@ -584,6 +584,14 @@ TokenAssert.prototype.noTrailingSpaces = function(options) {
fixed = true;
}

if (!fixed && precendingToken && precendingToken.type === 'EOF') {
precendingToken = this._file.getPrevToken(precendingToken, { includeWhitespace: true });
if (precendingToken && precendingToken.isWhitespace) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You have 3 tests in outer if and 2 in inner, are you sure you need all of them?
Can you cover it? That's why coveralls reporting about coverage decrease.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no I'm not sure I need them. are you sure I don't? Its the classic push-pull between defensive coding and code coverage. If you know better tell me what to change or a test that checks it. Or alternatively, maybe you prefer my more radical approach in #1981?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, you don't need test precendingToken here if there is no purpose ;-).

I can't get how to break it if you remove precendingToken.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm waiting on making this change to see if the better approach in #1981 will be considered.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants