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

Forbid new check warnings #2404

Merged
merged 32 commits into from Sep 19, 2019

Conversation

infotroph
Copy link
Member

@infotroph infotroph commented Sep 4, 2019

Description

Experimental, opening PR for discussion but not confident this is the right approach. Opinions, please!

Increments the strictness of PEcAn's package checks by forbidding newly added WARNINGs or NOTEs without breaking the build for the (many) pre-existing messages.

In keeping with #1949, the idea here is to move toward eventually requiring all changes to maintain a clean devtools::check result: Many check messages indicate issues with potentially severe consequences even if are labeled as "WARNING" or "NOTE" rather than "ERROR", and it's preferable to to fix even the minor-looking issues so that we don't miss the severe ones in the noise.

Since #2174, all packages are checked during Travis builds and the build is marked broken if any ERRORs are found. It would be very simple to ratchet this up to break on any WARNING, but fixing all existing warnings from legacy code would be a big undertaking and we might accumulate new warnings faster than we fixed old ones.

What I proposed in #1949 was to blacklist a slowly growing list of warning types, e.g. fix all '::' or ':::' import not declared and break the build on new ones, then tackle Undocumented code objects, and so on. On consideration this still feels Sisyphean, so what I propose here is an across-the-board grandfather clause: We cache current check outputs and break the build on any message newly added by the current build, while continuing to let existing messages slide like we have been doing. This should enforce good practice in newly added code without forcing too much immediate cleanup in the old stuff. As historic warnings get cleaned up in future refactorings, we can update the cached check results to make sure they stay gone.

Motivation and Context

Review Time Estimate

  • Immediately
  • Within one week
  • When possible

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My change requires a change to the documentation.
  • I have updated the CHANGELOG.md.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@infotroph
Copy link
Member Author

infotroph commented Sep 4, 2019

Sample of Travis output when a new problem is detected: https://travis-ci.org/infotroph/pecan/jobs/580354445#L6106-L6128

@ashiklom ashiklom self-requested a review September 5, 2019 14:38
Apparently R check now does some static analysis and complains about "unstated dependencies in tests" because of these lines even though they never run. Easier to remove them than to fight it.
@ashiklom
Copy link
Member

It's still marked as "Draft", so not sure if a formal review is appropriate, but in general, this looks super useful -- thanks for putting it together!

@infotroph
Copy link
Member Author

@ashiklom I marked this as draft to emphasize that I wanted feedback before it was merged, so reviews are very helpful.

If the overall approach seems sound, I'll make whatever other tweaks are needed to make the build pass and then solicit a final round of review.

@ashiklom
Copy link
Member

I would like to see this go in sooner rather than later, especially given the flurry of PEcAn development that will be happening in anticipating of upcoming meetings. So feel free to drop the "Draft" status whenever you're ready so we can give this a formal review.

If you have the time, one thing that would help this PR is adding a brief (maybe even just in bullet form) section on "Continuous Integration / Travis" to our documentation. I think this would work as either an appendix, a sub-section of "Developer Guide -> Testing", or maybe even a full section under "Developer Guide". I would be perfectly happy with just a list of checks that are performed on Travis and a few notes about solving common errors (e.g. forgetting to run make document, fixing new "check" messages per this PR, re-starting the build if it times out).

R 3.5 reports the bare Rd filename, R >= 3.6 reports it as `man/<file>.Rd`.
Decided it was easier to fix the error than to make the script handle it gracefully
@robkooper
Copy link
Member

robkooper commented Sep 18, 2019

Do we need all the Rcheck_reference.log or those there as a what still needs to be fixed, or does the code use this to see if new warnings/errors are produced?

Saw where the files are needed.

@infotroph
Copy link
Member Author

@robkooper We need them (the code compares each new check result against Rcheck_reference.log to find out what errors are new), but I'm not certain tests is the best place to store them and would welcome suggestions.

@infotroph infotroph marked this pull request as ready for review September 18, 2019 21:43
#' @return
#' @return A list with two entries:
#' * `sys`: Exit value returned by the workflow (0 for sucess).
#' * `outdir`: Path where the workflow results are saved
Copy link
Member Author

Choose a reason for hiding this comment

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

@ashiklom please verify this is a sensible return type description

unlist(lapply(msg, function(x)paste(x[[1]], x[-1], sep=": ")))
}

old_file <- file.path(pkg, "tests", "Rcheck_reference.log")
Copy link
Member

Choose a reason for hiding this comment

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

This answers my own question about the Rcheck_reference.log

Copy link
Member

@robkooper robkooper left a comment

Choose a reason for hiding this comment

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

I'd would suggest to commit. That way people can fix a WARNING/ERROR etc and commit it so it is easy to see warnings being fixed instead of having this ever changing pull request.

@@ -49,7 +49,7 @@ sda.enkf <- function(settings,
host <- settings$host
forecast.time.step <- settings$state.data.assimilation$forecast.time.step #idea for later generalizing
nens <- as.numeric(settings$ensemble$size)
processvar <- settings$state.data.assimilation$process.variance %>% as.logical()
processvar <- as.logical(settings$state.data.assimilation$process.variance)
Copy link
Member Author

Choose a reason for hiding this comment

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

@para2x I think my changes in this file are mostly in your code, especially from #2405 (it was merged after I created the reference files and therefore its check warnings aren't ignored). I tried to only remove pipes without changing code behavior, but please check that I didn't break anything.

@infotroph
Copy link
Member Author

infotroph commented Sep 18, 2019

TODO before merging:

  • Get last few errors through Travis
  • Optionally, could punt to a separate PR: Documentation per @ashiklom request

Copy link
Member

@ashiklom ashiklom left a comment

Choose a reason for hiding this comment

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

This looks great, thanks again for your hard work on this!

* Retrieves any cached files available from previous Travis builds.
- The main thing in the cache is previously-installed dependency R packages, to avoid recompiling them every time.
- If the cache becomes stale or is preventing a package update needed by the build (e.g. to get a new version that contains a needed bug fix), delete the cache through the Travis web interface and it will be reconstructed on the next build.
- Because PEcAn has so many dependencies, builds with no cache will spend most of their time recompiling packages and will often run out of time before the tests complete. You can fix this by [triggering a custom build](https://blog.travis-ci.com/2017-08-24-trigger-custom-build) using a custom config that installs but does not test PEcAn (e.g. `script: make install`), waiting for this to finish and upload its new cache, then restarting the standard full build.
Copy link
Member

Choose a reason for hiding this comment

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

This is an excellent suggestion. I did not know about this workaround.

Copy link
Member

@mdietze mdietze left a comment

Choose a reason for hiding this comment

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

@infotroph I was about to merge this, but then I noticed all these new get.model.output.[MODEL] functions, all of which are dummy functions. What do these do and why are they being added?

@ashiklom
Copy link
Member

@mdietze Unless I'm missing something, I only see one new get.model.output function in this PR -- get.model.output.dalec -- and it's just there to replace hand-written documentation about a non-existent get.model.output.generic function. We currently have a bunch of other get.model.output.[MODEL] functions (e.g. get.model.output.ED2, get.model.output.BIOCRO) that are real functions that do real things.

That said, for the get.model.output.dalec specifically, it may be worth either (1) having this function throw an error that says it hasn't yet been implemented, or (2) just deleting it altogether to avoid confusion.

@infotroph
Copy link
Member Author

infotroph commented Sep 19, 2019

@mdietze the man/ directory for DALEC contained a hand-written Rd file whose \title was get.model.output.generic but its \usage showed get.model.output.dalec, leading to a check complaint about "code/documentation mismatch".

No idea why this showed up now but not in the stored check results file, but I figured the quickest fix was to add the dummy function so that Roxygen would regenerate the Rd with correct formatting (and with the correct filename).

I'm happy with either of @ashiklom's suggestions (add error or delete) and will do whichever the boss says.

infotroph and others added 3 commits September 19, 2019 14:58
…s/04-testing.Rmd

Co-Authored-By: Alexey Shiklomanov <alexey.shiklomanov@gmail.com>
…s/04-testing.Rmd

Co-Authored-By: Alexey Shiklomanov <alexey.shiklomanov@gmail.com>
@mdietze mdietze merged commit e0716a2 into PecanProject:develop Sep 19, 2019
@infotroph infotroph deleted the forbid-new-check-warnings branch October 23, 2019 08:24
@robkooper robkooper added this to the 1.8.0 milestone Apr 14, 2020
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.

None yet

4 participants