Skip to content

Commit

Permalink
fix: clippy warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
wangl-cc committed Dec 11, 2023
1 parent 3c4d915 commit 0556deb
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 13 deletions.
4 changes: 2 additions & 2 deletions maa-cli/src/config/asst.rs
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ impl ResourceConfig {
let global_resource_dir = PathBuf::from("global")
.join(global_resource)

Check warning on line 277 in maa-cli/src/config/asst.rs

View check run for this annotation

Codecov / codecov/patch

maa-cli/src/config/asst.rs#L272-L277

Added lines #L272 - L277 were not covered by tests
.join("resource");
let full_paths = global_path(base_dirs, &global_resource_dir);
let full_paths = global_path(base_dirs, global_resource_dir);
if full_paths.is_empty() {
warning!(format!(
"Global resource {} not found",
Expand All @@ -290,7 +290,7 @@ impl ResourceConfig {
let platform_diff_resource_dir = PathBuf::from("platform_diff")
.join(platform_diff_resource)

Check warning on line 291 in maa-cli/src/config/asst.rs

View check run for this annotation

Codecov / codecov/patch

maa-cli/src/config/asst.rs#L289-L291

Added lines #L289 - L291 were not covered by tests
.join("resource");
let full_paths = global_path(base_dirs, &platform_diff_resource_dir);
let full_paths = global_path(base_dirs, platform_diff_resource_dir);
if full_paths.is_empty() {
warning!(format!(
"Platform diff resource {} not found",
Expand Down
2 changes: 1 addition & 1 deletion maa-cli/src/log.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ impl<T: Into<u8>> From<T> for LogLevel {
}

impl LogLevel {
pub fn to_git_flag(&self) -> &str {
pub fn to_git_flag(self) -> &'static str {
match self {
Self::Error => "-qq",
Self::Warning => "-q",
Expand Down
8 changes: 1 addition & 7 deletions maa-cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,13 +214,7 @@ fn main() -> Result<()> {
let cli = CLI::parse();

if cli.verbose != cli.quiet {
unsafe {
set_level(
(level() as u8 + cli.verbose)
.checked_sub(cli.quiet)
.unwrap_or(0),
)
};
unsafe { set_level((level() as u8 + cli.verbose).saturating_sub(cli.quiet)) };

Check warning on line 217 in maa-cli/src/main.rs

View check run for this annotation

Codecov / codecov/patch

maa-cli/src/main.rs#L216-L217

Added lines #L216 - L217 were not covered by tests
}

if cli.batch {
Expand Down
6 changes: 3 additions & 3 deletions maa-cli/src/run/copilot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ pub fn copilot(uri: impl AsRef<str>, resource_dirs: &Vec<PathBuf>) -> Result<Tas
}

enum CopilotJson<'a> {
URL(&'a str),
Code(&'a str),
File(&'a Path),
}

Expand All @@ -75,7 +75,7 @@ impl CopilotJson<'_> {
if let Some(code_str) = trimed.strip_prefix("maa://") {

Check warning on line 75 in maa-cli/src/run/copilot.rs

View check run for this annotation

Codecov / codecov/patch

maa-cli/src/run/copilot.rs#L75

Added line #L75 was not covered by tests
// just check if it's a number
if code_str.parse::<i64>().is_ok() {
return Ok(CopilotJson::URL(code_str));
return Ok(CopilotJson::Code(code_str));

Check warning on line 78 in maa-cli/src/run/copilot.rs

View check run for this annotation

Codecov / codecov/patch

maa-cli/src/run/copilot.rs#L77-L78

Added lines #L77 - L78 were not covered by tests
} else {
bail!("Invalid code: {}", code_str);

Check warning on line 80 in maa-cli/src/run/copilot.rs

View check run for this annotation

Codecov / codecov/patch

maa-cli/src/run/copilot.rs#L80

Added line #L80 was not covered by tests
}
Expand All @@ -86,7 +86,7 @@ impl CopilotJson<'_> {

pub fn get_json_and_file(&self) -> Result<(JsonValue, PathBuf)> {
match self {
CopilotJson::URL(code) => {
CopilotJson::Code(code) => {
let json_file = dirs::copilot().ensure()?.join(code).with_extension("json");

Check warning on line 90 in maa-cli/src/run/copilot.rs

View check run for this annotation

Codecov / codecov/patch

maa-cli/src/run/copilot.rs#L87-L90

Added lines #L87 - L90 were not covered by tests

if json_file.is_file() {
Expand Down

0 comments on commit 0556deb

Please sign in to comment.