Skip to content

Commit

Permalink
add warning on use of unnamed args
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.r-project.org/R/trunk@87828 00db46b3-68df-0310-9c12-caf00c1e9a41
  • Loading branch information
ripley committed Feb 26, 2025
1 parent 3886231 commit 9209836
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
9 changes: 8 additions & 1 deletion src/library/base/man/grep.Rd
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
% File src/library/base/man/grep.Rd
% Part of the R package, https://www.R-project.org
% Copyright 1995-2022 R Core Team
% Copyright 1995-2025 R Core Team
% Distributed under GPL 2 or later

\name{grep}
Expand Down Expand Up @@ -286,6 +286,13 @@ gregexec(pattern, text, ignore.case = FALSE, perl = FALSE,
in 8-bit encodings can differ considerably between platforms, modes
and from the UTF-8 versions.
}
\section{Warning}{
An all too cmmmon mis-usage is to pass unnamed arguments which are then
matched to one or more of \code{ignore.case}, \code{perl}, \code{value},
\code{fixed}, \code{useBytes} and \code{invert}. So it is good
practice to name all the arguments (especially as
\code{x}/\code{text} is not the first argument).
}

\references{
Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988)
Expand Down
10 changes: 9 additions & 1 deletion src/library/base/man/grepRaw.Rd
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
% File src/library/base/man/grepRaw.Rd
% Part of the R package, https://www.R-project.org
% Copyright 1995-2016 R Core Team
% Copyright 1995-2025 R Core Team
% Distributed under GPL 2 or later

\name{grepRaw}
Expand Down Expand Up @@ -73,6 +73,14 @@ grepRaw(pattern, x, offset = 1L, ignore.case = FALSE,
is used except for \code{fixed = TRUE}.
}

\section{Warning}{
An all too cmmmon mis-usage is to pass unnamed arguments which are then
matched to one or more of \code{ignore.case}, \code{value},
\code{fixed}, \code{all} or \code{invert}. So it is good practice to
name all the arguments.
}


% the `aka' below is for ESS
\seealso{
\link{regular expression} (aka \code{\link{regexp}}) for the details
Expand Down
9 changes: 8 additions & 1 deletion src/library/base/man/strsplit.Rd
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
% File src/library/base/man/strsplit.Rd
% Part of the R package, https://www.R-project.org
% Copyright 1995-2024 R Core Team
% Copyright 1995-2024=5 R Core Team
% Distributed under GPL 2 or later

\name{strsplit}
Expand Down Expand Up @@ -104,6 +104,13 @@ strsplit(x, split, fixed = FALSE, perl = FALSE, useBytes = FALSE)
substituted invalid bytes.
}

\section{Warning}{
An all too cmmmon mis-usage is to pass unnamed arguments which are then
matched to one or more of \code{fixed},
\code{perl} and \code{useBytes}. So it is good
practice to name all the arguments.
}

\seealso{
\code{\link{paste}} for the reverse,
\code{\link{grep}} and \code{\link{sub}} for string search and
Expand Down

0 comments on commit 9209836

Please sign in to comment.