Require usage of a leading zero in all fractional numerics
Source:R/numeric_leading_zero_linter.R
numeric_leading_zero_linter.Rd
While .1 and 0.1 mean the same thing, the latter is easier to read due to the small size of the '.' glyph.
See also
linters for a complete list of linters available in lintr.
Examples
# will produce lints
lint(
text = "x <- .1",
linters = numeric_leading_zero_linter()
)
#> <text>:1:6: warning: [numeric_leading_zero_linter] Include the leading zero for fractional numeric constants.
#> x <- .1
#> ^~
lint(
text = "x <- -.1",
linters = numeric_leading_zero_linter()
)
#> <text>:1:7: warning: [numeric_leading_zero_linter] Include the leading zero for fractional numeric constants.
#> x <- -.1
#> ^~
# okay
lint(
text = "x <- 0.1",
linters = numeric_leading_zero_linter()
)
#> ℹ No lints found.
lint(
text = "x <- -0.1",
linters = numeric_leading_zero_linter()
)
#> ℹ No lints found.