Skip to content

fix: 3 shinipsum issues — geom_line(size=) deprecation (#13), random_image args (#9), n_bars (#5)#15

Open
VincentGuyader wants to merge 3 commits into
masterfrom
fix/multiple-issues
Open

fix: 3 shinipsum issues — geom_line(size=) deprecation (#13), random_image args (#9), n_bars (#5)#15
VincentGuyader wants to merge 3 commits into
masterfrom
fix/multiple-issues

Conversation

@VincentGuyader
Copy link
Copy Markdown
Member

Summary

# Type Résumé
#13 bug random_ggplot("line") triggered ggplot2's size → linewidth deprecation warning. Replace geom_line(size = 2) with geom_line(linewidth = 2).
#9 feat random_image() now accepts width = NULL, height = NULL, alt = NULL and includes them in the returned list when set. Default shape unchanged (just src), so existing callers are untouched.
#5 feat New n_bars = NULL argument on random_ggplot(): when set together with type = "bar", the function generates a synthetic categorical data frame so the rendered plot has exactly that many bars. Without the argument, the legacy datasets-based behaviour is kept.

Test plan

  • testthat::test_local(): 3175 PASS / 0 FAIL.
  • New tests:
    • test-no_deprecated_args.R (ggplot_build under expect_no_warning, plus static sweep on Plot.R)
    • test-image_args.R (default src-only, all three extras propagated, NULL extras dropped)
    • test-bar_n.R (1 / 3 / 7 / 27 bars match the rendered output, invalid n_bars rejected)

Tracking notes in dev/SUIVI_ISSUES.md.

Closes #5
Closes #9
Closes #13

…bars (#5)

- #13: random_ggplot('line') was using geom_line(size=) which ggplot2
  >= 3.4 deprecated in favour of linewidth=. Switch the call.
  Regression test builds a 'line' plot and asserts no lifecycle
  warning, plus a static sweep on Plot.R.
- #9: random_image() now accepts width / height / alt and includes them
  in the returned list when set. Default shape unchanged (just src).
- #5: random_ggplot('bar', n_bars = n) generates a synthetic
  categorical data frame so the rendered plot has *exactly* n bars.
  Without the argument, the legacy datasets-based behaviour is kept.

Tracking notes in dev/SUIVI_ISSUES.md.
…drop brittle sweep)

- Drop withr::with_seed() in tests in favour of an inline
  set.seed/.Random.seed save-restore: withr is not declared in the
  package's DESCRIPTION, R CMD check NOTE'd '::' import not declared.
- Declare 'category' and 'value' in R/globals.R: random_ggplot('bar',
  n_bars=) uses them in aes() and was raising 'no visible binding'.
- Drop the static-sweep test in test-no_deprecated_args.R: it tried to
  read R/Plot.R from the source tree, which doesn't exist past
  installation, so R CMD check tests errored. The first regression
  test (build the plot, assert no lifecycle warning) is sufficient.
Pre-existing CI used actions/cache@v2 (now hard-failed by GitHub) and
r-lib/actions setup-r@v1. Replace test-coverage and pkgdown with the
standard r-lib/actions v2 templates on ubuntu-latest, bump
R-CMD-check checkout v3 -> v5 (Node.js 24).
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR addresses three tracked shinipsum issues by updating ggplot generation to avoid a ggplot2 deprecation warning, extending random_image() to pass through common <img> attributes, and adding deterministic bar-count control for random_ggplot(type = "bar").

Changes:

  • Add n_bars to random_ggplot() and generate synthetic categorical data when set.
  • Extend random_image() with optional width, height, and alt fields (while preserving the default list(src=...) shape).
  • Add regression tests for the above, plus CI workflow modernizations and refreshed roxygen outputs.

Reviewed changes

Copilot reviewed 11 out of 14 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
tests/testthat/test-no_deprecated_args.R Adds a test to ensure building a line plot doesn’t emit the ggplot2 size/linewidth deprecation warning.
tests/testthat/test-image_args.R Adds tests verifying random_image() default return shape and optional argument propagation.
tests/testthat/test-bar_n.R Adds tests ensuring n_bars yields exactly N bars and invalid inputs error.
R/Plot.R Implements n_bars support and switches a line plot from size to linewidth.
R/Image.R Adds width, height, alt arguments and includes them in the returned renderImage list when non-NULL.
R/globals.R Registers new NSE column symbols used by the synthetic bar plot path.
man/shinipsum-package.Rd Minor formatting update to the package description.
man/random_image.Rd Documents new random_image() arguments/return value.
man/random_ggplot.Rd Documents new n_bars argument.
dev/SUIVI_ISSUES.md Adds internal tracking notes for issues #5/#9/#13.
DESCRIPTION Updates RoxygenNote.
.github/workflows/test-coverage.yaml Modernizes coverage workflow (r-lib/actions v2, ubuntu-latest, expanded branch triggers).
.github/workflows/R-CMD-check.yaml Updates checkout action version.
.github/workflows/pkgdown.yaml Modernizes pkgdown build/deploy workflow (r-lib/actions v2, deploy action).
Files not reviewed (3)
  • man/random_ggplot.Rd: Language not supported
  • man/random_image.Rd: Language not supported
  • man/shinipsum-package.Rd: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread R/Plot.R
ggplot(datasets::women) +
aes(height, weight) +
geom_line(size = 2) +
geom_line(linewidth = 2) +
Comment thread R/Plot.R
Comment on lines +48 to +49
stopifnot(is.numeric(n_bars), length(n_bars) == 1L,
!is.na(n_bars), n_bars >= 1L)
Comment thread R/Image.R
@@ -2,14 +2,25 @@
#'
#' This function returns a random image that can be passed into `renderImage` and `plotOutput`.
@VincentGuyader VincentGuyader requested a review from Copilot May 12, 2026 12:09
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 11 out of 14 changed files in this pull request and generated 4 comments.

Files not reviewed (3)
  • man/random_ggplot.Rd: Language not supported
  • man/random_image.Rd: Language not supported
  • man/shinipsum-package.Rd: Language not supported

Comment thread R/Plot.R
Comment on lines +47 to +54
if (type_matched == "bar" && !is.null(n_bars)) {
stopifnot(is.numeric(n_bars), length(n_bars) == 1L,
!is.na(n_bars), n_bars >= 1L)
n_bars <- as.integer(n_bars)
df <- data.frame(
category = factor(make_bar_labels(n_bars),
levels = make_bar_labels(n_bars)),
value = sample.int(100L, n_bars, replace = TRUE)
Comment thread R/Plot.R
ggplot(datasets::women) +
aes(height, weight) +
geom_line(size = 2) +
geom_line(linewidth = 2) +
Comment on lines +22 to +23
msgs <- capture_warnings(invisible(ggplot2::ggplot_build(p)))
expect_false(any(grepl("size.*deprecated", msgs)))
Comment on lines +15 to +20
set.seed(42)
p <- random_ggplot("line")
# Building the plot is what triggers the lifecycle warning, not the
# construction. expect_no_warning() requires testthat 3.1.5+.
if (utils::packageVersion("testthat") >= "3.1.5") {
expect_no_warning(invisible(ggplot2::ggplot_build(p)))
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.

random_ggplot() using depredated args Pass arguments to random_image Specify number of bars in random_ggplot("bar")

2 participants