Skip to content

Commit b233d7a

Browse files
Rename no_tab_linter to whitespace_linter (#1955)
* Rename no_tab_linter to whitespace_linter * NEWS * syntax error in test * rename other references to no_tab_linter * syntax in one more test * trailing blank line
1 parent fb294cc commit b233d7a

18 files changed

+90
-45
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,6 @@ Collate:
127127
'namespace.R'
128128
'namespace_linter.R'
129129
'nested_ifelse_linter.R'
130-
'no_tab_linter.R'
131130
'nonportable_path_linter.R'
132131
'numeric_leading_zero_linter.R'
133132
'object_length_linter.R'
@@ -169,6 +168,7 @@ Collate:
169168
'unused_import_linter.R'
170169
'use_lintr.R'
171170
'vector_logic_linter.R'
171+
'whitespace_linter.R'
172172
'with.R'
173173
'with_id.R'
174174
'xml_nodes_to_lints.R'

NAMESPACE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ export(unreachable_code_linter)
136136
export(unused_import_linter)
137137
export(use_lintr)
138138
export(vector_logic_linter)
139+
export(whitespace_linter)
139140
export(with_defaults)
140141
export(with_id)
141142
export(xml_nodes_to_lints)

NEWS.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
* `single_quotes_linter()` is deprecated in favor of the more generalizable `quotes_linter()` (#1729, @MichaelChirico).
66
* `unneeded_concatentation_linter()` is deprecated in favor of `unnecessary_concatenation_linter()` for naming consistency (#1707, @IndrajeetPatil).
77
* `consecutive_stopifnot_linter()` is deprecated in favor of the more general (see below) `consecutive_assertion_linter()` (#1604, @MichaelChirico).
8+
* `no_tab_linter()` is deprecated in favor of `whitespace_linter()` for naming consistency and future generalization (#1954, @MichaelChirico).
89

910
## Bug fixes
1011

@@ -65,6 +66,7 @@
6566
+ `indentation_linter()`
6667
+ `quotes_linter()`
6768
+ `unnecessary_concatenation_linter()`
69+
+ `whitespace_linter()`
6870

6971
## New and improved features
7072

@@ -152,6 +154,8 @@
152154

153155
* `consecutive_assertion_linter()` (f.k.a. `consecutive_stopifnot_linter()`) now lints for consecutive calls to `assertthat::assert_that()` (as long as the `msg=` argument is not used; #1604, @MichaelChirico).
154156

157+
* `whitespace_linter()` is simply `no_tab_linter()`, renamed. In the future, we plan to extend it to work for different whitespace preferences.
158+
155159
## Notes
156160

157161
* {lintr} now depends on R version 3.5.0, in line with the tidyverse policy for R version compatibility.

R/lintr-deprecated.R

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,3 +239,16 @@ consecutive_stopifnot_linter <- function() {
239239
)
240240
consecutive_assertion_linter()
241241
}
242+
243+
#' No tabs linter
244+
#' @rdname lintr-deprecated
245+
#' @export
246+
no_tab_linter <- function() {
247+
lintr_deprecated(
248+
old = "no_tab_linter",
249+
new = "whitespace_linter",
250+
version = "3.1.0",
251+
type = "Linter"
252+
)
253+
whitespace_linter()
254+
}

R/no_tab_linter.R renamed to R/whitespace_linter.R

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,35 @@
1-
#' No tab linter
1+
#' Whitespace linter
22
#'
3-
#' Check that only spaces are used for indentation, not tabs. Much ink has been
4-
#' spilled on this topic, and we encourage you to check out references for more
5-
#' information.
3+
#' Check that the correct character is used for indentation.
4+
#'
5+
#' Currently, only supports linting in the presence of tabs.
6+
#'
7+
#' Much ink has been spilled on this topic, and we encourage you to check
8+
#' out references for more information.
69
#'
710
#' @include make_linter_from_regex.R
811
#'
912
#' @examples
1013
#' # will produce lints
1114
#' lint(
1215
#' text = "\tx",
13-
#' linters = no_tab_linter()
16+
#' linters = whitespace_linter()
1417
#' )
1518
#'
1619
#' # okay
1720
#' lint(
1821
#' text = " x",
19-
#' linters = no_tab_linter()
22+
#' linters = whitespace_linter()
2023
#' )
2124
#'
22-
#' @evalRd rd_tags("no_tab_linter")
25+
#' @evalRd rd_tags("whitespace_linter")
2326
#' @seealso [linters] for a complete list of linters available in lintr.
2427
#'
2528
#' @references
2629
#' - https://www.jwz.org/doc/tabs-vs-spaces.html
2730
#' - https://blog.codinghorror.com/death-to-the-space-infidels/
2831
#' @export
29-
no_tab_linter <- make_linter_from_regex(
32+
whitespace_linter <- make_linter_from_regex(
3033
regex = rex(start, zero_or_more(regex("\\s")), one_or_more("\t")),
3134
lint_type = "style",
3235
lint_msg = "Use spaces to indent, not tabs."

R/zzz.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ default_linters <- modify_defaults(
2323
indentation_linter(),
2424
infix_spaces_linter(),
2525
line_length_linter(),
26-
no_tab_linter(),
2726
object_length_linter(),
2827
object_name_linter(),
2928
object_usage_linter(),
@@ -37,7 +36,8 @@ default_linters <- modify_defaults(
3736
T_and_F_symbol_linter(),
3837
trailing_blank_lines_linter(),
3938
trailing_whitespace_linter(),
40-
vector_logic_linter()
39+
vector_logic_linter(),
40+
whitespace_linter()
4141
)
4242

4343
#' Default undesirable functions and operators

inst/lintr/linters.csv

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ missing_argument_linter,correctness common_mistakes configurable
4949
missing_package_linter,robustness common_mistakes
5050
namespace_linter,correctness robustness configurable executing
5151
nested_ifelse_linter,efficiency readability
52-
no_tab_linter,style consistency default
52+
no_tab_linter,style consistency deprecated
5353
nonportable_path_linter,robustness best_practices configurable
5454
numeric_leading_zero_linter,style consistency readability
5555
object_length_linter,style readability default configurable executing
@@ -93,4 +93,5 @@ unneeded_concatenation_linter,style readability efficiency configurable deprecat
9393
unreachable_code_linter,best_practices readability
9494
unused_import_linter,best_practices common_mistakes configurable executing
9595
vector_logic_linter,default efficiency best_practices
96+
whitespace_linter,style consistency default
9697
yoda_test_linter,package_development best_practices readability

man/consistency_linters.Rd

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/default_linters.Rd

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/deprecated_linters.Rd

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)