25
25
# [1]: https://github.com/jimhester/lintr
26
26
27
27
# Ensure that the `lintr` package is installed...
28
- if ( ! require( " lintr" , quietly = TRUE , character.only = TRUE ) ) {
29
- install.packages( " lintr" , repos = " http://lib.stat.cmu.edu/R/CRAN/" , quiet = TRUE );
28
+ if ( ! require( ' lintr' , quietly = TRUE , character.only = TRUE ) ) {
29
+ install.packages( ' lintr' , repos = ' http://lib.stat.cmu.edu/R/CRAN/' , quiet = TRUE );
30
30
}
31
31
32
32
# Get only the trailing command-line arguments:
33
33
args <- commandArgs( trailingOnly = TRUE );
34
34
35
35
# Check that at least one filepath has been provided...
36
36
n <- length( args );
37
- if ( n == 0 ) {
38
- stop( " Must provide at least one file to lint." , call. = FALSE );
37
+ if ( n == 0L ) {
38
+ stop( ' Must provide at least one file to lint.' , call. = FALSE );
39
39
}
40
40
41
41
# Specify which linters to use...
@@ -65,7 +65,8 @@ linters <- lintr::linters_with_defaults( defaults = default_linters,
65
65
line_length_linter = lintr :: line_length_linter( 200L ),
66
66
67
67
# Allow tabs:
68
- no_tab_linter = NULL , # lintr::no_tab_linter(),
68
+ indentation_linter = NULL , # lintr::indentation_linter(),
69
+ whitespace_linter = NULL , # lintr::whitespace_linter(),
69
70
70
71
# Require that `file.path()` is used to construct safe and portable paths:
71
72
nonportable_path_linter = lintr :: nonportable_path_linter(),
@@ -74,7 +75,7 @@ linters <- lintr::linters_with_defaults( defaults = default_linters,
74
75
object_length_linter = lintr :: object_length_linter( 30L ),
75
76
76
77
# Require that object names conform to a single naming style (e.g., snake_case or lowerCamelCase):
77
- object_name_linter = lintr :: object_name_linter( " snake_case" ),
78
+ object_name_linter = lintr :: object_name_linter( ' snake_case' ),
78
79
79
80
# Require that closures have the proper usage using `checkUsage`:
80
81
object_usage_linter = lintr :: object_usage_linter(),
@@ -89,7 +90,7 @@ linters <- lintr::linters_with_defaults( defaults = default_linters,
89
90
semicolon_linter = lintr :: semicolon_linter( allow_trailing = TRUE ),
90
91
91
92
# Require that only single quotes be used to delimit strings:
92
- single_quotes_linter = lintr :: single_quotes_linter( ),
93
+ quotes_linter = lintr :: quotes_linter( delimiter = " ' " ),
93
94
94
95
# Allow spaces directly inside parentheses and square brackets:
95
96
spaces_inside_linter = NULL , # lintr::spaces_inside_linter(),
@@ -116,15 +117,15 @@ linters <- lintr::linters_with_defaults( defaults = default_linters,
116
117
undesirable_operator_linter = lintr :: undesirable_operator_linter(),
117
118
118
119
# Ensure that the `c` function is not used without arguments or with a single constant:
119
- unneeded_concatenation_linter = lintr :: unneeded_concatenation_linter ()
120
+ unnecessary_concatenation_linter = lintr :: unnecessary_concatenation_linter ()
120
121
);
121
122
122
123
# Lint each file...
123
- status <- 0 ;
124
- for ( i in 1 : n ) {
124
+ status <- 0L ;
125
+ for ( i in 1L : n ) {
125
126
results <- lintr :: lint( args [ i ], linters = linters );
126
- if ( length( results ) > 0 ) {
127
- status <- 1 ;
127
+ if ( length( results ) > 0L ) {
128
+ status <- 1L ;
128
129
print( results );
129
130
}
130
131
}
0 commit comments