Author:
Hash:
Timestamp:
+23 -24 +/-11 browse
Kevin Schoon [me@kevinschoon.com]
9086865e0e7be671f1456be7b96671e77bd841b8
Sun, 04 Feb 2024 15:20:32 +0000 (1.4 years ago)
1 | diff --git a/ayllu-build/src/evaluate.rs b/ayllu-build/src/evaluate.rs |
2 | index b47e2e4..54bb5e6 100644 |
3 | --- a/ayllu-build/src/evaluate.rs |
4 | +++ b/ayllu-build/src/evaluate.rs |
5 | @@ -404,7 +404,7 @@ mod tests { |
6 | .steps |
7 | .first() |
8 | .expect("missing first set of steps"); |
9 | - let step_1 = steps.get(0).expect("first step is missing"); |
10 | + let step_1 = steps.first().expect("first step is missing"); |
11 | assert!(step_1.id == 1); |
12 | assert!(step_1.name == "Hello"); |
13 | assert!(step_1 |
14 | diff --git a/ayllu-build/src/main.rs b/ayllu-build/src/main.rs |
15 | index 5f5fafe..0333534 100644 |
16 | --- a/ayllu-build/src/main.rs |
17 | +++ b/ayllu-build/src/main.rs |
18 | @@ -68,7 +68,7 @@ fn print_completions<G: Generator>(gen: G, cmd: &mut Command) { |
19 | #[tokio::main(flavor = "current_thread")] |
20 | async fn main() -> Result<()> { |
21 | let cli = Cli::parse(); |
22 | - let cfg = config::load(cli.config.as_ref().map(|cfg| cfg.as_path()))?; |
23 | + let cfg = config::load(cli.config.as_deref())?; |
24 | let log_level = Level::from_str(&cfg.log_level)?; |
25 | tracing_subscriber::fmt() |
26 | .compact() |
27 | diff --git a/ayllu-build/src/rpc_server.rs b/ayllu-build/src/rpc_server.rs |
28 | index 5871a98..fe57e0b 100644 |
29 | --- a/ayllu-build/src/rpc_server.rs |
30 | +++ b/ayllu-build/src/rpc_server.rs |
31 | @@ -1,4 +1,4 @@ |
32 | - use std::error::Error as StdError; |
33 | + |
34 | |
35 | use anyhow::Result; |
36 | use capnp::{capability::Promise, Error as CapnpError}; |
37 | diff --git a/ayllu-mail/src/declarative.rs b/ayllu-mail/src/declarative.rs |
38 | index 545eb0a..6a842a7 100644 |
39 | --- a/ayllu-mail/src/declarative.rs |
40 | +++ b/ayllu-mail/src/declarative.rs |
41 | @@ -99,11 +99,10 @@ pub fn initialize(cfg: &Config) -> MpResult<()> { |
42 | |
43 | let extras: Vec<&String> = lists_by_id |
44 | .keys() |
45 | - .into_iter() |
46 | - .filter(|name| managed_lists.contains(name) == false) |
47 | + .filter(|name| !managed_lists.contains(name)) |
48 | .collect(); |
49 | |
50 | - if extras.len() > 0 { |
51 | + if !extras.is_empty() { |
52 | log::info!("database contains the following superfluous lists:"); |
53 | extras.iter().for_each(|extra| { |
54 | log::info!("List: {}", extra); |
55 | diff --git a/ayllu-mail/src/main.rs b/ayllu-mail/src/main.rs |
56 | index 67cf6a6..c0f87be 100644 |
57 | --- a/ayllu-mail/src/main.rs |
58 | +++ b/ayllu-mail/src/main.rs |
59 | @@ -57,7 +57,7 @@ fn print_completions<G: Generator>(gen: G, cmd: &mut Command) { |
60 | |
61 | fn main() -> Result<(), Box<dyn std::error::Error>> { |
62 | let cli = Cli::parse(); |
63 | - let ayllu_config = config::load(cli.config.as_ref().map(|cfg| cfg.as_path()))?; |
64 | + let ayllu_config = config::load(cli.config.as_deref())?; |
65 | let config_level = Level::from_str(&ayllu_config.log_level)?; |
66 | tracing_subscriber::fmt() |
67 | .compact() |
68 | @@ -127,7 +127,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> { |
69 | ) |
70 | })?; |
71 | let result = child.wait_with_output()?; |
72 | - if result.status.success() == false { |
73 | + if !result.status.success() { |
74 | return Err(format_err!( |
75 | "sendmail proccess failed with exit code: {:?}\n{}", |
76 | result.status.code(), |
77 | diff --git a/ayllu-mail/src/server.rs b/ayllu-mail/src/server.rs |
78 | index 87f89e0..d77357f 100644 |
79 | --- a/ayllu-mail/src/server.rs |
80 | +++ b/ayllu-mail/src/server.rs |
81 | @@ -193,7 +193,7 @@ impl Server for ServerImpl { |
82 | .ok_or(format_err!("no mailing list with id: {}", list_id))?; |
83 | let buf = self.db.export_mbox( |
84 | list.pk, |
85 | - message_id.as_ref().map(|message| message.as_str()), |
86 | + message_id.as_deref(), |
87 | params.get_as_thread(), |
88 | )?; |
89 | results.get().set_thread(&buf); |
90 | diff --git a/crates/config/src/reader.rs b/crates/config/src/reader.rs |
91 | index d828e77..b1e8f6f 100644 |
92 | --- a/crates/config/src/reader.rs |
93 | +++ b/crates/config/src/reader.rs |
94 | @@ -69,7 +69,7 @@ where |
95 | |
96 | /// load the config from a string |
97 | pub fn from_str(config_str: &str) -> Result<T, Error> { |
98 | - let mut config = from_str::<T>(&config_str)?; |
99 | + let mut config = from_str::<T>(config_str)?; |
100 | config.initialize()?; |
101 | config.validate()?; |
102 | Ok(config) |
103 | diff --git a/src/web2/error.rs b/src/web2/error.rs |
104 | index 3936d7b..38d078e 100644 |
105 | --- a/src/web2/error.rs |
106 | +++ b/src/web2/error.rs |
107 | @@ -57,7 +57,7 @@ impl From<GitError> for Error { |
108 | impl From<IoError> for Error { |
109 | fn from(value: IoError) -> Self { |
110 | match value.kind() { |
111 | - std::io::ErrorKind::NotFound => Error::NotFound(format!("IO: {}", value.to_string())), |
112 | + std::io::ErrorKind::NotFound => Error::NotFound(format!("IO: {}", value)), |
113 | _ => Error::Message(format!("IO: {:?}", value)), |
114 | } |
115 | } |
116 | diff --git a/src/web2/middleware/error.rs b/src/web2/middleware/error.rs |
117 | index 4b33ab8..cecd638 100644 |
118 | --- a/src/web2/middleware/error.rs |
119 | +++ b/src/web2/middleware/error.rs |
120 | @@ -1,4 +1,4 @@ |
121 | - use std::io::ErrorKind as IoErrorKind; |
122 | + |
123 | use std::sync::Arc; |
124 | |
125 | use axum::{ |
126 | diff --git a/src/web2/middleware/repository.rs b/src/web2/middleware/repository.rs |
127 | index 060270e..d451684 100644 |
128 | --- a/src/web2/middleware/repository.rs |
129 | +++ b/src/web2/middleware/repository.rs |
130 | @@ -60,7 +60,7 @@ impl Preamble { |
131 | }; |
132 | let gitbug_enabled = Gitbug::new(&repo_path) |
133 | .enabled() |
134 | - .is_ok_and(|enabled| enabled == true); |
135 | + .is_ok_and(|enabled| enabled); |
136 | let repository = Repository::new(&repo_path)?; |
137 | let is_empty = repository.is_empty()?; |
138 | let config = repository.config()?; |
139 | diff --git a/src/web2/routes/rss.rs b/src/web2/routes/rss.rs |
140 | index 3fd2bfc..8a1387b 100644 |
141 | --- a/src/web2/routes/rss.rs |
142 | +++ b/src/web2/routes/rss.rs |
143 | @@ -245,7 +245,7 @@ impl Builder { |
144 | } |
145 | |
146 | // don't generate a new rss item if there is nothing within it |
147 | - if all_data.len() == 0 { |
148 | + if all_data.is_empty() { |
149 | return Ok(self.channel(vec![])); |
150 | } |
151 | |
152 | @@ -297,7 +297,7 @@ pub async fn feed_firehose( |
153 | title: String::from("Firehose"), |
154 | time_to_live: cfg |
155 | .rss_time_to_live |
156 | - .map(|seconds| Duration::seconds(seconds)), |
157 | + .map(Duration::seconds), |
158 | current_time: OffsetDateTime::now_utc(), |
159 | }; |
160 | let channel = builder.firehose( |
161 | @@ -322,7 +322,7 @@ pub async fn feed_1d( |
162 | title: String::from("Daily Update Summary"), |
163 | time_to_live: cfg |
164 | .rss_time_to_live |
165 | - .map(|seconds| Duration::seconds(seconds)), |
166 | + .map(Duration::seconds), |
167 | current_time: OffsetDateTime::now_utc(), |
168 | }; |
169 | let channel = builder.summary( |
170 | @@ -347,7 +347,7 @@ pub async fn feed_1w( |
171 | title: String::from("Weekly Update Summary"), |
172 | time_to_live: cfg |
173 | .rss_time_to_live |
174 | - .map(|seconds| Duration::seconds(seconds)), |
175 | + .map(Duration::seconds), |
176 | current_time: OffsetDateTime::now_utc(), |
177 | }; |
178 | let channel = builder.summary( |
179 | @@ -372,7 +372,7 @@ pub async fn feed_1m( |
180 | title: String::from("Monthly Update Summary"), |
181 | time_to_live: cfg |
182 | .rss_time_to_live |
183 | - .map(|seconds| Duration::seconds(seconds)), |
184 | + .map(Duration::seconds), |
185 | current_time: OffsetDateTime::now_utc(), |
186 | }; |
187 | let channel = builder.summary( |
188 | @@ -403,7 +403,7 @@ pub async fn feed_repository_firehose( |
189 | ), |
190 | time_to_live: cfg |
191 | .rss_time_to_live |
192 | - .map(|seconds| Duration::seconds(seconds)), |
193 | + .map(Duration::seconds), |
194 | current_time: OffsetDateTime::now_utc(), |
195 | }; |
196 | let channel = builder.firehose(vec![(preamble.repo_path, project_url)], Duration::days(7))?; |
197 | @@ -431,7 +431,7 @@ pub async fn feed_repository_1d( |
198 | ), |
199 | time_to_live: cfg |
200 | .rss_time_to_live |
201 | - .map(|seconds| Duration::seconds(seconds)), |
202 | + .map(Duration::seconds), |
203 | current_time: OffsetDateTime::now_utc(), |
204 | }; |
205 | let channel = builder.summary(vec![(preamble.repo_path, project_url)], Timeframe::DAILY)?; |
206 | @@ -459,7 +459,7 @@ pub async fn feed_repository_1w( |
207 | ), |
208 | time_to_live: cfg |
209 | .rss_time_to_live |
210 | - .map(|seconds| Duration::seconds(seconds)), |
211 | + .map(Duration::seconds), |
212 | current_time: OffsetDateTime::now_utc(), |
213 | }; |
214 | let channel = builder.summary(vec![(preamble.repo_path, project_url)], Timeframe::WEEKLY)?; |
215 | @@ -487,7 +487,7 @@ pub async fn feed_repository_1m( |
216 | ), |
217 | time_to_live: cfg |
218 | .rss_time_to_live |
219 | - .map(|seconds| Duration::seconds(seconds)), |
220 | + .map(Duration::seconds), |
221 | current_time: OffsetDateTime::now_utc(), |
222 | }; |
223 | let channel = builder.summary(vec![(preamble.repo_path, project_url)], Timeframe::MONTHLY)?; |
224 | @@ -510,7 +510,7 @@ mod tests { |
225 | // Thu, 07 Apr 2005 22:13:13 +0200 |
226 | |
227 | /// all tests assume the current time is as below |
228 | - const CURRENT_TIME: &'static str = "Tue, 19 Dec 2023 20:55:10 +0000"; |
229 | + const CURRENT_TIME: &str = "Tue, 19 Dec 2023 20:55:10 +0000"; |
230 | |
231 | #[test] |
232 | fn test_firehose_commits() { |
233 | @@ -768,7 +768,7 @@ mod tests { |
234 | let channel = builder |
235 | .summary(vec![(path, name)], Timeframe::DAILY) |
236 | .expect("failed to build items"); |
237 | - assert!(channel.items.len() == 0); |
238 | + assert!(channel.items.is_empty()); |
239 | assert!(channel.ttl.as_ref().is_some_and(|ttl| ttl == "60")) |
240 | } |
241 |