Skip to content

Bad error handling for invalid Lint()s #763

@AshesITR

Description

@AshesITR

When a linter returns a Lint with an invalid (NA) column_number, as has recently happened in some regex-based linters, the error message is extremely confusing:

Error in rep.int(character, length) : invalid 'times' value
Calls: <Anonymous> ... print.lint -> cat -> highlight_string -> fill_with -> paste0
Execution halted

IMO Lint() should do some mild verification during construction so that invalid Lint()s can't be created successfully.

Here are a bunch of checks we could add:

  1. No NAs are allowed anywhere.
  2. 1L <= column_number <= nchar(line) + 1L.
  3. line_number >= 1L.
  4. ranges is a list of length 2 integer(ish) vectors, or NULL.
  5. 1L <= ranges[[i]][1L] <= ranges[[i]][2L] <= nchar(line) + 1L for all i.

WDYT?

Metadata

Metadata

Assignees

No one assigned

    Labels

    featurea feature request or enhancement

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions