Skip to content

Conversation

@MichaelChirico
Copy link
Collaborator

Basically extending @russHyde / @AshesITR script here:

https://gist.github.com/russHyde/568fd5af558c860d97e1b932ca773ff7

And tracking it here for transparency/easy versioning. Put in .dev which can hold various helpers for doing dev on the package.

Have been testing it on some sample CRAN packages but it's tough to get started. Lots of Depends to install from packages chosen at random... library is bloating quickly 😸

Copy link
Collaborator

@russHyde russHyde left a comment

Choose a reason for hiding this comment

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

Thanks for adding this, mostly looks sound.
I hadn't heard of gert before, so thanks for that tip.
Would it be possible to allow the user to turn off running the load_all step; and could we use optparse for option handling, rather than rolling our own handler, please.

@MichaelChirico
Copy link
Collaborator Author

Didn't add the option for turning load_all on/off (it's easy enough), i got confused about it... I think we have to run load_all to source the lintr functions for each branch.

What I think should be optional is running load_all for the package sources, which I don't think is happening now? But then I don't know why I ran into some "package not found" issues... I guess it's because object_usage_linter does run it for the package code? In which case I'm not sure how to turn it off.

Anyway I'll take a closer look at it later.

@russHyde
Copy link
Collaborator

Sorry about that. I confused myself. Please disregard my note about devtools::load_all; I mistakenly thought you were loading the analysed package prior to linting.

russHyde
russHyde previously approved these changes Feb 16, 2021
Copy link
Collaborator

@russHyde russHyde left a comment

Choose a reason for hiding this comment

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

LGTM

@russHyde
Copy link
Collaborator

The failing tests in CI aren't related to this PR.

@AshesITR
Copy link
Collaborator

Running load_all() on the linted package is necessary for object_usage_linter (AFAIK the only one needing to know global package state). So we might want to add this in the future.

But I ran into very messy issues while running the tests for packages that are needed by the script and contain binaries (e.g. purrr, rlang, dplyr, tidyr, ...) so that feature should probably come with more safety measures like running in separate R processes and maybe installing the active lintr branch into a temporary local library.

@MichaelChirico
Copy link
Collaborator Author

Also needed for object_name_linter btw... maybe not loading the full package, but I believe linter:::namespace_imports won't work if the package's Depends are not available... certainly running into that issue now trying to run a comparison for #755

MichaelChirico and others added 3 commits February 16, 2021 23:09
* add name attribute to Linter class

fixes #746

* fix test failures

* document()

* restore 100% coverage for utils.R

* deprecate Lint(linter = ...) and remove all calling instances

make expect_lint() resilient to complete removal of the argument

* add NEWS bullet

* document()

* fix lint, collapse with space

fix test expectation

Co-authored-by: Michael Chirico <[email protected]>
skip Depends except on object_usage_linter

typo

need check higher up

forgot to supply arg

just exit early if Depends unavailable

provide an interactive() experience for debugging

tweak
@MichaelChirico
Copy link
Collaborator Author

Added some functionality for running interactively, I think it works pretty nicely. Would be happy to merge now, PTAL

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 mostly good to me.

AshesITR and others added 3 commits February 17, 2021 00:21
* add name attribute to Linter class

fixes #746

* fix test failures

* document()

* restore 100% coverage for utils.R

* deprecate Lint(linter = ...) and remove all calling instances

make expect_lint() resilient to complete removal of the argument

* add NEWS bullet

* document()

* fix lint, collapse with space

fix test expectation

Co-authored-by: Michael Chirico <[email protected]>
not working from command line

testing more

debugging Rscript sucks

progress -- we need to skip missing Imports too

more progress -- skip on platforms without tcl/tk

need testing again

need to exit early
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.

LGTM, thanks for polishing. This will be very useful.

@AshesITR AshesITR merged commit 94b745b into master Feb 18, 2021
@AshesITR AshesITR deleted the add-dev-script branch February 18, 2021 09:17
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.

4 participants