diff options
author | Akshay <[email protected]> | 2022-05-01 16:12:12 +0100 |
---|---|---|
committer | Akshay <[email protected]> | 2022-05-01 16:12:12 +0100 |
commit | 53b454cd6acba89fe6b5bb39df431afa28a6ee13 (patch) | |
tree | cd70026307c98a33c6ce25b0849d9e297e5bf842 | |
parent | 448e6f2096b855bee1464c514dfb73477fb39774 (diff) |
add `ignore` to statix.tomlv0.5.5
-rw-r--r-- | Cargo.lock | 2 | ||||
-rw-r--r-- | Cargo.toml | 2 | ||||
-rw-r--r-- | bin/Cargo.toml | 2 | ||||
-rw-r--r-- | bin/src/config.rs | 22 | ||||
-rw-r--r-- | bin/src/fix.rs | 2 | ||||
-rw-r--r-- | bin/src/lint.rs | 6 | ||||
-rw-r--r-- | flake.nix | 19 |
7 files changed, 43 insertions, 12 deletions
@@ -588,7 +588,7 @@ dependencies = [ | |||
588 | 588 | ||
589 | [[package]] | 589 | [[package]] |
590 | name = "statix" | 590 | name = "statix" |
591 | version = "0.5.4" | 591 | version = "0.5.5" |
592 | dependencies = [ | 592 | dependencies = [ |
593 | "ariadne", | 593 | "ariadne", |
594 | "clap", | 594 | "clap", |
@@ -4,6 +4,6 @@ members = [ | |||
4 | "bin", | 4 | "bin", |
5 | "lib", | 5 | "lib", |
6 | "macros", | 6 | "macros", |
7 | "vfs" | 7 | "vfs", |
8 | ] | 8 | ] |
9 | 9 | ||
diff --git a/bin/Cargo.toml b/bin/Cargo.toml index 095d048..8897996 100644 --- a/bin/Cargo.toml +++ b/bin/Cargo.toml | |||
@@ -1,6 +1,6 @@ | |||
1 | [package] | 1 | [package] |
2 | name = "statix" | 2 | name = "statix" |
3 | version = "0.5.4" | 3 | version = "0.5.5" |
4 | edition = "2018" | 4 | edition = "2018" |
5 | license = "MIT" | 5 | license = "MIT" |
6 | authors = [ "Akshay <[email protected]>" ] | 6 | authors = [ "Akshay <[email protected]>" ] |
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() |
@@ -108,5 +108,24 @@ | |||
108 | RUST_BACKTRACE = 1; | 108 | RUST_BACKTRACE = 1; |
109 | }); | 109 | }); |
110 | 110 | ||
111 | |||
112 | apps = forAllSystems | ||
113 | (system: | ||
114 | let | ||
115 | pkgs = nixpkgsFor."${system}"; | ||
116 | cachix-push-script = pkgs.writeScriptBin "cachix-push" '' | ||
117 | ${pkgs.nixUnstable}/bin/nix build --json \ | ||
118 | | ${pkgs.jq}/bin/jq -r '.[].outputs | to_entries[].value' \ | ||
119 | | ${pkgs.cachix}/bin/cachix push statix | ||
120 | ''; | ||
121 | in | ||
122 | { | ||
123 | cachix-push = { | ||
124 | type = "app"; | ||
125 | program = "${cachix-push-script}/bin/cachix-push"; | ||
126 | }; | ||
127 | } | ||
128 | ); | ||
129 | |||
111 | }; | 130 | }; |
112 | } | 131 | } |