Skip to content

Commit

Permalink
Merge branch 'master' into equals-na-comment
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelChirico authored Nov 29, 2020
2 parents 45f585f + e48ace4 commit 50ed33a
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
* New `sprintf_linter()` (#544, #578, #624, #625, @renkun-ken, @AshesITR)
* Exclusions specified in the `.lintr` file are now relative to the location of that file
and support excluding entire directories (#158, #438, @AshesITR)
* `object_name_linter()` now excludes special R hook functions such as `.onLoad` (#500, #614, @AshesITR)
* `equals_na_linter()` now lints `x != NA` and `NA == x`, and skips usages in comments (#545, @michaelchirico)

# lintr 2.0.1
Expand Down
18 changes: 17 additions & 1 deletion R/object_name_linters.R
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,8 @@ make_object_linter <- function(fun) {
keep_indices <- which(
!is_operator(names) &
!is_known_generic(names) &
!is_base_function(names)
!is_base_function(names) &
!is_special_function(names)
)

lapply(
Expand Down Expand Up @@ -239,6 +240,21 @@ is_base_function <- function(x) {
x %in% base_funs
}

# see ?".onLoad" and ?"Startup"
special_funs <- c(
".onLoad",
".onAttach",
".onUnload",
".onDetach",
".Last.lib",
".First",
".Last"
)

is_special_function <- function(x) {
x %in% special_funs
}

object_lint <- function(source_file, token, message, type) {
Lint(
filename = source_file$filename,
Expand Down
2 changes: 1 addition & 1 deletion R/zzz.R
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ default_settings <- NULL

settings <- NULL

.onLoad <- function(libname, pkgname) { # nolint
.onLoad <- function(libname, pkgname) {
op <- options()
op.lintr <- list(
lintr.linter_file = ".lintr"
Expand Down

0 comments on commit 50ed33a

Please sign in to comment.