Skip to content

Commit ae43675

Browse files
committed
Linting
1 parent fe055ac commit ae43675

13 files changed

+83
-76
lines changed

.lintr

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
linters: with_defaults(
2+
assignment_linter = NULL,
3+
object_name_linter = NULL,
4+
line_length_linter(100),
5+
commented_code_linter = NULL
6+
)

R/actions.R

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#' Update the status of an article.
22
#'
33
#' \code{reject}, \code{accept} and \code{withdraw} update the status,
4-
#' move the file to the correct directory and draft an email from a
4+
#' move the file to the correct directory and draft an email from a
55
#' template of the corresponding name.
66
#'
77
#' @rdname action
@@ -23,7 +23,7 @@ update_status <- function(article, status, comments = "", date = Sys.Date()) {
2323
#' @export
2424
reject <- function(article, comments = "", date = Sys.Date()) {
2525
article <- as.article(article)
26-
26+
2727
cli::cli_h1(paste("Rejecting paper", format(article$id)))
2828
cli::cli_alert_info("Updating DESCRIPTION file")
2929
update_status(article, "rejected", comments = comments, date = date)

R/article.R

+16-14
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,22 @@
1010
#' @export
1111
article <- function(..., quiet = FALSE) {
1212
tryCatch(make_article(...),
13-
error = function(e) {
14-
article <- unparsed(...)
15-
if (!quiet) {
16-
message("Failed to parse: ")
17-
print(article)
18-
message(e, "\n")
19-
}
20-
article
21-
}
13+
error = function(e) {
14+
article <- unparsed(...)
15+
if (!quiet) {
16+
message("Failed to parse: ")
17+
print(article)
18+
message(e, "\n")
19+
}
20+
article
21+
}
2222
)
2323
}
2424

2525
#' Convert input into an article.
2626
#'
27-
#' @param id a path to a DESCRIPTION, a path to a directory containing
28-
#' DESCRIPTION, or a article name, found in a sub-directory rejected,
27+
#' @param id a path to a DESCRIPTION, a path to a directory containing
28+
#' DESCRIPTION, or a article name, found in a sub-directory rejected,
2929
#' accepted or submissions
3030
#' @export
3131
#' @examples
@@ -65,7 +65,7 @@ load_article <- function(path, quiet = FALSE) {
6565
if (nrow(dcf) != 1) stop("DCF parsing error: ", path, call. = FALSE)
6666

6767
# Remove field names that keep.white incorrectly preserves
68-
for(field in fields) {
68+
for (field in fields) {
6969
dcf[, field] <- gsub(paste(field, ": ?", sep = ""), "", dcf[, field])
7070
}
7171
# Convert missing values to empty strings
@@ -75,7 +75,7 @@ load_article <- function(path, quiet = FALSE) {
7575
dcf <- as.list(as.data.frame(dcf, stringsAsFactors = FALSE))
7676
# Only should be manually set in tests
7777
if (is.null(dcf$id) || identical(dcf$id, "")) {
78-
dcf$id <- basename(dirname(path))
78+
dcf$id <- basename(dirname(path))
7979
}
8080
dcf$path <- dirname(path)
8181
do.call(article, dcf)
@@ -101,7 +101,9 @@ make_article <- function(id, slug = "", authors = "", title = "", editor = "",
101101
parse_supplementaries <- function(suppl) {
102102
x <- str_trim(str_split(suppl, "\n")[[1]])
103103
x <- x[str_length(x) > 0]
104-
xs <-lapply(x, function(y) {class(y) <- "supplfile"; y})
104+
xs <- lapply(x, function(y) {
105+
class(y) <- "supplfile"; y
106+
})
105107
class(xs) <- "supplfile_list"
106108
xs
107109
}

R/assignments.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
globalVariables("titles")
12
# XXX: Repetition below. But I intend to split out the different
23
# sections in the future
34
#' @export
@@ -13,7 +14,6 @@ summarise_articles = function(editor = NULL) {
1314
all_articles = get_assignments(editor)
1415
latest = get_latest_assignments(all_articles)
1516

16-
1717
cli::cli_h1("Submitted")
1818
art = latest[latest$status_status == "submitted", ]
1919
titles = str_trunc(art$title, 30)

R/convert_landing.R

+24-24
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ convert_proofs <- function(issue, action="report_only", clean=TRUE) {
1717
has_slug_ptr <- character(length(has_slug))
1818
has_slug_ptr[has_slug] <- sapply(conf_articles[has_slug], function(x) x$slug)
1919

20-
if (!dir.exists(file.path(web_path, "archive", yr_id))
20+
if (!dir.exists(file.path(web_path, "archive", yr_id))
2121
&& action == "report_and_commit")
2222
dir.create(file.path(web_path, "archive", yr_id))
2323
i <- 0L
@@ -26,7 +26,7 @@ convert_proofs <- function(issue, action="report_only", clean=TRUE) {
2626
fls0 <- list.files(file.path(web_path, "archive", issue))
2727
fls <- fls0[str_detect(fls0, "^RJournal_")]
2828
strings <- "[A-Z][a-z][a-z]*"
29-
nms0 <- str_subset(str_replace_all(str_sub(fls, 17L, str_length(fls)-4L),
29+
nms0 <- str_subset(str_replace_all(str_sub(fls, 17L, str_length(fls) - 4L),
3030
"[_\\+\\~]", " "), strings)
3131
nms <- str_replace(nms0, " et al", "")
3232
}
@@ -84,9 +84,9 @@ convert_proofs <- function(issue, action="report_only", clean=TRUE) {
8484
i <- ifelse(length(current_dirs) > 0,
8585
as.integer(max(as.integer(str_sub(current_dirs, 9L, 11L)))) + 1L, 1L)
8686
}
87-
next_dir <- formatC(i, format="d", flag="0", width=3L)
87+
next_dir <- formatC(i, format = "d", flag = "0", width = 3L)
8888
slug <- paste0("RJ-", yr_id, "-", next_dir)
89-
if (action == "report_and_commit")
89+
if (action == "report_and_commit")
9090
dir.create(file.path(web_path, "archive", yr_id, slug))
9191
} else{
9292
slug <- article$slug
@@ -116,7 +116,7 @@ convert_proofs <- function(issue, action="report_only", clean=TRUE) {
116116
refs_list$CTV_rev <- rev_dep_ctv(refs_list$CRANpkgs)
117117

118118
# print(refs_list)
119-
119+
120120
metadata <- c(list(
121121
title = pdf_list$title,
122122
bibtitle = pdf_list$bibtitle,
@@ -127,22 +127,22 @@ convert_proofs <- function(issue, action="report_only", clean=TRUE) {
127127
), refs_list[!sapply(refs_list, is.null)])
128128
metadata <- c(metadata, list(landing = str_sub(slug, 4L, 7L)))
129129

130-
aus <- unlist(str_split(paste(metadata$author, collapse=" "), " "))
131-
if ("R\xc3\xb6nneg\xc3\xa5rd" %in% aus)
130+
aus <- unlist(str_split(paste(metadata$author, collapse = " "), " "))
131+
if ("R\xc3\xb6nneg\xc3\xa5rd" %in% aus)
132132
aus <- str_replace(str_replace(aus, "[\xc3\xb6]", "oe"), "[\xc3\xa5]", "aa")
133-
if ("S\xc3\xb3lymos" %in% aus)
133+
if ("S\xc3\xb3lymos" %in% aus)
134134
aus <- str_replace(aus, "[\xc3\xb3]", "o")
135-
if ("Herv\xc3\xa9" %in% aus)
135+
if ("Herv\xc3\xa9" %in% aus)
136136
aus <- str_replace(aus, "[\xc3\xa9]", "e")
137-
if ("B\xc3\xa5\xc3\xa5th" %in% aus)
137+
if ("B\xc3\xa5\xc3\xa5th" %in% aus)
138138
aus <- str_replace_all(aus, "[\xc3\xa5]", "aa")
139139
pub_file <- NULL
140140
if (issue == "2009-2" && art == "2009-07") aus <- "Coeurjolly"
141141
if (issue == "2012-2" && art == "2011-22")
142142
pub_file <- "RJournal_2012-2_Murrell+Ly.pdf"
143143
if (issue == "2012-2" && art == "2011-32")
144144
pub_file <- "RJournal_2012-2_Murrell.pdf"
145-
if (issue == "2012-2" && art == "2011-35")
145+
if (issue == "2012-2" && art == "2011-35")
146146
pub_file <- "RJournal_2012-2_Murrell2.pdf"
147147

148148
if (is.null(pub_file)) pub_file <- fls[which(sapply(lapply(nms,
@@ -151,10 +151,10 @@ convert_proofs <- function(issue, action="report_only", clean=TRUE) {
151151

152152
if (length(pub_file) == 0) {
153153
cat(nms, "\n")
154-
cat(metadata$author, collapse=" ", "\n")
154+
cat(metadata$author, collapse = " ", "\n")
155155
stop(issue, " ", art, " no match")
156156
}
157-
157+
158158
# cat(issue, art, paste(metadata$author, collapse=" "), "\n")
159159
# cat(pub_file, "\n")
160160

@@ -163,7 +163,7 @@ convert_proofs <- function(issue, action="report_only", clean=TRUE) {
163163
stop("published file :", pub_file, "not found in ", issue)
164164

165165
metadata <- c(metadata, list(old_slug = str_sub(pub_file, 17L,
166-
str_length(pub_file)-4L)))
166+
str_length(pub_file) - 4L)))
167167
# cat(from, "\n")
168168

169169
} else {
@@ -178,7 +178,7 @@ convert_proofs <- function(issue, action="report_only", clean=TRUE) {
178178
refs_list$CTV_rev <- rev_dep_ctv(refs_list$CRANpkgs)
179179

180180
# print(refs_list)
181-
181+
182182
sl <- as.data.frame(article$status)
183183
metadata <- c(list(
184184
title = pdf_list$title,
@@ -220,18 +220,18 @@ convert_proofs <- function(issue, action="report_only", clean=TRUE) {
220220
}
221221

222222
article_config_content <- list(
223-
slug=metadata$slug,
224-
old_slug=metadata$old_slug,
225-
title=metadata$title,
226-
bibtitle=metadata$bibtitle,
227-
author=metadata$author,
228-
bibauthor=metadata$bibauthor,
229-
landing=metadata$landing,
230-
abstract=metadata$abstract
223+
slug = metadata$slug,
224+
old_slug = metadata$old_slug,
225+
title = metadata$title,
226+
bibtitle = metadata$bibtitle,
227+
author = metadata$author,
228+
bibauthor = metadata$bibauthor,
229+
landing = metadata$landing,
230+
abstract = metadata$abstract
231231
)
232232
if (!is.null(conf_articles[[conf_art]]$pages))
233233
article_config_content <- c(article_config_content,
234-
list(pages=conf_articles[[conf_art]]$pages))
234+
list(pages = conf_articles[[conf_art]]$pages))
235235
if (!is.null(metadata$acknowledged))
236236
article_config_content <- c(article_config_content,
237237
list(acknowledged=metadata$acknowledged))

R/crossref.R

+6-6
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ journal_metadata = list(
2828
doi_batch_id_tpl = "<doi_batch_id>{{ID}}</doi_batch_id>\n"
2929
print_doi_batch_id <- function(file) {
3030
x <- as.POSIXlt(Sys.time())
31-
mon <- if(nchar(x$mon) == 1) paste("0", x$mon, sep="") else x$mon
32-
mday <- if(nchar(x$mday) == 1) paste("0", x$mday, sep="") else x$mday
33-
hour <- if(nchar(x$hour) == 1) paste("0", x$hour, sep="") else x$hour
34-
min <- if(nchar(x$min) == 1) paste("0", x$min, sep="") else x$min
35-
sec <- if(nchar(round(x$sec)) == 1) paste("0", round(x$sec), sep="") else round(x$sec)
31+
mon <- if (nchar(x$mon) == 1) paste("0", x$mon, sep="") else x$mon
32+
mday <- if (nchar(x$mday) == 1) paste("0", x$mday, sep="") else x$mday
33+
hour <- if (nchar(x$hour) == 1) paste("0", x$hour, sep="") else x$hour
34+
min <- if (nchar(x$min) == 1) paste("0", x$min, sep="") else x$min
35+
sec <- if(nchar(round(x$sec)) == 1) paste("0", round(x$sec), sep="") else round(x$sec)
3636
ID = paste(x$year, mon, mday, hour, min, sec, sep="")
3737
txt = whisker.render(doi_batch_id_tpl, list(ID=ID))
3838
cat(txt, file=file, append=TRUE)
@@ -255,7 +255,7 @@ newDeposit = function(x, out="") {
255255
cat("<registrant>CrossRef</registrant> \n </head>\n
256256
<body>\n", file=out, append=TRUE)
257257
## this generates xml for all bib items stored in a bib file
258-
for(i in 1:length(x$articles)) {
258+
for (i in 1:length(x$articles)) {
259259
cat("<journal>\n", file=out, append=TRUE)
260260
print_journal_metadata(out)
261261
print_journal_issue(x, out)

R/email.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ email_text <- function(text) {
5656

5757
url <- paste0("mailto:", to, "?",
5858
paste0(names(fields), "=", unlist(fields), collapse = "&"))
59-
59+
6060
browseURL(url)
6161
}
6262

R/path.R

+3-2
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,12 @@ set_articles_path <- function(path) {
99
.articles$path <- path
1010
}
1111

12-
get_articles_path <- function(){
12+
get_articles_path <- function() {
1313
dir <- .articles$path %||% getwd()
1414
if (!(basename(dir) %in% c("articles", "articles_test"))) {
1515
abort(
16-
sprintf("The current articles path is not correct. Set the path to the articles repository with `set_articles_path()`",
16+
sprintf("The current articles path is not correct.
17+
Set the path to the articles repository with `set_articles_path()`",
1718
dir)
1819
)
1920
}

R/report.R

+5-5
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ report <- function(articles = active_articles()) {
1515
report_line <- function(x) {
1616
message(x$path) # to identify culprit when things go wrong
1717
stopifnot(is.article(x))
18-
18+
1919
todo <- todo(x)
20-
status <- last_status(x)
20+
#status <- last_status(x)
2121
last_date <- last_status(x)$date
22-
22+
2323
days_taken <- difftime(Sys.Date(), last_date, "days")
2424
stars <- sum(days_taken > deadlines(todo))
25-
25+
2626
data.frame(
2727
status = todo,
2828
ed = editor_abbr(x$editor),
@@ -75,7 +75,7 @@ order_status <- function(x) {
7575
x <- unique(x)
7676
eic <- x[grepl("editor-in-chief", x)]
7777
editors <- setdiff(x[grepl("editor", x)], eic)
78-
others <- setdiff(x, c(eic, editors))
78+
others <- setdiff(x, c(eic, editors))
7979
c(eic, editors, others)
8080
}
8181

R/reviewers.R

-1
Original file line numberDiff line numberDiff line change
@@ -147,4 +147,3 @@ add_review = function(article, reviewer_id, review, recommend = NULL) {
147147
comment = recommend)
148148
return(invisible(NULL))
149149
}
150-

R/rfc822.R

-1
Original file line numberDiff line numberDiff line change
@@ -79,4 +79,3 @@ parse_address <- function(x) {
7979

8080
address(email, name, comment)
8181
}
82-

R/status.R

+3-3
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ parse_status <- function(x) {
207207
re <- "^(\\d{4}-\\d{2}-\\d{2}) ([^\\[]*)(?: \\[([^\\[]+)\\])?$"
208208
if (!str_detect(x, re)) {
209209
# NM added line
210-
cat('bad status:',x,'\n')
210+
cat("bad status:", x, "\n")
211211
stop("Status must have form 'yyyy-mm-dd status [optional comments]'",
212212
call. = FALSE)
213213
}
@@ -226,7 +226,7 @@ parse_status <- function(x) {
226226

227227
as.data.frame.status_list <- function(status_list) {
228228
message("DF")
229-
ml <- vector(mode="list", length=length(status_list))
230-
for (i in seq(along=ml)) ml[[i]] <- as.data.frame(unclass(status_list[[i]]))
229+
ml <- vector(mode = "list", length = length(status_list))
230+
for (i in seq(along = ml)) ml[[i]] <- as.data.frame(unclass(status_list[[i]]))
231231
do.call("rbind", ml)
232232
}

0 commit comments

Comments
 (0)