diff --git a/src/athena/error.rs b/src/athena/error.rs index 8714232..4a09730 100644 --- a/src/athena/error.rs +++ b/src/athena/error.rs @@ -20,22 +20,27 @@ pub enum AthenaError { ValidationError(String), #[error("Template error: {0}")] + #[allow(dead_code)] TemplateError(String), } impl AthenaError { + #[allow(dead_code)] pub fn parse_error>(msg: T) -> Self { AthenaError::ParseError(msg.into()) } + #[allow(dead_code)] pub fn config_error>(msg: T) -> Self { AthenaError::ConfigError(msg.into()) } + #[allow(dead_code)] pub fn validation_error>(msg: T) -> Self { AthenaError::ValidationError(msg.into()) } + #[allow(dead_code)] pub fn template_error>(msg: T) -> Self { AthenaError::TemplateError(msg.into()) } diff --git a/src/athena/generator/compose.rs b/src/athena/generator/compose.rs index 4618130..bd28779 100644 --- a/src/athena/generator/compose.rs +++ b/src/athena/generator/compose.rs @@ -91,7 +91,7 @@ pub fn generate_docker_compose(athena_file: &AthenaFile) -> AthenaResult // Generate optimized YAML let yaml = serde_yaml::to_string(&compose) - .map_err(|e| AthenaError::YamlError(e))?; + .map_err(AthenaError::YamlError)?; // Improve formatting for better readability let formatted_yaml = improve_yaml_formatting(yaml); diff --git a/src/athena/generator/defaults.rs b/src/athena/generator/defaults.rs index f42b340..f469ba6 100644 --- a/src/athena/generator/defaults.rs +++ b/src/athena/generator/defaults.rs @@ -4,28 +4,37 @@ use crate::athena::parser::ast::*; /// Default Docker Compose configurations based on service patterns and Docker standards #[derive(Debug, Clone)] +#[allow(dead_code)] pub struct ServiceDefaults { pub restart_policy: RestartPolicy, pub health_check_interval: String, pub health_check_timeout: String, pub health_check_retries: u32, pub health_check_start_period: String, + #[allow(dead_code)] pub network_mode: NetworkMode, pub pull_policy: PullPolicy, } #[derive(Debug, Clone)] +#[allow(dead_code)] pub enum NetworkMode { Bridge, + #[allow(dead_code)] Host, + #[allow(dead_code)] None, + #[allow(dead_code)] Custom(String), } #[derive(Debug, Clone)] +#[allow(dead_code)] pub enum PullPolicy { + #[allow(dead_code)] Always, Missing, + #[allow(dead_code)] Never, } diff --git a/src/athena/mod.rs b/src/athena/mod.rs index 27e6852..f6a5fe9 100644 --- a/src/athena/mod.rs +++ b/src/athena/mod.rs @@ -3,23 +3,14 @@ pub mod parser; pub mod generator; pub use error::{AthenaError, AthenaResult}; -pub use parser::{parse_athena_file, AthenaFile, Service}; +pub use parser::parse_athena_file; pub use generator::generate_docker_compose; /// Configuration for Athena operations -#[derive(Debug, Clone)] +#[derive(Debug, Clone, Default)] +#[allow(dead_code)] pub struct AthenaConfig { pub output_file: Option, pub validate_only: bool, pub verbose: bool, -} - -impl Default for AthenaConfig { - fn default() -> Self { - Self { - output_file: None, - validate_only: false, - verbose: false, - } - } } \ No newline at end of file diff --git a/src/athena/parser/ast.rs b/src/athena/parser/ast.rs index 1d16f40..213f2cc 100644 --- a/src/athena/parser/ast.rs +++ b/src/athena/parser/ast.rs @@ -53,18 +53,13 @@ pub struct PortMapping { pub protocol: Protocol, } -#[derive(Debug, Clone, Serialize, Deserialize)] +#[derive(Debug, Clone, Serialize, Deserialize, Default)] pub enum Protocol { + #[default] Tcp, Udp, } -impl Default for Protocol { - fn default() -> Self { - Protocol::Tcp - } -} - #[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)] pub enum EnvironmentVariable { Template(String), // {{VAR_NAME}} diff --git a/src/athena/parser/mod.rs b/src/athena/parser/mod.rs index 8824d57..efbe475 100644 --- a/src/athena/parser/mod.rs +++ b/src/athena/parser/mod.rs @@ -2,6 +2,4 @@ pub mod ast; pub mod parser; pub mod optimized_parser; -pub use ast::*; -pub use parser::{parse_athena_file, AthenaParser}; -pub use optimized_parser::OptimizedParser; \ No newline at end of file +pub use parser::parse_athena_file; \ No newline at end of file diff --git a/src/athena/parser/optimized_parser.rs b/src/athena/parser/optimized_parser.rs index 7296eed..61be2bd 100644 --- a/src/athena/parser/optimized_parser.rs +++ b/src/athena/parser/optimized_parser.rs @@ -3,10 +3,13 @@ use crate::athena::error::{AthenaError, AthenaResult}; use super::ast::*; /// Optimized parser with performance improvements and better error handling +#[allow(dead_code)] pub struct OptimizedParser; impl OptimizedParser { /// Parse Athena file with optimized performance and enhanced error reporting + #[allow(dead_code)] + #[allow(dead_code)] pub fn parse_with_performance_optimizations(input: &str) -> AthenaResult { // Pre-validate input for common issues Self::pre_validate_input(input)?; @@ -19,6 +22,7 @@ impl OptimizedParser { } /// Pre-validation for common syntax issues to fail fast + #[allow(dead_code)] fn pre_validate_input(input: &str) -> AthenaResult<()> { let trimmed = input.trim(); @@ -60,6 +64,7 @@ impl OptimizedParser { } /// Optimize the AST after parsing for better runtime performance + #[allow(dead_code)] fn optimize_ast(mut athena_file: AthenaFile) -> AthenaResult { // Sort services by dependency order for faster dependency resolution athena_file.services.services = Self::topological_sort_services(athena_file.services.services)?; @@ -76,6 +81,7 @@ impl OptimizedParser { } /// Topological sort services by dependencies for optimal processing order + #[allow(dead_code)] fn topological_sort_services(services: Vec) -> AthenaResult> { use std::collections::{HashMap, VecDeque}; @@ -140,6 +146,7 @@ impl OptimizedParser { } /// Optimize individual service configuration + #[allow(dead_code)] fn optimize_service(service: &mut Service) { // Remove duplicate environment variables service.environment.dedup(); @@ -160,6 +167,7 @@ impl OptimizedParser { } /// Apply intelligent defaults based on service patterns + #[allow(dead_code)] fn apply_intelligent_defaults(athena_file: &mut AthenaFile) { // Set default deployment if missing if athena_file.deployment.is_none() { @@ -196,6 +204,7 @@ impl OptimizedParser { } /// Parse with caching for repeated parsing operations + #[allow(dead_code)] pub fn parse_with_cache( input: &str, cache: &mut HashMap @@ -221,6 +230,7 @@ impl OptimizedParser { } /// Validate syntax without full parsing for quick feedback + #[allow(dead_code)] pub fn quick_syntax_check(input: &str) -> AthenaResult<()> { Self::pre_validate_input(input)?; @@ -264,6 +274,7 @@ mod tests { use super::*; #[test] + #[allow(dead_code)] fn test_pre_validation() { assert!(OptimizedParser::pre_validate_input("").is_err()); assert!(OptimizedParser::pre_validate_input("DEPLOYMENT-ID test").is_err()); @@ -278,6 +289,7 @@ mod tests { } #[test] + #[allow(dead_code)] fn test_unbalanced_service_blocks() { let invalid_input = r#" SERVICES SECTION @@ -291,6 +303,7 @@ mod tests { } #[test] + #[allow(dead_code)] fn test_quick_syntax_check() { let invalid_port = r#" SERVICES SECTION diff --git a/src/boilerplate/fastapi.rs b/src/boilerplate/fastapi.rs index 5e5efe6..165cd3f 100644 --- a/src/boilerplate/fastapi.rs +++ b/src/boilerplate/fastapi.rs @@ -7,6 +7,12 @@ use std::path::Path; pub struct FastAPIGenerator; +impl Default for FastAPIGenerator { + fn default() -> Self { + Self::new() + } +} + impl FastAPIGenerator { pub fn new() -> Self { Self @@ -75,11 +81,6 @@ impl FastAPIGenerator { "MySQL is not supported for FastAPI projects. Use Flask for MySQL support.".to_string() )); } - DatabaseType::MySQL => { - return Err(crate::athena::AthenaError::ValidationError( - "MySQL is not supported for FastAPI projects. Use Flask for MySQL support.".to_string() - )); - } } config_content = replace_template_vars_string(&config_content, &vars); write_file(base_path.join("app/core/config.py"), &config_content)?; @@ -284,7 +285,7 @@ async def get_current_user_info(current_user = Depends(get_current_user)): } fn generate_database_files(&self, config: &ProjectConfig, base_path: &Path) -> BoilerplateResult<()> { - let vars = self.get_template_vars(config); + let _vars = self.get_template_vars(config); write_file(base_path.join("app/database/__init__.py"), "")?; @@ -324,7 +325,7 @@ def get_database(): """Get database instance""" return db.database "#; - write_file(base_path.join("app/database/connection.py"), &mongodb_connection)?; + write_file(base_path.join("app/database/connection.py"), mongodb_connection)?; } DatabaseType::PostgreSQL => { let postgres_connection = r#"from sqlalchemy.ext.asyncio import create_async_engine, AsyncSession, async_sessionmaker @@ -396,7 +397,7 @@ def get_engine(): """Get database engine""" return engine "#; - write_file(base_path.join("app/database/connection.py"), &postgres_connection)?; + write_file(base_path.join("app/database/connection.py"), postgres_connection)?; } DatabaseType::MySQL => { return Err(crate::athena::AthenaError::ValidationError( @@ -409,7 +410,7 @@ def get_engine(): } fn generate_models_and_services(&self, config: &ProjectConfig, base_path: &Path) -> BoilerplateResult<()> { - let vars = self.get_template_vars(config); + let _vars = self.get_template_vars(config); // Models write_file(base_path.join("app/models/__init__.py"), "")?; @@ -799,13 +800,13 @@ def test_invalid_login(): ) assert response.status_code == 401 "#; - write_file(base_path.join("tests/test_auth.py"), &test_auth)?; + write_file(base_path.join("tests/test_auth.py"), test_auth)?; Ok(()) } fn generate_documentation(&self, config: &ProjectConfig, base_path: &Path) -> BoilerplateResult<()> { - let vars = self.get_template_vars(config); + let _vars = self.get_template_vars(config); let names = ProjectNames::new(&config.name); let readme = format!(r#"# {project_name} diff --git a/src/boilerplate/flask.rs b/src/boilerplate/flask.rs index fb3b16d..1e23760 100644 --- a/src/boilerplate/flask.rs +++ b/src/boilerplate/flask.rs @@ -7,6 +7,12 @@ use std::path::Path; pub struct FlaskGenerator; +impl Default for FlaskGenerator { + fn default() -> Self { + Self::new() + } +} + impl FlaskGenerator { pub fn new() -> Self { Self diff --git a/src/boilerplate/go.rs b/src/boilerplate/go.rs index 497dde7..6398986 100644 --- a/src/boilerplate/go.rs +++ b/src/boilerplate/go.rs @@ -7,6 +7,12 @@ use std::path::Path; pub struct GoGenerator; +impl Default for GoGenerator { + fn default() -> Self { + Self::new() + } +} + impl GoGenerator { pub fn new() -> Self { Self @@ -423,7 +429,7 @@ func VerifyToken(tokenString, jwtSecret, expectedType string) (*Claims, error) { } fn generate_models_files(&self, config: &ProjectConfig, base_path: &Path) -> BoilerplateResult<()> { - let vars = self.get_template_vars(config); + let _vars = self.get_template_vars(config); let models_go = match config.database { DatabaseType::MySQL => { @@ -1421,7 +1427,7 @@ func TestHealth(t *testing.T) { } fn generate_documentation(&self, config: &ProjectConfig, base_path: &Path) -> BoilerplateResult<()> { - let vars = self.get_template_vars(config); + let _vars = self.get_template_vars(config); let names = ProjectNames::new(&config.name); let readme = format!(r#"# {project_name} diff --git a/src/boilerplate/mod.rs b/src/boilerplate/mod.rs index 7575c9d..b7149ae 100644 --- a/src/boilerplate/mod.rs +++ b/src/boilerplate/mod.rs @@ -38,6 +38,7 @@ pub struct ProjectConfig { pub directory: String, pub database: DatabaseType, pub include_docker: bool, + #[allow(dead_code)] pub framework: Option, } diff --git a/src/boilerplate/utils.rs b/src/boilerplate/utils.rs index e03b6ab..eba1f39 100644 --- a/src/boilerplate/utils.rs +++ b/src/boilerplate/utils.rs @@ -11,7 +11,7 @@ pub fn create_directory_structure(base_path: &Path, dirs: &[&str]) -> UtilResult for dir in dirs { let full_path = base_path.join(dir); fs::create_dir_all(&full_path) - .map_err(|e| AthenaError::IoError(e))?; + .map_err(AthenaError::IoError)?; } Ok(()) } @@ -23,16 +23,17 @@ pub fn write_file>(path: P, content: &str) -> UtilResult<()> { // Create parent directories if they don't exist if let Some(parent) = path.parent() { fs::create_dir_all(parent) - .map_err(|e| AthenaError::IoError(e))?; + .map_err(AthenaError::IoError)?; } fs::write(path, content) - .map_err(|e| AthenaError::IoError(e))?; + .map_err(AthenaError::IoError)?; Ok(()) } /// Replace template variables in content +#[allow(dead_code)] pub fn replace_template_vars(content: &str, vars: &[(&str, &str)]) -> String { let mut result = content.to_string(); for (key, value) in vars { @@ -58,6 +59,7 @@ pub fn generate_secret_key() -> String { /// Convert project name to different cases pub struct ProjectNames { + #[allow(dead_code)] pub original: String, pub snake_case: String, pub kebab_case: String, @@ -70,7 +72,7 @@ impl ProjectNames { let snake_case = name.replace("-", "_").to_lowercase(); let kebab_case = name.replace("_", "-").to_lowercase(); let pascal_case = name - .split(|c| c == '_' || c == '-') + .split(['_', '-']) .map(|word| { let mut chars = word.chars(); match chars.next() { diff --git a/src/cli/commands.rs b/src/cli/commands.rs index 5a3468d..450afcc 100644 --- a/src/cli/commands.rs +++ b/src/cli/commands.rs @@ -52,7 +52,7 @@ fn execute_build( } // Read and parse the input file - let content = fs::read_to_string(&input).map_err(|e| AthenaError::IoError(e))?; + let content = fs::read_to_string(&input).map_err(AthenaError::IoError)?; // Automatic validation (always done) if verbose { @@ -84,7 +84,7 @@ fn execute_build( let output_path = output.unwrap_or_else(|| "docker-compose.yml".into()); // Write output - fs::write(&output_path, &compose_yaml).map_err(|e| AthenaError::IoError(e))?; + fs::write(&output_path, &compose_yaml).map_err(AthenaError::IoError)?; println!( "Generated docker-compose.yml at: {}", @@ -114,7 +114,7 @@ fn execute_init(init_cmd: InitCommands, verbose: bool) -> AthenaResult<()> { InitCommands::Fastapi { name, directory, - with_mongodb, + with_mongodb: _, with_postgresql, no_docker, } => { @@ -181,7 +181,7 @@ fn execute_init(init_cmd: InitCommands, verbose: bool) -> AthenaResult<()> { name, directory, framework, - with_mongodb, + with_mongodb: _, with_postgresql, no_docker, } => { @@ -227,7 +227,7 @@ fn execute_validate(input: Option, verbose: bool) -> AthenaR println!("Validating Athena file: {}", input.display()); } - let content = fs::read_to_string(&input).map_err(|e| AthenaError::IoError(e))?; + let content = fs::read_to_string(&input).map_err(AthenaError::IoError)?; let athena_file = parse_athena_file(&content)?; diff --git a/src/cli/mod.rs b/src/cli/mod.rs index e056a96..86e2552 100644 --- a/src/cli/mod.rs +++ b/src/cli/mod.rs @@ -2,6 +2,5 @@ pub mod args; pub mod commands; pub mod utils; -pub use args::{Cli, Commands, InitCommands, GoFramework}; -pub use commands::execute_command; -pub use utils::{auto_detect_ath_file, should_be_verbose}; \ No newline at end of file +pub use args::Cli; +pub use commands::execute_command; \ No newline at end of file diff --git a/src/cli/utils.rs b/src/cli/utils.rs index 2d8b02e..7341e67 100644 --- a/src/cli/utils.rs +++ b/src/cli/utils.rs @@ -10,7 +10,7 @@ pub fn auto_detect_ath_file(input: Option) -> AthenaResult { None => { // Search for .ath files in the current directory let ath_files: Vec<_> = fs::read_dir(".") - .map_err(|e| AthenaError::IoError(e))? + .map_err(AthenaError::IoError)? .filter_map(|entry| { let entry = entry.ok()?; let path = entry.path(); @@ -45,7 +45,7 @@ pub fn auto_detect_ath_file(input: Option) -> AthenaResult { } /// Determine if we should be in verbose mode (default yes, unless --quiet) -pub fn should_be_verbose(global_verbose: bool, quiet: bool) -> bool { +pub fn should_be_verbose(_global_verbose: bool, quiet: bool) -> bool { if quiet { false } else {