Skip to content

Linter warnings bubble up as config formatting errors with confusing message #2253

Closed
@Bisaloo

Description

@Bisaloo

See the following reprex package: https://github.com/Bisaloo/testlintrconfigerror/:

linters: linters_with_defaults(
    backport_linter("2.10.0")
  )

The config file is correctly formatted but the backport_linter() setting will generate a warning:

lintr/R/backport_linter.R

Lines 116 to 119 in 1493c5e

if (r_version < "3.0.0") {
warning("It is not recommended to depend on an R version older than 3.0.0. Resetting 'r_version' to 3.0.0.")
r_version <- R_system_version("3.0.0")
}

This warning is totally unrelated with the config formatting but will bubble up when config is read and produce a red herring message:

lintr::lint_package()

Error: Malformed config file, ensure it ends in a newline
Malformed config file, ensure it ends in a newline
It is not recommended to depend on an R version older than 3.0.0. Resetting 'r_version' to 3.0.0.

I looked again and again for the missing newline and couldn't figure out what was wrong until I realized the error came from the warning added at the end of the error message.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions