Skip to content

Improve error message for misspelled arguments? #2134

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    featurea feature request or enhancement

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions