Skip to content

paren_brace_linter false positive within regex strings: "(match_group){quantifier}" #441

Closed

Description

@russHyde

paren_brace_linter flags the "){" within regex definition below:

#' Checks if a file has a .tar or .tar.bz2 extension
#'
#' @noRd
.is_tar_file <- function(x) {
  grepl(pattern = ".*\\.tar(\\.bz2){0,1}", x)
}

Should paren_brace_linter be made more strict - so that it doesn't consider strings?

Activity

  1. added
    bug
    on Jan 6, 2020
  2. linusjf commented on Jan 27, 2020

    @linusjf
    grepl("(iss){2}", "Mississippi")
  3. russHyde commented on Jan 27, 2020

    @russHyde
    CollaboratorAuthor

    This seems to be a more general issue with using regex-based linters.

    For example, the following throws with equals_na_linter, despite the NA comprison code actually being in a string, or a comment

    dont_lint_me <- "xyz == NA shouldn't occur in an R script"
    
    x <- NA
    dont_lint_me_either <- is.na(x) # use is.na instead of x == NA
    

    Similarly no_tab_linter throws on this:

    multi_line_tabbed_string <- "lorem ipsum
    <tab>blah de blah"
    
  4. linusjf commented on Jan 31, 2020

    @linusjf

    This can be mitigated by allowing the # nolint comment to specify the linter to be turned off.
    eg,
    #nolint paren_brace_linter

  5. bersbersbers commented on Feb 23, 2021

    @bersbersbers

    It seems this did not make it into a release: it was fixed on Dec 4, 2020, and there was a 2.0.1 release on Dec 5, 2020: https://github.com/jimhester/lintr/releases/tag/v2.0.1

    However, 2.0.1 on CRAN is from Feb 19, 2020: https://cran.r-project.org/web/packages/lintr/index.html

  6. russHyde commented on Feb 23, 2021

    @russHyde
    CollaboratorAuthor

    I believe the commit that was tagged as v2.0.1 came from Feb 2020 (01e57c2). It's simply that the released 2.0.1 version didn't get tagged on github at the time that it was released. (That is, in December 2020 @AshesITR ensured that the CRAN-destined v2.0.1 commit from Feb 2020 was tagged with the git tag "v2.0.1")

  7. bersbersbers commented on Feb 23, 2021

    @bersbersbers

    Sounds convincing, but that means there hasn't been a release in over a year. Would you recommend installing from GitHub master rather than from CRAN?

  8. russHyde commented on Feb 23, 2021

    @russHyde
    CollaboratorAuthor

    If having this paren-brace issue solved is necessary, then use the github master. I always use the github master in continuous integration. Locally, I use multiple R environments: using the CRAN-lintr when working on stuff other than lintr.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions