Skip to content

Commit 104f2d9

Browse files
committed
Merge pull request #146 from schloerke/master
fix cache logic
2 parents 7ca6637 + 88f6b9b commit 104f2d9

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

NEWS.md

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
* trailing_semicolon_linter (#147, @gaborcsardi)
55

6+
* Fixed lint_package bug where cache was not caching (#146, @schloerke)
67
* Commas linter handles missing arguments calls properly (#145)
78

89
# lintr 1.0.0 #

R/lint.R

+12-6
Original file line numberDiff line numberDiff line change
@@ -42,17 +42,22 @@ lint <- function(filename, linters = NULL, cache = FALSE, ..., parse_settings =
4242
itr <- 0
4343

4444
if (isTRUE(cache)) {
45-
cache <- settings$cache_directory
46-
} else if (is.logical(cache)) {
47-
cache <- character(0)
45+
cache_dir <- settings$cache_directory
46+
} else if (is.character(cache)) {
47+
cache_dir <- cache
48+
} else {
49+
cache_dir <- character(0)
4850
}
4951

50-
if (length(cache)) {
51-
lint_cache <- load_cache(filename, cache)
52+
if (length(cache_dir)) {
53+
lint_cache <- load_cache(filename, cache_dir)
5254
lints <- retrieve_file(lint_cache, filename, linters)
5355
if (!is.null(lints)) {
5456
return(exclude(lints, ...))
5557
}
58+
cache = TRUE
59+
} else {
60+
cache = FALSE
5661
}
5762

5863
for (expr in source_expressions$expressions) {
@@ -119,6 +124,7 @@ lint_package <- function(path = ".", relative_path = TRUE, ...) {
119124
on.exit(clear_settings, add = TRUE)
120125

121126
names(settings$exclusions) <- normalizePath(file.path(path, names(settings$exclusions)))
127+
exclusions = force(settings$exclusions)
122128

123129
files <- dir(
124130
path = file.path(path,
@@ -138,7 +144,7 @@ lint_package <- function(path = ".", relative_path = TRUE, ...) {
138144
if (interactive()) {
139145
message(".", appendLF = FALSE)
140146
}
141-
lint(file, ..., parse_settings = FALSE)
147+
lint(file, ..., parse_settings = FALSE, exclusions = exclusions)
142148
}))
143149

144150
if (interactive()) {

0 commit comments

Comments
 (0)