|
| 1 | +dt_linters = new.env() |
| 2 | +for (f in list.files('.ci/linters/r', full.names=TRUE)) sys.source(f, dt_linters) |
| 3 | +rm(f) |
| 4 | + |
| 5 | +# NB: Could do this inside the linter definition, this separation makes those files more standardized |
| 6 | +dt_linters <- eapply(dt_linters, function(linter_factory) linter_factory()) |
| 7 | + |
| 8 | +linters = c(dt_linters, all_linters( |
| 9 | + packages = "lintr", # TODO(lintr->3.2.0): Remove this. |
| 10 | + # eq_assignment_linter(), |
| 11 | + brace_linter(allow_single_line = TRUE), |
| 12 | + implicit_integer_linter(allow_colon = TRUE), |
| 13 | + # TODO(michaelchirico): Activate these incrementally. These are the |
| 14 | + # parameterizations that match our style guide. |
| 15 | + # implicit_assignment_linter(allow_lazy = TRUE, allow_scoped = TRUE), |
| 16 | + # system_time_linter = undesirable_function_linter(c( |
| 17 | + # system.time = "Only run timings in benchmark.Rraw" |
| 18 | + # )), |
| 19 | + undesirable_function_linter(c( |
| 20 | + cat = "Use catf to enable translations", |
| 21 | + message = "Use messagef to avoid fragmented translations.", |
| 22 | + warning = "Use warningf to avoid fragmented translations.", |
| 23 | + stop = "Use stopf to avoid fragmented translations.", |
| 24 | + rev = "Use frev internally, or setfrev if by-reference is safe.", |
| 25 | + NULL |
| 26 | + )), |
| 27 | + # undesirable_function_linter(modify_defaults( |
| 28 | + # default_undesirable_functions, |
| 29 | + # ifelse = "Use fifelse instead.", |
| 30 | + # Sys.setenv = NULL, |
| 31 | + # library = NULL, |
| 32 | + # options = NULL, |
| 33 | + # par = NULL, |
| 34 | + # setwd = NULL |
| 35 | + # )), |
| 36 | + undesirable_operator_linter(), |
| 37 | + # TODO(lintr#2765): Use upstream implementation. |
| 38 | + # assignment_linter(operator = "="), |
| 39 | + assignment_linter = NULL, |
| 40 | + absolute_path_linter = NULL, # too many false positives |
| 41 | + # TODO(lintr#2442): Use this once x[ , j, by] is supported. |
| 42 | + commas_linter = NULL, |
| 43 | + commented_code_linter = NULL, |
| 44 | + # TODO(linter->3.2.0): Activate this. |
| 45 | + consecutive_assertion_linter = NULL, |
| 46 | + cyclocomp_linter = NULL, |
| 47 | + function_argument_linter = NULL, |
| 48 | + indentation_linter = NULL, |
| 49 | + infix_spaces_linter = NULL, |
| 50 | + line_length_linter = NULL, |
| 51 | + missing_package_linter = NULL, |
| 52 | + namespace_linter = NULL, |
| 53 | + nonportable_path_linter = NULL, |
| 54 | + object_name_linter = NULL, |
| 55 | + object_usage_linter = NULL, |
| 56 | + quotes_linter = NULL, |
| 57 | + semicolon_linter = NULL, |
| 58 | + spaces_inside_linter = NULL, |
| 59 | + spaces_left_parentheses_linter = NULL, |
| 60 | + # TODO(michaelchirico): Only exclude from vignettes, not sure what's wrong. |
| 61 | + strings_as_factors_linter = NULL, |
| 62 | + # TODO(lintr->3.2.0): Fix on a valid TODO style, enforce it, and re-activate. |
| 63 | + todo_comment_linter = NULL, |
| 64 | + # TODO(michaelchirico): Enforce these and re-activate them one-by-one. |
| 65 | + brace_linter = NULL, |
| 66 | + fixed_regex_linter = NULL, |
| 67 | + if_not_else_linter = NULL, |
| 68 | + implicit_assignment_linter = NULL, |
| 69 | + implicit_integer_linter = NULL, |
| 70 | + keyword_quote_linter = NULL, |
| 71 | + object_overwrite_linter = NULL, |
| 72 | + paren_body_linter = NULL, |
| 73 | + redundant_equals_linter = NULL, |
| 74 | + undesirable_function_linter = NULL, |
| 75 | + unnecessary_concatenation_linter = NULL, |
| 76 | + unnecessary_nesting_linter = NULL, |
| 77 | + unreachable_code_linter = NULL, |
| 78 | + unused_import_linter = NULL |
| 79 | +)) |
| 80 | +rm(dt_linters) |
| 81 | + |
| 82 | +exclusions = list( |
| 83 | + `../tests` = list( |
| 84 | + quotes_linter = Inf, |
| 85 | + # TODO(michaelchirico): Enforce these and re-activate them one-by-one. |
| 86 | + implicit_integer_linter = Inf, |
| 87 | + infix_spaces_linter = Inf, |
| 88 | + undesirable_function_linter = Inf |
| 89 | + ), |
| 90 | + `../vignettes*` = list( |
| 91 | + # assignment_linter = Inf, |
| 92 | + implicit_integer_linter = Inf, |
| 93 | + quotes_linter = Inf, |
| 94 | + sample_int_linter = Inf |
| 95 | + # strings_as_factors_linter = Inf |
| 96 | + # system_time_linter = Inf |
| 97 | + ), |
| 98 | + `../inst/tests` = list( |
| 99 | + library_call_linter = Inf, |
| 100 | + numeric_leading_zero_linter = Inf, |
| 101 | + undesirable_operator_linter = Inf, # For ':::', possibly we could be more careful to only exclude ':::'. |
| 102 | + # TODO(michaelchirico): Enforce these and re-activate them one-by-one. |
| 103 | + comparison_negation_linter = Inf, |
| 104 | + condition_call_linter = Inf, |
| 105 | + duplicate_argument_linter = Inf, |
| 106 | + equals_na_linter = Inf, |
| 107 | + missing_argument_linter = Inf, |
| 108 | + paste_linter = Inf, |
| 109 | + rep_len_linter = Inf, |
| 110 | + sample_int_linter = Inf, |
| 111 | + seq_linter = Inf, |
| 112 | + unnecessary_lambda_linter = Inf |
| 113 | + ), |
| 114 | + `../inst/tests/froll.Rraw` = list( |
| 115 | + dt_test_literal_linter = Inf # TODO(michaelchirico): Fix these once #5898, #5692, #5682, #5576, #5575, #5441 are merged. |
| 116 | + ) |
| 117 | +) |
0 commit comments