diff --git a/NEWS.md b/NEWS.md index dcc6b9aac..3195fb488 100644 --- a/NEWS.md +++ b/NEWS.md @@ -200,6 +200,9 @@ * `object_usage_linter()` gives a more helpful warning when a `glue()` expression fails to evaluate (#1985, @MichaelChirico) +* The documentation of `object_name_linter()` now describes how `"symbols"` +works when passed to the `styles` parameter (#1924, @hedsnz). + # lintr 3.0.2 * Fix test to avoid leaving behind cache files in the global cache directory. diff --git a/R/object_name_linter.R b/R/object_name_linter.R index a81d399bc..10674136b 100644 --- a/R/object_name_linter.R +++ b/R/object_name_linter.R @@ -45,7 +45,12 @@ object_name_xpath <- local({ #' #' @param styles A subset of #' \Sexpr[stage=render, results=rd]{lintr:::regexes_rd}. A name should -#' match at least one of these styles. +#' match at least one of these styles. The `"symbols"` style refers to +#' names containing *only* non-alphanumeric characters; e.g., defining `%+%` +#' from ggplot2 or `%>%` from magrittr would not generate lint markers, +#' whereas `%m+%` from lubridate (containing both alphanumeric *and* +#' non-alphanumeric characters) would. +#' #' @param regexes A (possibly named) character vector specifying a custom naming convention. #' If named, the names will be used in the lint message. Otherwise, the regexes enclosed by `/` will be used in the #' lint message. diff --git a/man/object_name_linter.Rd b/man/object_name_linter.Rd index ad5e9ebb4..63d8640c6 100644 --- a/man/object_name_linter.Rd +++ b/man/object_name_linter.Rd @@ -9,7 +9,11 @@ object_name_linter(styles = c("snake_case", "symbols"), regexes = character()) \arguments{ \item{styles}{A subset of \Sexpr[stage=render, results=rd]{lintr:::regexes_rd}. A name should -match at least one of these styles.} +match at least one of these styles. The \code{"symbols"} style refers to +names containing \emph{only} non-alphanumeric characters; e.g., defining \verb{\%+\%} +from ggplot2 or \verb{\%>\%} from magrittr would not generate lint markers, +whereas \verb{\%m+\%} from lubridate (containing both alphanumeric \emph{and} +non-alphanumeric characters) would.} \item{regexes}{A (possibly named) character vector specifying a custom naming convention. If named, the names will be used in the lint message. Otherwise, the regexes enclosed by \code{/} will be used in the