Skip to content

Commit

Permalink
Linting
Browse files Browse the repository at this point in the history
  • Loading branch information
clente committed Jul 2, 2019
1 parent efe43d1 commit 497981f
Show file tree
Hide file tree
Showing 14 changed files with 167 additions and 180 deletions.
9 changes: 5 additions & 4 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@ Title: Useful Tools for Jurimetrical Analysis Used by the
Version: 0.2.3
Date: 2019-07-02
Authors@R:
person(
family = "ABJ",
email = "[email protected]",
role = c("aut", "cre", "cph"))
person(family = "ABJ",
role = c("aut", "cre", "cph"),
email = "[email protected]")
Maintainer: Caio Lente <[email protected]>
Description: The Brazilian Jurimetrics Association (ABJ in
Portuguese, see <http://www.abjur.org.br/en/> for more information) is
Expand All @@ -33,9 +32,11 @@ Imports:
tidyr
Suggests:
devtools,
usethis,
furrr,
future,
testthat
Encoding: UTF-8
LazyData: TRUE
Roxygen: list(markdown = TRUE, roclets = c("rd", "namespace",
"collate"))
Expand Down
42 changes: 20 additions & 22 deletions R/carf.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,25 @@ verify_length <- function(val) {
}

#' @title Calculate check digit for CARF
#'
#'
#' @description Returns the check digit of a CARF number or full number with
#' the check digit.
#'
#'
#' @param id Lawsuit number (including trailling zeros), excluding
#' the check digit.
#' @param build Whether or not the function return the complete number
#' (or only the check digits)?
#' @param verify Verify if number is well formed (gives error if it's not)
#'
#'
#'
#' @return The check digits or the complete identification number
#'
#' @examples {
#' carf_calc_dig("10120.008427/2003", build = TRUE)
#' carf_calc_dig("15374.002430/99", build = FALSE)
#' carf_calc_dig(c("101200084272003", "1537400243099"))
#' \donttest{
#' carf_calc_dig("10766.000511/96-12")
#' }
#'
#' @examples
#' {
#' carf_calc_dig("10120.008427/2003", build = TRUE)
#' carf_calc_dig("15374.002430/99", build = FALSE)
#' carf_calc_dig(c("101200084272003", "1537400243099"))
#' }
#'
#' @export
carf_calc_dig <- function(id, build = FALSE, verify = TRUE) {
val <- gsub("[^0-9]", "", id)
Expand Down Expand Up @@ -59,16 +56,17 @@ carf_calc_dig <- function(id, build = FALSE, verify = TRUE) {

#' @title Validate check digits for Brazilian lawsuits identification
#' number
#'
#'
#' @description Verifies if a check digit is correct
#'
#'
#' @param id String containing the complete lawsuit number
#'
#'
#' @return Whether or not the check digit is well calculated
#'
#' @examples {
#' carf_check_dig("10120.008427/2003-02")
#' carf_check_dig(c("10120008427200302", "10766.000511/96-12"))
#'
#' @examples
#' {
#' carf_check_dig("10120.008427/2003-02")
#' carf_check_dig(c("10120008427200302", "10766.000511/96-12"))
#' }
#' @export
carf_check_dig <- function(id) {
Expand All @@ -80,9 +78,9 @@ carf_check_dig <- function(id) {
}

#' Add separators to CARF lawsuits
#'
#'
#' @param id One or more lawsuit ids
#'
#'
#' @export
carf_build_id <- function(id) {
val <- gsub("[^0-9]", "", id)
Expand All @@ -91,6 +89,6 @@ carf_build_id <- function(id) {
pattern <- "\\1.\\2/\\3-\\4"
gsub(mask, pattern, val)
} else {
stop ("Length must be 15 or 17.")
stop("Length must be 15 or 17.")
}
}
Loading

0 comments on commit 497981f

Please sign in to comment.