Skip to content

Commit

Permalink
linting package
Browse files Browse the repository at this point in the history
  • Loading branch information
joethorley committed Oct 11, 2023
1 parent 4818c3c commit dceed5e
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 9 deletions.
2 changes: 1 addition & 1 deletion R/ggproto.R
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ GeomHcintersect <- ggproto(
default_aes = aes(colour = "black", linewidth = 0.5, linetype = "dotted", alpha = NA),
draw_key = draw_key_path,
draw_panel = function(data, panel_params, coord) {
data$group <- 1:nrow(data)
data$group <- seq_len(nrow(data))
data$x <- data$xintercept
data$y <- data$yintercept
start <- data
Expand Down
4 changes: 2 additions & 2 deletions R/gompertz.R
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ sgompertz <- function(data, pars = NULL) {
if (!is.null(pars)) {
pars <- rev(unlist(pars))
}

fit <- suppressWarnings(vglm(x ~ 1, gompertz, coefstart = pars))
data <- data.frame(x = x)
fit <- suppressWarnings(vglm(x ~ 1, gompertz, coefstart = pars, data = data))
list(
log_location = unname(coef(fit)[2]),
log_shape = unname(coef(fit)[1])
Expand Down
4 changes: 2 additions & 2 deletions R/test-helpers.R
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ expect_snapshot_plot <- function(x, name) {
}

expect_snapshot_boot_data <- function(x, name, digits = 6, min_pboot = 0.9, max_pboot = 1) {
if (!is.na(min_pboot) & min_pboot > 0) {
if (!is.na(min_pboot) && min_pboot > 0) {
testthat::expect_true(all(x$pboot >= min_pboot))
}
if (!is.na(min_pboot) & max_pboot < 1) {
if (!is.na(min_pboot) && max_pboot < 1) {
testthat::expect_true(all(x$pboot <= max_pboot))
}
x$pboot <- NULL
Expand Down
4 changes: 4 additions & 0 deletions scripts/build.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ styler::style_pkg(
scope = "line_breaks",
filetype = c("R", "Rmd")
)

lintr::lint_package(linters = linters_with_defaults(
line_length_linter = line_length_linter(1000))
)
lintr::lint_package()

devtools::test()
Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/test-print.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ test_that("print fitdists", {

test_that("summary fitdists with left censored, rescaled, weighted data", {
data <- ssddata::ccme_boron
data$Mass <- 1:nrow(data)
data$Mass <- seq_len(nrow(data))
data$Other <- data$Conc
data$Conc[2] <- NA
fits <- ssd_fit_dists(data, right = "Other", weight = "Mass", rescale = TRUE, dists = "lnorm")
Expand All @@ -28,7 +28,7 @@ test_that("summary fitdists with inconsistently censored data", {

test_that("summary fitdists with right censored, rescaled, weighted data", {
data <- ssddata::ccme_boron
data$Mass <- 1:nrow(data)
data$Mass <- seq_len(nrow(data))
data$Other <- data$Conc
data$Other[1] <- Inf
expect_error(fits <- ssd_fit_dists(data, right = "Other", weight = "Mass", rescale = TRUE, dists = "lnorm"))
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-summary.R
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ test_that("summary fitdists with multiple dists", {

test_that("summary fitdists with censored, rescaled, unequally weighted data", {
data <- ssddata::ccme_boron
data$Mass <- 1:nrow(data)
data$Mass <- seq_len(nrow(data))
data$Other <- data$Conc
data$Conc[2] <- NA
fits <- ssd_fit_dists(data, right = "Other", weight = "Mass", rescale = TRUE, dists = "lnorm")
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ test_that("ssd_sort_data works censored data", {
data <- ssddata::ccme_boron
data$Other <- data$Conc * 2
data$Conc[1] <- NA
data$ID <- 1:nrow(data)
data$ID <- seq_len(nrow(data))
expect_identical(
ssd_sort_data(data, right = "Other")$ID[1:5],
c(1L, 19L, 20L, 21L, 2L)
Expand Down

0 comments on commit dceed5e

Please sign in to comment.