Skip to content

Commit 7cff982

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 08c3c0c commit 7cff982

File tree

1 file changed

+31
-17
lines changed
  • martin-core/src/resources/sprites

1 file changed

+31
-17
lines changed

martin-core/src/resources/sprites/mod.rs

Lines changed: 31 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -100,13 +100,17 @@ impl SpriteSources {
100100
if ext == "svg" {
101101
svg_count += 1;
102102
} else if ext == "png" || ext == "json" {
103-
let filename = entry_path.file_stem()
103+
let filename = entry_path
104+
.file_stem()
104105
.map(|s| s.to_string_lossy().to_string())
105106
.unwrap_or_default();
106107
if filename.contains("sprite") || filename.contains("@2x") {
107-
sprite_output_files.push(entry_path.file_name()
108-
.map(|s| s.to_string_lossy().to_string())
109-
.unwrap_or_default());
108+
sprite_output_files.push(
109+
entry_path
110+
.file_name()
111+
.map(|s| s.to_string_lossy().to_string())
112+
.unwrap_or_default(),
113+
);
110114
}
111115
}
112116
}
@@ -146,7 +150,7 @@ impl SpriteSources {
146150
}
147151
}
148152
}
149-
153+
150154
/// Validates a sprite source directory to ensure it contains valid SVG files.
151155
/// Checks include:
152156
/// - Directory existence and accessibility
@@ -163,7 +167,7 @@ impl SpriteSources {
163167
warn!("Sprite source is not a directory: {disp_path}");
164168
return Err(SpriteError::DirectoryValidationFailed(
165169
path.clone(),
166-
"Path is not a directory".to_string()
170+
"Path is not a directory".to_string(),
167171
));
168172
}
169173

@@ -187,13 +191,17 @@ impl SpriteSources {
187191
warn!("Invalid SVG file {}: {}", entry_path.display(), e);
188192
}
189193
} else if ext == "png" || ext == "json" {
190-
let filename = entry_path.file_stem()
194+
let filename = entry_path
195+
.file_stem()
191196
.map(|s| s.to_string_lossy().to_string())
192197
.unwrap_or_default();
193198
if filename.contains("sprite") || filename.contains("@2x") {
194-
sprite_output_files.push(entry_path.file_name()
195-
.map(|s| s.to_string_lossy().to_string())
196-
.unwrap_or_default());
199+
sprite_output_files.push(
200+
entry_path
201+
.file_name()
202+
.map(|s| s.to_string_lossy().to_string())
203+
.unwrap_or_default(),
204+
);
197205
}
198206
}
199207
}
@@ -219,15 +227,19 @@ impl SpriteSources {
219227
"Directory contains pre-generated sprite files ({}) but no source SVG files. \
220228
Please provide a directory with .svg files instead.",
221229
sprite_output_files.join(", ")
222-
)
230+
),
223231
));
224232
} else {
225-
warn!("No SVG files found in sprite directory: {disp_path}. Please ensure the directory contains .svg files.");
233+
warn!(
234+
"No SVG files found in sprite directory: {disp_path}. Please ensure the directory contains .svg files."
235+
);
226236
return Err(SpriteError::NoSpriteFilesFound(path.clone()));
227237
}
228238
}
229239

230-
info!("Validated sprite directory {disp_path}: found {svg_count} SVG files out of {total_files} total files");
240+
info!(
241+
"Validated sprite directory {disp_path}: found {svg_count} SVG files out of {total_files} total files"
242+
);
231243
Ok(())
232244
}
233245

@@ -241,22 +253,22 @@ impl SpriteSources {
241253
if content.is_empty() {
242254
return Err(SpriteError::InvalidSvgFormat(
243255
path.clone(),
244-
"File is empty".to_string()
256+
"File is empty".to_string(),
245257
));
246258
}
247259

248260
if !content.starts_with("<?xml") && !content.starts_with("<svg") {
249261
return Err(SpriteError::InvalidSvgFormat(
250262
path.clone(),
251-
"Missing SVG or XML declaration".to_string()
263+
"Missing SVG or XML declaration".to_string(),
252264
));
253265
}
254266

255267
// Check if it contains an SVG tag
256268
if !content.contains("<svg") {
257269
return Err(SpriteError::InvalidSvgFormat(
258270
path.clone(),
259-
"No SVG element found".to_string()
271+
"No SVG element found".to_string(),
260272
));
261273
}
262274

@@ -304,7 +316,9 @@ impl SpriteSources {
304316
} else {
305317
warn!(
306318
"Sprite source validation completed with errors: {}/{} sources valid, {} errors encountered",
307-
valid_sources, total_sources, validation_errors.len()
319+
valid_sources,
320+
total_sources,
321+
validation_errors.len()
308322
);
309323
for (id, error) in &validation_errors {
310324
warn!(" - {}: {}", id, error);

0 commit comments

Comments
 (0)