Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@amirabbas-gh
Copy link
Collaborator

@amirabbas-gh amirabbas-gh commented Sep 18, 2025

πŸ“š Description

Things done in this PR:

  • Converted verbose and disable analytics into a single global argument and fixed the issue with using -‍‍- before calling them
  • Fixed the param issue in the jssg run and run commands
  • Passed the --no-telemetry argument to the legacy command

@vercel
Copy link

vercel bot commented Sep 18, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Preview Comments Updated (UTC)
codemod Ignored Ignored Preview Sep 18, 2025 6:53pm

@pkg-pr-new
Copy link

pkg-pr-new bot commented Sep 18, 2025

Open in StackBlitz

npm i https://pkg.pr.new/codemod@1781

commit: 1a62671

Comment on lines 311 to 329
// #[test]
// fn test_parse_params_invalid() {
// // Test parsing invalid parameters
// let params = vec![
// "key1=value1".to_string(),
// "invalid_param".to_string(), // Missing '='
// ];

// let result = utils::parse_params(&params);

// // Verify that parsing fails
// assert!(result.is_err());
// match result {
// Err(Error::Other(msg)) => {
// assert!(msg.contains("Invalid parameter format"));
// }
// _ => panic!("Expected Other error"),
// }
// }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you comment this out?

Comment on lines 199 to 203
println!(
"\x1b[33mWarning\x1b[0m: Invalid parameter format: {}",
param
);
continue;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this change related? also we should use console::style for these ansi codes

@mohebifar mohebifar requested a review from Copilot September 18, 2025 17:35
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes a bug related to the disable analytics flag by modifying parameter parsing behavior and adding validation for the analytics flag usage. The change allows the system to handle invalid parameter formats more gracefully while ensuring proper usage of the disable analytics flag.

  • Changed parameter parsing to emit warnings instead of errors for invalid formats
  • Added validation to prevent misuse of the disable analytics flag in implicit run commands
  • Commented out tests that verify error handling for invalid parameters

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
crates/core/src/utils.rs Modified parse_params to continue with warnings instead of returning errors for invalid parameter formats
crates/core/tests/utils_tests.rs Commented out test that verified error handling for invalid parameter parsing
crates/cli/src/main.rs Added validation to ensure disable analytics flag is used correctly with explicit run command syntax

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines 199 to 202
println!(
"\x1b[33mWarning\x1b[0m: Invalid parameter format: {}",
param
);
Copy link

Copilot AI Sep 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using println! with hardcoded ANSI escape codes for colored output is not ideal. Consider using a proper logging framework or a colored output library like colored or termcolor for better maintainability and consistency.

Copilot uses AI. Check for mistakes.
"--disable-analytics"
};
return Err(anyhow::anyhow!(
"You can use disable-analytics flag like this: codemod run codemod-name -- {which_flag}"
Copy link

Copilot AI Sep 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error message uses string interpolation syntax {which_flag} but this is not valid Rust string interpolation. It should use format! macro syntax or string formatting to properly substitute the variable value.

Suggested change
"You can use disable-analytics flag like this: codemod run codemod-name -- {which_flag}"
"You can use disable-analytics flag like this: codemod run codemod-name -- {}", which_flag

Copilot uses AI. Check for mistakes.
Comment on lines 38 to 39
#[arg(long)]
param: Option<Vec<String>>,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#[arg(long)]
param: Option<Vec<String>>,
#[arg(long = "param", value_name = "KEY=VALUE")]
params: Vec<String>,

Also why do we need to make it Option? doesn't it yield an empty vector by default?

@mohebifar mohebifar requested a review from Copilot September 18, 2025 19:00
@amirabbas-gh amirabbas-gh merged commit 22dcda2 into main Sep 18, 2025
11 checks passed
@amirabbas-gh amirabbas-gh deleted the analytics-error branch September 18, 2025 19:00
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines +176 to +206
let mut filtered_args = Vec::new();
let mut disable_analytics = false;
let mut verbose = false;

for arg in &trailing_args {
match arg.as_str() {
"--disable-analytics" => {
disable_analytics = true;
}
"--verbose" | "-v" => {
verbose = true;
}
_ => {
filtered_args.push(arg.clone());
}
}
}

if disable_analytics {
std::env::set_var("DISABLE_ANALYTICS", "true");
}
if verbose {
std::env::set_var("RUST_LOG", "debug");
}

let mut full_args = vec!["codemod".to_string(), "run".to_string()];
full_args.extend(trailing_args.clone());
full_args.extend(filtered_args.clone());

if disable_analytics {
full_args.push("--disable-analytics".to_string());
}
Copy link

Copilot AI Sep 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This manual argument parsing duplicates the logic that clap already handles for global arguments. Since verbose and disable_analytics are now marked as global = true, clap should handle these automatically. Consider removing this manual parsing and letting clap handle the global arguments.

Copilot uses AI. Check for mistakes.
Comment on lines +204 to +209
if disable_analytics {
full_args.push("--disable-analytics".to_string());
}
if verbose {
full_args.push("--verbose".to_string());
}
Copy link

Copilot AI Sep 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These flags are being added back to full_args after being filtered out earlier, which creates unnecessary complexity. Since these are now global arguments, they should be handled by clap's global argument mechanism instead of this manual manipulation.

Suggested change
if disable_analytics {
full_args.push("--disable-analytics".to_string());
}
if verbose {
full_args.push("--verbose".to_string());
}
// No need to manually re-add global flags; clap will handle them as global arguments.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants