Refactor JSON handling and improve code clarity

- Updated error messages in Http.jsonDecode for better context.
- Enhanced serialization error handling in CompactJson5Serializer.
- Reformatted struct definitions in tests for improved readability.
- Adjusted assertions in tests for better clarity and consistency.
- Refactored project file name checks for improved readability.
This commit is contained in:
Joe 2026-01-22 22:22:03 -06:00
parent fdd1d145cf
commit 2b716351c1
4 changed files with 48 additions and 15 deletions

View file

@ -16,7 +16,11 @@ use crate::{
};
/// Represents 'default' project names that act as `init` files
pub static DEFAULT_PROJECT_NAMES: [&str; 3] = ["default.project.json", "default.project.jsonc", "default.project.json5"];
pub static DEFAULT_PROJECT_NAMES: [&str; 3] = [
"default.project.json",
"default.project.jsonc",
"default.project.json5",
];
/// Error type returned by any function that handles projects.
#[derive(Debug, Error)]
@ -146,7 +150,11 @@ impl Project {
pub fn is_project_file(path: &Path) -> bool {
path.file_name()
.and_then(|name| name.to_str())
.map(|name| name.ends_with(".project.json") || name.ends_with(".project.jsonc") || name.ends_with(".project.json5"))
.map(|name| {
name.ends_with(".project.json")
|| name.ends_with(".project.jsonc")
|| name.ends_with(".project.json5")
})
.unwrap_or(false)
}