# will produce lints
lint(
text = strrep("x", 23L),
linters = line_length_linter(length = 20L)
)
# the trailing ' is counted towards line length, so this still lints
lint(
text = "'a long single-line string'",
linters = line_length_linter(length = 15L, ignore_string_bodies = TRUE)
)
lines <- paste(
"query <- '",
" SELECT *",
" FROM MyTable",
" WHERE profit > 0",
"'",
sep = "\n"
)
writeLines(lines)
lint(
text = lines,
linters = line_length_linter(length = 10L)
)
# okay
lint(
text = strrep("x", 21L),
linters = line_length_linter(length = 40L)
)
lines <- paste(
"paste(",
" 'a long',",
" 'single-line',",
" 'string'",
")",
sep = "\n"
)
writeLines(lines)
lint(
text = lines,
linters = line_length_linter(length = 15L, ignore_string_bodies = TRUE)
)
lines <- paste(
"query <- '",
" SELECT *",
" FROM MyTable",
" WHERE profit > 0",
"'",
sep = "\n"
)
writeLines(lines)
lint(
text = lines,
linters = line_length_linter(length = 10L, ignore_string_bodies = TRUE)
)
Run the code above in your browser using DataLab