Repository navigation
Avoid implicit assignments in expectations - #1879
Conversation
Codecov Report
@@ Coverage Diff @@
## main #1879 +/- ##
=======================================
Coverage 98.84% 98.84%
=======================================
Files 112 112
Lines 4857 4857
=======================================
Hits 4801 4801
Misses 56 56 Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
|
I haven't touched the tests for deprecated functions, which also contains some implicit assignment lints. TBH, I think we should |
|
The new warning appearing in tests is unrelated to the current PR. I have created an issue to track this: #1905. |
|
@AshesITR This is ready for a review, btw. Tagging just in case you missed the original review request during the holidays. |
AshesITR
left a comment
There was a problem hiding this comment.
Looks good. Just wondering if we should commit to the brace-syntax from magrittr or grab the result in an extra supressWarnings() for the xml_nodes_to_lints() tests.
The former would not be compatible with the native pipe once we drop support for R versions without it.
Bumping the minimum needed R version to 4.1 should be many years away, so that's not too worrisome. That said, the brace syntax is not too straightforward to reason about, and so maybe it's better to avoid it. Thus, I have removed the brace-syntax, and have instead used temp variables for the tests in question. |
|
|
||
| expect_warning(e2 <- lintr:::load_cache(file = f1, path = d1), "Could not load cache file") | ||
| expect_warning( | ||
| { |
There was a problem hiding this comment.
I found myself ready to suggest nesting the expectations instead & then remembered that's basically what we just undid by removing magrittr :)
Someday we'll depend on R>4.1 & then we can use |>....
In the meantime, there may be some cases where 2-nesting looks fine:
expect_warning(
expect_identical(ls(lintr:::load_cache(file = f1, path = d1), character()),
"Could not load cache file",
fixed = TRUE
)up to you whether / which cases you agree
There was a problem hiding this comment.
TBH, I personally prefer to keep each expectation separate. Nested expectations are much harder to reason about.
Closes #1820