Closed
Description
> library(lintr)
> txt <- c("var_one <- 1", "varTwo <- 2", "var.three <- 3")
> linter <- object_name_linter(c("snake_case", "lowerCamelCase"))
Current behavior:
> expect_lint(txt, list("should be snake_case", line_number=3), linter)
Error in vapply(x, `[[`, character(1), "message") :
values must be length 1,
but FUN(X[[1]]) result is length 2
In addition: Warning messages:
1: In if (!matches_styles(name, style)) { :
the condition has length > 1 and only the first element will be used
2: In if (!matches_styles(name, style)) { :
the condition has length > 1 and only the first element will be used
3: In if (!matches_styles(name, style)) { :
the condition has length > 1 and only the first element will be used
Proposed:
> expect_lint(txt, list("should be snake_case or lowerCamelCase", line_number=3), linter)
>
I realize it's usually far better to pick one naming style and stick to it, but today I'm writing a package whose interface is dictated by two incompatible upstream APIs, so I'd like to allow "snake_case or dotted.case, but no others". Since users would need to explicitly opt into it by specifying multiple styles, I submit that this change doesn't pose too much of a moral hazard :)
Since matches_styles
already returns a vector, I think this should be easy to implement and I can take a stab at it if y'all are OK with the concept.
Metadata
Metadata
Assignees
Labels
No labels