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

Catch consecutive calls to assert_that in renamed consecutive_asserion_linter #1940

Merged
merged 7 commits into from
Apr 4, 2023

Conversation

MichaelChirico
Copy link
Collaborator

Closes #1604

@codecov-commenter
Copy link

codecov-commenter commented Mar 29, 2023

Codecov Report

Merging #1940 (47f0585) into main (ddc1b71) will increase coverage by 0.00%.
The diff coverage is 100.00%.

❗ Current head 47f0585 differs from pull request most recent head 5a302fe. Consider uploading reports for the commit 5a302fe to get more accurate results

@@           Coverage Diff           @@
##             main    #1940   +/-   ##
=======================================
  Coverage   98.94%   98.95%           
=======================================
  Files         113      113           
  Lines        4939     4953   +14     
=======================================
+ Hits         4887     4901   +14     
  Misses         52       52           
Impacted Files Coverage Δ
R/utils.R 98.29% <ø> (ø)
R/consecutive_assertion_linter.R 100.00% <100.00%> (ø)
R/lintr-deprecated.R 100.00% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

#' @seealso [linters] for a complete list of linters available in lintr.
#' @export
consecutive_stopifnot_linter <- function() {
# match on the expr, not the SYMBOL_FUNCTION_CALL, to ensure
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

NB: this comment intentionally removed as the logic now lints on cases like:

assert_that(x)
assertthat::assert_that(y)

Technically it would also lint on

SomePkg::stopifnot(x)
base::stopifnot(y)

But that seems unlikely in practice. We could extend the logic to something like "lint if the namespaces are equal or both absent, or if only present once, but not if both present and not equal" but that seems like overkill.

Copy link
Collaborator

@IndrajeetPatil IndrajeetPatil left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks!

@IndrajeetPatil IndrajeetPatil merged commit 020c4b6 into main Apr 4, 2023
@IndrajeetPatil IndrajeetPatil deleted the consec branch April 4, 2023 05:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

consecutive_stopifnot_linter should include assert_that (and hence be renamed)
3 participants