Skip to content

Prefer nzchar() #2483

@maelle

Description

@maelle

Replace occurrences of x != ""' with !nzchar(x) https://github.com/search?q=repo%3Aigraph%2Frigraph+%2F%21%3D+%22%22%2F+path%3A%2F%5ER%5C%2F%2F&type=code

Replace occurrences of x == "" with nzchar(x) https://github.com/search?q=repo%3Aigraph%2Frigraph+%2F%3D%3D+%22%22%2F+path%3A%2F%5ER%5C%2F%2F&type=code

@krlmlr If you agree, is this something you'd assign to Copilot? It seems flir doesn't fix this, it only lints it:

flir::fix_text('x == ""', linters = flir::nzchar_linter())
flir::lint_text('x == ""', linters = flir::nzchar_linter())
#> Original code: x == "" 
#> Suggestion: Use !nzchar(x) instead of x == "". Use !nzchar(x, keepNA = TRUE) if missing data is possible. Use !nzchar(as.character(x)) if x may not be a character vector. 
#> Rule ID: nzchar-4

Created on 2025-11-04 with reprex v2.1.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    upkeepmaintenance, infrastructure, and similar

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions