Skip to content

Improve error message for misspelled arguments? #2134

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
IndrajeetPatil opened this issue Sep 11, 2023 · 1 comment · Fixed by #2147
Closed

Improve error message for misspelled arguments? #2134

IndrajeetPatil opened this issue Sep 11, 2023 · 1 comment · Fixed by #2147
Labels
feature a feature request or enhancement
Milestone

Comments

@IndrajeetPatil
Copy link
Collaborator

IndrajeetPatil commented Sep 11, 2023

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?
@MichaelChirico MichaelChirico added the feature a feature request or enhancement label Sep 11, 2023
@MichaelChirico
Copy link
Collaborator

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature a feature request or enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants