Skip to content

Commit 7b5797f

Browse files
committed
fix: fix github actions
1 parent 9c254a9 commit 7b5797f

File tree

7 files changed

+81
-64
lines changed

7 files changed

+81
-64
lines changed

.pre-commit-config.yaml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v4.4.0
4+
hooks:
5+
- id: trailing-whitespace
6+
- id: end-of-file-fixer
7+
- id: check-yaml
8+
- id: check-added-large-files
9+
10+
- repo: https://github.com/lorenzwalthert/precommit
11+
rev: v0.3.2.9007
12+
hooks:
13+
- id: style-files
14+
args: [--style_pkg=styler, --style_fun=tidyverse_style]
15+
- id: lintr
16+
- id: readme-rmd-rendered
17+
- id: parsable-R
18+
- id: no-browser-statement
19+
- id: deps-in-desc

DESCRIPTION

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Encoding: UTF-8
1010
LazyData: true
1111
Roxygen: list(markdown = TRUE)
1212
RoxygenNote: 7.3.0
13-
Suggests:
13+
Suggests:
1414
covr,
1515
knitr,
1616
lintr,
@@ -24,7 +24,7 @@ Config/testthat/edition: 3
2424
VignetteBuilder: knitr
2525
URL: https://github.com/DiogoRibeiro7/myrpackage, https://diogoribeiro7.github.io/myrpackage/
2626
BugReports: https://github.com/DiogoRibeiro7/myrpackage/issues
27-
Imports:
27+
Imports:
2828
lifecycle
29-
Depends:
29+
Depends:
3030
R (>= 3.5)

R/goodbye.R

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#' different names and languages.
55
#'
66
#' @param name Character string. The name to bid farewell to. Default is "world".
7-
#' @param language Character string. The language for the farewell.
7+
#' @param language Character string. The language for the farewell.
88
#' Supported languages: "english" (default), "spanish", "french", "portuguese".
99
#' @param exclamation Logical. Whether to add an exclamation mark. Default is TRUE.
1010
#'
@@ -16,23 +16,22 @@
1616
#' goodbye("R Users")
1717
#' goodbye("amigos", language = "spanish")
1818
#' goodbye("mes amis", language = "french", exclamation = FALSE)
19-
#'
19+
#'
2020
#' @seealso \code{\link{hello}} for a greeting function
2121
goodbye <- function(name = "world", language = "english", exclamation = TRUE) {
22-
2322
# Input validation
2423
if (!is.character(name) || length(name) != 1) {
2524
stop("'name' must be a single character string")
2625
}
27-
26+
2827
if (!is.character(language) || length(language) != 1) {
2928
stop("'language' must be a single character string")
3029
}
31-
30+
3231
if (!is.logical(exclamation) || length(exclamation) != 1) {
3332
stop("'exclamation' must be a single logical value")
3433
}
35-
34+
3635
# Select farewell based on language
3736
farewell <- switch(
3837
tolower(language),
@@ -43,20 +42,20 @@ goodbye <- function(name = "world", language = "english", exclamation = TRUE) {
4342
# Default to English if language not supported
4443
"Goodbye"
4544
)
46-
45+
4746
# Construct the farewell
4847
result <- paste0(farewell, ", ", name)
49-
48+
5049
# Add exclamation mark if requested
5150
if (exclamation) {
5251
result <- paste0(result, "!")
5352
} else {
5453
result <- paste0(result, ".")
5554
}
56-
55+
5756
# Print the farewell and return it invisibly
5857
cat(result, "\n")
59-
58+
6059
# Return the farewell
6160
invisible(result)
6261
}

R/hello.R

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#' different names and languages.
55
#'
66
#' @param name Character string. The name to greet. Default is "world".
7-
#' @param language Character string. The language for the greeting.
7+
#' @param language Character string. The language for the greeting.
88
#' Supported languages: "english" (default), "spanish", "french", "portuguese".
99
#' @param exclamation Logical. Whether to add an exclamation mark. Default is TRUE.
1010
#'
@@ -16,23 +16,22 @@
1616
#' hello("R Users")
1717
#' hello("amigos", language = "spanish")
1818
#' hello("mes amis", language = "french", exclamation = FALSE)
19-
#'
19+
#'
2020
#' @seealso \code{\link{goodbye}} for a farewell function
2121
hello <- function(name = "world", language = "english", exclamation = TRUE) {
22-
2322
# Input validation
2423
if (!is.character(name) || length(name) != 1) {
2524
stop("'name' must be a single character string")
2625
}
27-
26+
2827
if (!is.character(language) || length(language) != 1) {
2928
stop("'language' must be a single character string")
3029
}
31-
30+
3231
if (!is.logical(exclamation) || length(exclamation) != 1) {
3332
stop("'exclamation' must be a single logical value")
3433
}
35-
34+
3635
# Select greeting based on language
3736
greeting <- switch(
3837
tolower(language),
@@ -43,20 +42,20 @@ hello <- function(name = "world", language = "english", exclamation = TRUE) {
4342
# Default to English if language not supported
4443
"Hello"
4544
)
46-
45+
4746
# Construct the greeting
4847
result <- paste0(greeting, ", ", name)
49-
48+
5049
# Add exclamation mark if requested
5150
if (exclamation) {
5251
result <- paste0(result, "!")
5352
} else {
5453
result <- paste0(result, ".")
5554
}
56-
55+
5756
# Print the greeting and return it invisibly
5857
cat(result, "\n")
59-
58+
6059
# Return the greeting
6160
invisible(result)
6261
}

_pkgdown.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,5 +61,5 @@ home:
6161
community:
6262
title: Community
6363
text: >
64-
If you have questions or issues about the package, please file an issue on
64+
If you have questions or issues about the package, please file an issue on
6565
[GitHub](https://github.com/DiogoRibeiro7/myrpackage/issues).

tests/testthat/test-goodbye.R

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
test_that("goodbye() prints correctly with default arguments", {
22
# Test the default output
33
expect_output(goodbye(), "Goodbye, world!")
4-
4+
55
# Test that the invisible return value is correct
66
expect_equal(suppressMessages(goodbye()), "Goodbye, world!")
77
})
@@ -14,24 +14,24 @@ test_that("goodbye() accepts custom name parameter", {
1414
test_that("goodbye() supports different languages", {
1515
# Test English (default)
1616
expect_output(goodbye(language = "english"), "Goodbye, world!")
17-
17+
1818
# Test Spanish
1919
expect_output(goodbye(language = "spanish"), "Adiós, world!")
20-
20+
2121
# Test French
2222
expect_output(goodbye(language = "french"), "Au revoir, world!")
23-
23+
2424
# Test Portuguese
2525
expect_output(goodbye(language = "portuguese"), "Adeus, world!")
26-
26+
2727
# Test unknown language (should default to English)
2828
expect_output(goodbye(language = "german"), "Goodbye, world!")
2929
})
3030

3131
test_that("goodbye() correctly handles exclamation parameter", {
3232
# Test with exclamation = TRUE (default)
3333
expect_output(goodbye(exclamation = TRUE), "Goodbye, world!")
34-
34+
3535
# Test with exclamation = FALSE
3636
expect_output(goodbye(exclamation = FALSE), "Goodbye, world.")
3737
})
@@ -40,11 +40,11 @@ test_that("goodbye() validates input parameters", {
4040
# Test invalid name parameter
4141
expect_error(goodbye(name = c("world", "everyone")), "'name' must be a single character string")
4242
expect_error(goodbye(name = 123), "'name' must be a single character string")
43-
43+
4444
# Test invalid language parameter
4545
expect_error(goodbye(language = c("english", "spanish")), "'language' must be a single character string")
4646
expect_error(goodbye(language = 123), "'language' must be a single character string")
47-
47+
4848
# Test invalid exclamation parameter
4949
expect_error(goodbye(exclamation = c(TRUE, FALSE)), "'exclamation' must be a single logical value")
5050
expect_error(goodbye(exclamation = "yes"), "'exclamation' must be a single logical value")

tests/testthat/test-hello.R

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,59 @@
1-
test_that("hello() prints correctly with default arguments", {
1+
test_that("goodbye() prints correctly with default arguments", {
22
# Test the default output
3-
expect_output(hello(), "Hello, world!")
4-
3+
expect_output(goodbye(), "Goodbye, world!")
4+
55
# Test that the invisible return value is correct
6-
expect_equal(suppressMessages(hello()), "Hello, world!")
6+
expect_equal(suppressMessages(goodbye()), "Goodbye, world!")
77
})
88

9-
test_that("hello() accepts custom name parameter", {
9+
test_that("goodbye() accepts custom name parameter", {
1010
# Test with a custom name
11-
expect_output(hello("R Users"), "Hello, R Users!")
11+
expect_output(goodbye("R Users"), "Goodbye, R Users!")
1212
})
1313

14-
test_that("hello() supports different languages", {
14+
test_that("goodbye() supports different languages", {
1515
# Test English (default)
16-
expect_output(hello(language = "english"), "Hello, world!")
17-
16+
expect_output(goodbye(language = "english"), "Goodbye, world!")
17+
1818
# Test Spanish
19-
expect_output(hello(language = "spanish"), "Hola, world!")
20-
19+
expect_output(goodbye(language = "spanish"), "Adiós, world!")
20+
2121
# Test French
22-
expect_output(hello(language = "french"), "Bonjour, world!")
23-
22+
expect_output(goodbye(language = "french"), "Au revoir, world!")
23+
2424
# Test Portuguese
25-
expect_output(hello(language = "portuguese"), "Olá, world!")
26-
25+
expect_output(goodbye(language = "portuguese"), "Adeus, world!")
26+
2727
# Test unknown language (should default to English)
28-
expect_output(hello(language = "german"), "Hello, world!")
28+
expect_output(goodbye(language = "german"), "Goodbye, world!")
2929
})
3030

31-
test_that("hello() correctly handles exclamation parameter", {
31+
test_that("goodbye() correctly handles exclamation parameter", {
3232
# Test with exclamation = TRUE (default)
33-
expect_output(hello(exclamation = TRUE), "Hello, world!")
34-
33+
expect_output(goodbye(exclamation = TRUE), "Goodbye, world!")
34+
3535
# Test with exclamation = FALSE
36-
expect_output(hello(exclamation = FALSE), "Hello, world.")
36+
expect_output(goodbye(exclamation = FALSE), "Goodbye, world.")
3737
})
3838

39-
test_that("hello() validates input parameters", {
39+
test_that("goodbye() validates input parameters", {
4040
# Test invalid name parameter
41-
expect_error(hello(name = c("world", "everyone")), "'name' must be a single character string")
42-
expect_error(hello(name = 123), "'name' must be a single character string")
43-
41+
expect_error(goodbye(name = c("world", "everyone")), "'name' must be a single character string")
42+
expect_error(goodbye(name = 123), "'name' must be a single character string")
43+
4444
# Test invalid language parameter
45-
expect_error(hello(language = c("english", "spanish")), "'language' must be a single character string")
46-
expect_error(hello(language = 123), "'language' must be a single character string")
47-
45+
expect_error(goodbye(language = c("english", "spanish")), "'language' must be a single character string")
46+
expect_error(goodbye(language = 123), "'language' must be a single character string")
47+
4848
# Test invalid exclamation parameter
49-
expect_error(hello(exclamation = c(TRUE, FALSE)), "'exclamation' must be a single logical value")
50-
expect_error(hello(exclamation = "yes"), "'exclamation' must be a single logical value")
49+
expect_error(goodbye(exclamation = c(TRUE, FALSE)), "'exclamation' must be a single logical value")
50+
expect_error(goodbye(exclamation = "yes"), "'exclamation' must be a single logical value")
5151
})
5252

53-
test_that("hello() works with all combinations of parameters", {
53+
test_that("goodbye() works with all combinations of parameters", {
5454
# Test with all parameters customized
5555
expect_output(
56-
hello(name = "friends", language = "spanish", exclamation = FALSE),
57-
"Hola, friends."
56+
goodbye(name = "friends", language = "spanish", exclamation = FALSE),
57+
"Adiós, friends."
5858
)
5959
})

0 commit comments

Comments
 (0)