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

flagging commented arguments of a function being tested #386

Closed
IndrajeetPatil opened this issue May 25, 2019 · 2 comments · Fixed by #1419
Closed

flagging commented arguments of a function being tested #386

IndrajeetPatil opened this issue May 25, 2019 · 2 comments · Fixed by #1419
Labels
feature a feature request or enhancement help wanted ❤️ we'd love your help!

Comments

@IndrajeetPatil
Copy link
Collaborator

If a line of code is commented, then lintr produces a lint of type

Commented code should be removed.

Example of this would be the following line of code-

# testthat::expect_equal(broom_df1$p.value, tidy_df1$p.value, tolerance = 0.001)

Does it also make sense to produce a lint of type

Commented arguments should be removed.

For example, here the second argument is commented out-

 d <- t.test(
        x = dplyr::starwars$height,
       # var.equal = TRUE,
        conf.level = .99,
        mu = 175
      )

testthat::expect_equal(d$statistic[[1]], -0.1661693, tolerance = 0.001)

This can typically happen when interactively writing tests and it will be nice for lintr to highlight such vestiges.

@jimhester
Copy link
Member

jimhester commented Sep 24, 2019

The issue is it is harder to determine if a line is an argument, particularly without introducing false positives.

I don't have the time to spend on it, but if you or someone else wants to try implementing a PR for it that addressed the detection and false positive issues above I would review it.

@jimhester jimhester added feature a feature request or enhancement help wanted ❤️ we'd love your help! labels Sep 24, 2019
@AshesITR
Copy link
Collaborator

Maybe we could extend commented code linter to also lint if it encounters a comment with a trailing comma whose preceding text is parsable().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature a feature request or enhancement help wanted ❤️ we'd love your help!
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants