Skip to content

Commit

Permalink
enable object_name_linter and apply it (#634)
Browse files Browse the repository at this point in the history
Co-authored-by: AshesITR <alexander.rosenstock@web.de>
  • Loading branch information
MichaelChirico and AshesITR authored Dec 6, 2020
1 parent 20d37fa commit f2d2666
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 8 deletions.
1 change: 0 additions & 1 deletion .lintr
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
linters: with_defaults( # The following TODOs are part of an effort to have {lintr} lint-free (#584)
line_length_linter = line_length_linter(120),
cyclocomp_linter = cyclocomp_linter(29), # TODO reduce to 15
object_name_linter = NULL, # TODO enable (#597)
equals_na_linter = NULL, # TODO enable (#601)
paren_brace_linter = NULL # TODO enable (#603)
)
Expand Down
2 changes: 1 addition & 1 deletion R/T_and_F_symbol_linter.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#'
#' @describeIn linters Avoid the symbols \code{T} and \code{F} (for \code{TRUE} and \code{FALSE}).
#' @export
T_and_F_symbol_linter <- function(source_file) {
T_and_F_symbol_linter <- function(source_file) { # nolint: object_name_linter.
lapply(
ids_with_token(source_file, "SYMBOL"),
function(id) {
Expand Down
6 changes: 3 additions & 3 deletions R/equals_na_linter.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ equals_na_linter <- function(source_file) {

comparators <- c("EQ", "NE")
comparator_table <- paste0("self::", comparators, collapse = " or ")
NA_values <- c("NA", "NA_integer_", "NA_real_", "NA_complex_", "NA_character_")
NA_table <- paste("text() =", quote_wrap(NA_values, "'"), collapse = " or ")
na_values <- c("NA", "NA_integer_", "NA_real_", "NA_complex_", "NA_character_")
na_table <- paste("text() =", quote_wrap(na_values, "'"), collapse = " or ")

xpath_fmt <- "//expr[expr[NUM_CONST[%s]]]/*[%s]"
xpath <- sprintf(xpath_fmt, NA_table, comparator_table)
xpath <- sprintf(xpath_fmt, na_table, comparator_table)

bad_expr <- xml2::xml_find_all(xml, xpath)

Expand Down
3 changes: 2 additions & 1 deletion R/lint.R
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,8 @@ pkg_name <- function(path = find_package()) {
#' @param ranges a list of ranges on the line that should be emphasized.
#' @param linter name of linter that created the Lint object.
#' @export
Lint <- function(filename, line_number = 1L, column_number = 1L,
Lint <- function( # nolint: object_name_linter.
filename, line_number = 1L, column_number = 1L,
type = c("style", "warning", "error"),
message = "", line = "", ranges = NULL, linter = "") {

Expand Down
5 changes: 3 additions & 2 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,9 @@ logical_env <- function(x) {
# from ?chartr
rot <- function(ch, k = 13) {
p0 <- function(...) paste(c(...), collapse = "")
A <- c(letters, LETTERS, " '")
I <- seq_len(k); chartr(p0(A), p0(c(A[-I], A[I])), ch)
alphabet <- c(letters, LETTERS, " '")
idx <- seq_len(k)
chartr(p0(alphabet), p0(c(alphabet[-idx], alphabet[idx])), ch)
}

trim_ws <- function(x) {
Expand Down

0 comments on commit f2d2666

Please sign in to comment.