Skip to content

Commit 41d0471

Browse files
apply some linters to R/ (#591)
1 parent 20f4140 commit 41d0471

File tree

6 files changed

+6
-11
lines changed

6 files changed

+6
-11
lines changed

R/cyclocomp_linter.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ cyclocomp_linter <- function(complexity_limit = 25) {
2222
type = "style",
2323
message = paste0(
2424
"functions should have cyclomatic complexity of less than ",
25-
complexity_limit, ", this has ", complexity,"."
25+
complexity_limit, ", this has ", complexity, "."
2626
),
2727
ranges = list(c(source_file[["column"]][1], source_file[["column"]][1])),
2828
line = source_file$lines[1],

R/get_source_expressions.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ fix_eq_assigns <- function(pc) {
373373

374374
prev_locs <- vapply(eq_assign_locs, prev_with_parent, pc = pc, integer(1))
375375
next_locs <- vapply(eq_assign_locs, next_with_parent, pc = pc, integer(1))
376-
expr_locs <- (function(x){
376+
expr_locs <- (function(x) {
377377
x[is.na(x)] <- FALSE
378378
!x
379379
})(prev_locs == lag(next_locs)) # nolint

R/object_name_linters.R

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ object_name_linter <- function(styles = "snake_case") {
2323
"Variable and function name style should be ", .or_string(styles), "."
2424
)
2525

26-
function (source_file) {
26+
function(source_file) {
2727
x <- global_xml_parsed_content(source_file)
2828
if (is.null(x)) {
2929
return()
@@ -120,7 +120,7 @@ make_object_linter <- function(fun) {
120120
token_nums <- ids_with_token(
121121
source_file, rex(start, "SYMBOL" %if_next_isnt% "_SUB"), fun=re_matches
122122
)
123-
if(length(token_nums) == 0){
123+
if (length(token_nums) == 0) {
124124
return(list())
125125
}
126126
tokens <- with_id(source_file, token_nums)
@@ -136,7 +136,6 @@ make_object_linter <- function(fun) {
136136
keep_indices,
137137
function(i) {
138138
token <- tokens[i, ]
139-
name <- names[i]
140139
if (is_declared_here(token, source_file) &&
141140
!is_external_reference(source_file, token[["id"]])) {
142141
fun(source_file, token)

R/object_usage_linter.R

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,10 @@ object_usage_linter <- function(source_file) {
2929
symbols <- get_assignment_symbols(source_file$xml_parsed_content)
3030

3131
# Just assign them an empty function
32-
for(symbol in symbols) {
32+
for (symbol in symbols) {
3333
assign(symbol, function(...) invisible(), envir = env)
3434
}
3535

36-
all_globals <- unique(recursive_ls(env))
37-
3836
fun_info <- get_function_assignments(source_file$xml_parsed_content)
3937

4038
lapply(seq_len(NROW(fun_info)), function(i) {
@@ -128,7 +126,7 @@ parse_check_usage <- function(expression) {
128126

129127
vals <- list()
130128

131-
report <- function (x) {
129+
report <- function(x) {
132130
vals[[length(vals) + 1L]] <<- x
133131
}
134132

R/semicolon_terminator_linter.R

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,3 @@ is_trailing_sc <- function(sc_tokens, source_file) {
4545
tail_str <- substr(line_str, sc_tokens[["col1"]] + 1L, nchar(line_str))
4646
grepl("^\\s*(#|}|\\z)", tail_str, perl = TRUE)
4747
}
48-

R/undesirable_operator_linter.R

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,3 @@ undesirable_operator_linter <- function(op=default_undesirable_operators) {
4444
)
4545
}
4646
}
47-

0 commit comments

Comments
 (0)