\name{QA}
\alias{QA}
\alias{checkAssignFuns}
\alias{checkDocArgs}
\alias{checkDocStyle}
\alias{checkMethods}
\title{QA Checks for R Code and/or Documentation}
\description{
  Functions for performing various quality checks.
}
\usage{
checkAssignFuns(package, dir, lib.loc = NULL)
checkDocArgs(package, dir, lib.loc = NULL)
checkDocStyle(package, dir, lib.loc = NULL)
checkMethods(package, dir, lib.loc = NULL)
}
\arguments{
  \item{package}{a character string naming an installed package.}
  \item{dir}{a character string specifying the path to a package's root
    source directory.  This should contain the subdirectories \code{R}
    (for R code) and \file{man} with \R documentation sources (in Rd
    format).  Only used if \code{package} is not given.}
  \item{lib.loc}{a character vector of directory names of \R libraries,
    or \code{NULL}.  The default value of \code{NULL} corresponds to all
    libraries currently known.  The specified library trees are used to
    to search for \code{package}.}
}
\details{
  \code{checkAssignFuns} checks whether assignment functions in the
  package R code have their final argument named \code{value}.
  
  \code{checkDocArgs} checks, for all Rd files in a package, whether all
  arguments shown in the usage sections of the Rd file are documented in
  its arguments section.  It also reports duplicated entries in the
  arguments section.

  \code{checkDocStyle} investigates how (S3) methods are shown in the
  usages of the Rd files in a package.  It reports if methods are shown
  along with their generic, which typically causes problems for the
  documentation of the primary argument of the generic.  It also finds
  the methods shown by their full name (rather than that of the generic
  using the Rd \code{\\method} markup).

  \code{checkMethods} checks whether all methods defined in the package
  R code have all arguments of the corresponding generic, with
  positional arguments of the generics in the same positions for the
  method.  The generics are sought first in the given package and then
  in the base package.  The rules when \code{\dots} is involved are
  subtle: see the source code.

  If using an installed package, the checks needing access to all R
  objects of the package will load the package (unless it is the base
  package), after possibly detaching an already loaded version of the
  package.
}
\section{Warning}{
  These functions are still experimental.  Both names and interfaces
  might change in future versions.
}
\keyword{utilities}
\keyword{documentation}
\name{checkFF}
\alias{checkFF}
\title{Check Foreign Function Calls}
\usage{
checkFF(package, dir, file, lib.loc = NULL,
        verbose = getOption("verbose"))
}
\description{
  Performs checks on calls to compiled code from R code.  Currently only
  whether the interface functions such as \code{.C} and \code{.Fortran}
  are called with argument \code{PACKAGE} specified, which is highly
  recommended to avoid name clashes in foreign function calls.
}
\arguments{
  \item{package}{a character string naming an installed package.  If
    given, the installed R code of the package is checked.}
  \item{dir}{a character string specifying the path to a package's root
    source directory.  This should contain the subdirectory \code{R}
    (for R code).  Only used if \code{package} is not given.}
  \item{file}{the name of a file containing R code to be checked.  Used
    if neither \code{package} nor \code{dir} are given.}
  \item{lib.loc}{a character vector of directory names of \R libraries,
    or \code{NULL}.  The default value of \code{NULL} corresponds to all
    libraries currently known.  The specified library trees are used to
    to search for \code{package}.}
  \item{verbose}{a logical.  If \code{TRUE}, additional diagnostics are
    printed.}
}
\seealso{
  \code{\link{.C}},
  \code{\link{.Fortran}};
  \code{\link{Foreign}}.
}
\examples{
checkFF(package = "ts", verbose = TRUE)
}
\keyword{programming}
\keyword{utilities}
\name{checkTnF}
\alias{checkTnF}
\title{Check R Code for T/F}
\description{
  Checks the specified R code for occurrences of \code{T} or \code{F},
  and reports the expression containing these.  This is useful as in R
  \code{T} and \code{F} are just variables which are set to the logicals
  \code{TRUE} and \code{FALSE} by default, but are not reserved words
  and hence can be overwritten by the user.  Hence, one should always
  use \code{TRUE} and \code{FALSE} for the logicals.
}
\usage{
checkTnF(package, dir, file, lib.loc = NULL)
}
\arguments{
  \item{package}{a character string naming an installed package.  If
    given, the installed R code of the package is checked.  R code
    installed as an image file cannot be checked.}
  \item{dir}{a character string specifying the path to a package's root
    source directory.  This should contain the subdirectory \code{R}
    (for R code).  Only used if \code{package} is not given.}
  \item{file}{the name of a file containing R code to be checked.  Used
    if neither \code{package} nor \code{dir} are given.}
  \item{lib.loc}{a character vector of directory names of \R libraries,
    or \code{NULL}.  The default value of \code{NULL} corresponds to all
    libraries currently known.  The specified library trees are used to
    to search for \code{package}.}
}
\section{Warning}{
  This function is still experimental.  Both name and interface might
  change in future versions.
}
\keyword{utilities}
\keyword{documentation}
\name{codoc}
\alias{codoc}
\alias{print.codoc}
\title{Check Code/Documentation Consistency}
\usage{
codoc(package, dir, lib.loc = NULL,
      use.values = FALSE, use.positions = TRUE,
      ignore.generic.functions = FALSE,
      keep.tempfiles = FALSE,
      verbose = getOption("verbose"))
}
\description{
  Find inconsistencies between actual and documented usage of \R
  function objects in a package, by comparing names and optionally also
  corresponding positions and default values of the arguments of the
  functions.
}
\arguments{
  \item{package}{a character string naming an installed package.}
  \item{dir}{a character string specifying the path to a package's root
    source directory.  This must contain the subdirectories \file{man}
    with \R documentation sources (in Rd format) and \file{R} with \R
    code.  Only used if \code{package} is not given.}
  \item{lib.loc}{a character vector of directory names of \R libraries,
    or \code{NULL}.  The default value of \code{NULL} corresponds to all
    libraries currently known.  The specified library trees are used to
    to search for \code{package}.}
  \item{use.positions}{a logical indicating whether to use the positions
    of function arguments when comparing.}
  \item{use.values}{a logical indicating whether to use function default
    values when comparing code and docs.}
  \item{ignore.generic.functions}{if \code{TRUE}, functions the body of
    which contains \code{"UseMethod"} are ignored.}
  \item{keep.tempfiles}{if \code{TRUE}, keep temporary code and docs
    files used for comparison.  This used to be useful for debugging,
    but is now deprecated and will be removed in future versions.}
  \item{verbose}{a logical.  If \code{TRUE}, additional diagnostics are
    printed.}
}
\details{
  The purpose of this function is to check whether the documented usage
  of function objects agrees with their formal arguments as defined in
  the \R code.  This is not always straightforward, in particular as the
  usage information for methods to generic functions often employs the
  name of the generic rather than the method.

  The following algorithm is used.  If an installed package is used, it
  is loaded (unless it is the base package), after possibly detaching an
  already loaded version of the package.  Otherwise, if the sources are
  used, the \R code files of the package are collected and sourced in a
  new environment.  Then, the usage sections of the Rd files are
  extracted and manipulated in order to give function stubs
  corresponding to the indicated usage, which are then sourced in
  another new environment.  For interpreted functions in both the code
  and docs environment, the formals are compared according to the values
  of the arguments \code{use.positions} and \code{use.values}.

  Currently, synopsis sections are used, but multiple usage examples
  (such as in \code{\link{abline}}) are not combined when building the
  stubs.
}
\value{
  A list the names of which are the names of the functions where an
  inconsistency was found.  The elements of the list are lists of length
  2 with elements \code{code} and \code{docs}, giving the corresponding
  arguments obtained from the function's code and documented usage.
}
\seealso{
  \code{\link{undoc}}
}
\keyword{documentation}
\name{tools-internal}
\title{Internal tools functions}
\alias{listFilesWithExts}
\alias{sQuote}
\description{
  Internal tools functions.
}
\usage{
listFilesWithExts(dir, exts, path = TRUE)
sQuote(s)
}
\details{
  These are not to be called by the user.
}
\keyword{internal}
\name{undoc}
\alias{undoc}
\title{Find Undocumented Objects}
\usage{
undoc(package, dir, lib.loc = NULL)
}
\description{
  Finds the objects in a package which are undocumented, in the sense
  that they are visible to the user (or data objects provided by the
  package), but no documentation entry exists.
}
\arguments{
  \item{package}{a character string naming an installed package.}
  \item{dir}{a character string specifying the path to a package's root
    source directory.  This must contain the subdirectory \file{man}
    with \R documentation sources (in Rd format), and at least one of
    the \file{R} or \file{data} subdirectories with \R code or data
    objects, respectively.}
  \item{lib.loc}{a character vector of directory names of \R libraries,
    or \code{NULL}.  The default value of \code{NULL} corresponds to all
    libraries currently known.  The specified library trees are used to
    to search for \code{package}.}
}
\details{
  This function is useful for package maintainers mostly.  In principle,
  \emph{all} user level \R objects should be documented; note however
  that the precise rules for documenting methods of generic functions
  are still under discussion.
}
\value{
  A character vector containing the names of the undocumented objects.
}
\examples{
undoc("eda")                   # Undocumented objects in `eda'
}
\keyword{documentation}
