You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: code_issues.qmd
+7-7Lines changed: 7 additions & 7 deletions
Original file line number
Diff line number
Diff line change
@@ -125,7 +125,7 @@ To allow users to suppress the console output CRAN recommends two different ways
125
125
126
126
* exchanging `cat()`/`print()` with other generics
127
127
-[`message()`](https://stat.ethz.ch/R-manual/R-devel/library/base/html/message.html): for information messages and status updates
128
-
-[`warning()`](https://stat.ethz.ch/R-manual/R-devel/library/base/html/warning.html): for warning, will print a "Warning: " before the output
128
+
-[`warning()`](https://stat.ethz.ch/R-manual/R-devel/library/base/html/warning.html): for warnings, will print a "Warning: " before the output
129
129
-[`stop()`](https://stat.ethz.ch/R-manual/R-devel/library/base/html/stop.html): for error messages, will print an "Error: " before the output and halt the execution
130
130
131
131
This allows to use functions like `suppressMessages()` to avoid unwanted output.
@@ -152,7 +152,7 @@ Functions can print per default, like the example above, as long as the printing
152
152
:::{.callout-note}
153
153
154
154
`print()` and `cat()` are not the only functions which can write output onto the console. The issue described in the recipe, also applies to the use of other printing function like `writeLines()`.
155
-
If you are using loggers to document your functions' process, make sure that users can set their log level such that not messages are displayed.
155
+
If you are using loggers to document your functions' process, make sure that users can set their log level such that messages are not displayed.
156
156
157
157
:::
158
158
@@ -255,8 +255,8 @@ Here the code will only reset the options if the example runs without breaking.
255
255
256
256
:::{.callout-tip}
257
257
258
-
If you need to change more than one option in the same function, example, vignette or demo, you can use `oldpar <- par(no.readonly = TRUE)` or `oldop <- options()` to reset all parameters at once. Saving the entire
259
-
Note, that for `par()` the `no.readonly` argument must be set to `TRUE` or else warnings will be produced.
258
+
If you need to change more than one option in the same function, example, vignette or demo, you can use `oldpar <- par(no.readonly = TRUE)` or `oldop <- options()` to reset all parameters at once.
259
+
Note that, in this case, for `par()` the `no.readonly` argument must be set to `TRUE` or else warnings will be produced.
260
260
261
261
:::
262
262
@@ -322,7 +322,7 @@ Check: for detritus in the temp directory, Result: NOTE\
322
322
   ‘this\_is\_detritus382e569a7712’
323
323
:::
324
324
325
-
The code responsible for the detritus may include your own tests and examples creating files under `tempdir()`, child processes, or 'Python' code launched using 'reticulate'. For example, R packages that use the 'tensorflow' 'Python' package [find and remove temporary files created by its auto-gradient feature](https://github.com/cran/vetiver/blob/35b24768cf0e84fab96610e001bba377dc777953/tests/testthat/setup.R#L13).
325
+
The code responsible for the detritus may include your own tests and examples creating files under `tempdir()`, child processes, or 'Python' code launched using 'reticulate'. For example, R packages that use the 'tensorflow' 'Python' package may use the following to [find and remove temporary files created by its auto-gradient feature](https://github.com/cran/vetiver/blob/35b24768cf0e84fab96610e001bba377dc777953/tests/testthat/setup.R#L13).
326
326
327
327
A package that uses the 'testthat' test suite will benefit from [the self-cleaning functions `withr::local_tempfile()` and `withr::local_tempdir()`](https://r-pkgs.org/testing-design.html#sec-tests-files-where-write) to work with temporary files. Even without 'testthat', the 'withr' package has no external strong dependencies and can be used independently.
328
328
@@ -348,7 +348,7 @@ Please do not modify the global environment (e.g., by using <<-) in your functio
348
348
349
349
The `.GlobalEnv` is the main workspace of users. It can also be accessed by `globalenv()`. Writing to the global environment is forbidden for CRAN packages.
350
350
351
-
Sometimes package maintainers use the operator `<<-`. This operator not only evaluates the expression in the environment it is called in, checks parent environments for an existing definition of the variable. If such a variable is found then its value is redefined, otherwise assignment takes place in the `.GlobalEnv`.
351
+
Sometimes package maintainers use the operator `<<-`. This operator not only evaluates the expression in the environment it is called in, but checks parent environments for an existing definition of the variable. If such a variable is found then its value is redefined, otherwise assignment takes place in the `.GlobalEnv`.
352
352
To avoid writing to the global environment, the variable must be defined in a parent environment.
353
353
354
354
```{r eval=FALSE}
@@ -453,7 +453,7 @@ Create special functions for the purpose of installing software and don't instal
Please do not install packages in your functions, examples or vignette. This can make the functions, examples and cran-check very slow.
456
+
Please do not install packages in your functions, examples or vignettes. This can make the functions, examples and CRAN-check very slow.
457
457
:::
458
458
459
459
Packages should usually not be installed within functions, especially since dependencies should already be listed in the DESCRIPTION. For external software this is typically the same. However, if the purpose of your package is to connect to specific APIs or provides easier installation for some programs, installing software or packages is allowed on CRAN.
0 commit comments