Skip to content

Commit f0bed47

Browse files
committed
fix CLI default for files-changed-only
1 parent b853c7e commit f0bed47

File tree

4 files changed

+11
-14
lines changed

4 files changed

+11
-14
lines changed

Cargo.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,3 @@ authors = [
1212
]
1313
description = "Run clang-format and clang-tidy on a batch of files."
1414
documentation = "https://example.com/bar"
15-
16-
[workspace.dependencies]

cpp-linter-lib/src/cli.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ The following values are accepted:
183183
.short('f')
184184
.long("files-changed-only")
185185
.default_value_if("lines-changed-only", ArgPredicate::Equals("true".into()), "true")
186+
.default_value("false")
186187
.value_parser(FalseyValueParser::new())
187188
.help_heading("source options")
188189
.long_help(

cpp-linter-lib/src/common_fs.rs

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
//! A module to hold all common file system functionality.
22
3+
use std::fs;
34
use std::io::Read;
45
use std::path::{Component, Path};
5-
use std::{fs, io};
66
use std::{ops::RangeInclusive, path::PathBuf};
77

88
use crate::clang_tools::clang_format::FormatAdvice;
@@ -172,15 +172,12 @@ pub fn list_source_files(
172172
root_path: &str,
173173
) -> Vec<FileObj> {
174174
let mut files: Vec<FileObj> = Vec::new();
175-
let entries = fs::read_dir(root_path)
176-
.expect("repo root-path should exist")
177-
.map(|res| res.map(|e| e.path()))
178-
.collect::<Result<Vec<_>, io::Error>>()
179-
.unwrap();
180-
for entry in entries {
181-
if entry.is_dir() {
175+
let entries = fs::read_dir(root_path).expect("repo root-path should exist");
176+
for entry in entries.flatten() {
177+
let path = entry.path();
178+
if path.is_dir() {
182179
let mut is_hidden = false;
183-
let parent = entry.components().last().expect("parent not known");
180+
let parent = path.components().last().expect("parent not known");
184181
if parent.as_os_str().to_str().unwrap().starts_with('.') {
185182
is_hidden = true;
186183
}
@@ -189,14 +186,14 @@ pub fn list_source_files(
189186
extensions,
190187
ignored,
191188
not_ignored,
192-
&entry.into_os_string().into_string().unwrap(),
189+
&path.into_os_string().into_string().unwrap(),
193190
));
194191
}
195192
} else {
196-
let is_valid_src = is_source_or_ignored(&entry, extensions, ignored, not_ignored);
193+
let is_valid_src = is_source_or_ignored(&path, extensions, ignored, not_ignored);
197194
if is_valid_src {
198195
files.push(FileObj::new(
199-
entry.clone().strip_prefix("./").unwrap().to_path_buf(),
196+
path.clone().strip_prefix("./").unwrap().to_path_buf(),
200197
));
201198
}
202199
}

cspell.config.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ words:
99
- gitmodules
1010
- libgit
1111
- nonminimal
12+
- peekable
1213
- posix
1314
- pyfunction
1415
- pymodule

0 commit comments

Comments
 (0)