Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"no-commented-test" false positive #61

Closed
Turbo87 opened this issue Apr 5, 2017 · 5 comments
Closed

"no-commented-test" false positive #61

Turbo87 opened this issue Apr 5, 2017 · 5 comments

Comments

@Turbo87
Copy link
Contributor

Turbo87 commented Apr 5, 2017

// TODO: refactor with a Component test (instead of an Acceptance test)

led to triggering the no-commented-test rule. we should probably check for test( instead of just test.

@platinumazure
Copy link
Owner

Thanks for the issue! Agreed that this is a false positive and a bug.

Unfortunately, the regular expression does check test\s*\( (among other things). Technically, a space can be used between a call expression's callee and the argument parentheses. But now I'll have to come up with something better, maybe involving a parser.

@platinumazure
Copy link
Owner

Hi @Turbo87, sorry for taking so long to get to this.

I have a branch up that might be a pretty good approach (without relying on trying to do a fuzzy parse).

Basically it will only warn if the characters after test( (etc.) meet one of the following criteria:

  • Could be a valid string (i.e., has matching single quotes/double quotes/backticks with content in between, i.e., potential test name)
  • Could be multiple args (contiguous non-space/-right-paren/-comma text, followed by comma with optional space on either side, followed by more text-- multiple words with space and no comma are automatically allowed)

So there will still be a few false positives, but much, much fewer than before... Looking forward to any feedback you might have.

@Krinkle
Copy link
Contributor

Krinkle commented Apr 5, 2021

Ran into another one in QUnit's own code base:

// Run actual test (without context).

Perhaps to improve the signal-noise ratio we could reduce the pattern to only cases where a quote follows the open parenthesis? E.g. extend the pattern by \s*['"]. This in theory could miss a case where a variable name is used, but I think that's perhaps sufficiently rare to be worth the small loss in assistance.

@platinumazure
Copy link
Owner

@Krinkle I like that idea but still want to give users the option either way. How about if we create a new option, defaulting to the current behavior but letting users opt in to the more lenient check? And we can flip the default option value on the next major release.

@platinumazure
Copy link
Owner

I've decided that we can just do the quote check as a non-breaking change (as it will result in fewer warnings).

I'll work on a PR.

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

No branches or pull requests

3 participants