From 887de4f869436603ce373532fdfd954829235628 Mon Sep 17 00:00:00 2001 From: AshesITR Date: Mon, 18 Dec 2023 21:32:22 +0000 Subject: [PATCH] =?UTF-8?q?Deploying=20to=20gh-pages=20from=20@=20r-lib/li?= =?UTF-8?q?ntr@033c0d98486c743e442b674b72c464e57aa7ca2f=20=F0=9F=9A=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dev/articles/creating_linters.html | 2 +- dev/articles/lintr.html | 17 ++++----- dev/news/index.html | 4 +- dev/pkgdown.yml | 2 +- dev/reference/all_linters.html | 10 ++--- dev/reference/best_practices_linters.html | 2 +- dev/reference/deprecated_linters.html | 1 + dev/reference/get_r_string.html | 4 +- dev/reference/get_source_expressions.html | 2 +- dev/reference/ids_with_token.html | 2 +- dev/reference/index.html | 5 --- dev/reference/is_lint_level.html | 2 +- dev/reference/lint.html | 2 +- dev/reference/linters.html | 7 ++-- dev/reference/linters_with_defaults.html | 2 +- dev/reference/lintr-deprecated.html | 2 + dev/reference/readability_linters.html | 1 - .../trailing_blank_lines_linter.html | 8 ++-- dev/reference/unnecessary_nesting_linter.html | 38 ++++++++++++++++++- dev/search.json | 2 +- dev/sitemap.xml | 3 -- 21 files changed, 74 insertions(+), 44 deletions(-) diff --git a/dev/articles/creating_linters.html b/dev/articles/creating_linters.html index 8b7c1e968..18b1088a9 100644 --- a/dev/articles/creating_linters.html +++ b/dev/articles/creating_linters.html @@ -87,7 +87,7 @@

lintr maintainers

-

2023-12-16

+

2023-12-18

Source: vignettes/creating_linters.Rmd
creating_linters.Rmd
diff --git a/dev/articles/lintr.html b/dev/articles/lintr.html index 434d7624a..a79ef60e3 100644 --- a/dev/articles/lintr.html +++ b/dev/articles/lintr.html @@ -527,10 +527,9 @@

Customizing active linters#> [61] "spaces_left_parentheses_linter" "stopifnot_all_linter" #> [63] "string_boundary_linter" "system_file_linter" #> [65] "T_and_F_symbol_linter" "unnecessary_concatenation_linter" -#> [67] "unnecessary_lambda_linter" "unnecessary_nested_if_linter" -#> [69] "unnecessary_nesting_linter" "unnecessary_placeholder_linter" -#> [71] "unreachable_code_linter" "which_grepl_linter" -#> [73] "yoda_test_linter" +#> [67] "unnecessary_lambda_linter" "unnecessary_nesting_linter" +#> [69] "unnecessary_placeholder_linter" "unreachable_code_linter" +#> [71] "which_grepl_linter" "yoda_test_linter"

You can include tag-based linters in the configuration file, and customize them further:

+#> [105] "unnecessary_lambda_linter" "unnecessary_nesting_linter" +#> [107] "unnecessary_placeholder_linter" "unreachable_code_linter" +#> [109] "unused_import_linter" "vector_logic_linter" +#> [111] "which_grepl_linter" "whitespace_linter" +#> [113] "yoda_test_linter"

If you want to use all available linters, you can include this in your .lintr file:

linters: all_linters()
diff --git a/dev/news/index.html b/dev/news/index.html index 6c55317f2..e98ecde14 100644 --- a/dev/news/index.html +++ b/dev/news/index.html @@ -82,6 +82,8 @@

Deprecations & b
  • Adjusted various lint messages for consistency in readability (#1330, @MichaelChirico). In general, we favor lint messages to be phrased like “Action, reason” to but the “what” piece of the message front-and-center. This may be a breaking change for code that tests the specific phrasing of lints.
  • extraction_operator_linter() is deprecated. Although switching from $ to [[ has some robustness benefits for package code, it can lead to non-idiomatic code in many contexts (e.g. R6 classes, Shiny applications, etc.) (#2409, @IndrajeetPatil). To enable the detection of the $ operator for extraction through partial matching, use options(warnPartialMatchDollar = TRUE).
  • +
  • +unnecessary_nested_if_linter() is deprecated and subsumed into the new/more general unnecessary_nesting_linter().
  • Bug fixes

    @@ -461,7 +463,7 @@

    New linters

    unnecessary_placeholder_linter() for identifying where usage of the {magrittr} placeholder . could be omitted (@MichaelChirico)

  • routine_registration_linter() for identifying native routines that don’t use registration (useDynLib in the NAMESPACE; @MichaelChirico)

  • indentation_linter() for checking that the indentation conforms to 2-space Tidyverse-style (@AshesITR and @dgkf, #1411, #1792, #1898).

  • -
  • unnecessary_nested_if_linter() for checking unnecessary nested if statements where a single if statement with appropriate conditional expression would suffice (@IndrajeetPatil and @AshesITR, #1778).

  • +
  • unnecessary_nested_if_linter() for checking unnecessary nested if statements where a single if statement with appropriate conditional expression would suffice (@IndrajeetPatil and @AshesITR, #1778).

  • implicit_assignment_linter() for checking implicit assignments in function calls (@IndrajeetPatil and @AshesITR, #1777).

  • quotes_linter() is a generalized version of (now deprecated) single_quotes_linter(). It accepts an argument delimiter to specify whether " or ' should be the accepted method for delimiting character literals. The default, ", reflects the Tidyverse style guide recommendation and matches the behavior of single_quotes_linter().

  • unnecessary_concatenation_linter() is simply unneeded_concatenation_linter(), renamed.

  • diff --git a/dev/pkgdown.yml b/dev/pkgdown.yml index 3def02dc4..4a56543e4 100644 --- a/dev/pkgdown.yml +++ b/dev/pkgdown.yml @@ -6,7 +6,7 @@ articles: creating_linters: creating_linters.html editors: editors.html lintr: lintr.html -last_built: 2023-12-16T15:31Z +last_built: 2023-12-18T21:31Z urls: reference: https://lintr.r-lib.org/reference article: https://lintr.r-lib.org/articles diff --git a/dev/reference/all_linters.html b/dev/reference/all_linters.html index 4d83bd69f..e45e0b740 100644 --- a/dev/reference/all_linters.html +++ b/dev/reference/all_linters.html @@ -148,11 +148,11 @@

    Examples#> [99] "todo_comment_linter" "trailing_blank_lines_linter" #> [101] "trailing_whitespace_linter" "undesirable_function_linter" #> [103] "undesirable_operator_linter" "unnecessary_concatenation_linter" -#> [105] "unnecessary_lambda_linter" "unnecessary_nested_if_linter" -#> [107] "unnecessary_nesting_linter" "unnecessary_placeholder_linter" -#> [109] "unreachable_code_linter" "unused_import_linter" -#> [111] "vector_logic_linter" "which_grepl_linter" -#> [113] "whitespace_linter" "yoda_test_linter" +#> [105] "unnecessary_lambda_linter" "unnecessary_nesting_linter" +#> [107] "unnecessary_placeholder_linter" "unreachable_code_linter" +#> [109] "unused_import_linter" "vector_logic_linter" +#> [111] "which_grepl_linter" "whitespace_linter" +#> [113] "yoda_test_linter"

    diff --git a/dev/reference/best_practices_linters.html b/dev/reference/best_practices_linters.html index 72a3b69f0..3a6493c77 100644 --- a/dev/reference/best_practices_linters.html +++ b/dev/reference/best_practices_linters.html @@ -130,7 +130,7 @@

    Linters

    undesirable_function_linter

  • undesirable_operator_linter

  • unnecessary_lambda_linter

  • -
  • unnecessary_nested_if_linter

  • +
  • unnecessary_nesting_linter

  • unnecessary_placeholder_linter

  • unreachable_code_linter

  • unused_import_linter

  • diff --git a/dev/reference/deprecated_linters.html b/dev/reference/deprecated_linters.html index d3c52c2fa..e6da6a30f 100644 --- a/dev/reference/deprecated_linters.html +++ b/dev/reference/deprecated_linters.html @@ -80,6 +80,7 @@

    Linters

    extraction_operator_linter

  • no_tab_linter

  • single_quotes_linter

  • +
  • unnecessary_nested_if_linter

  • unneeded_concatenation_linter

  • diff --git a/dev/reference/get_r_string.html b/dev/reference/get_r_string.html index dceea3568..166288564 100644 --- a/dev/reference/get_r_string.html +++ b/dev/reference/get_r_string.html @@ -106,7 +106,7 @@

    ArgumentsExamples

    tmp <- withr::local_tempfile(lines = "c('a', 'b')")
     expr_as_xml <- get_source_expressions(tmp)$expressions[[1L]]$xml_parsed_content
    -#> Warning: cannot open file '/tmp/RtmpfwIXYL/file187c5c5402a0': No such file or directory
    +#> Warning: cannot open file '/tmp/RtmpJ8tIhj/file18ed719a0c8c': No such file or directory
     #> Error in file(con, "r"): cannot open the connection
     writeLines(as.character(expr_as_xml))
     #> Error in eval(expr, envir, enclos): object 'expr_as_xml' not found
    @@ -118,7 +118,7 @@ 

    Examples# more importantly, extract strings under R>=4 raw strings tmp4.0 <- withr::local_tempfile(lines = "c(R'(a\\b)', R'--[a\\\"\'\"\\b]--')") expr_as_xml4.0 <- get_source_expressions(tmp4.0)$expressions[[1L]]$xml_parsed_content -#> Warning: cannot open file '/tmp/RtmpfwIXYL/file187c24810c16': No such file or directory +#> Warning: cannot open file '/tmp/RtmpJ8tIhj/file18ed1e62d0db': No such file or directory #> Error in file(con, "r"): cannot open the connection writeLines(as.character(expr_as_xml4.0)) #> Error in eval(expr, envir, enclos): object 'expr_as_xml4.0' not found diff --git a/dev/reference/get_source_expressions.html b/dev/reference/get_source_expressions.html index 25f2b7aa6..5b8236222 100644 --- a/dev/reference/get_source_expressions.html +++ b/dev/reference/get_source_expressions.html @@ -136,7 +136,7 @@

    DetailsExamples

    tmp <- withr::local_tempfile(lines = c("x <- 1", "y <- x + 1"))
     get_source_expressions(tmp)
    -#> Warning: cannot open file '/tmp/RtmpfwIXYL/file187c15506c7': No such file or directory
    +#> Warning: cannot open file '/tmp/RtmpJ8tIhj/file18ed629f2edc': No such file or directory
     #> Error in file(con, "r"): cannot open the connection
     
    diff --git a/dev/reference/ids_with_token.html b/dev/reference/ids_with_token.html index de03359a8..a89eb85c5 100644 --- a/dev/reference/ids_with_token.html +++ b/dev/reference/ids_with_token.html @@ -126,7 +126,7 @@

    FunctionsExamples

    tmp <- withr::local_tempfile(lines = c("x <- 1", "y <- x + 1"))
     source_exprs <- get_source_expressions(tmp)
    -#> Warning: cannot open file '/tmp/RtmpfwIXYL/file187c6542599b': No such file or directory
    +#> Warning: cannot open file '/tmp/RtmpJ8tIhj/file18ed28a1189e': No such file or directory
     #> Error in file(con, "r"): cannot open the connection
     ids_with_token(source_exprs$expressions[[1L]], value = "SYMBOL")
     #> Error in eval(expr, envir, enclos): object 'source_exprs' not found
    diff --git a/dev/reference/index.html b/dev/reference/index.html
    index f850d7aa2..759cf88f4 100644
    --- a/dev/reference/index.html
    +++ b/dev/reference/index.html
    @@ -650,11 +650,6 @@ 

    Individual lintersunnecessary_nested_if_linter() - -
    Avoid unnecessary nested if conditional statements
    -
    - unnecessary_nesting_linter()
    Block instances of unnecessary nesting
    diff --git a/dev/reference/is_lint_level.html b/dev/reference/is_lint_level.html index 5e73a2ff9..c5c0c8ee6 100644 --- a/dev/reference/is_lint_level.html +++ b/dev/reference/is_lint_level.html @@ -92,7 +92,7 @@

    ArgumentsExamples

    tmp <- withr::local_tempfile(lines = c("x <- 1", "y <- x + 1"))
     source_exprs <- get_source_expressions(tmp)
    -#> Warning: cannot open file '/tmp/RtmpfwIXYL/file187c7a8d5089': No such file or directory
    +#> Warning: cannot open file '/tmp/RtmpJ8tIhj/file18ed3d97a75a': No such file or directory
     #> Error in file(con, "r"): cannot open the connection
     is_lint_level(source_exprs$expressions[[1L]], level = "expression")
     #> Error in eval(expr, envir, enclos): object 'source_exprs' not found
    diff --git a/dev/reference/lint.html b/dev/reference/lint.html
    index 95d918f70..a1500a3f4 100644
    --- a/dev/reference/lint.html
    +++ b/dev/reference/lint.html
    @@ -191,7 +191,7 @@ 

    DetailsExamples

    f <- withr::local_tempfile(lines = "a=1", fileext = "R")
     lint(f)                # linting a file
    -#> Warning: cannot open file '/tmp/RtmpfwIXYL/file187c7a25235cR': No such file or directory
    +#> Warning: cannot open file '/tmp/RtmpJ8tIhj/file18ed40ca6363R': No such file or directory
     #> Error in file(con, "r"): cannot open the connection
     lint("a = 123\n")      # linting inline-code
     #> ::warning file=<text>,line=1,col=3::file=<text>,line=1,col=3,[assignment_linter] Use <-, not =, for assignment.
    diff --git a/dev/reference/linters.html b/dev/reference/linters.html
    index d7c308fdb..05a2757ed 100644
    --- a/dev/reference/linters.html
    +++ b/dev/reference/linters.html
    @@ -93,12 +93,12 @@ 

    Tags

  • consistency (32 linters)

  • correctness (7 linters)

  • default (26 linters)

  • -
  • deprecated (5 linters)

  • +
  • deprecated (6 linters)

  • efficiency (32 linters)

  • executing (6 linters)

  • package_development (14 linters)

  • pkg_testthat (12 linters)

  • -
  • readability (65 linters)

  • +
  • readability (64 linters)

  • regex (4 linters)

  • robustness (17 linters)

  • style (40 linters)

  • @@ -211,8 +211,7 @@

    Linters

    undesirable_operator_linter (tags: best_practices, configurable, efficiency, robustness, style)

  • unnecessary_concatenation_linter (tags: configurable, efficiency, readability, style)

  • unnecessary_lambda_linter (tags: best_practices, configurable, efficiency, readability)

  • -
  • unnecessary_nested_if_linter (tags: best_practices, readability)

  • -
  • unnecessary_nesting_linter (tags: configurable, consistency, readability)

  • +
  • unnecessary_nesting_linter (tags: best_practices, configurable, consistency, readability)

  • unnecessary_placeholder_linter (tags: best_practices, readability)

  • unreachable_code_linter (tags: best_practices, configurable, readability)

  • unused_import_linter (tags: best_practices, common_mistakes, configurable, executing)

  • diff --git a/dev/reference/linters_with_defaults.html b/dev/reference/linters_with_defaults.html index 5facd0d3f..fc882c2c9 100644 --- a/dev/reference/linters_with_defaults.html +++ b/dev/reference/linters_with_defaults.html @@ -104,7 +104,7 @@

    Examples
    # When using interactively you will usually pass the result onto `lint` or `lint_package()`
     f <- withr::local_tempfile(lines = "my_slightly_long_variable_name <- 2.3", fileext = "R")
     lint(f, linters = linters_with_defaults(line_length_linter = line_length_linter(120L)))
    -#> Warning: cannot open file '/tmp/RtmpfwIXYL/file187c12c3d1d2R': No such file or directory
    +#> Warning: cannot open file '/tmp/RtmpJ8tIhj/file18ed62ea00efR': No such file or directory
     #> Error in file(con, "r"): cannot open the connection
     
     # the default linter list with a different line length cutoff
    diff --git a/dev/reference/lintr-deprecated.html b/dev/reference/lintr-deprecated.html
    index a15254710..4041e8bc7 100644
    --- a/dev/reference/lintr-deprecated.html
    +++ b/dev/reference/lintr-deprecated.html
    @@ -101,6 +101,8 @@ 

    Usage extraction_operator_linter() +unnecessary_nested_if_linter() + with_defaults(..., default = default_linters)

    diff --git a/dev/reference/readability_linters.html b/dev/reference/readability_linters.html index e4f8fb76c..be2ef414e 100644 --- a/dev/reference/readability_linters.html +++ b/dev/reference/readability_linters.html @@ -132,7 +132,6 @@

    Linters

    T_and_F_symbol_linter

  • unnecessary_concatenation_linter

  • unnecessary_lambda_linter

  • -
  • unnecessary_nested_if_linter

  • unnecessary_nesting_linter

  • unnecessary_placeholder_linter

  • unreachable_code_linter

  • diff --git a/dev/reference/trailing_blank_lines_linter.html b/dev/reference/trailing_blank_lines_linter.html index 02226555a..5b130e277 100644 --- a/dev/reference/trailing_blank_lines_linter.html +++ b/dev/reference/trailing_blank_lines_linter.html @@ -85,25 +85,25 @@

    Examples
    # will produce lints
     f <- withr::local_tempfile(lines = "x <- 1\n")
     readLines(f)
    -#> Warning: cannot open file '/tmp/RtmpfwIXYL/file187c714934e': No such file or directory
    +#> Warning: cannot open file '/tmp/RtmpJ8tIhj/file18ed59cddaab': No such file or directory
     #> Error in file(con, "r"): cannot open the connection
     lint(
       filename = f,
       linters = trailing_blank_lines_linter()
     )
    -#> Warning: cannot open file '/tmp/RtmpfwIXYL/file187c714934e': No such file or directory
    +#> Warning: cannot open file '/tmp/RtmpJ8tIhj/file18ed59cddaab': No such file or directory
     #> Error in file(con, "r"): cannot open the connection
     
     # okay
     f <- withr::local_tempfile(lines = "x <- 1")
     readLines(f)
    -#> Warning: cannot open file '/tmp/RtmpfwIXYL/file187c5129908e': No such file or directory
    +#> Warning: cannot open file '/tmp/RtmpJ8tIhj/file18ed45a9b644': No such file or directory
     #> Error in file(con, "r"): cannot open the connection
     lint(
       filename = f,
       linters = trailing_blank_lines_linter()
     )
    -#> Warning: cannot open file '/tmp/RtmpfwIXYL/file187c5129908e': No such file or directory
    +#> Warning: cannot open file '/tmp/RtmpJ8tIhj/file18ed45a9b644': No such file or directory
     #> Error in file(con, "r"): cannot open the connection
     

    diff --git a/dev/reference/unnecessary_nesting_linter.html b/dev/reference/unnecessary_nesting_linter.html index 41e2a7249..75c91249d 100644 --- a/dev/reference/unnecessary_nesting_linter.html +++ b/dev/reference/unnecessary_nesting_linter.html @@ -94,7 +94,7 @@

    See also
    @@ -141,6 +141,19 @@

    Examples) #> ::warning file=<text>,line=2,col=3::file=<text>,line=2,col=3,[unnecessary_nesting_linter] Reduce the nesting of this statement by removing the braces {}. +writeLines("if (x) { \n if (y) { \n return(1L) \n } \n}") +#> if (x) { +#> if (y) { +#> return(1L) +#> } +#> } +lint( + text = "if (x) { \n if (y) { \n return(1L) \n } \n}", + linters = unnecessary_nested_if_linter() +) +#> Warning: Linter unnecessary_nested_if_linter was deprecated in lintr version 3.2.0. Use unnecessary_nesting_linter instead. +#> ::warning file=<text>,line=2,col=3::file=<text>,line=2,col=3,[unnecessary_nested_if_linter] Don't use nested `if` statements, where a single `if` with the combined conditional expression will do. For example, instead of `if (x) { if (y) { ... }}`, use `if (x && y) { ... }`. + # okay code <- "if (A) {\n stop('A is bad because a.')\n} else {\n stop('!A is bad too.')\n}" writeLines(code) @@ -177,6 +190,29 @@

    Examples linters = unnecessary_nesting_linter() ) +writeLines("if (x && y) { \n return(1L) \n}") +#> if (x && y) { +#> return(1L) +#> } +lint( + text = "if (x && y) { \n return(1L) \n}", + linters = unnecessary_nested_if_linter() +) +#> Warning: Linter unnecessary_nested_if_linter was deprecated in lintr version 3.2.0. Use unnecessary_nesting_linter instead. + +writeLines("if (x) { \n y <- x + 1L\n if (y) { \n return(1L) \n } \n}") +#> if (x) { +#> y <- x + 1L +#> if (y) { +#> return(1L) +#> } +#> } +lint( + text = "if (x) { \n y <- x + 1L\n if (y) { \n return(1L) \n } \n}", + linters = unnecessary_nested_if_linter() +) +#> Warning: Linter unnecessary_nested_if_linter was deprecated in lintr version 3.2.0. Use unnecessary_nesting_linter instead. +