-
Notifications
You must be signed in to change notification settings - Fork 0
Add Curseforge Support #21
base: main
Are you sure you want to change the base?
Conversation
*this should partially sync this branch with [this commit](https://github.com/Kiwifuit/DMS/pull/6/commits/bb55dcc37ec15061bde1dd2306a5939558a03b6f)*
Reviewer's Guide by SourceryThis pull request adds Curseforge support to the project by introducing a new module with initial functionality and tests. It also includes refactoring of existing code across multiple files to improve readability and maintainability, as well as enhancements to error handling and logging. File-Level Changes
Sequence DiagramNo sequence diagram generated. Tips
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @Kiwifuit - I've reviewed your changes and they look great!
Here's what I looked at during the review
- 🟡 General issues: 5 issues found
- 🟢 Security: all looks good
- 🟢 Testing: all looks good
- 🟢 Complexity: all looks good
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment to tell me if it was helpful.
sourcery stop complaining
@sourcery-ai review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @Kiwifuit - I've reviewed your changes and they look great!
Here's what I looked at during the review
- 🟢 General issues: all looks good
- 🟢 Security: all looks good
- 🟢 Testing: all looks good
- 🟡 Complexity: 1 issue found
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment to tell me if it was helpful.
@sourcery-ai review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @Kiwifuit - I've reviewed your changes and they look great!
Here's what I looked at during the review
- 🟡 General issues: 4 issues found
- 🟢 Security: all looks good
- 🟢 Testing: all looks good
- 🟡 Complexity: 1 issue found
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment to tell me if it was helpful.
where | ||
E: serde::de::Error, | ||
{ | ||
if value == "*" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: Consider adding more specific error handling
While the simplification of the ModLoaderVersionVisitor is good for readability, consider adding more specific error messages for different cases to maintain detailed error reporting.
if value == "*" {
Ok(ForgeModVersion::Any)
} else if value.is_empty() {
Err(E::custom("Empty version string"))
} else if !value.chars().all(|c| c.is_ascii_digit() || c == '.' || c == '-') {
Err(E::custom("Invalid characters in version string"))
} else {
Ok(ForgeModVersion::Specific(value.to_string()))
}
@@ -14,91 +14,91 @@ const MODRINTH_META: &str = "modrinth.index.json"; | |||
|
|||
#[derive(Debug, Error)] | |||
pub enum UnzipError { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: Consider using an enum for error types instead of hardcoded strings
Using an enum for error types would make the code more maintainable and allow for better error matching downstream. This can improve error handling and make it easier to add new error types in the future.
pub enum UnzipError {
IoError(std::io::Error),
ZipError(zip::result::ZipError),
InvalidArchive,
ExtractionFailed,
}
curseforge/src/types/project.rs
Outdated
} | ||
|
||
impl CurseCategory { | ||
fn from_id<'de, D>(deserializer: D) -> Result<Self, D::Error> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue (bug_risk): Implement CurseCategory::from_id
properly or add a TODO comment
The current implementation creates a dummy category with hardcoded values. This could lead to incorrect data being used. Either implement this function properly or add a TODO comment if it's intentionally left for future work.
inner: T, | ||
} | ||
|
||
impl<T> Deref for CurseResponse<T> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: Consider using #[derive(Deref, DerefMut)]
for CurseResponse
You can simplify the Deref
implementation by using #[derive(Deref, DerefMut)]
from the derive_more
crate. This would make the code more concise and easier to maintain.
use derive_more::{Deref, DerefMut};
#[derive(Deref, DerefMut)]
pub struct CurseResponse<T> {
#[deref]
#[deref_mut]
pub data: T,
}
formatter.write_str("valid string or struct representing ModLoaderVersion variant") | ||
} | ||
|
||
fn visit_str<E>(self, value: &str) -> Result<ForgeModVersion, E> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue (complexity): Consider refactoring the visit_str method to improve readability and maintainability.
The changes to the visit_str
method in ModLoaderVersionVisitor
have increased complexity and reduced readability. Consider refactoring this section to improve clarity while maintaining the new functionality. Here's a suggested approach:
fn visit_str<E>(self, value: &str) -> Result<ForgeModVersion, E>
where
E: serde::de::Error,
{
match value {
"*" => Ok(ForgeModVersion::Any),
v if v.starts_with('[') => Ok(ForgeModVersion::VersionRange(
v.parse().map_err(serde::de::Error::custom)?,
)),
v => Ok(ForgeModVersion::SpecificVersion(
v.parse().map_err(serde::de::Error::custom)?,
)),
}
}
This refactored version:
- Uses a match expression for better readability
- Handles the "*" case first
- Checks for version ranges starting with '['
- Treats all other cases as specific versions
This approach simplifies the logic while maintaining the new behavior. It also removes the commented-out code, reducing noise in the codebase. If there are specific edge cases that this doesn't cover, consider adding them as additional match arms with clear comments explaining their purpose.
* made `version` `ModSemver`
* added `serde_qs` as a temp dependency
still working on the dependency stuffs :>
yay
this pr fixes #5
Summary by Sourcery
Add support for Curseforge by introducing new types and structures to handle Curseforge mod data, and refactor existing code for improved readability and maintainability.
New Features:
Enhancements: