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

assignment_linter(allow_trailing = FALSE) fails when comment in brace #1701

Closed
ashbaldry opened this issue Oct 13, 2022 · 0 comments · Fixed by #1702
Closed

assignment_linter(allow_trailing = FALSE) fails when comment in brace #1701

ashbaldry opened this issue Oct 13, 2022 · 0 comments · Fixed by #1702
Labels
false-positive code that shouldn't lint, but does

Comments

@ashbaldry
Copy link
Contributor

I have found an issue with the new allow_trailing argument for assignment_linter where if there is a comment somewhere in a set of braces, then it will flag all of the assignments in the braces

text <- 'testthat::test_that("app ui", {
  ui <- appUI()
  golem::expect_shinytaglist(ui)
  # Check that formals have not been removed
  fmls <- formals(appUI)
    
  for (i in "request") {
    testthat::expect_true(i %in% names(fmls))
  }
})

testthat::test_that("app server", {
  server <- appServer
  testthat::expect_type(server, "closure")
  # Check that formals have not been removed
  fmls <- formals(appServer)
  for (i in c("input", "output", "session")) {
    testthat::expect_true(i %in% names(fmls))
  }
})'

lint(
  text = text,
  linters = assignment_linter(allow_trailing = FALSE)
)

Expected: no lints
Actual: 4 lints

<text>:2:6: style: [assignment_linter] Assignment <- should not be trailing at end of line
  ui <- appUI()
     ^~
<text>:5:8: style: [assignment_linter] Assignment <- should not be trailing at end of line
  fmls <- formals(appUI)
       ^~
<text>:13:10: style: [assignment_linter] Assignment <- should not be trailing at end of line
  server <- appServer
         ^~
<text>:16:8: style: [assignment_linter] Assignment <- should not be trailing at end of line
  fmls <- formals(appServer)
       ^~
@MichaelChirico MichaelChirico added the false-positive code that shouldn't lint, but does label Oct 13, 2022
@MichaelChirico MichaelChirico added this to the 3.0.2 milestone Oct 13, 2022
@MichaelChirico MichaelChirico modified the milestones: 3.0.3, 3.1.0 Mar 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
false-positive code that shouldn't lint, but does
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants