diff options
Diffstat (limited to 'bin/src')
-rw-r--r-- | bin/src/config.rs | 22 | ||||
-rw-r--r-- | bin/src/fix.rs | 2 | ||||
-rw-r--r-- | bin/src/lint.rs | 6 |
3 files changed, 21 insertions, 9 deletions
diff --git a/bin/src/config.rs b/bin/src/config.rs index 07b3f17..d3c3e91 100644 --- a/bin/src/config.rs +++ b/bin/src/config.rs | |||
@@ -65,7 +65,7 @@ pub struct Check { | |||
65 | } | 65 | } |
66 | 66 | ||
67 | impl Check { | 67 | impl Check { |
68 | pub fn vfs(&self) -> Result<ReadOnlyVfs, ConfigErr> { | 68 | pub fn vfs(&self, extra_ignores: &[String]) -> Result<ReadOnlyVfs, ConfigErr> { |
69 | if self.streaming { | 69 | if self.streaming { |
70 | use std::io::{self, BufRead}; | 70 | use std::io::{self, BufRead}; |
71 | let src = io::stdin() | 71 | let src = io::stdin() |
@@ -76,7 +76,8 @@ impl Check { | |||
76 | .join("\n"); | 76 | .join("\n"); |
77 | Ok(ReadOnlyVfs::singleton("<stdin>", src.as_bytes())) | 77 | Ok(ReadOnlyVfs::singleton("<stdin>", src.as_bytes())) |
78 | } else { | 78 | } else { |
79 | let ignore = dirs::build_ignore_set(&self.ignore, &self.target, self.unrestricted)?; | 79 | let all_ignores = dbg!([self.ignore.as_slice(), extra_ignores].concat()); |
80 | let ignore = dirs::build_ignore_set(&all_ignores, &self.target, self.unrestricted)?; | ||
80 | let files = dirs::walk_nix_files(ignore, &self.target)?; | 81 | let files = dirs::walk_nix_files(ignore, &self.target)?; |
81 | vfs(files.collect::<Vec<_>>()) | 82 | vfs(files.collect::<Vec<_>>()) |
82 | } | 83 | } |
@@ -117,7 +118,7 @@ pub enum FixOut { | |||
117 | } | 118 | } |
118 | 119 | ||
119 | impl Fix { | 120 | impl Fix { |
120 | pub fn vfs(&self) -> Result<ReadOnlyVfs, ConfigErr> { | 121 | pub fn vfs(&self, extra_ignores: &[String]) -> Result<ReadOnlyVfs, ConfigErr> { |
121 | if self.streaming { | 122 | if self.streaming { |
122 | use std::io::{self, BufRead}; | 123 | use std::io::{self, BufRead}; |
123 | let src = io::stdin() | 124 | let src = io::stdin() |
@@ -128,7 +129,8 @@ impl Fix { | |||
128 | .join("\n"); | 129 | .join("\n"); |
129 | Ok(ReadOnlyVfs::singleton("<stdin>", src.as_bytes())) | 130 | Ok(ReadOnlyVfs::singleton("<stdin>", src.as_bytes())) |
130 | } else { | 131 | } else { |
131 | let ignore = dirs::build_ignore_set(&self.ignore, &self.target, self.unrestricted)?; | 132 | let all_ignores = [self.ignore.as_slice(), extra_ignores].concat(); |
133 | let ignore = dirs::build_ignore_set(&all_ignores, &self.target, self.unrestricted)?; | ||
132 | let files = dirs::walk_nix_files(ignore, &self.target)?; | 134 | let files = dirs::walk_nix_files(ignore, &self.target)?; |
133 | vfs(files.collect::<Vec<_>>()) | 135 | vfs(files.collect::<Vec<_>>()) |
134 | } | 136 | } |
@@ -260,16 +262,22 @@ impl FromStr for OutFormat { | |||
260 | pub struct ConfFile { | 262 | pub struct ConfFile { |
261 | #[serde(default = "Vec::new")] | 263 | #[serde(default = "Vec::new")] |
262 | disabled: Vec<String>, | 264 | disabled: Vec<String>, |
265 | |||
263 | nix_version: Option<String>, | 266 | nix_version: Option<String>, |
267 | |||
268 | #[serde(default = "Vec::new")] | ||
269 | pub ignore: Vec<String>, | ||
264 | } | 270 | } |
265 | 271 | ||
266 | impl Default for ConfFile { | 272 | impl Default for ConfFile { |
267 | fn default() -> Self { | 273 | fn default() -> Self { |
268 | let disabled = vec![]; | 274 | let disabled = Default::default(); |
269 | let nix_version = None; | 275 | let ignore = Default::default(); |
276 | let nix_version = Default::default(); | ||
270 | Self { | 277 | Self { |
271 | disabled, | 278 | disabled, |
272 | nix_version, | 279 | nix_version, |
280 | ignore, | ||
273 | } | 281 | } |
274 | } | 282 | } |
275 | } | 283 | } |
@@ -298,9 +306,11 @@ impl ConfFile { | |||
298 | let ideal_config = { | 306 | let ideal_config = { |
299 | let disabled = vec![]; | 307 | let disabled = vec![]; |
300 | let nix_version = Some(utils::default_nix_version()); | 308 | let nix_version = Some(utils::default_nix_version()); |
309 | let ignore = vec![".direnv".into()]; | ||
301 | Self { | 310 | Self { |
302 | disabled, | 311 | disabled, |
303 | nix_version, | 312 | nix_version, |
313 | ignore, | ||
304 | } | 314 | } |
305 | }; | 315 | }; |
306 | toml::ser::to_string_pretty(&ideal_config).unwrap() | 316 | toml::ser::to_string_pretty(&ideal_config).unwrap() |
diff --git a/bin/src/fix.rs b/bin/src/fix.rs index 84186d4..da5a470 100644 --- a/bin/src/fix.rs +++ b/bin/src/fix.rs | |||
@@ -51,8 +51,8 @@ pub mod main { | |||
51 | use similar::TextDiff; | 51 | use similar::TextDiff; |
52 | 52 | ||
53 | pub fn all(fix_config: FixConfig) -> Result<(), StatixErr> { | 53 | pub fn all(fix_config: FixConfig) -> Result<(), StatixErr> { |
54 | let vfs = fix_config.vfs()?; | ||
55 | let conf_file = ConfFile::discover(&fix_config.conf_path)?; | 54 | let conf_file = ConfFile::discover(&fix_config.conf_path)?; |
55 | let vfs = fix_config.vfs(conf_file.ignore.as_slice())?; | ||
56 | 56 | ||
57 | let lints = conf_file.lints(); | 57 | let lints = conf_file.lints(); |
58 | let version = conf_file.version()?; | 58 | let version = conf_file.version()?; |
diff --git a/bin/src/lint.rs b/bin/src/lint.rs index e1544e1..b7529ba 100644 --- a/bin/src/lint.rs +++ b/bin/src/lint.rs | |||
@@ -53,12 +53,14 @@ pub mod main { | |||
53 | use rayon::prelude::*; | 53 | use rayon::prelude::*; |
54 | 54 | ||
55 | pub fn main(check_config: CheckConfig) -> Result<(), StatixErr> { | 55 | pub fn main(check_config: CheckConfig) -> Result<(), StatixErr> { |
56 | let vfs = check_config.vfs()?; | ||
57 | let mut stdout = io::stdout(); | ||
58 | let conf_file = ConfFile::discover(&check_config.conf_path)?; | 56 | let conf_file = ConfFile::discover(&check_config.conf_path)?; |
59 | let lints = conf_file.lints(); | 57 | let lints = conf_file.lints(); |
60 | let version = conf_file.version()?; | 58 | let version = conf_file.version()?; |
61 | let session = SessionInfo::from_version(version); | 59 | let session = SessionInfo::from_version(version); |
60 | |||
61 | let vfs = check_config.vfs(conf_file.ignore.as_slice())?; | ||
62 | |||
63 | let mut stdout = io::stdout(); | ||
62 | let lint = |vfs_entry| lint_with(vfs_entry, &lints, &session); | 64 | let lint = |vfs_entry| lint_with(vfs_entry, &lints, &session); |
63 | let results = vfs | 65 | let results = vfs |
64 | .par_iter() | 66 | .par_iter() |