Skip to content

Improve error message for misspelled arguments? #2134

Closed

Description

@IndrajeetPatil

I am reporting a minimal version of the function call here, but it took me a long time to figure out that linting was failing for a very simple reason: I had misspelled an argument. It took so long because the error message just spit out a big block of code, instead of an informative error message.

Should we improve error message here?

library(lintr)
lint_package(litners = all_linters())

Actual error message

Error in FUN(X[[i]], ...) : 
  unused argument (litners = list(function (source_expression) 
{
    lapply(ids_with_token(source_expression, "STR_CONST"), function(id) {
        token <- with_id(source_expression, id)
        path <- get_r_string(token$text)
        if (path_function(path)) {
            start <- token[["col1"]] + 1
            end <- token[["col2"]] - 1
            Lint(filename = source_expression[["filename"]], line_number = token[["line1"]], column_number = start, type = "warning", message = message, line = source_expression[["lines"]][[as.character(token[["line1"]])]], ranges = list(c(start, end)))
        }
    })
}, function (source_expression) 
{
    if (!is_lint_level(source_expression, "expression")) {
        return(list())
    }
    xml <- source_expression$xml_parsed_content
    any_duplicated_expr <- xml_find_all(xml, any_duplicated_xpath)
    any_duplicated_lints <- xml_nodes_to_lints(any_duplicated_expr, source_expression = source_expression, lint_message = "anyDuplicated(x, 

Expected error message

Error: There is no argument called `litners`. Did you misspell argument name?

Activity

  1. added
    feature
    on Sep 11, 2023
  2. MichaelChirico commented on Sep 12, 2023

    @MichaelChirico
    Collaborator

    More context: exclude() and then parse_exclusions() is picking up ... so that's where the error's coming from.

  3. added this to the 3.1.1 milestone on Sep 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions