Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix lints with flint #475

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,7 @@ tests\^spelling
^WIP/.
\.code-workspace$
^CRAN-SUBMISSION$


# flint files
^flint$
8 changes: 4 additions & 4 deletions R/cite_easystats.R
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,11 @@
"performance", "parameters",
"see"
) %in% packages)
if (sum(letters_ludeckePackages != "") == 1) {

Check warning on line 86 in R/cite_easystats.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=R/cite_easystats.R,line=86,col=13,[nzchar_linter] Use nzchar(x) instead of x != "". Note that unlike nzchar(), NE coerces to character, so you'll have to use as.character() if x is a factor. Whenever missing data is possible, please take care to use nzchar(., keepNA = TRUE); nzchar(NA) is TRUE by default.

Check warning on line 86 in R/cite_easystats.R

View workflow job for this annotation

GitHub Actions / lint / lint

file=R/cite_easystats.R,line=86,col=13,[nzchar_linter] Use nzchar(x) instead of x != "". Note that unlike nzchar(), NE coerces to character, so you'll have to use as.character() if x is a factor. Whenever missing data is possible, please take care to use nzchar(., keepNA = TRUE); nzchar(NA) is TRUE by default.
letters_ludeckePackages <- rep("", length(letters_ludeckePackages))
}
letters_ludeckeArticles <- .disamguation_letters(c("performance", "see") %in% packages)
if (sum(letters_ludeckeArticles != "") == 1) {

Check warning on line 90 in R/cite_easystats.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=R/cite_easystats.R,line=90,col=13,[nzchar_linter] Use nzchar(x) instead of x != "". Note that unlike nzchar(), NE coerces to character, so you'll have to use as.character() if x is a factor. Whenever missing data is possible, please take care to use nzchar(., keepNA = TRUE); nzchar(NA) is TRUE by default.

Check warning on line 90 in R/cite_easystats.R

View workflow job for this annotation

GitHub Actions / lint / lint

file=R/cite_easystats.R,line=90,col=13,[nzchar_linter] Use nzchar(x) instead of x != "". Note that unlike nzchar(), NE coerces to character, so you'll have to use as.character() if x is a factor. Whenever missing data is possible, please take care to use nzchar(., keepNA = TRUE); nzchar(NA) is TRUE by default.
letters_ludeckeArticles <- rep("", length(letters_ludeckeArticles))
}
letters_makowskiPackages <- .disamguation_letters(c(
Expand All @@ -95,7 +95,7 @@
"correlation", "modelbased",
"report"
) %in% packages)
if (sum(letters_makowskiPackages != "") == 1) {

Check warning on line 98 in R/cite_easystats.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=R/cite_easystats.R,line=98,col=13,[nzchar_linter] Use nzchar(x) instead of x != "". Note that unlike nzchar(), NE coerces to character, so you'll have to use as.character() if x is a factor. Whenever missing data is possible, please take care to use nzchar(., keepNA = TRUE); nzchar(NA) is TRUE by default.

Check warning on line 98 in R/cite_easystats.R

View workflow job for this annotation

GitHub Actions / lint / lint

file=R/cite_easystats.R,line=98,col=13,[nzchar_linter] Use nzchar(x) instead of x != "". Note that unlike nzchar(), NE coerces to character, so you'll have to use as.character() if x is a factor. Whenever missing data is possible, please take care to use nzchar(., keepNA = TRUE); nzchar(NA) is TRUE by default.
letters_makowskiPackages <- rep("", length(letters_makowskiPackages))
}
easystats <- "_easystats_"
Expand Down Expand Up @@ -185,7 +185,7 @@
"easystats: Streamline model interpretation, visualization, and reporting%s [R package].",
"https://easystats.github.io/easystats/ (Original work published 2019)"
),
ifelse(installed_packages["easystats"] == "", "", paste0(" (", installed_packages["easystats"], ")"))

Check warning on line 188 in R/cite_easystats.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=R/cite_easystats.R,line=188,col=18,[nzchar_linter] Use !nzchar(x) instead of x == "". Note that unlike nzchar(), EQ coerces to character, so you'll have to use as.character() if x is a factor. Whenever missing data is possible, please take care to use nzchar(., keepNA = TRUE); nzchar(NA) is TRUE by default.

Check warning on line 188 in R/cite_easystats.R

View workflow job for this annotation

GitHub Actions / lint / lint

file=R/cite_easystats.R,line=188,col=18,[nzchar_linter] Use !nzchar(x) instead of x == "". Note that unlike nzchar(), EQ coerces to character, so you'll have to use as.character() if x is a factor. Whenever missing data is possible, please take care to use nzchar(., keepNA = TRUE); nzchar(NA) is TRUE by default.
),
insight = c(
article = paste(
Expand Down Expand Up @@ -345,10 +345,10 @@
ref_packages[-c(1:2, length(ref_packages))],
ref_packages[length(ref_packages)]
)
ref_packages[[2]] <- split(ref_packages[[2]], cumsum(ref_packages[[2]] == ""))

Check warning on line 348 in R/cite_easystats.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=R/cite_easystats.R,line=348,col=58,[nzchar_linter] Use !nzchar(x) instead of x == "". Note that unlike nzchar(), EQ coerces to character, so you'll have to use as.character() if x is a factor. Whenever missing data is possible, please take care to use nzchar(., keepNA = TRUE); nzchar(NA) is TRUE by default.

Check warning on line 348 in R/cite_easystats.R

View workflow job for this annotation

GitHub Actions / lint / lint

file=R/cite_easystats.R,line=348,col=58,[nzchar_linter] Use !nzchar(x) instead of x == "". Note that unlike nzchar(), EQ coerces to character, so you'll have to use as.character() if x is a factor. Whenever missing data is possible, please take care to use nzchar(., keepNA = TRUE); nzchar(NA) is TRUE by default.
ref_packages.index <- grep(paste0("id: ((", paste0(packages, collapse = ")|("), "))"), ref_packages[[2]])
ref_packages.index <- grep(paste0("id: ((", paste(packages, collapse = ")|("), "))"), ref_packages[[2]])
ref_packages[[2]] <- unlist(ref_packages[[2]][ref_packages.index], use.names = FALSE)
ref_packages <- paste0(unlist(ref_packages, use.names = FALSE), collapse = "\n")
ref_packages <- paste(unlist(ref_packages, use.names = FALSE), collapse = "\n")
} else {
ref_packages <- readLines(system.file("easystats_bib.bib", package = "report"))
ref_packages[ref_packages == " version = {%s}"] <- sprintf(
Expand All @@ -362,13 +362,13 @@
installed_packages["see"]
)
)
ref_packages <- split(ref_packages, cumsum(ref_packages == ""))

Check warning on line 365 in R/cite_easystats.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=R/cite_easystats.R,line=365,col=48,[nzchar_linter] Use !nzchar(x) instead of x == "". Note that unlike nzchar(), EQ coerces to character, so you'll have to use as.character() if x is a factor. Whenever missing data is possible, please take care to use nzchar(., keepNA = TRUE); nzchar(NA) is TRUE by default.

Check warning on line 365 in R/cite_easystats.R

View workflow job for this annotation

GitHub Actions / lint / lint

file=R/cite_easystats.R,line=365,col=48,[nzchar_linter] Use !nzchar(x) instead of x == "". Note that unlike nzchar(), EQ coerces to character, so you'll have to use as.character() if x is a factor. Whenever missing data is possible, please take care to use nzchar(., keepNA = TRUE); nzchar(NA) is TRUE by default.
ref_packages.index <- grep(paste0(
"((article)|(software))\\{((",
paste0(packages, collapse = ")|("), "))"
paste(packages, collapse = ")|("), "))"
), ref_packages)
ref_packages <- unlist(ref_packages[ref_packages.index], use.names = FALSE)
ref_packages <- paste0(unlist(ref_packages, use.names = FALSE), collapse = "\n")
ref_packages <- paste(unlist(ref_packages, use.names = FALSE), collapse = "\n")
}


Expand All @@ -393,7 +393,7 @@
bib = ,
refs = "refs"
)
if (what == "all") {

Check warning on line 396 in R/cite_easystats.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=R/cite_easystats.R,line=396,col=3,[if_switch_linter] Prefer switch() statements over repeated if/else equality tests, e.g., switch(x, a = 1, b = 2) over if (x == "a") 1 else if (x == "b") 2.

Check warning on line 396 in R/cite_easystats.R

View workflow job for this annotation

GitHub Actions / lint / lint

file=R/cite_easystats.R,line=396,col=3,[if_switch_linter] Prefer switch() statements over repeated if/else equality tests, e.g., switch(x, a = 1, b = 2) over if (x == "a") 1 else if (x == "b") 2.
insight::print_colour("\nCitations\n----------\n\n", "blue")
cat(strwrap(object$intext, exdent = 0, width = 0.95 * getOption("width")), sep = "\n")
cat("\n")
Expand Down Expand Up @@ -436,6 +436,6 @@
}
count <- sum(x)
x[!x] <- ""
x[x != ""] <- letters[seq_len(count)]

Check warning on line 439 in R/cite_easystats.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=R/cite_easystats.R,line=439,col=5,[nzchar_linter] Use nzchar(x) instead of x != "". Note that unlike nzchar(), NE coerces to character, so you'll have to use as.character() if x is a factor. Whenever missing data is possible, please take care to use nzchar(., keepNA = TRUE); nzchar(NA) is TRUE by default.

Check warning on line 439 in R/cite_easystats.R

View workflow job for this annotation

GitHub Actions / lint / lint

file=R/cite_easystats.R,line=439,col=5,[nzchar_linter] Use nzchar(x) instead of x != "". Note that unlike nzchar(), NE coerces to character, so you'll have to use as.character() if x is a factor. Whenever missing data is possible, please take care to use nzchar(., keepNA = TRUE); nzchar(NA) is TRUE by default.
x
}
2 changes: 1 addition & 1 deletion R/format_formula.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@
#' @export
format_formula <- function(x, what = "conditional") {
f <- insight::safe_deparse(insight::find_formula(x, verbose = FALSE)[[what]])
paste0("formula: ", paste0(f, collapse = " + "))
paste0("formula: ", paste(f, collapse = " + "))
}
4 changes: 2 additions & 2 deletions R/report.bayesfactor_models.R
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ report_text.bayesfactor_inclusion <- function(x,
bf_text <- paste0(
"Bayesian model averaging (BMA) was used to obtain the average evidence ",
"for each predictor. We found ",
paste0(
paste(
paste0(bf_results$evidence, " including ", bf_results$Term),
collapse = "; "
), "."
Expand Down Expand Up @@ -349,7 +349,7 @@ report_text.bayesfactor_inclusion <- function(x,
bf_explain,
paste0(
"We found ",
paste0(
paste(
paste0(
bf_results$evidence, " including ", bf_results$Term,
", with models including ", bf_results$Term,
Expand Down
4 changes: 2 additions & 2 deletions R/report.character.R
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ report_text.character <- function(x,
...
)

text <- paste0(summary(params), collapse = "; ")
text <- paste(summary(params), collapse = "; ")
if (nrow(entries) > 1) {
text <- paste0(name, ": ", nrow(entries), " entries, such as ", text)
} else {
Expand Down Expand Up @@ -198,5 +198,5 @@ report_statistics.character <- function(x,
text <- paste0(entries$Entry, ", n = ", entries$n_Entry)
}

as.report_statistics(paste0(text, collapse = "; "), summary = paste0(text[1:n_entries], collapse = "; "))
as.report_statistics(paste(text, collapse = "; "), summary = paste(text[1:n_entries], collapse = "; "))
}
2 changes: 1 addition & 1 deletion R/report.estimate_contrasts.R
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ report_text.estimate_contrasts <- function(x, table = NULL, ...) {
collapse = ". "
)

text <- paste("The marginal contrasts analysis suggests the following.", paste0(text, collapse = ""))
text <- paste("The marginal contrasts analysis suggests the following.", paste(text, collapse = ""))

as.report_text(text)
}
2 changes: 1 addition & 1 deletion R/report.factor.R
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ report_statistics.factor <- function(x, table = NULL, levels_percentage = "auto"
)
}

as.report_statistics(paste0(text_full, collapse = "; "), summary = paste0(text, collapse = "; "))
as.report_statistics(paste(text_full, collapse = "; "), summary = paste(text, collapse = "; "))
}

#' @export
Expand Down
2 changes: 1 addition & 1 deletion R/report.stanreg.R
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ report_priors.stanreg <- function(x, ...) {
)
)

values <- paste0(values, collapse = "; ")
values <- paste(values, collapse = "; ")
values <- paste0(params$Prior_Distribution, " (", values, ")")

if (length(unique(values)) == 1 && nrow(params) > 1) {
Expand Down
2 changes: 1 addition & 1 deletion R/report_effectsize.R
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
cat(attributes(x)$rules, "\n\n")
}

cat(paste0(x, collapse = "\n"))
cat(paste(x, collapse = "\n"))
}


Expand All @@ -90,9 +90,9 @@
.text_effectsize <- function(interpretation) {
# Effect size
if (is.null(interpretation)) {
text <- ""

Check warning on line 93 in R/report_effectsize.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=R/report_effectsize.R,line=93,col=5,[object_overwrite_linter] 'text' is an exported object from package 'graphics'. Avoid re-using such symbols.
} else {
if (is.character(interpretation)) {

Check warning on line 95 in R/report_effectsize.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=R/report_effectsize.R,line=95,col=5,[unnecessary_nesting_linter] Simplify this condition by using 'else if' instead of 'else { if.
effsize_name <- switch(interpretation,
cohen1988 = "Cohen's (1988)",
sawilowsky2009 = "Savilowsky's (2009)",
Expand Down
2 changes: 1 addition & 1 deletion R/report_info.R
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ summary.report_info <- function(object, ...) {

#' @export
print.report_info <- function(x, ...) {
cat(paste0(x, collapse = "\n"))
cat(paste(x, collapse = "\n"))
}


Expand Down
2 changes: 1 addition & 1 deletion R/report_intercept.R
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ summary.report_intercept <- function(object, ...) {

#' @export
print.report_intercept <- function(x, ...) {
cat(paste0(x, collapse = "\n"))
cat(paste(x, collapse = "\n"))
}


Expand Down
2 changes: 1 addition & 1 deletion R/report_model.R
Original file line number Diff line number Diff line change
Expand Up @@ -73,5 +73,5 @@ summary.report_model <- function(object, ...) {

#' @export
print.report_model <- function(x, ...) {
cat(paste0(x, collapse = "\n"))
cat(paste(x, collapse = "\n"))
}
4 changes: 2 additions & 2 deletions R/report_parameters.R
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ as.character.report_parameters <- function(x, prefix = NULL, ...) {

# Concatenate
text <- paste0(prefix, x)
text <- paste0(text, collapse = "\n")
text <- paste(text, collapse = "\n")
text
}

Expand Down Expand Up @@ -125,7 +125,7 @@ print.report_parameters <- function(x, ...) {
# Interaction
if (grepl(" * ", names[i], fixed = TRUE)) {
parts <- unlist(strsplit(names[i], " * ", fixed = TRUE))
basis <- paste0(utils::head(parts, -1), collapse = " * ")
basis <- paste(utils::head(parts, -1), collapse = " * ")
names[i] <- paste0("The interaction effect of ", utils::tail(parts, 1), " on ", basis)

# Intercept
Expand Down
2 changes: 1 addition & 1 deletion R/report_priors.R
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,5 @@ summary.report_priors <- function(object, ...) {

#' @export
print.report_priors <- function(x, ...) {
cat(paste0(x, collapse = "\n"))
cat(paste(x, collapse = "\n"))
}
2 changes: 1 addition & 1 deletion R/report_random.R
Original file line number Diff line number Diff line change
Expand Up @@ -74,5 +74,5 @@ summary.report_random <- function(object, ...) {

#' @export
print.report_random <- function(x, ...) {
cat(paste0(x, collapse = "\n"))
cat(paste(x, collapse = "\n"))
}
2 changes: 1 addition & 1 deletion R/report_statistics.R
Original file line number Diff line number Diff line change
Expand Up @@ -76,5 +76,5 @@ summary.report_statistics <- summary.report_parameters

#' @export
print.report_statistics <- function(x, ...) {
cat(paste0(x, collapse = "\n"))
cat(paste(x, collapse = "\n"))
}
Loading