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

Use a slightly altered isS3stdGeneric() to detect non-standard generics #857

Merged
merged 6 commits into from
May 23, 2022

Conversation

jonkeane
Copy link
Contributor

I followed the path described in #846 and added a test. If it's preferable I'm happy to make that test be more of an integration-style test with one of the test fixture packages in the tests directory. I decided to not (yet?) add functionality to scan for UseMethod() elsewhere in the function, since that could produce false positives (if it's in an if/else and the other branch doesn't call UseMethod(), though that would be a very odd use of UseMethod() IMO). I'm happy to add it in if y'all think that's useful (or add a TODO that one could do that if there are requests to). I also still gated this on R > 3.5.0, though if we've implemented this ourselves and aren't depending on utils, we could probably use that for any version of R.

I also ran .dev/compare_branches.R (after a bit of RTFS to figure out how to call it). I couldn't find any documentation for the right way to interpret the results, but what I did was look at the output and confirm that there were no new lints in the "branch" rows that aren't also there in the "main" rows. Is there anything else I should do to use that script?

Resolves #846

R/namespace.R Outdated Show resolved Hide resolved
@AshesITR
Copy link
Collaborator

@jimhester it appears that ubuntu-16.04 (release) is still an expected check for this PR. Can you take a look?
Thanks!

AshesITR
AshesITR previously approved these changes Sep 15, 2021
Copy link
Collaborator

@AshesITR AshesITR left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, thanks!
Feel free to also add a NEWS bullet describing your improvement and referencing this PR.

@jonkeane
Copy link
Contributor Author

Added a bullet to News

@jonkeane
Copy link
Contributor Author

Is there anything else I can do to get this past the finish line? I'm happy to rebase/unconflict NEWS if that helps.

@AshesITR
Copy link
Collaborator

This PR should be compared using the branch compare script to make sure all changes in linting behavior are intended compared to master.

If you want, you can try running the comparison script found in .dev.

@jonkeane
Copy link
Contributor Author

I did run the branch compare script on the first version of the implementation (the only additions after that were NEWS + making it use the new code in all versions of R not just those > 3.5)

I also ran .dev/compare_branches.R (after a bit of RTFS to figure out how to call it). I couldn't find any documentation for the right way to interpret the results, but what I did was look at the output and confirm that there were no new lints in the "branch" rows that aren't also there in the "main" rows. Is there anything else I should do to use that script?

Was what I ran sufficient? Is there a better way to run or report the results from those? Happy to learn what the appropriate way to run/report those are if I've made a mistake. I can also run it again if that's helpful (though I'm running R 4.1 or 4.0 locally, so the code change shouldn't actually do anything differently).

@AshesITR
Copy link
Collaborator

It would be nice to see a sample of the lints that disappear from the checked packages in comparison to master to ensure no false negatives occur as well as to verify that no new lints appear (which I think you did).

@MichaelChirico
Copy link
Collaborator

Thanks @jonkeane for the PR & feedback about .dev/compare_branches.R. I wrote up some more documentation for it in #870 -- PTAL & LMK if things are still unclear. Further feedback/improvements to the script welcome.

R/namespace.R Outdated Show resolved Hide resolved
@MichaelChirico MichaelChirico added this to the 3.0.0 milestone May 21, 2022
@MichaelChirico
Copy link
Collaborator

As luck would have it this PR would fix #1161! So I've marked it for inclusion in 3.0.0.

@jonkeane will you be able to update the PR in the next few days? If not, I can take over to get it over the finish line. Thanks again!

@AshesITR AshesITR linked an issue May 21, 2022 that may be closed by this pull request
@MichaelChirico
Copy link
Collaborator

@AshesITR I don't see a lot of risk here for unexpected regression, so going ahead to merge.

Part of my release to-do list is to do some more extensive compare_branches runs of CRAN vs. current dev, so any concerns should be addressed by that as well.

@AshesITR
Copy link
Collaborator

Okay with me as long as we do a before/after comparison at some point in time before release.

Comment on lines +2 to +5
func <- function(x) {
print(x)
UseMethod("func")
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a valid use case for the other way around?
i.e. for

func <- function(x) {
  x <- UseMethod("func")
  common_postprocessing(x)
}

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's try & keep close to the base definition unless there's a compelling reason? i'm also a bit hesitant for this change if it's not being suggested upstream as well

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The base definition checks the first call, so would find my example iinm. That's why I'm asking.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isn't the call that's found <- though, not UseMethod?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, right. I wonder why base R looks for the first call instead of the last, then...

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't see anything about isS3stdGeneric() on r-devel in a quick search... maybe worth bringing up there.

cc @moodymudskipper who identified the bug fix at root in #1161

@MichaelChirico MichaelChirico merged commit 89c37d2 into r-lib:main May 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

warnings in test suite Is isS3stdGeneric() the right way to detect S3 generics?
3 participants