lintr icon indicating copy to clipboard operation
lintr copied to clipboard

Static Code Analysis for R

Results 314 lintr issues
Sort by recently updated
recently updated
newest added

Since R 3.4.0 `utils::hasName()` was added as a convient way of testing the existence of a name i.e. the pattern `"name" %in% names(x)` or for checking the `!is.null(x$abc)` pattern without...

new-linter

Some `lintr` messages show the potential replacement for a linter, e.g. in `any_duplicated_linter`: ``` r library(lintr) lint( text = "any(duplicated(x), na.rm = TRUE)", linters = any_duplicated_linter() ) #> :1:1: warning:...

feature

That's not the only case in mind for `seq_linter()`: ``` microbenchmark(times=100, seq(1, 1e7), seq_len(1e7)) # Unit: nanoseconds # expr min lq mean median uq max neval cld # seq(1, 1e+07)...

feature

Found this edge case quite deep in a package and it's hard to come up with a less convoluted example. `lintr` suggests using `lengths()`: ``` r lintr::lint( text = '...

false-positive

https://github.com/r-lib/lintr/blob/5990da6a347de8b87566b6d7516e307497ce0680/R/regex_subset_linter.R#L4 Just noticed R will start shipping `grepv()` as a shorthand for `grep(ptn, x, value=TRUE)`: https://github.com/r-devel/r-svn/blob/874fa1008e6cb090c7c898c422d703ca0026d600/doc/NEWS.Rd#L39-L40 We can reference that once it makes an R release.

documentation

`lintr::condition_call_linter()` will recommend the addition of `call.` even for custom conditions crafted with `errorCondition()` / `warningCondition()` when these don't support `call.=`. ``` r stop(errorCondition("stop right there!", class = "custom_error_condition")) #>...

I was expecting that the second call here would be faster because it would use cache, but that's not what I see (at least locally). ```r library(lintr) local_dir

feature

``` r library(lintr) lint( text = "ivreg::ivreg(Q ~ P + D | D + F + A, data = Kmenta)", linters = T_and_F_symbol_linter() ) #> :1:31: style: [T_and_F_symbol_linter] Use FALSE...

```r lint('grepl("\\\\^", spec)\n', string_boundary_linter()) # :1:7: warning: [string_boundary_linter] NA Doing so is more readable and more efficient. # grepl("\\^", spec) # ^~~~~ ```

bug
false-positive

I believe this should lint: ``` r lintr::lint(text = "x |> f()", linters = lintr::backport_linter("3.0.0")) ``` Created on 2024-07-22 with [reprex v2.1.1](https://reprex.tidyverse.org)

feature