Skip to content

allow_scoped in implicit_assignment_linter() for scope-limited assignments - #2171

Merged
MichaelChirico merged 24 commits into
mainfrom
implicit-scoped
Sep 15, 2023
Merged

MichaelChirico merged 24 commits into
mainfrom
implicit-scoped

Conversation

@MichaelChirico

@MichaelChirico MichaelChirico commented Sep 14, 2023 •

Copy link
Copy Markdown
Collaborator

Closes #2015.

@MichaelChirico
MichaelChirico marked this pull request as ready for review September 14, 2023 23:02
@codecov-commenter

codecov-commenter commented Sep 14, 2023 •

Copy link
Copy Markdown

Codecov Report

Merging #2171 (1801eb9) into main (4c88419) will increase coverage by 0.00%.
Report is 1 commits behind head on main.
The diff coverage is 100.00%.

❗ Current head 1801eb9 differs from pull request most recent head ead4058. Consider uploading reports for the commit ead4058 to get more accurate results

@@           Coverage Diff           @@
##             main    #2171   +/-   ##
=======================================
  Coverage   99.64%   99.64%           
=======================================
  Files         112      112           
  Lines        5124     5129    +5     
=======================================
+ Hits         5106     5111    +5     
  Misses         18       18           
Files Changed Coverage Δ
R/implicit_assignment_linter.R 100.00% <100.00%> (ø)

@MichaelChirico

MichaelChirico commented Sep 14, 2023 •

Copy link
Copy Markdown
Collaborator Author

Ran this on my local github directory.

Compared to allow_scoped = FALSE (4407 lints), allow_scoped = TRUE has 3661 lints (746=17% of lints removed).

Here is a sample of 10 that were eliminated (some would also be skipped under allow_lazy = TRUE):

Details

repro code

library(data.table)

pkgload::load_all() # from this branch
old = implicit_assignment_linter()
new = implicit_assignment_linter(allow_scoped=TRUE)
attr(new, "name") = "implicit_assignment_linter_allow_scoped"
x = as.data.table(lint_dir("..", list(old, new)))

compare <- dcast(x, filename + line_number + column_number ~ linter, value.var = "line")
not_scoped <- compare[
  !is.na(implicit_assignment_linter) & is.na(implicit_assignment_linter_allow_scoped)
]
cat(sprintf(
  "Compared to `allow_scoped = FALSE` (%d lints), `allow_scoped = TRUE` has %d lints (%d=%.0f%% of lints removed).\n",
  nrow(compare), nrow(compare) - nrow(not_scoped), nrow(not_scoped), 100 * nrow(not_scoped) / nrow(compare)
))
not_scoped[sample(.N, 5)]

Comment thread R/implicit_assignment_linter.R Resolved
@MichaelChirico
MichaelChirico merged commit 0d528cd into main Sep 15, 2023
@MichaelChirico
MichaelChirico deleted the implicit-scoped branch September 15, 2023 05:23
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.

New argument for implicit_assignment_linter to skip "scoped" usages

3 participants