Skip to contents

While .1 and 0.1 mean the same thing, the latter is easier to read due to the small size of the '.' glyph.

Usage

numeric_leading_zero_linter()

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.