Skip to content

Detect broken configuration #886

Closed
@AshesITR

Description

@AshesITR

A lot of new users seem to stumble upon the quirkiness of the dcf format we use for .lintr.
I see three major pitfalls:

  1. Indentation of multiline code is not intuitive
# Wrong
linters: with_defaults(
    line_length_linter = line_length_linter(120)
)

# Right
linters: with_defaults(
    line_length_linter = line_length_linter(120)
  )
  1. Trailing newline is mandatory, but not reported as an error
# Wrong
linters: with_defaults(
    line_length_linter = line_length_linter(120)
  )
(EOF)

# Right
linters: with_defaults(
    line_length_linter = line_length_linter(120)
  )

(EOF)
  1. The proper location of the .lintr config files sometimes causes confusion.

It would be nice of us to catch these and report a warning (or maybe even an error?) if the config file is malformed.

Regarding the location issue, maybe reporting the config file used (if any) would help diagnosing the problem more quickly.
I see a few options here as to when to report it:

  1. Only if some option (linter.verbose, or lintr.debug?) is set.
  2. Only if some argument (verbose, or debug?) is TRUE.
  3. Always if running interactively.
  4. Always at the start of a top-level call (lint_dir, lint_package or lint if the latter isn't called from within lint_*).

WDYT?
I think the most user-friendly version would be to use getOption("lintr.???", default = interactive()) to decide whether to print this diagnostic info at the start of a top-level call.
If no config file is found, the info could be

Using the default linter configuration. See vignette("using_lintr", package = "lintr") for customization options.

or something like that.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions