fname <- commandArgs(trailingOnly = TRUE) stopifnot(length(fname) == 1) library(lintr) my_linters <- default_linters ## this currently requires the dedelopment version of lintr ## install with 'remotes:install_hithub("r-lib/lintr")' if (! is.null(my_linters$indentation_linter)) my_linters$indentation_linter <- indentation_linter(indent = 4) ## turn off some linters for now my_linters$object_name_linter <- NULL my_linters$commented_code_linter <- NULL my_linters$trailing_blank_lines_linter <- NULL #my_linters$trailing_whitespace_linter <- NULL my_linters$semicolon_linter <- NULL v <- lint(fname, linters = my_linters) ## drop complaints about multi-line functions without braces v <- v[! sapply(v, function(x) x$linter == "brace_linter" && grepl("Either both or neither", x$message))] ## drop complaints both or none braces in `if` expressions v <- v[! sapply(v, function(x) x$linter == "brace_linter" && grepl("Any function spanning multiple lines", x$message))] ## drop complaints about else following } elsemsg <- "`else` should come on the same line as the previous `}`" v <- v[! sapply(v, function(x) x$linter == "brace_linter" && grepl(elsemsg, x$message))] print(v) if (length(v) > 0) { tbl <- as.data.frame(table(sapply(v, function(x) x$linter))) names(tbl)[1] <- "Linter" tbl }