r-lib / styler
Showing 2 of 7 files from the diff.

@@ -110,47 +110,42 @@
Loading
110 110
                         include_roxygen_examples,
111 111
                         base_indention,
112 112
                         dry) {
113 -
  filetype <- set_and_assert_arg_filetype(filetype)
113 +
  filetype_ <- set_and_assert_arg_filetype(filetype)
114 114
  r_files <- rprofile_files <- vignette_files <- readme <- NULL
115 -
  exclude_files <- set_arg_paths(exclude_files)
116 -
  exclude_dirs <- set_arg_paths(exclude_dirs)
117 -
  without_excluded <- purrr::partial(setdiff, y = exclude_dirs)
118 -
  if ("\\.r" %in% filetype) {
115 +
  exclude_files <- c(
116 +
    set_arg_paths(exclude_files),
117 +
    dir_without_.(exclude_dirs, pattern = map_filetype_to_pattern(filetype))
118 +
  )
119 +
  if ("\\.r" %in% filetype_) {
119 120
    r_files <- dir_without_.(
120 -
      path = without_excluded(c("R", "tests", "data-raw", "demo")),
121 -
      pattern = "\\.r$",
122 -
      ignore.case = TRUE,
123 -
      recursive = TRUE
121 +
      path = c("R", "tests", "data-raw", "demo"),
122 +
      pattern = "\\.r$"
124 123
    )
125 124
  }
126 125
127 -
  if ("\\.rprofile" %in% filetype) {
126 +
  if ("\\.rprofile" %in% filetype_) {
128 127
    rprofile_files <- dir_without_.(
129 -
      path = without_excluded("."), pattern = "^\\.rprofile$",
130 -
      ignore.case = TRUE, recursive = FALSE, all.files = TRUE
128 +
      path = ".", pattern = "^\\.rprofile$"
131 129
    )
132 130
  }
133 -
  if ("\\.rmd" %in% filetype) {
131 +
  if ("\\.rmd" %in% filetype_) {
134 132
    vignette_files <- dir_without_.(
135 -
      path = without_excluded("vignettes"), pattern = "\\.rmd$",
136 -
      ignore.case = TRUE, recursive = TRUE
133 +
      path = "vignettes", pattern = "\\.rmd$"
137 134
    )
138 135
    readme <- dir_without_.(
139 136
      path = ".",
140 -
      pattern = without_excluded("^readme\\.rmd$"), ignore.case = TRUE
137 +
      pattern = "^readme\\.rmd$"
141 138
    )
142 139
  }
143 140
144 -
  if ("\\.rnw" %in% filetype) {
141 +
  if ("\\.rnw" %in% filetype_) {
145 142
    vignette_files <- append(
146 143
      vignette_files,
147 144
      dir_without_.(
148 -
        path = without_excluded("vignettes"), pattern = "\\.rnw$",
149 -
        ignore.case = TRUE, recursive = TRUE
145 +
        path = "vignettes", pattern = "\\.rnw$"
150 146
      )
151 147
    )
152 148
  }
153 -
154 149
  files <- setdiff(
155 150
    c(r_files, rprofile_files, vignette_files, readme),
156 151
    exclude_files
@@ -277,8 +272,7 @@
Loading
277 272
      setdiff(c("", exclude_dirs)) %>%
278 273
      dir_without_.(
279 274
        pattern = map_filetype_to_pattern(filetype),
280 -
        ignore.case = TRUE, recursive = FALSE,
281 -
        all.files = TRUE
275 +
        recursive = FALSE
282 276
      )
283 277
  } else {
284 278
    files_other <- c()

@@ -27,28 +27,36 @@
Loading
27 27
  paste0("(", paste(set_and_assert_arg_filetype(filetype), collapse = "|"), ")$")
28 28
}
29 29
30 -
#' `dir()`, but without dot-prefix
30 +
#' `dir()`, but without dot-prefix and different defaults
31 31
#'
32 32
#' When using `dir()`, you can set `full.names = FALSE`, but then you can only
33 33
#' pass a character vector of length one as `path` to not loose the information
34 34
#' about where the files are. This function solves that case. It's needed when
35 35
#' one wants to standardize paths to use set operations on them, i.e. when the
36 36
#' user supplied input does not have a dot prefix. See 'Examples'.
37 +
#'
38 +
#' For different defaults, see `dir_without_._one`.
37 39
#' @param path A path.
38 40
#' @param ... Passed to [base::dir()].
39 41
#' @seealso set_and_assert_arg_paths
40 42
#' @keywords internal
41 43
#' @examples
42 44
#' setdiff("./file.R", "file.R") # you want to standardize first.
43 -
dir_without_. <- function(path, ...) {
44 -
  purrr::map(path, dir_without_._one, ...) %>%
45 +
dir_without_. <- function(path, recursive = TRUE, ...) {
46 +
  purrr::map(path, dir_without_._one, recursive = recursive, ...) %>%
45 47
    unlist()
46 48
}
47 49
48 -
dir_without_._one <- function(path, ...) {
50 +
#' `dir()`, but with full names, ignored case, and included hidden files and
51 +
#' recursive.
52 +
#' @keywords internal
53 +
dir_without_._one <- function(path, recursive, ...) {
49 54
  relative <- dir(
50 55
    path = path,
51 56
    full.names = FALSE,
57 +
    ignore.case = TRUE,
58 +
    recursive = recursive,
59 +
    all.files = TRUE,
52 60
    ...
53 61
  )
54 62
  if (path == ".") {
Files Coverage
R 90.45%
Project Totals (47 files) 90.45%

No yaml found.

Create your codecov.yml to customize your Codecov experience

Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading