Skip to content
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

New warning in 'designer' from object_usage_linter #1986

Closed
MichaelChirico opened this issue Jun 28, 2023 · 7 comments · Fixed by #1993
Closed

New warning in 'designer' from object_usage_linter #1986

MichaelChirico opened this issue Jun 28, 2023 · 7 comments · Fixed by #1993
Labels
bug an unexpected problem or unintended behavior

Comments

@MichaelChirico
Copy link
Collaborator

Haven't confirmed this is a regression yet, but we observe this warning on main that is not present on v3.0.2:

Possible bug in lintr: Couldn't parse usage message ‘<anonymous>: no visible global function definition for 'find_cache_dir'
’. Ignoring 1 usage warnings. Please report an issue at https://github.com/r-lib/lintr/issues.
@MichaelChirico MichaelChirico added the regression code that used to work, but now doesn't label Jun 28, 2023
@MichaelChirico MichaelChirico added this to the 3.1.0 milestone Jun 28, 2023
@MichaelChirico
Copy link
Collaborator Author

Similar warnings also in other packages:

** latrend
Possible bug in lintr: Couldn't parse usage message ‘<anonymous>: no visible binding for global variable 'id'
’. Ignoring 1 usage warnings. Please report an issue at https://github.com/r-lib/lintr/issues.
** mlrCPO
Possible bug in lintr: Couldn't parse usage message ‘<anonymous>: local variable 't' assigned but may not be used
’. Ignoring 1 usage warnings. Please report an issue at https://github.com/r-lib/lintr/issues.
** rextendr
Possible bug in lintr: Couldn't parse usage message ‘<anonymous>: no visible binding for global variable 'wrap__hello_world'
’. Ignoring 1 usage warnings. Please report an issue at https://github.com/r-lib/lintr/issues.

@MichaelChirico
Copy link
Collaborator Author

Here's an MRE for the type of error that's unrecognized:

lintr::lint(linters = lintr::object_usage_linter(), "
foo <- function() bar()
")
Warning message:
In parse_check_usage(fun, known_used_symbols = known_used_symbols,  :
  Possible bug in lintr: Couldn't parse usage message ‘<anonymous>: no visible global function definition for 'bar'
’. Ignoring 1 usage warnings. Please report an issue at https://github.com/r-lib/lintr/issues.

@MichaelChirico
Copy link
Collaborator Author

MichaelChirico commented Jun 29, 2023

c.f. the codetools::checkUsage() output:

codetools::checkUsage({
  foo <- function() bar()
})
# <anonymous>: no visible global function definition for ‘bar’

codetools::checkUsage({
  foo <- function() {
    bar()
  }
})
# <anonymous>: no visible global function definition for ‘bar’ (:3)

@AshesITR
Copy link
Collaborator

Not really a regression, the old version just kept silent about the problem.

We should try to fix this though.
At this point I'm wondering whether it might be worthwhile to fork and fix the issues in codetools directly.

@MichaelChirico
Copy link
Collaborator Author

would you mind having a crack at a fix?

I thought it would be as simple as making this a maybe() but I think that's having an interaction with all the other maybe()s I couldn't figure out quickly:

line_info

@MichaelChirico MichaelChirico removed the regression code that used to work, but now doesn't label Jun 30, 2023
@MichaelChirico MichaelChirico modified the milestones: 3.1.0, 3.1.1 Jun 30, 2023
@AshesITR
Copy link
Collaborator

AshesITR commented Jul 1, 2023

I can take a look, do you have MWEs for all the "Couldn't parse usage message" warnings you found?

AshesITR added a commit that referenced this issue Jul 1, 2023
@AshesITR AshesITR added the bug an unexpected problem or unintended behavior label Jul 1, 2023
@AshesITR
Copy link
Collaborator

AshesITR commented Jul 1, 2023

It was surprisingly easy to remedy - you were almost there. Just had to make the message part fit lazily.

@AshesITR AshesITR modified the milestones: 3.1.1, 3.1.0 Jul 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug an unexpected problem or unintended behavior
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants