-
Notifications
You must be signed in to change notification settings - Fork 195
Implement all_linters() wrapper to access all available linters
#1854
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
Changes from all commits
bbdaa67
dd37a75
123c2a5
bffab55
f514cf7
e8d1031
e6047e3
7bf4b20
a180456
88d53e7
79e2319
a0605ad
8da7c64
2a55b7c
c9e38e4
930552a
41ae46a
70166c6
79a8402
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,7 +8,14 @@ | |
| #' @param defaults named list of elements to modify. | ||
| #' @return A modified list of elements, sorted by name. To achieve this sort in a platform-independent way, two | ||
| #' transformations are applied to the names: (1) replace `_` with `0` and (2) convert [tolower()]. | ||
| #' @seealso [linters_with_tags], [linters_with_defaults] for creating linter lists. | ||
| #' | ||
| #' @seealso | ||
| #' - [linters_with_defaults] for basing off lintr's set of default linters. | ||
| #' - [all_linters] for basing off all available linters in lintr. | ||
| #' - [linters_with_tags] for basing off tags attached to linters, possibly across multiple packages. | ||
| #' - [available_linters] to get a data frame of available linters. | ||
| #' - [linters] for a complete list of linters available in lintr. | ||
| #' | ||
| #' @examples | ||
| #' # custom list of undesirable functions: | ||
| #' # remove `sapply` (using `NULL`) | ||
|
|
@@ -65,19 +72,17 @@ modify_defaults <- function(defaults, ...) { | |
| #' | ||
| #' @return A modified list of linters. | ||
| #' @seealso | ||
| #' [linters_with_defaults] for basing off lintr's set of default linters. | ||
| #' [available_linters] to get a data frame of available linters. | ||
| #' [linters] for a complete list of linters available in lintr. | ||
| #' - [linters_with_defaults] for basing off lintr's set of default linters. | ||
| #' - [all_linters] for basing off all available linters in lintr. | ||
| #' - [available_linters] to get a data frame of available linters. | ||
| #' - [linters] for a complete list of linters available in lintr. | ||
| #' | ||
| #' @examples | ||
| #' # `linters_with_defaults()` and `linters_with_tags("default")` are the same: | ||
| #' all.equal(linters_with_defaults(), linters_with_tags("default")) | ||
| #' | ||
| #' # Get all linters useful for package development | ||
| #' linters <- linters_with_tags(tags = "package_development") | ||
| #' names(linters) | ||
| #' | ||
| #' # Get all linters provided by lintr | ||
| #' linters <- linters_with_tags(tags = NULL) | ||
| #' linters <- linters_with_tags(tags = c("package_development", "style")) | ||
| #' names(linters) | ||
| #' | ||
| #' # Get all linters tagged as "default" from lintr and mypkg | ||
|
|
@@ -117,6 +122,23 @@ linters_with_tags <- function(tags, ..., packages = "lintr", exclude_tags = "dep | |
| modify_defaults(..., defaults = tagged_linters) | ||
| } | ||
|
|
||
| #' Create a linter configuration based on all available linters | ||
| #' | ||
| #' @inheritParams linters_with_tags | ||
| #' | ||
| #' @examples | ||
| #' names(all_linters()) | ||
| #' | ||
| #' @seealso | ||
| #' - [linters_with_defaults] for basing off lintr's set of default linters. | ||
| #' - [linters_with_tags] for basing off tags attached to linters, possibly across multiple packages. | ||
| #' - [available_linters] to get a data frame of available linters. | ||
| #' - [linters] for a complete list of linters available in lintr. | ||
| #' @export | ||
| all_linters <- function(packages = "lintr", ...) { | ||
| linters_with_tags(tags = NULL, packages = packages, ...) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What happens in the unlikely case that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It will produce an error: library(lintr)
all_linters(tags = "default")
#> Error in linters_with_tags(tags = NULL, packages = packages, ...): formal argument "tags" matched by multiple actual argumentsCreated on 2022-12-18 with reprex v2.0.2 But I doubt anyone will do this because this assumes that the user has looked at the implementation details for this newly introduced function and figured out that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| } | ||
|
|
||
| #' Create a linter configuration based on defaults | ||
| #' | ||
| #' Make a new list based on \pkg{lintr}'s default linters. | ||
|
|
@@ -148,6 +170,7 @@ linters_with_tags <- function(tags, ..., packages = "lintr", exclude_tags = "dep | |
| #' | ||
| #' @seealso | ||
| #' - [linters_with_tags] for basing off tags attached to linters, possibly across multiple packages. | ||
| #' - [all_linters] for basing off all available linters in lintr. | ||
| #' - [available_linters] to get a data frame of available linters. | ||
| #' - [linters] for a complete list of linters available in lintr. | ||
| #' @export | ||
|
|
@@ -180,6 +203,8 @@ with_defaults <- function(..., default = default_linters) { | |
| linters_with_defaults(..., defaults = default) | ||
| } | ||
|
|
||
| #' @keywords internal | ||
| #' @noRd | ||
| call_linter_factory <- function(linter_factory, linter_name, package) { | ||
| linter <- tryCatch( | ||
| linter_factory(), | ||
|
|
@@ -192,6 +217,8 @@ call_linter_factory <- function(linter_factory, linter_name, package) { | |
| linter | ||
| } | ||
|
|
||
| #' @keywords internal | ||
| #' @noRd | ||
| guess_names <- function(..., missing_index) { | ||
| args <- as.character(eval(substitute(alist(...)[missing_index]))) | ||
| # foo_linter(x=1) => "foo" | ||
|
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.