diff --git a/CLAUDE.md b/CLAUDE.md index 7c1167b..be477d6 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -122,7 +122,7 @@ Commands share common arguments via `#[command(flatten)]`: pub struct MyCmd { pub module: String, #[command(flatten)] - pub common: CommonArgs, // Adds --project, --regex, --limit + pub common: CommonArgs, // Adds --regex, --limit } ``` diff --git a/README.md b/README.md index 75653e3..c0d5174 100644 --- a/README.md +++ b/README.md @@ -144,7 +144,6 @@ Use `code_search describe` to see detailed documentation, or `code_search descri **Setup flags:** - `--install-skills`: Install skill and agent templates to `.claude/` (34 skills + 1 agent) - `--install-hooks`: Install post-commit git hook for automatic incremental updates -- `--project-name `: Project name for git hook config (optional, used with `--install-hooks`) - `--mix-env `: Mix environment for git hook (used with `--install-hooks`, default: dev) - `--force`: Overwrite existing template/hook files (preserves by default) - `--dry-run`: Show what would be created without making changes @@ -155,7 +154,6 @@ Most commands support these options: - `-l, --limit `: Maximum results to return (default: 100, max: 1000) - `-r, --regex`: Treat patterns as regular expressions -- `--project `: Filter to a specific project (default: "default") - `--db `: Database file path (auto-resolved if not specified) - `-o, --format `: Output format (table, json, toon) @@ -232,8 +230,7 @@ The post-commit hook automatically: **No configuration required!** The hook works out of the box. Optional configuration: ```bash -git config code-search.project-name my_app # For multi-project databases -git config code-search.mix-env test # Default: dev +git config code-search.mix-env test # Default: dev ``` See [docs/GIT_HOOKS.md](docs/GIT_HOOKS.md) for detailed documentation and troubleshooting. @@ -272,5 +269,5 @@ After installation: - Written in Rust using clap for CLI parsing - Uses SurrealDB (RocksDB-backed) for graph queries - Call graph data is extracted separately by [ex_ast](https://github.com/CamonZ/ex_ast) -- Supports multiple projects in the same database via `--project` flag +- One database per project (stored in `.code_search/surrealdb.rocksdb`) - Embeds templates in binary for self-contained distribution diff --git a/cli/src/commands/accepts/execute.rs b/cli/src/commands/accepts/execute.rs index 761ae14..fc73fcf 100644 --- a/cli/src/commands/accepts/execute.rs +++ b/cli/src/commands/accepts/execute.rs @@ -51,7 +51,6 @@ impl Execute for AcceptsCmd { let entries = find_accepts( db, &self.pattern, - &self.common.project, self.common.regex, self.module.as_deref(), self.common.limit, diff --git a/cli/src/commands/boundaries/execute.rs b/cli/src/commands/boundaries/execute.rs index 51c14d3..accfab9 100644 --- a/cli/src/commands/boundaries/execute.rs +++ b/cli/src/commands/boundaries/execute.rs @@ -23,7 +23,6 @@ impl Execute for BoundariesCmd { db, HotspotKind::Ratio, self.module.as_deref(), - &self.common.project, self.common.regex, self.common.limit, false, @@ -89,7 +88,6 @@ mod tests { min_ratio: 2.0, module: None, common: crate::commands::CommonArgs { - project: "default".to_string(), regex: false, limit: 50, }, diff --git a/cli/src/commands/browse_module/execute.rs b/cli/src/commands/browse_module/execute.rs index 3bb84ba..afc4545 100644 --- a/cli/src/commands/browse_module/execute.rs +++ b/cli/src/commands/browse_module/execute.rs @@ -20,9 +20,6 @@ pub struct BrowseModuleResult { #[serde(skip_serializing_if = "Option::is_none")] pub kind_filter: Option, - /// Project that was searched - pub project: String, - /// Total number of definitions found (before limit applied) pub total_items: usize, @@ -133,7 +130,6 @@ impl Execute for BrowseModuleCmd { let funcs = find_functions_in_module( db, &self.module_or_file, - &self.common.project, self.common.regex, self.common.limit, )?; @@ -169,7 +165,6 @@ impl Execute for BrowseModuleCmd { &self.module_or_file, self.name.as_deref(), None, // kind filter (optional, not used for browse) - &self.common.project, self.common.regex, self.common.limit, )?; @@ -195,7 +190,6 @@ impl Execute for BrowseModuleCmd { &self.module_or_file, self.name.as_deref(), None, // kind filter (optional, not used for browse) - &self.common.project, self.common.regex, self.common.limit, )?; @@ -214,7 +208,7 @@ impl Execute for BrowseModuleCmd { // Query structs if should_query_structs { - let fields = find_struct_fields(db, &self.module_or_file, &self.common.project, self.common.regex, self.common.limit)?; + let fields = find_struct_fields(db, &self.module_or_file, self.common.regex, self.common.limit)?; let structs = group_fields_into_structs(fields); for struct_def in structs { @@ -248,7 +242,6 @@ impl Execute for BrowseModuleCmd { Ok(BrowseModuleResult { search_term: self.module_or_file, kind_filter: self.kind, - project: self.common.project, total_items, definitions, }) diff --git a/cli/src/commands/browse_module/execute_tests.rs b/cli/src/commands/browse_module/execute_tests.rs index 4062a1f..e44b932 100644 --- a/cli/src/commands/browse_module/execute_tests.rs +++ b/cli/src/commands/browse_module/execute_tests.rs @@ -14,13 +14,11 @@ mod tests { crate::shared_fixture! { fixture_name: call_graph_db, fixture_type: call_graph, - project: "test_project", } crate::shared_fixture! { fixture_name: structs_db, fixture_type: structs, - project: "test_project", } // ========================================================================= @@ -35,7 +33,6 @@ mod tests { kind: Some(DefinitionKind::Functions), name: None, common: CommonArgs { - project: "test_project".to_string(), regex: false, limit: 100, }, @@ -59,7 +56,6 @@ mod tests { kind: Some(DefinitionKind::Functions), name: Some("get_user".to_string()), common: CommonArgs { - project: "test_project".to_string(), regex: false, limit: 100, }, @@ -87,7 +83,6 @@ mod tests { kind: Some(DefinitionKind::Specs), name: None, common: CommonArgs { - project: "test_project".to_string(), regex: false, limit: 100, }, @@ -115,7 +110,6 @@ mod tests { kind: Some(DefinitionKind::Types), name: None, common: CommonArgs { - project: "test_project".to_string(), regex: false, limit: 100, }, @@ -143,7 +137,6 @@ mod tests { kind: Some(DefinitionKind::Structs), name: None, common: CommonArgs { - project: "test_project".to_string(), regex: false, limit: 100, }, @@ -172,7 +165,6 @@ mod tests { kind: None, // No kind filter - get all name: None, common: CommonArgs { - project: "test_project".to_string(), regex: false, limit: 100, }, @@ -204,7 +196,6 @@ mod tests { kind: Some(DefinitionKind::Functions), name: None, common: CommonArgs { - project: "test_project".to_string(), regex: true, limit: 100, }, @@ -230,7 +221,6 @@ mod tests { kind: Some(DefinitionKind::Functions), name: None, common: CommonArgs { - project: "test_project".to_string(), regex: true, limit: 100, }, @@ -270,7 +260,6 @@ mod tests { kind: Some(DefinitionKind::Functions), name: None, common: CommonArgs { - project: "test_project".to_string(), regex: true, limit: 5, }, @@ -295,7 +284,6 @@ mod tests { kind: None, name: None, common: CommonArgs { - project: "test_project".to_string(), regex: false, limit: 100, }, diff --git a/cli/src/commands/browse_module/output.rs b/cli/src/commands/browse_module/output.rs index e6f0062..456314d 100644 --- a/cli/src/commands/browse_module/output.rs +++ b/cli/src/commands/browse_module/output.rs @@ -11,14 +11,11 @@ impl Outputable for BrowseModuleResult { // Header if let Some(kind) = self.kind_filter { output.push_str(&format!( - "Definitions in {} (kind: {}, project: {})\n\n", - self.search_term, kind, self.project + "Definitions in {} (kind: {})\n\n", + self.search_term, kind )); } else { - output.push_str(&format!( - "Definitions in {} (project: {})\n\n", - self.search_term, self.project - )); + output.push_str(&format!("Definitions in {}\n\n", self.search_term)); } // Empty state @@ -138,7 +135,6 @@ mod tests { let result = BrowseModuleResult { search_term: "NonExistent".to_string(), kind_filter: None, - project: "default".to_string(), total_items: 0, definitions: vec![], }; @@ -154,7 +150,6 @@ mod tests { let result = BrowseModuleResult { search_term: "MyApp.Accounts".to_string(), kind_filter: None, - project: "default".to_string(), total_items: 1, definitions: vec![Definition::Function { module: "MyApp.Accounts".to_string(), @@ -186,7 +181,6 @@ mod tests { let result = BrowseModuleResult { search_term: "MyApp.Accounts".to_string(), kind_filter: None, - project: "default".to_string(), total_items: 2, definitions: vec![ Definition::Function { diff --git a/cli/src/commands/browse_module/output_tests.rs b/cli/src/commands/browse_module/output_tests.rs index 425652b..2d7b01b 100644 --- a/cli/src/commands/browse_module/output_tests.rs +++ b/cli/src/commands/browse_module/output_tests.rs @@ -12,13 +12,13 @@ mod tests { // ========================================================================= const EMPTY_TABLE: &str = "\ -Definitions in NonExistent (project: default) +Definitions in NonExistent No definitions found. "; const FUNCTIONS_ONLY_TABLE: &str = "\ -Definitions in MyApp.Accounts (kind: functions, project: default) +Definitions in MyApp.Accounts (kind: functions) Found 2 definition(s): @@ -29,7 +29,7 @@ Found 2 definition(s): "; const MIXED_TYPES_TABLE: &str = "\ -Definitions in MyApp.Accounts (project: default) +Definitions in MyApp.Accounts Found 3 definition(s): @@ -43,7 +43,7 @@ Found 3 definition(s): "; const STRUCT_TABLE: &str = "\ -Definitions in MyApp.User (kind: structs, project: default) +Definitions in MyApp.User (kind: structs) Found 1 definition(s): @@ -63,7 +63,6 @@ Found 1 definition(s): BrowseModuleResult { search_term: "NonExistent".to_string(), kind_filter: None, - project: "default".to_string(), total_items: 0, definitions: vec![], } @@ -74,7 +73,6 @@ Found 1 definition(s): BrowseModuleResult { search_term: "MyApp.Accounts".to_string(), kind_filter: Some(DefinitionKind::Functions), - project: "default".to_string(), total_items: 2, definitions: vec![ Definition::Function { @@ -115,7 +113,6 @@ Found 1 definition(s): BrowseModuleResult { search_term: "MyApp.Accounts".to_string(), kind_filter: None, - project: "default".to_string(), total_items: 3, definitions: vec![ Definition::Type { @@ -159,7 +156,6 @@ Found 1 definition(s): BrowseModuleResult { search_term: "MyApp.User".to_string(), kind_filter: Some(DefinitionKind::Structs), - project: "default".to_string(), total_items: 1, definitions: vec![Definition::Struct { module: "MyApp.User".to_string(), diff --git a/cli/src/commands/calls_from/execute.rs b/cli/src/commands/calls_from/execute.rs index 38e23d6..de4e034 100644 --- a/cli/src/commands/calls_from/execute.rs +++ b/cli/src/commands/calls_from/execute.rs @@ -84,7 +84,6 @@ impl Execute for CallsFromCmd { &self.module, self.function.as_deref(), self.arity, - &self.common.project, self.common.regex, self.common.limit, )?; diff --git a/cli/src/commands/calls_from/execute_tests.rs b/cli/src/commands/calls_from/execute_tests.rs index 4011e75..6c232f5 100644 --- a/cli/src/commands/calls_from/execute_tests.rs +++ b/cli/src/commands/calls_from/execute_tests.rs @@ -28,7 +28,6 @@ mod tests { function: None, arity: None, common: CommonArgs { - project: "test_project".to_string(), regex: false, limit: 100, }, @@ -80,7 +79,6 @@ mod tests { function: Some("get_user".to_string()), arity: None, common: CommonArgs { - project: "test_project".to_string(), regex: false, limit: 100, }, @@ -120,7 +118,6 @@ mod tests { function: None, arity: None, common: CommonArgs { - project: "test_project".to_string(), regex: true, limit: 100, }, @@ -148,7 +145,6 @@ mod tests { function: None, arity: None, common: CommonArgs { - project: "test_project".to_string(), regex: false, limit: 100, }, @@ -172,7 +168,6 @@ mod tests { function: None, arity: None, common: CommonArgs { - project: "test_project".to_string(), regex: true, limit: 1, }, diff --git a/cli/src/commands/calls_to/execute.rs b/cli/src/commands/calls_to/execute.rs index 782b2d9..4739eda 100644 --- a/cli/src/commands/calls_to/execute.rs +++ b/cli/src/commands/calls_to/execute.rs @@ -72,7 +72,6 @@ impl Execute for CallsToCmd { &self.module, self.function.as_deref(), self.arity, - &self.common.project, self.common.regex, self.common.limit, )?; diff --git a/cli/src/commands/calls_to/execute_tests.rs b/cli/src/commands/calls_to/execute_tests.rs index a0aed05..c225b99 100644 --- a/cli/src/commands/calls_to/execute_tests.rs +++ b/cli/src/commands/calls_to/execute_tests.rs @@ -29,7 +29,6 @@ mod tests { function: None, arity: None, common: CommonArgs { - project: "test_project".to_string(), regex: false, limit: 100, }, @@ -85,7 +84,6 @@ mod tests { function: Some("get".to_string()), arity: None, common: CommonArgs { - project: "test_project".to_string(), regex: false, limit: 100, }, @@ -112,7 +110,6 @@ mod tests { function: Some("get".to_string()), arity: Some(2), common: CommonArgs { - project: "test_project".to_string(), regex: false, limit: 100, }, @@ -137,7 +134,6 @@ mod tests { function: Some("get|all".to_string()), arity: None, common: CommonArgs { - project: "test_project".to_string(), regex: true, limit: 100, }, @@ -158,7 +154,6 @@ mod tests { function: None, arity: None, common: CommonArgs { - project: "test_project".to_string(), regex: false, limit: 100, }, @@ -178,7 +173,6 @@ mod tests { function: Some("get".to_string()), arity: Some(99), common: CommonArgs { - project: "test_project".to_string(), regex: false, limit: 100, }, @@ -202,7 +196,6 @@ mod tests { function: None, arity: None, common: CommonArgs { - project: "test_project".to_string(), regex: false, limit: 2, }, diff --git a/cli/src/commands/clusters/execute.rs b/cli/src/commands/clusters/execute.rs index 0aed1e9..43ab253 100644 --- a/cli/src/commands/clusters/execute.rs +++ b/cli/src/commands/clusters/execute.rs @@ -46,7 +46,7 @@ impl Execute for ClustersCmd { fn execute(self, db: &dyn db::backend::Database) -> Result> { // Get all inter-module calls - let calls = get_module_calls(db, &self.common.project)?; + let calls = get_module_calls(db)?; // Extract namespace for each module and collect all unique modules let mut all_modules = HashSet::new(); @@ -323,7 +323,6 @@ mod tests { show_dependencies: false, module: None, common: crate::commands::CommonArgs { - project: "default".to_string(), regex: false, limit: 100, }, @@ -332,7 +331,6 @@ mod tests { assert_eq!(cmd.depth, 2); assert!(!cmd.show_dependencies); assert_eq!(cmd.module, None); - assert_eq!(cmd.common.project, "default"); } #[test] @@ -342,7 +340,6 @@ mod tests { show_dependencies: true, module: Some("MyApp.Core".to_string()), common: crate::commands::CommonArgs { - project: "custom".to_string(), regex: false, limit: 50, }, @@ -351,7 +348,6 @@ mod tests { assert_eq!(cmd.depth, 3); assert!(cmd.show_dependencies); assert_eq!(cmd.module, Some("MyApp.Core".to_string())); - assert_eq!(cmd.common.project, "custom"); } #[test] diff --git a/cli/src/commands/complexity/cli_tests.rs b/cli/src/commands/complexity/cli_tests.rs index 30385a0..5f03963 100644 --- a/cli/src/commands/complexity/cli_tests.rs +++ b/cli/src/commands/complexity/cli_tests.rs @@ -19,7 +19,6 @@ mod tests { min_depth: 0, exclude_generated: false, module: None, - common.project: "default".to_string(), common.regex: false, common.limit: 100, }, @@ -61,15 +60,6 @@ mod tests { expected: Some("MyApp.Accounts".to_string()), } - crate::cli_option_test! { - command: "complexity", - variant: Complexity, - test_name: test_with_project, - args: ["--project", "my_project"], - field: common.project, - expected: "my_project".to_string(), - } - crate::cli_option_test! { command: "complexity", variant: Complexity, diff --git a/cli/src/commands/complexity/execute.rs b/cli/src/commands/complexity/execute.rs index 944aad4..0b498dc 100644 --- a/cli/src/commands/complexity/execute.rs +++ b/cli/src/commands/complexity/execute.rs @@ -27,7 +27,6 @@ impl Execute for ComplexityCmd { self.min, self.min_depth, self.module.as_deref(), - &self.common.project, self.common.regex, self.exclude_generated, self.common.limit, @@ -71,7 +70,6 @@ mod tests { exclude_generated: false, module: Some("MyApp".to_string()), common: crate::commands::CommonArgs { - project: "default".to_string(), regex: false, limit: 20, }, diff --git a/cli/src/commands/complexity/execute_tests.rs b/cli/src/commands/complexity/execute_tests.rs index 485b9c2..013b8cd 100644 --- a/cli/src/commands/complexity/execute_tests.rs +++ b/cli/src/commands/complexity/execute_tests.rs @@ -9,7 +9,6 @@ mod tests { crate::shared_fixture! { fixture_name: populated_db, fixture_type: call_graph, - project: "test_project", } // ========================================================================= @@ -26,7 +25,6 @@ mod tests { exclude_generated: false, module: None, common: CommonArgs { - project: "test_project".to_string(), regex: false, limit: 100, }, @@ -48,7 +46,6 @@ mod tests { exclude_generated: false, module: None, common: CommonArgs { - project: "test_project".to_string(), regex: false, limit: 100, }, @@ -70,7 +67,6 @@ mod tests { exclude_generated: false, module: None, common: CommonArgs { - project: "test_project".to_string(), regex: false, limit: 100, }, @@ -91,7 +87,6 @@ mod tests { exclude_generated: false, module: Some("MyApp.Accounts".to_string()), common: CommonArgs { - project: "test_project".to_string(), regex: false, limit: 100, }, @@ -115,7 +110,6 @@ mod tests { exclude_generated: false, module: Some("MyApp\\..*".to_string()), common: CommonArgs { - project: "test_project".to_string(), regex: true, limit: 100, }, @@ -137,7 +131,6 @@ mod tests { exclude_generated: false, module: None, common: CommonArgs { - project: "test_project".to_string(), regex: false, limit: 5, }, diff --git a/cli/src/commands/cycles/execute.rs b/cli/src/commands/cycles/execute.rs index 348463d..5eac346 100644 --- a/cli/src/commands/cycles/execute.rs +++ b/cli/src/commands/cycles/execute.rs @@ -36,7 +36,6 @@ impl Execute for CyclesCmd { // Get cycle edges from the database let edges = find_cycle_edges( db, - &self.common.project, self.module.as_deref(), )?; diff --git a/cli/src/commands/depended_by/execute.rs b/cli/src/commands/depended_by/execute.rs index a9be565..c87d82e 100644 --- a/cli/src/commands/depended_by/execute.rs +++ b/cli/src/commands/depended_by/execute.rs @@ -115,7 +115,6 @@ impl Execute for DependedByCmd { let calls = find_dependents( db, &self.module, - &self.common.project, self.common.regex, self.common.limit, )?; diff --git a/cli/src/commands/depended_by/execute_tests.rs b/cli/src/commands/depended_by/execute_tests.rs index 4027bcf..16dc98d 100644 --- a/cli/src/commands/depended_by/execute_tests.rs +++ b/cli/src/commands/depended_by/execute_tests.rs @@ -25,7 +25,6 @@ mod tests { let cmd = DependedByCmd { module: "MyApp.Repo".to_string(), common: CommonArgs { - project: "test_project".to_string(), regex: false, limit: 100, }, @@ -50,7 +49,6 @@ mod tests { let cmd = DependedByCmd { module: "MyApp.Repo".to_string(), common: CommonArgs { - project: "test_project".to_string(), regex: false, limit: 100, }, @@ -86,7 +84,6 @@ mod tests { let cmd = DependedByCmd { module: "MyApp.Accounts".to_string(), common: CommonArgs { - project: "test_project".to_string(), regex: false, limit: 100, }, @@ -122,7 +119,6 @@ mod tests { let cmd = DependedByCmd { module: "NonExistent".to_string(), common: CommonArgs { - project: "test_project".to_string(), regex: false, limit: 100, }, @@ -144,7 +140,6 @@ mod tests { let cmd = DependedByCmd { module: "MyApp.Accounts".to_string(), common: CommonArgs { - project: "test_project".to_string(), regex: false, limit: 100, }, @@ -165,7 +160,6 @@ mod tests { let cmd = DependedByCmd { module: "MyApp\\.Repo".to_string(), common: CommonArgs { - project: "test_project".to_string(), regex: true, limit: 100, }, @@ -182,7 +176,6 @@ mod tests { let cmd = DependedByCmd { module: "MyApp.Accounts".to_string(), common: CommonArgs { - project: "test_project".to_string(), regex: false, limit: 1, }, diff --git a/cli/src/commands/depends_on/execute.rs b/cli/src/commands/depends_on/execute.rs index 793e2ab..0a6ed05 100644 --- a/cli/src/commands/depends_on/execute.rs +++ b/cli/src/commands/depends_on/execute.rs @@ -71,7 +71,6 @@ impl Execute for DependsOnCmd { let calls = find_dependencies( db, &self.module, - &self.common.project, self.common.regex, self.common.limit, )?; diff --git a/cli/src/commands/duplicates/cli_tests.rs b/cli/src/commands/duplicates/cli_tests.rs index 1feeea5..7580d08 100644 --- a/cli/src/commands/duplicates/cli_tests.rs +++ b/cli/src/commands/duplicates/cli_tests.rs @@ -12,7 +12,6 @@ mod tests { variant: Duplicates, required_args: [], defaults: { - common.project: "default", common.regex: false, exact: false, by_module: false, @@ -84,15 +83,6 @@ mod tests { expected: 75, } - crate::cli_option_test! { - command: "duplicates", - variant: Duplicates, - test_name: test_with_project, - args: ["--project", "my_project"], - field: common.project, - expected: "my_project", - } - crate::cli_error_test! { command: "duplicates", test_name: test_limit_zero_rejected, diff --git a/cli/src/commands/duplicates/execute.rs b/cli/src/commands/duplicates/execute.rs index 791a925..887833c 100644 --- a/cli/src/commands/duplicates/execute.rs +++ b/cli/src/commands/duplicates/execute.rs @@ -86,7 +86,6 @@ impl Execute for DuplicatesCmd { fn execute(self, db: &dyn db::backend::Database) -> Result> { let functions = find_duplicates( db, - &self.common.project, self.module.as_deref(), self.common.regex, self.exact, diff --git a/cli/src/commands/duplicates/execute_tests.rs b/cli/src/commands/duplicates/execute_tests.rs index 0cf47db..79fcdf4 100644 --- a/cli/src/commands/duplicates/execute_tests.rs +++ b/cli/src/commands/duplicates/execute_tests.rs @@ -10,7 +10,6 @@ mod tests { crate::shared_fixture! { fixture_name: populated_db, fixture_type: call_graph, - project: "test_project", } // ========================================================================= @@ -26,7 +25,6 @@ mod tests { exact: false, exclude_generated: false, common: CommonArgs { - project: "test_project".to_string(), regex: false, limit: 100, }, @@ -52,7 +50,6 @@ mod tests { exact: false, exclude_generated: false, common: CommonArgs { - project: "test_project".to_string(), regex: false, limit: 100, }, @@ -76,7 +73,6 @@ mod tests { exact: true, exclude_generated: false, common: CommonArgs { - project: "test_project".to_string(), regex: false, limit: 100, }, @@ -100,7 +96,6 @@ mod tests { exact: false, exclude_generated: false, common: CommonArgs { - project: "test_project".to_string(), regex: true, limit: 100, }, @@ -124,7 +119,6 @@ mod tests { exact: false, exclude_generated: false, common: CommonArgs { - project: "test_project".to_string(), regex: false, limit: 100, }, @@ -157,7 +151,6 @@ mod tests { exact: false, exclude_generated: false, common: CommonArgs { - project: "test_project".to_string(), regex: false, limit: 100, }, @@ -186,7 +179,6 @@ mod tests { exact: false, exclude_generated: false, common: CommonArgs { - project: "test_project".to_string(), regex: false, limit: 100, }, @@ -212,7 +204,6 @@ mod tests { exact: false, exclude_generated: true, common: CommonArgs { - project: "test_project".to_string(), regex: false, limit: 100, }, diff --git a/cli/src/commands/function/execute.rs b/cli/src/commands/function/execute.rs index ffac770..27378dd 100644 --- a/cli/src/commands/function/execute.rs +++ b/cli/src/commands/function/execute.rs @@ -57,7 +57,6 @@ impl Execute for FunctionCmd { &self.module, &self.function, self.arity, - &self.common.project, self.common.regex, self.common.limit, )?; diff --git a/cli/src/commands/god_modules/execute.rs b/cli/src/commands/god_modules/execute.rs index 3fc8989..f903eb5 100644 --- a/cli/src/commands/god_modules/execute.rs +++ b/cli/src/commands/god_modules/execute.rs @@ -24,7 +24,6 @@ impl Execute for GodModulesCmd { // Get function counts for all modules let func_counts = get_function_counts( db, - &self.common.project, self.module.as_deref(), self.common.regex, )?; @@ -32,7 +31,6 @@ impl Execute for GodModulesCmd { // Get lines of code per module let module_loc = get_module_loc( db, - &self.common.project, self.module.as_deref(), self.common.regex, )?; @@ -40,7 +38,6 @@ impl Execute for GodModulesCmd { // Get module-level connectivity (aggregated at database level) let module_connectivity = get_module_connectivity( db, - &self.common.project, self.module.as_deref(), self.common.regex, )?; @@ -134,7 +131,6 @@ mod tests { min_total: 15, module: Some("MyApp".to_string()), common: crate::commands::CommonArgs { - project: "default".to_string(), regex: false, limit: 20, }, diff --git a/cli/src/commands/god_modules/execute_tests.rs b/cli/src/commands/god_modules/execute_tests.rs index 3dbe7db..42fa5a3 100644 --- a/cli/src/commands/god_modules/execute_tests.rs +++ b/cli/src/commands/god_modules/execute_tests.rs @@ -31,7 +31,6 @@ mod tests { min_total: 1, module: None, common: CommonArgs { - project: "test_project".to_string(), regex: false, limit: 20, }, @@ -51,7 +50,6 @@ mod tests { min_total: 4, // At least 4 total calls module: None, common: CommonArgs { - project: "test_project".to_string(), regex: false, limit: 20, }, @@ -84,7 +82,6 @@ mod tests { min_total: 1, module: None, common: CommonArgs { - project: "test_project".to_string(), regex: false, limit: 20, }, @@ -116,7 +113,6 @@ mod tests { min_total: 1, module: None, common: CommonArgs { - project: "test_project".to_string(), regex: false, limit: 20, }, @@ -157,7 +153,6 @@ mod tests { min_total: 1, module: Some("Accounts".to_string()), common: CommonArgs { - project: "test_project".to_string(), regex: false, limit: 20, }, @@ -182,7 +177,6 @@ mod tests { min_total: 1, module: None, common: CommonArgs { - project: "test_project".to_string(), regex: false, limit: 2, }, @@ -204,7 +198,6 @@ mod tests { min_total: 999999, module: None, common: CommonArgs { - project: "test_project".to_string(), regex: false, limit: 20, }, @@ -224,7 +217,6 @@ mod tests { min_total: 1, module: Some("NonExistentModule".to_string()), common: CommonArgs { - project: "test_project".to_string(), regex: false, limit: 20, }, @@ -243,7 +235,6 @@ mod tests { min_total: 2, module: None, common: CommonArgs { - project: "test_project".to_string(), regex: false, limit: 20, }, diff --git a/cli/src/commands/hotspots/cli_tests.rs b/cli/src/commands/hotspots/cli_tests.rs index 0ca8f1e..53950ac 100644 --- a/cli/src/commands/hotspots/cli_tests.rs +++ b/cli/src/commands/hotspots/cli_tests.rs @@ -17,7 +17,6 @@ mod tests { variant: Hotspots, required_args: [], defaults: { - common.project: "default", common.regex: false, common.limit: 100, exclude_generated: false, @@ -34,15 +33,6 @@ mod tests { expected: Some("MyApp".to_string()), } - crate::cli_option_test! { - command: "hotspots", - variant: Hotspots, - test_name: test_with_project, - args: ["--project", "my_app"], - field: common.project, - expected: "my_app", - } - crate::cli_option_test! { command: "hotspots", variant: Hotspots, diff --git a/cli/src/commands/hotspots/execute.rs b/cli/src/commands/hotspots/execute.rs index 0dfc4a3..563c4c7 100644 --- a/cli/src/commands/hotspots/execute.rs +++ b/cli/src/commands/hotspots/execute.rs @@ -105,7 +105,6 @@ impl Execute for HotspotsCmd { db, self.kind, self.module.as_deref(), - &self.common.project, self.common.regex, self.common.limit, self.exclude_generated, diff --git a/cli/src/commands/hotspots/execute_tests.rs b/cli/src/commands/hotspots/execute_tests.rs index c806346..eb4181a 100644 --- a/cli/src/commands/hotspots/execute_tests.rs +++ b/cli/src/commands/hotspots/execute_tests.rs @@ -11,7 +11,6 @@ mod tests { crate::shared_fixture! { fixture_name: populated_db, fixture_type: call_graph, - project: "test_project", } // ========================================================================= @@ -25,7 +24,6 @@ mod tests { kind: HotspotKind::Incoming, exclude_generated: false, common: CommonArgs { - project: "test_project".to_string(), regex: false, limit: 20, }, @@ -43,7 +41,6 @@ mod tests { kind: HotspotKind::Outgoing, exclude_generated: false, common: CommonArgs { - project: "test_project".to_string(), regex: false, limit: 20, }, @@ -61,7 +58,6 @@ mod tests { kind: HotspotKind::Total, exclude_generated: false, common: CommonArgs { - project: "test_project".to_string(), regex: false, limit: 20, }, @@ -79,7 +75,6 @@ mod tests { kind: HotspotKind::Ratio, exclude_generated: false, common: CommonArgs { - project: "test_project".to_string(), regex: false, limit: 20, }, @@ -103,7 +98,6 @@ mod tests { kind: HotspotKind::Incoming, exclude_generated: false, common: CommonArgs { - project: "test_project".to_string(), regex: false, limit: 20, }, @@ -121,7 +115,6 @@ mod tests { kind: HotspotKind::Incoming, exclude_generated: false, common: CommonArgs { - project: "test_project".to_string(), regex: false, limit: 2, }, @@ -138,7 +131,6 @@ mod tests { kind: HotspotKind::Incoming, exclude_generated: true, common: CommonArgs { - project: "test_project".to_string(), regex: false, limit: 20, }, diff --git a/cli/src/commands/import/execute.rs b/cli/src/commands/import/execute.rs index b989718..632cef0 100644 --- a/cli/src/commands/import/execute.rs +++ b/cli/src/commands/import/execute.rs @@ -25,11 +25,11 @@ impl Execute for ImportCmd { // Clear existing data if requested if self.clear { - clear_project_data(db, &self.project)?; + clear_project_data(db)?; } // Import data - let mut result = import_graph(db, &self.project, &graph)?; + let mut result = import_graph(db, &graph)?; result.cleared = self.clear; Ok(result) @@ -123,7 +123,7 @@ mod tests { #[fixture] fn import_result() -> ImportResult { let db = open_mem_db().expect("Failed to create in-memory db"); - import_json_str(&*db, sample_call_graph_json(), "test_project") + import_json_str(&*db, sample_call_graph_json()) .expect("Import should succeed") } @@ -167,7 +167,6 @@ mod tests { // First import let cmd1 = ImportCmd { file: json_file.path().to_path_buf(), - project: "test_project".to_string(), clear: false, }; cmd1.execute(&*db).expect("First import should succeed"); @@ -175,7 +174,6 @@ mod tests { // Second import with clear let cmd2 = ImportCmd { file: json_file.path().to_path_buf(), - project: "test_project".to_string(), clear: true, }; let result = cmd2.execute(&*db).expect("Second import should succeed"); @@ -195,7 +193,7 @@ mod tests { let db = open_mem_db().expect("Failed to create in-memory db"); let result = - import_json_str(&*db, empty_json, "test_project").expect("Import should succeed"); + import_json_str(&*db, empty_json).expect("Import should succeed"); assert_eq!(result.modules_imported, 0); assert_eq!(result.functions_imported, 0); @@ -212,7 +210,6 @@ mod tests { let db = open_mem_db().expect("Failed to create in-memory db"); let cmd = ImportCmd { file: json_file.path().to_path_buf(), - project: "test_project".to_string(), clear: false, }; let result = cmd.execute(&*db); @@ -224,7 +221,6 @@ mod tests { let db = open_mem_db().expect("Failed to create in-memory db"); let cmd = ImportCmd { file: "/nonexistent/path/call_graph.json".into(), - project: "test_project".to_string(), clear: false, }; let result = cmd.execute(&*db); diff --git a/cli/src/commands/import/mod.rs b/cli/src/commands/import/mod.rs index 86bc17e..4887362 100644 --- a/cli/src/commands/import/mod.rs +++ b/cli/src/commands/import/mod.rs @@ -12,8 +12,6 @@ use db::backend::Database; use crate::commands::{CommandRunner, Execute}; use crate::output::{OutputFormat, Outputable}; -const DEFAULT_PROJECT: &str = "default"; - fn validate_file_exists(s: &str) -> Result { let path = PathBuf::from(s); if path.exists() { @@ -27,17 +25,13 @@ fn validate_file_exists(s: &str) -> Result { #[derive(Args, Debug)] #[command(after_help = "\ Examples: - code_search import -f call_graph.json # Import with default project name - code_search import -f cg.json -p my_app # Import into 'my_app' project + code_search import -f call_graph.json # Import call graph into database code_search import -f cg.json --clear # Clear DB before importing")] pub struct ImportCmd { /// Path to the call graph JSON file #[arg(short, long, value_parser = validate_file_exists)] pub file: PathBuf, - /// Project name for namespacing (allows multiple projects in same DB) - #[arg(short, long, default_value = DEFAULT_PROJECT)] - pub project: String, - /// Clear all existing data before import (or just project data if --project is set) + /// Clear all existing data before import #[arg(long, default_value_t = false)] pub clear: bool, } diff --git a/cli/src/commands/large_functions/execute.rs b/cli/src/commands/large_functions/execute.rs index 6b3830b..6b8bd4e 100644 --- a/cli/src/commands/large_functions/execute.rs +++ b/cli/src/commands/large_functions/execute.rs @@ -27,7 +27,6 @@ impl Execute for LargeFunctionsCmd { db, self.min_lines, self.module.as_deref(), - &self.common.project, self.common.regex, self.include_generated, self.common.limit, @@ -95,7 +94,6 @@ mod tests { include_generated: false, module: Some("MyApp".to_string()), common: crate::commands::CommonArgs { - project: "default".to_string(), regex: false, limit: 20, }, diff --git a/cli/src/commands/location/cli_tests.rs b/cli/src/commands/location/cli_tests.rs index b3b0dfc..ee4aba9 100644 --- a/cli/src/commands/location/cli_tests.rs +++ b/cli/src/commands/location/cli_tests.rs @@ -56,15 +56,6 @@ mod tests { expected: true, } - crate::cli_option_test! { - command: "location", - variant: Location, - test_name: test_with_project, - args: ["get_user", "MyApp.Accounts", "--project", "my_app"], - field: common.project, - expected: "my_app", - } - crate::cli_option_test! { command: "location", variant: Location, diff --git a/cli/src/commands/location/execute.rs b/cli/src/commands/location/execute.rs index a014ab1..58b012e 100644 --- a/cli/src/commands/location/execute.rs +++ b/cli/src/commands/location/execute.rs @@ -117,7 +117,6 @@ impl Execute for LocationCmd { self.module.as_deref(), &self.function, self.arity, - &self.common.project, self.common.regex, self.common.limit, )?; diff --git a/cli/src/commands/location/execute_tests.rs b/cli/src/commands/location/execute_tests.rs index 50be692..94868a3 100644 --- a/cli/src/commands/location/execute_tests.rs +++ b/cli/src/commands/location/execute_tests.rs @@ -33,7 +33,6 @@ mod tests { function: "get_user".to_string(), arity: Some(1), common: CommonArgs { - project: "test_project".to_string(), regex: false, limit: 100, }, @@ -59,7 +58,6 @@ mod tests { function: "get_user".to_string(), arity: None, common: CommonArgs { - project: "test_project".to_string(), regex: false, limit: 100, }, @@ -78,7 +76,6 @@ mod tests { function: "process_request".to_string(), arity: Some(2), common: CommonArgs { - project: "test_project".to_string(), regex: false, limit: 100, }, @@ -105,7 +102,6 @@ mod tests { function: "get_user".to_string(), arity: None, common: CommonArgs { - project: "test_project".to_string(), regex: false, limit: 100, }, @@ -129,7 +125,6 @@ mod tests { function: ".*user.*".to_string(), arity: None, common: CommonArgs { - project: "test_project".to_string(), regex: true, limit: 100, }, @@ -148,7 +143,6 @@ mod tests { function: "validate".to_string(), arity: Some(1), common: CommonArgs { - project: "test_project".to_string(), regex: false, limit: 100, }, @@ -171,7 +165,6 @@ mod tests { function: "foo".to_string(), arity: None, common: CommonArgs { - project: "test_project".to_string(), regex: false, limit: 100, }, @@ -189,7 +182,6 @@ mod tests { function: "get_user".to_string(), arity: Some(99), // Non-existent arity common: CommonArgs { - project: "test_project".to_string(), regex: false, limit: 100, }, @@ -210,7 +202,6 @@ mod tests { function: ".*".to_string(), arity: None, common: CommonArgs { - project: "test_project".to_string(), regex: true, limit: 3, }, @@ -227,7 +218,6 @@ mod tests { function: "list_users".to_string(), arity: Some(0), common: CommonArgs { - project: "test_project".to_string(), regex: false, limit: 100, }, @@ -249,7 +239,6 @@ mod tests { function: "get_user".to_string(), arity: Some(1), common: CommonArgs { - project: "test_project".to_string(), regex: false, limit: 100, }, diff --git a/cli/src/commands/many_clauses/execute.rs b/cli/src/commands/many_clauses/execute.rs index 2748a2b..cec497a 100644 --- a/cli/src/commands/many_clauses/execute.rs +++ b/cli/src/commands/many_clauses/execute.rs @@ -27,7 +27,6 @@ impl Execute for ManyClausesCmd { db, self.min_clauses, self.module.as_deref(), - &self.common.project, self.common.regex, self.include_generated, self.common.limit, @@ -94,7 +93,6 @@ mod tests { include_generated: false, module: Some("MyApp".to_string()), common: crate::commands::CommonArgs { - project: "default".to_string(), regex: false, limit: 20, }, diff --git a/cli/src/commands/mod.rs b/cli/src/commands/mod.rs index 32dab5d..90aa873 100644 --- a/cli/src/commands/mod.rs +++ b/cli/src/commands/mod.rs @@ -18,10 +18,6 @@ use clap::Args; /// ``` #[derive(Args, Debug, Clone)] pub struct CommonArgs { - /// Project to search in - #[arg(long, default_value = "default")] - pub project: String, - /// Treat patterns as regular expressions #[arg(short, long, default_value_t = false)] pub regex: bool, diff --git a/cli/src/commands/path/execute.rs b/cli/src/commands/path/execute.rs index 068f64b..36006d9 100644 --- a/cli/src/commands/path/execute.rs +++ b/cli/src/commands/path/execute.rs @@ -38,7 +38,6 @@ impl Execute for PathCmd { &self.to_module, &self.to_function, self.to_arity, - &self.project, self.depth, self.limit, )?; diff --git a/cli/src/commands/path/execute_tests.rs b/cli/src/commands/path/execute_tests.rs index e90c65d..9e464a8 100644 --- a/cli/src/commands/path/execute_tests.rs +++ b/cli/src/commands/path/execute_tests.rs @@ -8,7 +8,6 @@ mod tests { crate::shared_fixture! { fixture_name: populated_db, fixture_type: call_graph, - project: "test_project", } // ========================================================================= @@ -26,7 +25,6 @@ mod tests { to_module: "MyApp.Accounts".to_string(), to_function: "list_users".to_string(), to_arity: 0, - project: "test_project".to_string(), depth: 10, limit: 10, }, @@ -50,7 +48,6 @@ mod tests { to_module: "MyApp.Repo".to_string(), to_function: "all".to_string(), to_arity: 1, - project: "test_project".to_string(), depth: 10, limit: 10, }, @@ -80,7 +77,6 @@ mod tests { to_module: "MyApp.Repo".to_string(), to_function: "get".to_string(), to_arity: 2, - project: "test_project".to_string(), depth: 10, limit: 10, }, @@ -110,7 +106,6 @@ mod tests { to_module: "MyApp.Repo".to_string(), to_function: "get".to_string(), to_arity: 2, - project: "test_project".to_string(), depth: 10, limit: 10, }, @@ -133,7 +128,6 @@ mod tests { to_module: "MyApp.Accounts".to_string(), to_function: "list_users".to_string(), to_arity: 0, - project: "test_project".to_string(), depth: 10, limit: 10, }, @@ -156,7 +150,6 @@ mod tests { to_module: "MyApp.Accounts".to_string(), to_function: "list_users".to_string(), to_arity: 0, - project: "test_project".to_string(), depth: 10, limit: 10, }, @@ -178,7 +171,6 @@ mod tests { to_module: "MyApp.Controller".to_string(), to_function: "index".to_string(), to_arity: 2, - project: "test_project".to_string(), depth: 10, limit: 10, }, @@ -196,7 +188,6 @@ mod tests { to_module: "MyApp.Repo".to_string(), to_function: "all".to_string(), to_arity: 1, - project: "test_project".to_string(), depth: 1, limit: 10, }, diff --git a/cli/src/commands/path/mod.rs b/cli/src/commands/path/mod.rs index 75e83ec..bdac660 100644 --- a/cli/src/commands/path/mod.rs +++ b/cli/src/commands/path/mod.rs @@ -45,10 +45,6 @@ pub struct PathCmd { #[arg(long)] pub to_arity: i64, - /// Project to search in - #[arg(long, default_value = "default")] - pub project: String, - /// Maximum depth to search (1-20) #[arg(long, default_value_t = 10, value_parser = clap::value_parser!(u32).range(1..=20))] pub depth: u32, diff --git a/cli/src/commands/returns/execute.rs b/cli/src/commands/returns/execute.rs index 17d3841..20928b5 100644 --- a/cli/src/commands/returns/execute.rs +++ b/cli/src/commands/returns/execute.rs @@ -50,7 +50,6 @@ impl Execute for ReturnsCmd { let entries = find_returns( db, &self.pattern, - &self.common.project, self.common.regex, self.module.as_deref(), self.common.limit, diff --git a/cli/src/commands/reverse_trace/execute.rs b/cli/src/commands/reverse_trace/execute.rs index 7fbe88a..de68400 100644 --- a/cli/src/commands/reverse_trace/execute.rs +++ b/cli/src/commands/reverse_trace/execute.rs @@ -124,7 +124,6 @@ impl Execute for ReverseTraceCmd { &self.module, &self.function, self.arity, - &self.common.project, self.common.regex, self.depth, self.common.limit, diff --git a/cli/src/commands/reverse_trace/execute_tests.rs b/cli/src/commands/reverse_trace/execute_tests.rs index f5fb696..c9d67b6 100644 --- a/cli/src/commands/reverse_trace/execute_tests.rs +++ b/cli/src/commands/reverse_trace/execute_tests.rs @@ -9,7 +9,6 @@ mod tests { crate::shared_fixture! { fixture_name: populated_db, fixture_type: call_graph, - project: "test_project", } // ========================================================================= @@ -26,7 +25,6 @@ mod tests { arity: None, depth: 1, common: CommonArgs { - project: "test_project".to_string(), regex: false, limit: 100, }, @@ -48,7 +46,6 @@ mod tests { arity: None, depth: 2, common: CommonArgs { - project: "test_project".to_string(), regex: false, limit: 100, }, @@ -68,7 +65,6 @@ mod tests { arity: None, depth: 5, common: CommonArgs { - project: "test_project".to_string(), regex: false, limit: 100, }, @@ -91,7 +87,6 @@ mod tests { arity: None, depth: 5, common: CommonArgs { - project: "test_project".to_string(), regex: false, limit: 100, }, diff --git a/cli/src/commands/search/cli_tests.rs b/cli/src/commands/search/cli_tests.rs index e321f24..3e04700 100644 --- a/cli/src/commands/search/cli_tests.rs +++ b/cli/src/commands/search/cli_tests.rs @@ -30,15 +30,6 @@ mod tests { expected: "User", } - crate::cli_option_test! { - command: "search", - variant: Search, - test_name: test_search_with_project_filter, - args: ["User", "--project", "my_app"], - field: common.project, - expected: "my_app", - } - crate::cli_option_test! { command: "search", variant: Search, diff --git a/cli/src/commands/search/execute.rs b/cli/src/commands/search/execute.rs index fd0958d..e77ea93 100644 --- a/cli/src/commands/search/execute.rs +++ b/cli/src/commands/search/execute.rs @@ -75,7 +75,7 @@ impl Execute for SearchCmd { fn execute(self, db: &dyn db::backend::Database) -> Result> { match self.kind { SearchKind::Modules => { - let modules = search_modules(db, &self.pattern, &self.common.project, self.common.limit, self.common.regex)?; + let modules = search_modules(db, &self.pattern, self.common.limit, self.common.regex)?; Ok(SearchResult { pattern: self.pattern, kind: "modules".to_string(), @@ -85,7 +85,7 @@ impl Execute for SearchCmd { }) } SearchKind::Functions => { - let functions = search_functions(db, &self.pattern, &self.common.project, self.common.limit, self.common.regex)?; + let functions = search_functions(db, &self.pattern, self.common.limit, self.common.regex)?; Ok(SearchResult::from_functions(self.pattern, functions)) } } diff --git a/cli/src/commands/search/execute_tests.rs b/cli/src/commands/search/execute_tests.rs index 2a539d6..94334d9 100644 --- a/cli/src/commands/search/execute_tests.rs +++ b/cli/src/commands/search/execute_tests.rs @@ -9,7 +9,6 @@ mod tests { crate::shared_fixture! { fixture_name: populated_db, fixture_type: type_signatures, - project: "test_project", } // ========================================================================= @@ -24,7 +23,6 @@ mod tests { pattern: ".*MyApp.*".to_string(), // Use regex for substring matching kind: SearchKind::Modules, common: CommonArgs { - project: "test_project".to_string(), regex: true, limit: 100, }, @@ -43,7 +41,6 @@ mod tests { pattern: ".*user.*".to_string(), // Use regex for substring matching kind: SearchKind::Functions, common: CommonArgs { - project: "test_project".to_string(), regex: true, limit: 100, }, @@ -62,7 +59,6 @@ mod tests { pattern: ".*get.*".to_string(), // Use regex for substring matching kind: SearchKind::Functions, common: CommonArgs { - project: "test_project".to_string(), regex: true, limit: 100, }, @@ -79,7 +75,6 @@ mod tests { pattern: "^get_user$".to_string(), kind: SearchKind::Functions, common: CommonArgs { - project: "test_project".to_string(), regex: true, limit: 100, }, @@ -103,7 +98,6 @@ mod tests { pattern: "\\.(Accounts|Users)$".to_string(), kind: SearchKind::Modules, common: CommonArgs { - project: "test_project".to_string(), regex: true, limit: 100, }, @@ -121,7 +115,6 @@ mod tests { pattern: "MyApp.Accounts".to_string(), kind: SearchKind::Modules, common: CommonArgs { - project: "test_project".to_string(), regex: false, limit: 100, }, @@ -140,7 +133,6 @@ mod tests { pattern: "get_user".to_string(), kind: SearchKind::Functions, common: CommonArgs { - project: "test_project".to_string(), regex: false, limit: 100, }, @@ -164,7 +156,6 @@ mod tests { pattern: "user".to_string(), // Won't match get_user, list_users, etc. kind: SearchKind::Functions, common: CommonArgs { - project: "test_project".to_string(), regex: false, limit: 100, }, @@ -183,7 +174,6 @@ mod tests { pattern: "NonExistent".to_string(), kind: SearchKind::Modules, common: CommonArgs { - project: "test_project".to_string(), regex: false, limit: 100, }, @@ -198,7 +188,6 @@ mod tests { pattern: "^xyz".to_string(), kind: SearchKind::Functions, common: CommonArgs { - project: "test_project".to_string(), regex: true, limit: 100, }, @@ -217,7 +206,6 @@ mod tests { pattern: ".*user.*".to_string(), // Use regex for substring matching kind: SearchKind::Functions, common: CommonArgs { - project: "test_project".to_string(), regex: true, limit: 1, }, @@ -240,7 +228,6 @@ mod tests { pattern: "[invalid".to_string(), // Unclosed bracket kind: SearchKind::Modules, common: CommonArgs { - project: "test_project".to_string(), regex: true, limit: 100, }, @@ -263,7 +250,6 @@ mod tests { pattern: "*invalid".to_string(), // Invalid repetition kind: SearchKind::Functions, common: CommonArgs { - project: "test_project".to_string(), regex: true, limit: 100, }, @@ -287,7 +273,6 @@ mod tests { pattern: "[invalid".to_string(), kind: SearchKind::Modules, common: CommonArgs { - project: "test_project".to_string(), regex: false, // Not using regex mode limit: 100, }, diff --git a/cli/src/commands/search/output_tests.rs b/cli/src/commands/search/output_tests.rs index d895891..14eeea2 100644 --- a/cli/src/commands/search/output_tests.rs +++ b/cli/src/commands/search/output_tests.rs @@ -53,12 +53,10 @@ MyApp.Accounts: kind: "modules".to_string(), modules: vec![ ModuleResult { - project: "default".to_string(), name: "MyApp.Accounts".to_string(), source: "unknown".to_string(), }, ModuleResult { - project: "default".to_string(), name: "MyApp.Users".to_string(), source: "unknown".to_string(), }, diff --git a/cli/src/commands/setup/execute.rs b/cli/src/commands/setup/execute.rs index b6297e1..2a17dac 100644 --- a/cli/src/commands/setup/execute.rs +++ b/cli/src/commands/setup/execute.rs @@ -223,11 +223,7 @@ fn install_templates(force: bool) -> Result, - mix_env: Option, -) -> Result> { +fn install_hooks(force: bool, mix_env: Option) -> Result> { use std::process::Command; // Check if we're in a git repository @@ -278,14 +274,9 @@ fn install_hooks( // Configure git settings let mut git_config = Vec::new(); - // Build config list (only set values that are provided) + // Build config list let mut configs: Vec<(&str, String)> = Vec::new(); - // Only set project name if explicitly provided - if let Some(name) = project_name { - configs.push(("code-search.project-name", name)); - } - // Set mix-env (default to "dev" if not provided) configs.push(( "code-search.mix-env", @@ -369,7 +360,7 @@ impl Execute for SetupCmd { // Install git hooks if requested let hooks = if self.install_hooks { - Some(install_hooks(self.force, self.project_name, self.mix_env)?) + Some(install_hooks(self.force, self.mix_env)?) } else { None }; @@ -397,7 +388,6 @@ mod tests { dry_run: false, install_skills: false, install_hooks: false, - project_name: None, mix_env: None, }; @@ -428,7 +418,6 @@ mod tests { dry_run: false, install_skills: false, install_hooks: false, - project_name: None, mix_env: None, }; let result1 = cmd1.execute(&*db).expect("First setup should succeed"); @@ -440,7 +429,6 @@ mod tests { dry_run: false, install_skills: false, install_hooks: false, - project_name: None, mix_env: None, }; let result2 = cmd2.execute(&*db).expect("Second setup should succeed"); @@ -461,7 +449,6 @@ mod tests { dry_run: true, install_skills: false, install_hooks: false, - project_name: None, mix_env: None, }; @@ -488,7 +475,6 @@ mod tests { dry_run: true, install_skills: false, install_hooks: false, - project_name: None, mix_env: None, }; @@ -510,7 +496,6 @@ mod tests { dry_run: false, install_skills: false, install_hooks: false, - project_name: None, mix_env: None, }; @@ -550,7 +535,6 @@ mod tests { dry_run: false, install_skills: false, install_hooks: true, - project_name: Some("test_project".to_string()), mix_env: Some("test".to_string()), }; @@ -592,18 +576,10 @@ mod tests { TemplateFileState::Installed )); - // Should have configured 2 git settings (project-name and mix-env) - assert_eq!(hooks.git_config.len(), 2); + // Should have configured 1 git setting (mix-env) + assert_eq!(hooks.git_config.len(), 1); // Verify git config values - let project_config = hooks - .git_config - .iter() - .find(|c| c.key == "code-search.project-name"); - assert!(project_config.is_some()); - assert_eq!(project_config.unwrap().value, "test_project"); - assert!(project_config.unwrap().set); - let mix_env_config = hooks .git_config .iter() @@ -641,7 +617,6 @@ mod tests { dry_run: false, install_skills: false, install_hooks: true, - project_name: None, mix_env: None, }; @@ -650,7 +625,7 @@ mod tests { assert!(result.hooks.is_some()); let hooks = result.hooks.unwrap(); - // Should only set mix-env (project-name not set when None) + // Should set mix-env with default value assert_eq!(hooks.git_config.len(), 1); // Verify default values were used @@ -661,13 +636,6 @@ mod tests { assert!(mix_env_config.is_some()); assert_eq!(mix_env_config.unwrap().value, "dev"); - // Verify project-name was NOT set - let project_config = hooks - .git_config - .iter() - .find(|c| c.key == "code-search.project-name"); - assert!(project_config.is_none()); - // Restore original directory std::env::set_current_dir(&original_dir).ok(); } @@ -698,7 +666,6 @@ mod tests { dry_run: false, install_skills: false, install_hooks: true, - project_name: None, mix_env: None, }; @@ -711,7 +678,6 @@ mod tests { dry_run: false, install_skills: false, install_hooks: true, - project_name: None, mix_env: None, }; @@ -752,7 +718,6 @@ mod tests { dry_run: false, install_skills: false, install_hooks: true, - project_name: None, mix_env: None, }; @@ -764,7 +729,6 @@ mod tests { dry_run: false, install_skills: false, install_hooks: true, - project_name: None, mix_env: None, }; @@ -799,7 +763,6 @@ mod tests { dry_run: false, install_skills: false, install_hooks: true, - project_name: None, mix_env: None, }; diff --git a/cli/src/commands/setup/mod.rs b/cli/src/commands/setup/mod.rs index 1b30e53..7cdee7a 100644 --- a/cli/src/commands/setup/mod.rs +++ b/cli/src/commands/setup/mod.rs @@ -18,7 +18,6 @@ Examples: code_search setup --install-skills # Create schema and install skill templates code_search setup --install-skills --force # Overwrite existing skill files code_search setup --install-hooks # Install git hooks for incremental updates - code_search setup --install-hooks --project-name my_app # Configure project name code_search setup --install-skills --install-hooks # Install both skills and hooks")] pub struct SetupCmd { /// Overwrite existing template and hook files (does not affect schema) @@ -37,10 +36,6 @@ pub struct SetupCmd { #[arg(long, default_value_t = false)] pub install_hooks: bool, - /// Project name to configure in git hooks (only used with --install-hooks) - #[arg(long)] - pub project_name: Option, - /// Mix environment to configure in git hooks (defaults to 'dev', only used with --install-hooks) #[arg(long)] pub mix_env: Option, diff --git a/cli/src/commands/struct_usage/execute.rs b/cli/src/commands/struct_usage/execute.rs index 1722bf5..b674738 100644 --- a/cli/src/commands/struct_usage/execute.rs +++ b/cli/src/commands/struct_usage/execute.rs @@ -154,7 +154,6 @@ impl Execute for StructUsageCmd { let entries = find_struct_usage( db, &self.pattern, - &self.common.project, self.common.regex, self.module.as_deref(), self.common.limit, diff --git a/cli/src/commands/struct_usage/execute_tests.rs b/cli/src/commands/struct_usage/execute_tests.rs index e63bc9a..3db0efa 100644 --- a/cli/src/commands/struct_usage/execute_tests.rs +++ b/cli/src/commands/struct_usage/execute_tests.rs @@ -32,7 +32,6 @@ mod tests { module: None, by_module: false, common: CommonArgs { - project: "test_project".to_string(), regex: false, limit: 100, }, @@ -57,7 +56,6 @@ mod tests { module: Some("MyApp.Accounts".to_string()), by_module: false, common: CommonArgs { - project: "test_project".to_string(), regex: false, limit: 100, }, @@ -83,7 +81,6 @@ mod tests { module: None, by_module: false, common: CommonArgs { - project: "test_project".to_string(), regex: false, limit: 100, }, @@ -122,7 +119,6 @@ mod tests { module: None, by_module: true, common: CommonArgs { - project: "test_project".to_string(), regex: false, limit: 100, }, @@ -151,7 +147,6 @@ mod tests { module: None, by_module: true, common: CommonArgs { - project: "test_project".to_string(), regex: false, limit: 100, }, @@ -184,7 +179,6 @@ mod tests { module: None, by_module: false, common: CommonArgs { - project: "test_project".to_string(), regex: false, limit: 100, }, @@ -207,7 +201,6 @@ mod tests { module: None, by_module: true, common: CommonArgs { - project: "test_project".to_string(), regex: false, limit: 100, }, @@ -235,7 +228,6 @@ mod tests { module: None, by_module: false, common: CommonArgs { - project: "test_project".to_string(), regex: false, limit: 2, }, @@ -257,7 +249,6 @@ mod tests { module: None, by_module: false, common: CommonArgs { - project: "test_project".to_string(), regex: true, limit: 100, }, @@ -284,7 +275,6 @@ mod tests { module: None, by_module: false, common: CommonArgs { - project: "test_project".to_string(), regex: false, limit: 100, }, @@ -315,7 +305,6 @@ mod tests { module: None, by_module: false, common: CommonArgs { - project: "test_project".to_string(), regex: false, limit: 100, }, diff --git a/cli/src/commands/trace/cli_tests.rs b/cli/src/commands/trace/cli_tests.rs index 58f74f4..796e71e 100644 --- a/cli/src/commands/trace/cli_tests.rs +++ b/cli/src/commands/trace/cli_tests.rs @@ -44,15 +44,6 @@ mod tests { expected: "get_user", } - crate::cli_option_test! { - command: "trace", - variant: Trace, - test_name: test_with_project, - args: ["MyApp", "foo", "--project", "my_custom_project"], - field: common.project, - expected: "my_custom_project", - } - crate::cli_option_test! { command: "trace", variant: Trace, diff --git a/cli/src/commands/trace/execute.rs b/cli/src/commands/trace/execute.rs index 50274fa..ded85b3 100644 --- a/cli/src/commands/trace/execute.rs +++ b/cli/src/commands/trace/execute.rs @@ -147,7 +147,6 @@ impl Execute for TraceCmd { &self.module, &self.function, self.arity, - &self.common.project, self.common.regex, self.depth, self.common.limit, diff --git a/cli/src/commands/trace/execute_tests.rs b/cli/src/commands/trace/execute_tests.rs index d1d392d..0334963 100644 --- a/cli/src/commands/trace/execute_tests.rs +++ b/cli/src/commands/trace/execute_tests.rs @@ -9,7 +9,6 @@ mod tests { crate::shared_fixture! { fixture_name: populated_db, fixture_type: call_graph, - project: "test_project", } // ========================================================================= @@ -26,7 +25,6 @@ mod tests { arity: None, depth: 1, common: CommonArgs { - project: "test_project".to_string(), regex: false, limit: 100, }, @@ -52,7 +50,6 @@ mod tests { arity: None, depth: 3, common: CommonArgs { - project: "test_project".to_string(), regex: false, limit: 100, }, @@ -71,7 +68,6 @@ mod tests { arity: None, depth: 2, common: CommonArgs { - project: "test_project".to_string(), regex: false, limit: 100, }, @@ -95,7 +91,6 @@ mod tests { arity: None, depth: 5, common: CommonArgs { - project: "test_project".to_string(), regex: false, limit: 100, }, diff --git a/cli/src/commands/unused/cli_tests.rs b/cli/src/commands/unused/cli_tests.rs index 26c1ecd..1508159 100644 --- a/cli/src/commands/unused/cli_tests.rs +++ b/cli/src/commands/unused/cli_tests.rs @@ -16,7 +16,6 @@ mod tests { variant: Unused, required_args: [], defaults: { - common.project: "default", common.regex: false, private_only: false, public_only: false, @@ -34,15 +33,6 @@ mod tests { expected: Some("MyApp".to_string()), } - crate::cli_option_test! { - command: "unused", - variant: Unused, - test_name: test_with_project, - args: ["--project", "my_app"], - field: common.project, - expected: "my_app", - } - crate::cli_option_test! { command: "unused", variant: Unused, diff --git a/cli/src/commands/unused/execute.rs b/cli/src/commands/unused/execute.rs index 47e43df..4e9c2e4 100644 --- a/cli/src/commands/unused/execute.rs +++ b/cli/src/commands/unused/execute.rs @@ -51,7 +51,6 @@ impl Execute for UnusedCmd { let functions = find_unused_functions( db, self.module.as_deref(), - &self.common.project, self.common.regex, self.private_only, self.public_only, diff --git a/cli/src/commands/unused/execute_tests.rs b/cli/src/commands/unused/execute_tests.rs index 22a4ba1..e5c5e50 100644 --- a/cli/src/commands/unused/execute_tests.rs +++ b/cli/src/commands/unused/execute_tests.rs @@ -28,7 +28,6 @@ mod tests { public_only: false, exclude_generated: false, common: CommonArgs { - project: "test_project".to_string(), regex: false, limit: 100, }, @@ -58,7 +57,6 @@ mod tests { public_only: false, exclude_generated: false, common: CommonArgs { - project: "test_project".to_string(), regex: false, limit: 100, }, @@ -95,7 +93,6 @@ mod tests { public_only: false, exclude_generated: false, common: CommonArgs { - project: "test_project".to_string(), regex: true, limit: 100, }, @@ -131,7 +128,6 @@ mod tests { public_only: false, exclude_generated: false, common: CommonArgs { - project: "test_project".to_string(), regex: false, limit: 100, }, @@ -149,7 +145,6 @@ mod tests { public_only: false, exclude_generated: false, common: CommonArgs { - project: "test_project".to_string(), regex: false, limit: 100, }, @@ -173,7 +168,6 @@ mod tests { public_only: false, exclude_generated: false, common: CommonArgs { - project: "test_project".to_string(), regex: false, limit: 3, }, @@ -191,7 +185,6 @@ mod tests { public_only: false, exclude_generated: false, common: CommonArgs { - project: "test_project".to_string(), regex: false, limit: 100, }, @@ -234,7 +227,6 @@ mod tests { public_only: true, exclude_generated: false, common: CommonArgs { - project: "test_project".to_string(), regex: false, limit: 100, }, @@ -268,7 +260,6 @@ mod tests { public_only: false, exclude_generated: true, common: CommonArgs { - project: "test_project".to_string(), regex: false, limit: 100, }, @@ -301,7 +292,6 @@ mod tests { public_only: true, exclude_generated: true, common: CommonArgs { - project: "test_project".to_string(), regex: false, limit: 100, }, @@ -323,7 +313,6 @@ mod tests { public_only: false, exclude_generated: false, common: CommonArgs { - project: "test_project".to_string(), regex: false, limit: 100, }, diff --git a/cli/src/test_macros.rs b/cli/src/test_macros.rs index 76b965a..9e8a9bc 100644 --- a/cli/src/test_macros.rs +++ b/cli/src/test_macros.rs @@ -234,39 +234,35 @@ macro_rules! execute_test_fixture { /// crate::shared_fixture! { /// fixture_name: populated_db, /// fixture_type: call_graph, -/// project: "test_project", /// } /// ``` #[macro_export] macro_rules! shared_fixture { ( fixture_name: $name:ident, - fixture_type: call_graph, - project: $project:literal $(,)? + fixture_type: call_graph $(,)? ) => { #[fixture] fn $name() -> Box { - db::test_utils::call_graph_db($project) + db::test_utils::call_graph_db() } }; ( fixture_name: $name:ident, - fixture_type: type_signatures, - project: $project:literal $(,)? + fixture_type: type_signatures $(,)? ) => { #[fixture] fn $name() -> Box { - db::test_utils::type_signatures_db($project) + db::test_utils::type_signatures_db() } }; ( fixture_name: $name:ident, - fixture_type: structs, - project: $project:literal $(,)? + fixture_type: structs $(,)? ) => { #[fixture] fn $name() -> Box { - db::test_utils::structs_db($project) + db::test_utils::structs_db() } }; } diff --git a/cli/tests/acceptance.rs b/cli/tests/acceptance.rs index 62944c0..4c59150 100644 --- a/cli/tests/acceptance.rs +++ b/cli/tests/acceptance.rs @@ -56,9 +56,9 @@ impl TestProject { } /// Import a fixture file into the database. - fn import(&self, fixture_path: &PathBuf, project: &str) -> &Self { + fn import(&self, fixture_path: &PathBuf) -> &Self { self.cmd() - .args(["import", "--project", project, "--file"]) + .args(["import", "--file"]) .arg(fixture_path) .assert() .success(); @@ -111,7 +111,7 @@ fn test_full_workflow_setup_import_query() { // 2. Import fixture let fixture_path = project.write_fixture("call_graph.json", call_graph_fixture()); - project.import(&fixture_path, "my_app"); + project.import(&fixture_path); // 3. Query - search for modules (use regex for partial match) project.cmd() @@ -127,7 +127,7 @@ fn test_search_finds_modules() { project.setup(); let fixture_path = project.write_fixture("call_graph.json", call_graph_fixture()); - project.import(&fixture_path, "my_app"); + project.import(&fixture_path); // Search for Accounts module (use regex for partial match) project.cmd() @@ -143,7 +143,7 @@ fn test_search_finds_functions() { project.setup(); let fixture_path = project.write_fixture("call_graph.json", call_graph_fixture()); - project.import(&fixture_path, "my_app"); + project.import(&fixture_path); // Search for get_user function (use regex for partial match) project.cmd() @@ -159,7 +159,7 @@ fn test_location_finds_function_definition() { project.setup(); let fixture_path = project.write_fixture("call_graph.json", call_graph_fixture()); - project.import(&fixture_path, "my_app"); + project.import(&fixture_path); // Find location of get_user/1 (function first, then module) project.cmd() @@ -176,7 +176,7 @@ fn test_calls_from_shows_outgoing_calls() { project.setup(); let fixture_path = project.write_fixture("call_graph.json", call_graph_fixture()); - project.import(&fixture_path, "my_app"); + project.import(&fixture_path); // Check what Controller.index calls (positional args: MODULE FUNCTION) project.cmd() @@ -192,7 +192,7 @@ fn test_calls_to_shows_incoming_calls() { project.setup(); let fixture_path = project.write_fixture("call_graph.json", call_graph_fixture()); - project.import(&fixture_path, "my_app"); + project.import(&fixture_path); // Check what calls Repo.get (positional args: MODULE FUNCTION) project.cmd() @@ -208,7 +208,7 @@ fn test_browse_module_lists_functions() { project.setup(); let fixture_path = project.write_fixture("call_graph.json", call_graph_fixture()); - project.import(&fixture_path, "my_app"); + project.import(&fixture_path); // Browse MyApp.Accounts module project.cmd() @@ -226,7 +226,7 @@ fn test_json_output_format() { project.setup(); let fixture_path = project.write_fixture("call_graph.json", call_graph_fixture()); - project.import(&fixture_path, "my_app"); + project.import(&fixture_path); // Get JSON output (use regex for partial match) project.cmd() @@ -244,11 +244,11 @@ fn test_import_with_clear_flag() { let fixture_path = project.write_fixture("call_graph.json", call_graph_fixture()); // First import - project.import(&fixture_path, "my_app"); + project.import(&fixture_path); // Second import with --clear project.cmd() - .args(["import", "--project", "my_app", "--clear", "--file"]) + .args(["import", "--clear", "--file"]) .arg(&fixture_path) .assert() .success(); @@ -267,7 +267,7 @@ fn test_hotspots_command() { project.setup(); let fixture_path = project.write_fixture("call_graph.json", call_graph_fixture()); - project.import(&fixture_path, "my_app"); + project.import(&fixture_path); // Find hotspots (functions with most calls) - just verify command runs successfully project.cmd() @@ -283,7 +283,7 @@ fn test_unused_command() { project.setup(); let fixture_path = project.write_fixture("call_graph.json", call_graph_fixture()); - project.import(&fixture_path, "my_app"); + project.import(&fixture_path); // Find unused functions project.cmd() @@ -299,7 +299,7 @@ fn test_depends_on_shows_module_dependencies() { project.setup(); let fixture_path = project.write_fixture("call_graph.json", call_graph_fixture()); - project.import(&fixture_path, "my_app"); + project.import(&fixture_path); // Check what MyApp.Controller depends on project.cmd() @@ -315,7 +315,7 @@ fn test_depended_by_shows_reverse_dependencies() { project.setup(); let fixture_path = project.write_fixture("call_graph.json", call_graph_fixture()); - project.import(&fixture_path, "my_app"); + project.import(&fixture_path); // Check what depends on MyApp.Repo project.cmd() @@ -331,7 +331,7 @@ fn test_trace_command() { project.setup(); let fixture_path = project.write_fixture("call_graph.json", call_graph_fixture()); - project.import(&fixture_path, "my_app"); + project.import(&fixture_path); // Trace from Controller.index project.cmd() @@ -347,7 +347,7 @@ fn test_import_nonexistent_file_fails() { project.setup(); project.cmd() - .args(["import", "--project", "my_app", "--file", "/nonexistent/file.json"]) + .args(["import", "--file", "/nonexistent/file.json"]) .assert() .failure(); } @@ -360,7 +360,7 @@ fn test_import_invalid_json_fails() { let fixture_path = project.write_fixture("invalid.json", "{ not valid json }"); project.cmd() - .args(["import", "--project", "my_app", "--file"]) + .args(["import", "--file"]) .arg(&fixture_path) .assert() .failure(); diff --git a/db/src/fixtures/mod.rs b/db/src/fixtures/mod.rs index c61a082..ac683f2 100644 --- a/db/src/fixtures/mod.rs +++ b/db/src/fixtures/mod.rs @@ -17,7 +17,6 @@ //! crate::execute_test_fixture! { //! fixture_name: populated_db, //! json: fixtures::CALL_GRAPH, -//! project: "test_project", //! } //! ``` diff --git a/db/src/fixtures/output/search/modules.json b/db/src/fixtures/output/search/modules.json index 6560dc4..47dce9e 100644 --- a/db/src/fixtures/output/search/modules.json +++ b/db/src/fixtures/output/search/modules.json @@ -3,12 +3,10 @@ "kind": "modules", "modules": [ { - "project": "default", "name": "MyApp.Accounts", "source": "unknown" }, { - "project": "default", "name": "MyApp.Users", "source": "unknown" } diff --git a/db/src/fixtures/output/search/modules.toon b/db/src/fixtures/output/search/modules.toon index fb639a1..bcb64a2 100644 --- a/db/src/fixtures/output/search/modules.toon +++ b/db/src/fixtures/output/search/modules.toon @@ -1,5 +1,5 @@ kind: modules -modules[2]{name,project,source}: - MyApp.Accounts,default,unknown - MyApp.Users,default,unknown +modules[2]{name,source}: + MyApp.Accounts,unknown + MyApp.Users,unknown pattern: MyApp \ No newline at end of file diff --git a/db/src/queries/accepts.rs b/db/src/queries/accepts.rs index 8806d09..6dd54c4 100644 --- a/db/src/queries/accepts.rs +++ b/db/src/queries/accepts.rs @@ -29,7 +29,6 @@ pub struct AcceptsEntry { pub fn find_accepts( db: &dyn Database, pattern: &str, - _project: &str, use_regex: bool, module_pattern: Option<&str>, limit: u32, @@ -173,7 +172,7 @@ mod tests { fn test_find_accepts_integer_type() { let db = crate::test_utils::surreal_accepts_db(); - let result = find_accepts(&*db, "integer()", "default", false, None, 100); + let result = find_accepts(&*db, "integer()", false, None, 100); assert!(result.is_ok(), "Query should succeed: {:?}", result.err()); let entries = result.unwrap(); @@ -207,7 +206,7 @@ mod tests { fn test_find_accepts_string_type() { let db = crate::test_utils::surreal_accepts_db(); - let result = find_accepts(&*db, "String.t()", "default", false, None, 100); + let result = find_accepts(&*db, "String.t()", false, None, 100); assert!(result.is_ok()); let entries = result.unwrap(); @@ -232,7 +231,7 @@ mod tests { fn test_find_accepts_regex_pattern() { let db = crate::test_utils::surreal_accepts_db(); - let result = find_accepts(&*db, "^Ecto", "default", true, None, 100); + let result = find_accepts(&*db, "^Ecto", true, None, 100); assert!(result.is_ok(), "Regex query should succeed: {:?}", result.err()); let entries = result.unwrap(); @@ -254,7 +253,7 @@ mod tests { fn test_find_accepts_keyword_type() { let db = crate::test_utils::surreal_accepts_db(); - let result = find_accepts(&*db, "keyword()", "default", false, None, 100); + let result = find_accepts(&*db, "keyword()", false, None, 100); assert!(result.is_ok()); let entries = result.unwrap(); @@ -282,7 +281,6 @@ mod tests { let result = find_accepts( &*db, "integer()", - "default", false, Some("MyApp.Accounts"), 100, @@ -308,7 +306,7 @@ mod tests { fn test_find_accepts_nonexistent_type() { let db = crate::test_utils::surreal_accepts_db(); - let result = find_accepts(&*db, "NonExistent", "default", false, None, 100); + let result = find_accepts(&*db, "NonExistent", false, None, 100); assert!(result.is_ok()); let entries = result.unwrap(); @@ -323,7 +321,7 @@ mod tests { fn test_find_accepts_empty_pattern() { let db = crate::test_utils::surreal_accepts_db(); - let result = find_accepts(&*db, "", "default", false, None, 100); + let result = find_accepts(&*db, "", false, None, 100); assert!(result.is_ok()); let entries = result.unwrap(); @@ -340,7 +338,7 @@ mod tests { fn test_find_accepts_invalid_regex() { let db = crate::test_utils::surreal_accepts_db(); - let result = find_accepts(&*db, "[invalid", "default", true, None, 100); + let result = find_accepts(&*db, "[invalid", true, None, 100); assert!( result.is_err(), @@ -352,10 +350,10 @@ mod tests { fn test_find_accepts_respects_limit() { let db = crate::test_utils::surreal_accepts_db(); - let limit_3 = find_accepts(&*db, "", "default", false, None, 3) + let limit_3 = find_accepts(&*db, "", false, None, 3) .unwrap(); - let limit_100 = find_accepts(&*db, "", "default", false, None, 100) + let limit_100 = find_accepts(&*db, "", false, None, 100) .unwrap(); assert!(limit_3.len() <= 3, "Limit should be respected"); @@ -371,7 +369,7 @@ mod tests { fn test_find_accepts_zero_arity_excluded_from_integer_search() { let db = crate::test_utils::surreal_accepts_db(); - let result = find_accepts(&*db, "integer()", "default", false, None, 100); + let result = find_accepts(&*db, "integer()", false, None, 100); assert!(result.is_ok()); let entries = result.unwrap(); @@ -387,7 +385,7 @@ mod tests { fn test_find_accepts_returns_valid_structure() { let db = crate::test_utils::surreal_accepts_db(); - let result = find_accepts(&*db, "", "default", false, None, 100); + let result = find_accepts(&*db, "", false, None, 100); assert!(result.is_ok()); let entries = result.unwrap(); @@ -406,7 +404,7 @@ mod tests { fn test_find_accepts_preserves_sorting() { let db = crate::test_utils::surreal_accepts_db(); - let result = find_accepts(&*db, "", "default", false, None, 100); + let result = find_accepts(&*db, "", false, None, 100); assert!(result.is_ok()); let entries = result.unwrap(); diff --git a/db/src/queries/calls.rs b/db/src/queries/calls.rs index 5dfda42..7aa62db 100644 --- a/db/src/queries/calls.rs +++ b/db/src/queries/calls.rs @@ -43,7 +43,6 @@ pub fn find_calls( module_pattern: &str, function_pattern: Option<&str>, arity: Option, - _project: &str, use_regex: bool, limit: u32, ) -> Result, Box> { @@ -238,7 +237,6 @@ mod tests { "NonExistent", None, None, - "default", false, 100, ); @@ -261,7 +259,6 @@ mod tests { "[invalid", None, None, - "default", true, 100, ); @@ -282,7 +279,6 @@ mod tests { "NonExistentModule", None, None, - "default", false, 100, ); @@ -305,7 +301,6 @@ mod tests { "MyApp.Controller", None, None, - "default", false, 1, ) @@ -317,7 +312,6 @@ mod tests { "MyApp.Controller", None, None, - "default", false, 100, ) diff --git a/db/src/queries/calls_from.rs b/db/src/queries/calls_from.rs index 17e10cf..9e6d157 100644 --- a/db/src/queries/calls_from.rs +++ b/db/src/queries/calls_from.rs @@ -14,7 +14,6 @@ pub fn find_calls_from( module_pattern: &str, function_pattern: Option<&str>, arity: Option, - project: &str, use_regex: bool, limit: u32, ) -> Result, Box> { @@ -24,7 +23,6 @@ pub fn find_calls_from( module_pattern, function_pattern, arity, - project, use_regex, limit, ) @@ -43,7 +41,6 @@ mod tests { "module_a", None, None, - "default", false, 100, ); @@ -60,7 +57,6 @@ mod tests { "NonExistent", None, None, - "default", false, 100, ); @@ -79,7 +75,6 @@ mod tests { "MyApp.Controller", None, None, - "default", false, 2, ) @@ -97,7 +92,6 @@ mod tests { "module_a", Some("foo"), None, - "default", false, 100, ); @@ -114,7 +108,6 @@ mod tests { "[invalid", None, None, - "default", true, 100, ); diff --git a/db/src/queries/calls_to.rs b/db/src/queries/calls_to.rs index 644e83b..e797ca7 100644 --- a/db/src/queries/calls_to.rs +++ b/db/src/queries/calls_to.rs @@ -14,7 +14,6 @@ pub fn find_calls_to( module_pattern: &str, function_pattern: Option<&str>, arity: Option, - project: &str, use_regex: bool, limit: u32, ) -> Result, Box> { @@ -24,7 +23,6 @@ pub fn find_calls_to( module_pattern, function_pattern, arity, - project, use_regex, limit, ) @@ -43,7 +41,6 @@ mod tests { "module_a", None, None, - "default", false, 100, ); @@ -60,7 +57,6 @@ mod tests { "NonExistent", None, None, - "default", false, 100, ); @@ -79,7 +75,6 @@ mod tests { "MyApp.Accounts", None, None, - "default", false, 2, ) @@ -97,7 +92,6 @@ mod tests { "module_a", Some("bar"), None, - "default", false, 100, ); @@ -114,7 +108,6 @@ mod tests { "[invalid", None, None, - "default", true, 100, ); diff --git a/db/src/queries/clusters.rs b/db/src/queries/clusters.rs index 5fd7ca5..f3810d3 100644 --- a/db/src/queries/clusters.rs +++ b/db/src/queries/clusters.rs @@ -18,7 +18,7 @@ pub struct ModuleCall { /// /// Returns calls where caller_module != callee_module. /// These are used to compute internal vs external connectivity per namespace cluster. -pub fn get_module_calls(db: &dyn Database, _project: &str) -> Result, Box> { +pub fn get_module_calls(db: &dyn Database) -> Result, Box> { // Query calls relation, traversing to access caller and callee module names // calls is a RELATION FROM functions TO functions // in = caller function (has module_name) @@ -69,7 +69,7 @@ mod tests { #[test] fn test_get_module_calls_returns_results() { let db = get_db(); - let result = get_module_calls(&*db, "default"); + let result = get_module_calls(&*db); assert!(result.is_ok(), "Query should succeed: {:?}", result.err()); let calls = result.unwrap(); @@ -79,7 +79,7 @@ mod tests { #[test] fn test_get_module_calls_returns_exact_count() { let db = get_db(); - let calls = get_module_calls(&*db, "default").expect("Query should succeed"); + let calls = get_module_calls(&*db).expect("Query should succeed"); // The complex fixture has 20 inter-module calls: // Original (8): @@ -98,7 +98,7 @@ mod tests { #[test] fn test_get_module_calls_excludes_self_calls() { let db = get_db(); - let calls = get_module_calls(&*db, "default").expect("Query should succeed"); + let calls = get_module_calls(&*db).expect("Query should succeed"); // Verify no self-calls are present for call in &calls { @@ -114,7 +114,7 @@ mod tests { #[test] fn test_get_module_calls_returns_valid_modules() { let db = get_db(); - let calls = get_module_calls(&*db, "default").expect("Query should succeed"); + let calls = get_module_calls(&*db).expect("Query should succeed"); assert!(!calls.is_empty(), "Should have results"); @@ -133,7 +133,7 @@ mod tests { #[test] fn test_get_module_calls_all_modules_present() { let db = get_db(); - let calls = get_module_calls(&*db, "default").expect("Query should succeed"); + let calls = get_module_calls(&*db).expect("Query should succeed"); let modules: std::collections::HashSet<_> = calls .iter() @@ -156,7 +156,7 @@ mod tests { #[test] fn test_get_module_calls_contains_controller_to_accounts() { let db = get_db(); - let calls = get_module_calls(&*db, "default").expect("Query should succeed"); + let calls = get_module_calls(&*db).expect("Query should succeed"); // Controller.index calls Accounts.list_users let controller_to_accounts = calls.iter().any(|call| { @@ -172,7 +172,7 @@ mod tests { #[test] fn test_get_module_calls_contains_controller_to_service() { let db = get_db(); - let calls = get_module_calls(&*db, "default").expect("Query should succeed"); + let calls = get_module_calls(&*db).expect("Query should succeed"); // Controller.create calls Service.process_request let controller_to_service = calls.iter().any(|call| { @@ -188,7 +188,7 @@ mod tests { #[test] fn test_get_module_calls_contains_service_to_accounts() { let db = get_db(); - let calls = get_module_calls(&*db, "default").expect("Query should succeed"); + let calls = get_module_calls(&*db).expect("Query should succeed"); // Service.process_request calls Accounts.get_user let service_to_accounts = calls.iter().any(|call| { @@ -204,7 +204,7 @@ mod tests { #[test] fn test_get_module_calls_contains_service_to_notifier() { let db = get_db(); - let calls = get_module_calls(&*db, "default").expect("Query should succeed"); + let calls = get_module_calls(&*db).expect("Query should succeed"); // Service.process_request calls Notifier.send_email let service_to_notifier = calls.iter().any(|call| { @@ -220,7 +220,7 @@ mod tests { #[test] fn test_get_module_calls_contains_accounts_to_repo() { let db = get_db(); - let calls = get_module_calls(&*db, "default").expect("Query should succeed"); + let calls = get_module_calls(&*db).expect("Query should succeed"); // Accounts calls Repo (get_user->get, list_users->all) let accounts_to_repo = calls.iter().any(|call| { @@ -236,7 +236,7 @@ mod tests { #[test] fn test_get_module_calls_no_repo_internal_calls() { let db = get_db(); - let calls = get_module_calls(&*db, "default").expect("Query should succeed"); + let calls = get_module_calls(&*db).expect("Query should succeed"); // Repo has internal calls (get->query, all->query) which should be excluded let repo_internal = calls.iter().any(|call| { @@ -252,7 +252,7 @@ mod tests { #[test] fn test_get_module_calls_no_notifier_internal_calls() { let db = get_db(); - let calls = get_module_calls(&*db, "default").expect("Query should succeed"); + let calls = get_module_calls(&*db).expect("Query should succeed"); // Notifier has internal calls (send_email->format_message) which should be excluded let notifier_internal = calls.iter().any(|call| { @@ -268,7 +268,7 @@ mod tests { #[test] fn test_get_module_calls_no_accounts_internal_calls() { let db = get_db(); - let calls = get_module_calls(&*db, "default").expect("Query should succeed"); + let calls = get_module_calls(&*db).expect("Query should succeed"); // Accounts has internal calls (get_user/2->get_user/1) which should be excluded let accounts_internal = calls.iter().any(|call| { @@ -286,7 +286,7 @@ mod tests { let db = get_db(); // SurrealDB doesn't use project concept - database is per-project // But call with different project to verify no crash - let result = get_module_calls(&*db, "nonexistent"); + let result = get_module_calls(&*db); assert!(result.is_ok(), "Query should not error on different project"); } } diff --git a/db/src/queries/complexity.rs b/db/src/queries/complexity.rs index bedd916..f1863bf 100644 --- a/db/src/queries/complexity.rs +++ b/db/src/queries/complexity.rs @@ -33,7 +33,6 @@ pub fn find_complexity_metrics( min_complexity: i64, min_depth: i64, module_pattern: Option<&str>, - _project: &str, use_regex: bool, _exclude_generated: bool, limit: u32, @@ -151,7 +150,7 @@ mod tests { #[test] fn test_find_complexity_metrics_returns_results() { let db = get_db(); - let result = find_complexity_metrics(&*db, 0, 0, None, "default", false, false, 100); + let result = find_complexity_metrics(&*db, 0, 0, None, false, false, 100); assert!(result.is_ok(), "Query should succeed: {:?}", result.err()); let metrics = result.unwrap(); @@ -161,7 +160,7 @@ mod tests { #[test] fn test_find_complexity_metrics_returns_exact_count() { let db = get_db(); - let metrics = find_complexity_metrics(&*db, 0, 0, None, "default", false, false, 100) + let metrics = find_complexity_metrics(&*db, 0, 0, None, false, false, 100) .expect("Query should succeed"); // The fixture has 37 functions, each with at least 1 clause @@ -175,7 +174,7 @@ mod tests { #[test] fn test_find_complexity_metrics_calculates_complexity_from_clauses() { let db = get_db(); - let metrics = find_complexity_metrics(&*db, 0, 0, None, "default", false, false, 100) + let metrics = find_complexity_metrics(&*db, 0, 0, None, false, false, 100) .expect("Query should succeed"); // Find Controller.index/2 which has 2 clauses with complexity 3+1=4 @@ -193,7 +192,7 @@ mod tests { #[test] fn test_find_complexity_metrics_calculates_max_nesting_depth() { let db = get_db(); - let metrics = find_complexity_metrics(&*db, 0, 0, None, "default", false, false, 100) + let metrics = find_complexity_metrics(&*db, 0, 0, None, false, false, 100) .expect("Query should succeed"); // Controller.index/2 has clauses with depth 2 and 1, max should be 2 @@ -211,7 +210,7 @@ mod tests { #[test] fn test_find_complexity_metrics_multiple_functions_per_module() { let db = get_db(); - let metrics = find_complexity_metrics(&*db, 0, 0, None, "default", false, false, 100) + let metrics = find_complexity_metrics(&*db, 0, 0, None, false, false, 100) .expect("Query should succeed"); // Controller has 6 functions: index/2, show/2, create/2, handle_event/1, format_display/1, __generated__/0 @@ -255,7 +254,7 @@ mod tests { #[test] fn test_find_complexity_metrics_all_modules_present() { let db = get_db(); - let metrics = find_complexity_metrics(&*db, 0, 0, None, "default", false, false, 100) + let metrics = find_complexity_metrics(&*db, 0, 0, None, false, false, 100) .expect("Query should succeed"); let modules: std::collections::HashSet<_> = metrics.iter().map(|m| m.module.as_str()).collect(); @@ -275,7 +274,7 @@ mod tests { #[test] fn test_find_complexity_metrics_respects_min_complexity_threshold() { let db = get_db(); - let metrics = find_complexity_metrics(&*db, 3, 0, None, "default", false, false, 100) + let metrics = find_complexity_metrics(&*db, 3, 0, None, false, false, 100) .expect("Query should succeed"); // Service.process_request/2 has 3 clauses (complexity=3) @@ -302,7 +301,7 @@ mod tests { #[test] fn test_find_complexity_metrics_respects_min_depth_threshold() { let db = get_db(); - let metrics = find_complexity_metrics(&*db, 0, 3, None, "default", false, false, 100) + let metrics = find_complexity_metrics(&*db, 0, 3, None, false, false, 100) .expect("Query should succeed"); // All results should have max_nesting_depth >= 3 @@ -319,7 +318,7 @@ mod tests { #[test] fn test_find_complexity_metrics_filters_by_both_thresholds() { let db = get_db(); - let metrics = find_complexity_metrics(&*db, 3, 2, None, "default", false, false, 100) + let metrics = find_complexity_metrics(&*db, 3, 2, None, false, false, 100) .expect("Query should succeed"); // All results must satisfy both conditions @@ -345,7 +344,6 @@ mod tests { 0, 0, Some("MyApp.Controller"), - "default", false, false, 100, @@ -369,7 +367,7 @@ mod tests { #[test] fn test_find_complexity_metrics_with_regex_module_filter() { let db = get_db(); - let metrics = find_complexity_metrics(&*db, 0, 0, Some("^MyApp\\.Acc.*"), "default", true, false, 100) + let metrics = find_complexity_metrics(&*db, 0, 0, Some("^MyApp\\.Acc.*"), true, false, 100) .expect("Query should succeed"); assert_eq!( @@ -394,7 +392,6 @@ mod tests { 0, 0, Some("NonExistentModule"), - "default", false, false, 100, @@ -410,7 +407,7 @@ mod tests { #[test] fn test_find_complexity_metrics_regex_pattern_invalid() { let db = get_db(); - let result = find_complexity_metrics(&*db, 0, 0, Some("[invalid"), "default", true, false, 100); + let result = find_complexity_metrics(&*db, 0, 0, Some("[invalid"), true, false, 100); assert!( result.is_err(), @@ -423,11 +420,11 @@ mod tests { #[test] fn test_find_complexity_metrics_respects_limit() { let db = get_db(); - let metrics_5 = find_complexity_metrics(&*db, 0, 0, None, "default", false, false, 5) + let metrics_5 = find_complexity_metrics(&*db, 0, 0, None, false, false, 5) .expect("Query should succeed"); - let metrics_10 = find_complexity_metrics(&*db, 0, 0, None, "default", false, false, 10) + let metrics_10 = find_complexity_metrics(&*db, 0, 0, None, false, false, 10) .expect("Query should succeed"); - let metrics_100 = find_complexity_metrics(&*db, 0, 0, None, "default", false, false, 100) + let metrics_100 = find_complexity_metrics(&*db, 0, 0, None, false, false, 100) .expect("Query should succeed"); assert!(metrics_5.len() <= 5, "Should respect limit of 5"); @@ -451,7 +448,7 @@ mod tests { #[test] fn test_find_complexity_metrics_ordered_by_complexity_desc() { let db = get_db(); - let metrics = find_complexity_metrics(&*db, 0, 0, None, "default", false, false, 100) + let metrics = find_complexity_metrics(&*db, 0, 0, None, false, false, 100) .expect("Query should succeed"); // Results should be ordered by complexity descending, then by module/name @@ -470,7 +467,7 @@ mod tests { #[test] fn test_find_complexity_metrics_calculates_lines_correctly() { let db = get_db(); - let metrics = find_complexity_metrics(&*db, 0, 0, None, "default", false, false, 100) + let metrics = find_complexity_metrics(&*db, 0, 0, None, false, false, 100) .expect("Query should succeed"); for metric in &metrics { @@ -485,7 +482,7 @@ mod tests { #[test] fn test_find_complexity_metrics_valid_arity_values() { let db = get_db(); - let metrics = find_complexity_metrics(&*db, 0, 0, None, "default", false, false, 100) + let metrics = find_complexity_metrics(&*db, 0, 0, None, false, false, 100) .expect("Query should succeed"); // Verify all arities are non-negative @@ -506,7 +503,7 @@ mod tests { #[test] fn test_find_complexity_metrics_all_fields_populated() { let db = get_db(); - let metrics = find_complexity_metrics(&*db, 0, 0, None, "default", false, false, 100) + let metrics = find_complexity_metrics(&*db, 0, 0, None, false, false, 100) .expect("Query should succeed"); assert!(!metrics.is_empty(), "Should return results"); @@ -527,7 +524,7 @@ mod tests { #[test] fn test_accounts_get_user_arity_variations() { let db = get_db(); - let metrics = find_complexity_metrics(&*db, 0, 0, None, "default", false, false, 100) + let metrics = find_complexity_metrics(&*db, 0, 0, None, false, false, 100) .expect("Query should succeed"); // Accounts module has get_user/1 and get_user/2 @@ -554,7 +551,7 @@ mod tests { #[test] fn test_service_process_request_complexity() { let db = get_db(); - let metrics = find_complexity_metrics(&*db, 0, 0, None, "default", false, false, 100) + let metrics = find_complexity_metrics(&*db, 0, 0, None, false, false, 100) .expect("Query should succeed"); let service_process = metrics @@ -582,7 +579,7 @@ mod tests { #[test] fn test_find_complexity_metrics_empty_with_very_high_threshold() { let db = get_db(); - let metrics = find_complexity_metrics(&*db, 1000, 0, None, "default", false, false, 100) + let metrics = find_complexity_metrics(&*db, 1000, 0, None, false, false, 100) .expect("Query should succeed"); assert!( diff --git a/db/src/queries/cycles.rs b/db/src/queries/cycles.rs index 957437b..0b69397 100644 --- a/db/src/queries/cycles.rs +++ b/db/src/queries/cycles.rs @@ -24,7 +24,6 @@ pub struct CycleEdge { /// approach to detect cycles by finding modules that can reach themselves. pub fn find_cycle_edges( db: &dyn Database, - _project: &str, module_pattern: Option<&str>, ) -> Result, Box> { // Step 1: Get all direct module-to-module dependencies @@ -165,7 +164,7 @@ mod tests { #[test] fn test_find_cycle_edges_returns_exactly_17_edges() { let db = get_db(); - let edges = find_cycle_edges(&*db, "default", None) + let edges = find_cycle_edges(&*db, None) .expect("Query should succeed"); // The fixture has 17 unique module-level edges between modules that are in cycles @@ -180,7 +179,7 @@ mod tests { #[test] fn test_find_cycle_edges_contains_all_expected_edges() { let db = get_db(); - let edges = find_cycle_edges(&*db, "default", None) + let edges = find_cycle_edges(&*db, None) .expect("Query should succeed"); // All 17 expected edges (sorted alphabetically) @@ -217,7 +216,7 @@ mod tests { #[test] fn test_find_cycle_edges_contains_cycle_a_edges() { let db = get_db(); - let edges = find_cycle_edges(&*db, "default", None) + let edges = find_cycle_edges(&*db, None) .expect("Query should succeed"); // Cycle A: Service → Logger → Repo → Service @@ -240,7 +239,7 @@ mod tests { #[test] fn test_find_cycle_edges_contains_cycle_b_edges() { let db = get_db(); - let edges = find_cycle_edges(&*db, "default", None) + let edges = find_cycle_edges(&*db, None) .expect("Query should succeed"); // Cycle B: Controller → Events → Cache → Accounts → Controller @@ -264,7 +263,7 @@ mod tests { #[test] fn test_find_cycle_edges_contains_cycle_c_edges() { let db = get_db(); - let edges = find_cycle_edges(&*db, "default", None) + let edges = find_cycle_edges(&*db, None) .expect("Query should succeed"); // Cycle C: Notifier → Metrics → Logger → Events → Cache → Notifier @@ -289,7 +288,7 @@ mod tests { #[test] fn test_find_cycle_edges_involves_exactly_9_modules() { let db = get_db(); - let edges = find_cycle_edges(&*db, "default", None) + let edges = find_cycle_edges(&*db, None) .expect("Query should succeed"); let mut modules = std::collections::HashSet::new(); @@ -332,7 +331,7 @@ mod tests { #[test] fn test_find_cycle_edges_are_sorted_alphabetically() { let db = get_db(); - let edges = find_cycle_edges(&*db, "default", None) + let edges = find_cycle_edges(&*db, None) .expect("Query should succeed"); // Verify sorted order: by from module, then by to module @@ -358,7 +357,7 @@ mod tests { #[test] fn test_find_cycle_edges_has_no_duplicates() { let db = get_db(); - let edges = find_cycle_edges(&*db, "default", None) + let edges = find_cycle_edges(&*db, None) .expect("Query should succeed"); let mut seen = std::collections::HashSet::new(); @@ -375,7 +374,7 @@ mod tests { #[test] fn test_find_cycle_edges_has_no_self_loops() { let db = get_db(); - let edges = find_cycle_edges(&*db, "default", None) + let edges = find_cycle_edges(&*db, None) .expect("Query should succeed"); for edge in &edges { @@ -392,7 +391,7 @@ mod tests { #[test] fn test_find_cycle_edges_filter_by_service_module() { let db = get_db(); - let edges = find_cycle_edges(&*db, "default", Some("Service")) + let edges = find_cycle_edges(&*db, Some("Service")) .expect("Query should succeed"); // Edges involving Service: @@ -436,7 +435,7 @@ mod tests { #[test] fn test_find_cycle_edges_filter_by_cache_module() { let db = get_db(); - let edges = find_cycle_edges(&*db, "default", Some("Cache")) + let edges = find_cycle_edges(&*db, Some("Cache")) .expect("Query should succeed"); // Cache edges: @@ -469,7 +468,7 @@ mod tests { #[test] fn test_find_cycle_edges_filter_nonexistent_returns_empty() { let db = get_db(); - let edges = find_cycle_edges(&*db, "default", Some("NonExistentModule")) + let edges = find_cycle_edges(&*db, Some("NonExistentModule")) .expect("Query should succeed"); assert!( @@ -484,9 +483,9 @@ mod tests { #[test] fn test_find_cycle_edges_is_idempotent() { let db = get_db(); - let result1 = find_cycle_edges(&*db, "default", None) + let result1 = find_cycle_edges(&*db, None) .expect("First query should succeed"); - let result2 = find_cycle_edges(&*db, "default", None) + let result2 = find_cycle_edges(&*db, None) .expect("Second query should succeed"); assert_eq!(result1.len(), result2.len(), "Query should be idempotent"); diff --git a/db/src/queries/depended_by.rs b/db/src/queries/depended_by.rs index a27fa9c..93826ad 100644 --- a/db/src/queries/depended_by.rs +++ b/db/src/queries/depended_by.rs @@ -13,7 +13,6 @@ use crate::query_builders::validate_regex_patterns; pub fn find_dependents( db: &dyn Database, module_pattern: &str, - project: &str, use_regex: bool, limit: u32, ) -> Result, Box> { @@ -23,7 +22,6 @@ pub fn find_dependents( db, DependencyDirection::Incoming, module_pattern, - project, use_regex, limit, ) @@ -37,7 +35,7 @@ mod tests { fn test_find_dependents_returns_results() { let db = crate::test_utils::surreal_call_graph_db_complex(); - let result = find_dependents(&*db, "MyApp.Notifier", "default", false, 100); + let result = find_dependents(&*db, "MyApp.Notifier", false, 100); assert!(result.is_ok(), "Query should succeed"); let calls = result.unwrap(); @@ -59,7 +57,7 @@ mod tests { fn test_find_dependents_empty_for_nonexistent() { let db = crate::test_utils::surreal_call_graph_db_complex(); - let result = find_dependents(&*db, "NonExistent", "default", false, 100); + let result = find_dependents(&*db, "NonExistent", false, 100); assert!(result.is_ok()); assert!(result.unwrap().is_empty()); @@ -69,7 +67,7 @@ mod tests { fn test_find_dependents_excludes_self_references() { let db = crate::test_utils::surreal_call_graph_db_complex(); - let result = find_dependents(&*db, "MyApp.Notifier", "default", false, 100).unwrap(); + let result = find_dependents(&*db, "MyApp.Notifier", false, 100).unwrap(); for call in &result { assert_ne!( @@ -83,7 +81,7 @@ mod tests { fn test_find_dependents_invalid_regex() { let db = crate::test_utils::surreal_call_graph_db_complex(); - let result = find_dependents(&*db, "[invalid", "default", true, 100); + let result = find_dependents(&*db, "[invalid", true, 100); assert!(result.is_err(), "Should reject invalid regex"); let err = result.unwrap_err(); @@ -99,7 +97,7 @@ mod tests { let db = crate::test_utils::surreal_call_graph_db_complex(); // Invalid regex pattern should succeed in non-regex mode (treated as literal) - let result = find_dependents(&*db, "[invalid", "default", false, 100); + let result = find_dependents(&*db, "[invalid", false, 100); assert!(result.is_ok(), "Should succeed in non-regex mode"); } @@ -108,7 +106,7 @@ mod tests { fn test_find_dependents_with_regex_pattern() { let db = crate::test_utils::surreal_call_graph_db_complex(); - let result = find_dependents(&*db, "^MyApp\\.Accounts$", "default", true, 100); + let result = find_dependents(&*db, "^MyApp\\.Accounts$", true, 100); assert!(result.is_ok()); let calls = result.unwrap(); @@ -122,9 +120,9 @@ mod tests { fn test_find_dependents_respects_limit() { let db = crate::test_utils::surreal_call_graph_db_complex(); - let limit_1 = find_dependents(&*db, "MyApp.Accounts", "default", false, 1) + let limit_1 = find_dependents(&*db, "MyApp.Accounts", false, 1) .unwrap_or_default(); - let limit_100 = find_dependents(&*db, "MyApp.Accounts", "default", false, 100) + let limit_100 = find_dependents(&*db, "MyApp.Accounts", false, 100) .unwrap_or_default(); assert!(limit_1.len() <= 1, "Limit of 1 should be respected"); diff --git a/db/src/queries/dependencies.rs b/db/src/queries/dependencies.rs index 2a2f8cf..45c4abd 100644 --- a/db/src/queries/dependencies.rs +++ b/db/src/queries/dependencies.rs @@ -40,7 +40,6 @@ pub fn find_dependencies( db: &dyn Database, direction: DependencyDirection, module_pattern: &str, - _project: &str, use_regex: bool, limit: u32, ) -> Result, Box> { @@ -138,7 +137,6 @@ mod tests { &*db, DependencyDirection::Outgoing, "MyApp.Service", - "default", false, 100, ); @@ -179,7 +177,6 @@ mod tests { &*db, DependencyDirection::Incoming, "MyApp.Notifier", - "default", false, 100, ); @@ -223,7 +220,6 @@ mod tests { &*db, DependencyDirection::Outgoing, "MyApp.Controller", - "default", false, 100, ); @@ -251,7 +247,6 @@ mod tests { &*db, DependencyDirection::Outgoing, "MyApp.Controller", - "default", false, 100, ); @@ -294,7 +289,6 @@ mod tests { &*db, DependencyDirection::Incoming, "MyApp.Accounts", - "default", false, 100, ); @@ -336,7 +330,6 @@ mod tests { &*db, DependencyDirection::Outgoing, "NonExistent", - "default", false, 100, ); @@ -357,7 +350,6 @@ mod tests { &*db, DependencyDirection::Outgoing, "MyApp.Controller", - "default", false, 1, ) @@ -367,7 +359,6 @@ mod tests { &*db, DependencyDirection::Outgoing, "MyApp.Controller", - "default", false, 100, ) @@ -390,7 +381,6 @@ mod tests { &*db, DependencyDirection::Outgoing, "^MyApp\\.Controller$", - "default", true, 100, ); @@ -418,7 +408,6 @@ mod tests { &*db, DependencyDirection::Outgoing, "[invalid", - "default", true, 100, ); @@ -437,7 +426,6 @@ mod tests { &*db, DependencyDirection::Outgoing, "module_a", - "default", false, 100, ); @@ -490,7 +478,6 @@ mod tests { &*db, DependencyDirection::Incoming, "^MyApp\\.Accounts$", - "default", true, 100, ); @@ -519,7 +506,6 @@ mod tests { &*db, DependencyDirection::Outgoing, "^MyApp.*", - "default", true, 100, ); @@ -545,7 +531,6 @@ mod tests { &*db, DependencyDirection::Outgoing, "MyApp.Service", - "default", false, 100, ); @@ -577,7 +562,6 @@ mod tests { &*db, DependencyDirection::Incoming, "MyApp.Notifier", - "default", false, 100, ); @@ -610,7 +594,6 @@ mod tests { &*db, DependencyDirection::Outgoing, "module_a", - "default", false, 0, ); @@ -629,7 +612,6 @@ mod tests { &*db, DependencyDirection::Outgoing, "MyApp.Controller", - "default", false, 100, ) @@ -640,7 +622,6 @@ mod tests { &*db, DependencyDirection::Incoming, "MyApp.Accounts", - "default", false, 100, ) diff --git a/db/src/queries/depends_on.rs b/db/src/queries/depends_on.rs index 0d6a92b..8be0e4c 100644 --- a/db/src/queries/depends_on.rs +++ b/db/src/queries/depends_on.rs @@ -13,7 +13,6 @@ use crate::query_builders::validate_regex_patterns; pub fn find_dependencies( db: &dyn Database, module_pattern: &str, - project: &str, use_regex: bool, limit: u32, ) -> Result, Box> { @@ -23,7 +22,6 @@ pub fn find_dependencies( db, DependencyDirection::Outgoing, module_pattern, - project, use_regex, limit, ) @@ -37,7 +35,7 @@ mod tests { fn test_find_dependencies_returns_results() { let db = crate::test_utils::surreal_call_graph_db_complex(); - let result = find_dependencies(&*db, "MyApp.Service", "default", false, 100); + let result = find_dependencies(&*db, "MyApp.Service", false, 100); assert!(result.is_ok(), "Query should succeed"); let calls = result.unwrap(); @@ -59,7 +57,7 @@ mod tests { fn test_find_dependencies_empty_for_nonexistent() { let db = crate::test_utils::surreal_call_graph_db_complex(); - let result = find_dependencies(&*db, "NonExistent", "default", false, 100); + let result = find_dependencies(&*db, "NonExistent", false, 100); assert!(result.is_ok()); assert!(result.unwrap().is_empty()); @@ -69,7 +67,7 @@ mod tests { fn test_find_dependencies_excludes_self_references() { let db = crate::test_utils::surreal_call_graph_db_complex(); - let result = find_dependencies(&*db, "MyApp.Service", "default", false, 100).unwrap(); + let result = find_dependencies(&*db, "MyApp.Service", false, 100).unwrap(); for call in &result { assert_ne!( @@ -83,7 +81,7 @@ mod tests { fn test_find_dependencies_invalid_regex() { let db = crate::test_utils::surreal_call_graph_db_complex(); - let result = find_dependencies(&*db, "[invalid", "default", true, 100); + let result = find_dependencies(&*db, "[invalid", true, 100); assert!(result.is_err(), "Should reject invalid regex"); let err = result.unwrap_err(); @@ -99,7 +97,7 @@ mod tests { let db = crate::test_utils::surreal_call_graph_db_complex(); // Invalid regex pattern should succeed in non-regex mode (treated as literal) - let result = find_dependencies(&*db, "[invalid", "default", false, 100); + let result = find_dependencies(&*db, "[invalid", false, 100); assert!(result.is_ok(), "Should succeed in non-regex mode"); } @@ -108,7 +106,7 @@ mod tests { fn test_find_dependencies_with_regex_pattern() { let db = crate::test_utils::surreal_call_graph_db_complex(); - let result = find_dependencies(&*db, "^MyApp\\.Controller$", "default", true, 100); + let result = find_dependencies(&*db, "^MyApp\\.Controller$", true, 100); assert!(result.is_ok()); let calls = result.unwrap(); @@ -122,9 +120,9 @@ mod tests { fn test_find_dependencies_respects_limit() { let db = crate::test_utils::surreal_call_graph_db_complex(); - let limit_1 = find_dependencies(&*db, "MyApp.Controller", "default", false, 1) + let limit_1 = find_dependencies(&*db, "MyApp.Controller", false, 1) .unwrap_or_default(); - let limit_100 = find_dependencies(&*db, "MyApp.Controller", "default", false, 100) + let limit_100 = find_dependencies(&*db, "MyApp.Controller", false, 100) .unwrap_or_default(); assert!(limit_1.len() <= 1, "Limit of 1 should be respected"); diff --git a/db/src/queries/duplicates.rs b/db/src/queries/duplicates.rs index 6e151fb..c241869 100644 --- a/db/src/queries/duplicates.rs +++ b/db/src/queries/duplicates.rs @@ -27,7 +27,6 @@ pub struct DuplicateFunction { pub fn find_duplicates( db: &dyn Database, - _project: &str, module_pattern: Option<&str>, use_regex: bool, use_exact: bool, @@ -147,7 +146,7 @@ mod tests { fn test_find_duplicates_ast_hash_returns_expected_pairs() { let db = get_db(); let result = - find_duplicates(&*db, "default", None, false, false, false).expect("Query should succeed"); + find_duplicates(&*db, None, false, false, false).expect("Query should succeed"); // Expect exactly 4 duplicates: 2 pairs with matching ast_sha and 2 generated assert_eq!( @@ -186,7 +185,7 @@ mod tests { #[test] fn test_find_duplicates_source_hash_returns_exact_copies() { let db = get_db(); - let result = find_duplicates(&*db, "default", None, false, true, false) + let result = find_duplicates(&*db, None, false, true, false) .expect("Query should succeed"); // Expect exactly 2 duplicates: 1 pair with matching source_sha @@ -222,11 +221,11 @@ mod tests { let db = get_db(); // With generated - let with_gen = find_duplicates(&*db, "default", None, false, false, false) + let with_gen = find_duplicates(&*db, None, false, false, false) .expect("Query should succeed"); // Without generated - let without_gen = find_duplicates(&*db, "default", None, false, false, true) + let without_gen = find_duplicates(&*db, None, false, false, true) .expect("Query should succeed"); assert_eq!( @@ -253,7 +252,7 @@ mod tests { #[test] fn test_find_duplicates_module_filter_returns_matching_only() { let db = get_db(); - let result = find_duplicates(&*db, "default", Some("Accounts"), false, false, false) + let result = find_duplicates(&*db, Some("Accounts"), false, false, false) .expect("Query should succeed"); // Should find duplicates in or related to Accounts module @@ -271,7 +270,7 @@ mod tests { #[test] fn test_find_duplicates_ast_duplicates_with_excluded_generated() { let db = get_db(); - let result = find_duplicates(&*db, "default", None, false, false, true) + let result = find_duplicates(&*db, None, false, false, true) .expect("Query should succeed"); // Should only find AST duplicates without generated @@ -295,7 +294,7 @@ mod tests { #[test] fn test_find_duplicates_ordering_by_hash_module_name() { let db = get_db(); - let result = find_duplicates(&*db, "default", None, false, false, false) + let result = find_duplicates(&*db, None, false, false, false) .expect("Query should succeed"); // Verify ordering: by hash, then module, then name, then arity @@ -340,7 +339,7 @@ mod tests { let db = get_db(); // Test AST duplicates field values - let ast_result = find_duplicates(&*db, "default", None, false, false, false) + let ast_result = find_duplicates(&*db, None, false, false, false) .expect("Query should succeed"); // Find format_name duplicate (AST mode) @@ -356,7 +355,7 @@ mod tests { assert_eq!(format_name.file, "lib/my_app/accounts.ex"); // Test source duplicates field values (use_exact=true) - let src_result = find_duplicates(&*db, "default", None, false, true, false) + let src_result = find_duplicates(&*db, None, false, true, false) .expect("Query should succeed"); // Find validate duplicate (source mode) @@ -374,7 +373,7 @@ mod tests { fn test_find_duplicates_module_filter_excludes_non_matching() { let db = get_db(); // Service has source duplicates (not AST), so use_exact=true - let result = find_duplicates(&*db, "default", Some("Service"), false, true, false) + let result = find_duplicates(&*db, Some("Service"), false, true, false) .expect("Query should succeed"); // Should find Service validate duplicates @@ -389,7 +388,7 @@ mod tests { #[test] fn test_find_duplicates_nonexistent_module_returns_empty() { let db = get_db(); - let result = find_duplicates(&*db, "default", Some("NonExistent"), false, false, false) + let result = find_duplicates(&*db, Some("NonExistent"), false, false, false) .expect("Query should succeed"); assert_eq!(result.len(), 0, "Should return empty for non-existent module"); @@ -399,9 +398,9 @@ mod tests { fn test_find_duplicates_ast_and_source_mutually_exclusive() { let db = get_db(); - let ast_dups = find_duplicates(&*db, "default", None, false, false, false) + let ast_dups = find_duplicates(&*db, None, false, false, false) .expect("Query should succeed"); - let source_dups = find_duplicates(&*db, "default", None, false, true, false) + let source_dups = find_duplicates(&*db, None, false, true, false) .expect("Query should succeed"); // AST should return 4, source should return 2 diff --git a/db/src/queries/file.rs b/db/src/queries/file.rs index be79ff4..62e1808 100644 --- a/db/src/queries/file.rs +++ b/db/src/queries/file.rs @@ -32,7 +32,6 @@ pub struct FileFunctionDef { pub fn find_functions_in_module( db: &dyn Database, module_pattern: &str, - _project: &str, use_regex: bool, limit: u32, ) -> Result, Box> { @@ -138,7 +137,7 @@ mod tests { let db = crate::test_utils::surreal_call_graph_db_complex(); // Invalid regex pattern: unclosed bracket - let result = find_functions_in_module(&*db, "[invalid", "default", true, 100); + let result = find_functions_in_module(&*db, "[invalid", true, 100); assert!(result.is_err(), "Should reject invalid regex"); let err = result.unwrap_err(); @@ -160,7 +159,7 @@ mod tests { let db = crate::test_utils::surreal_call_graph_db_complex(); // Even invalid regex should work in non-regex mode (treated as literal string) - let result = find_functions_in_module(&*db, "[invalid", "default", false, 100); + let result = find_functions_in_module(&*db, "[invalid", false, 100); // Should succeed (no regex validation in non-regex mode) assert!( @@ -175,7 +174,7 @@ mod tests { let db = crate::test_utils::surreal_call_graph_db_complex(); // Search for exact module name without regex - let result = find_functions_in_module(&*db, "MyApp.Controller", "default", false, 100); + let result = find_functions_in_module(&*db, "MyApp.Controller", false, 100); assert!(result.is_ok(), "Query should succeed: {:?}", result.err()); let functions = result.unwrap(); @@ -205,7 +204,7 @@ mod tests { let db = crate::test_utils::surreal_call_graph_db_complex(); // Query all modules with regex pattern that matches all - let result = find_functions_in_module(&*db, ".*", "default", true, 100); + let result = find_functions_in_module(&*db, ".*", true, 100); assert!(result.is_ok(), "Query should succeed"); let functions = result.unwrap(); @@ -219,7 +218,7 @@ mod tests { let db = crate::test_utils::surreal_call_graph_db_complex(); // Test with limit=2 using regex to match all modules - let result = find_functions_in_module(&*db, ".*", "default", true, 2); + let result = find_functions_in_module(&*db, ".*", true, 2); assert!(result.is_ok(), "Query should succeed"); let functions = result.unwrap(); @@ -232,7 +231,7 @@ mod tests { let db = crate::test_utils::surreal_call_graph_db_complex(); // Test with limit=0 using regex pattern - let result = find_functions_in_module(&*db, ".*", "default", true, 0); + let result = find_functions_in_module(&*db, ".*", true, 0); assert!(result.is_ok(), "Query should succeed"); let functions = result.unwrap(); @@ -245,7 +244,7 @@ mod tests { let db = crate::test_utils::surreal_call_graph_db_complex(); // Search with regex pattern - let result = find_functions_in_module(&*db, "^module_.*$", "default", true, 100); + let result = find_functions_in_module(&*db, "^module_.*$", true, 100); assert!(result.is_ok(), "Query should succeed with valid regex"); let functions = result.unwrap(); @@ -265,7 +264,7 @@ mod tests { let db = crate::test_utils::surreal_call_graph_db_complex(); // Search for MyApp.Repo specifically - let result = find_functions_in_module(&*db, "MyApp.Repo", "default", false, 100); + let result = find_functions_in_module(&*db, "MyApp.Repo", false, 100); assert!(result.is_ok(), "Query should succeed"); let functions = result.unwrap(); @@ -287,7 +286,7 @@ mod tests { let db = crate::test_utils::surreal_call_graph_db_complex(); // Search for non-existent module - let result = find_functions_in_module(&*db, "nonexistent_module", "default", false, 100); + let result = find_functions_in_module(&*db, "nonexistent_module", false, 100); assert!(result.is_ok(), "Query should succeed but return empty"); let functions = result.unwrap(); @@ -304,7 +303,7 @@ mod tests { let db = crate::test_utils::surreal_call_graph_db_complex(); // Get all clauses using regex pattern - let result = find_functions_in_module(&*db, ".*", "default", true, 100); + let result = find_functions_in_module(&*db, ".*", true, 100); assert!(result.is_ok(), "Query should succeed"); let functions = result.unwrap(); @@ -332,7 +331,7 @@ mod tests { let db = crate::test_utils::surreal_call_graph_db_complex(); // Get clauses for a specific module to verify sorting using regex pattern - let result = find_functions_in_module(&*db, "MyApp.Accounts", "default", false, 100); + let result = find_functions_in_module(&*db, "MyApp.Accounts", false, 100); assert!(result.is_ok(), "Query should succeed"); let functions = result.unwrap(); @@ -366,7 +365,7 @@ mod tests { // Search with regex alternation pattern for Controller and Accounts let result = - find_functions_in_module(&*db, "MyApp\\.(Controller|Accounts)", "default", true, 100); + find_functions_in_module(&*db, "MyApp\\.(Controller|Accounts)", true, 100); assert!( result.is_ok(), @@ -395,7 +394,7 @@ mod tests { let db = crate::test_utils::surreal_call_graph_db_complex(); // Search with wrong case (should not match due to case sensitivity) - let result = find_functions_in_module(&*db, "myapp.controller", "default", false, 100); + let result = find_functions_in_module(&*db, "myapp.controller", false, 100); assert!(result.is_ok(), "Query should succeed"); let functions = result.unwrap(); @@ -413,7 +412,7 @@ mod tests { let db = crate::test_utils::surreal_call_graph_db_complex(); // Empty pattern in exact match mode should find no results - let result = find_functions_in_module(&*db, "", "default", false, 100); + let result = find_functions_in_module(&*db, "", false, 100); assert!(result.is_ok(), "Query should succeed"); let functions = result.unwrap(); @@ -431,7 +430,7 @@ mod tests { let db = crate::test_utils::surreal_call_graph_db_complex(); // Test with very large limit using regex pattern - let result = find_functions_in_module(&*db, ".*", "default", true, 1000); + let result = find_functions_in_module(&*db, ".*", true, 1000); assert!(result.is_ok(), "Query should succeed"); let functions = result.unwrap(); diff --git a/db/src/queries/function.rs b/db/src/queries/function.rs index 8f4a0d3..6e88cab 100644 --- a/db/src/queries/function.rs +++ b/db/src/queries/function.rs @@ -31,7 +31,6 @@ pub fn find_functions( module_pattern: &str, function_pattern: &str, arity: Option, - _project: &str, use_regex: bool, limit: u32, ) -> Result, Box> { @@ -136,7 +135,7 @@ mod tests { let db = crate::test_utils::surreal_call_graph_db_complex(); // Invalid regex pattern: unclosed bracket - let result = find_functions(&*db, "[invalid", "foo", None, "default", true, 100); + let result = find_functions(&*db, "[invalid", "foo", None, true, 100); assert!(result.is_err(), "Should reject invalid regex"); let err = result.unwrap_err(); @@ -153,7 +152,7 @@ mod tests { let db = crate::test_utils::surreal_call_graph_db_complex(); // Invalid regex pattern in function name: invalid repetition - let result = find_functions(&*db, "module_a", "*invalid", None, "default", true, 100); + let result = find_functions(&*db, "module_a", "*invalid", None, true, 100); assert!(result.is_err(), "Should reject invalid regex"); let err = result.unwrap_err(); @@ -170,7 +169,7 @@ mod tests { let db = crate::test_utils::surreal_call_graph_db_complex(); // Valid regex pattern should not error on validation - let result = find_functions(&*db, "^MyApp.*$", "^query$", None, "default", true, 100); + let result = find_functions(&*db, "^MyApp.*$", "^query$", None, true, 100); // Should not fail on validation assert!( @@ -185,7 +184,7 @@ mod tests { let db = crate::test_utils::surreal_call_graph_db_complex(); // Even invalid regex should work in non-regex mode (treated as literal string) - let result = find_functions(&*db, "[invalid", "foo", None, "default", false, 100); + let result = find_functions(&*db, "[invalid", "foo", None, false, 100); // Should succeed (no regex validation in non-regex mode) assert!( @@ -207,7 +206,6 @@ mod tests { "MyApp.Controller", "index", None, - "default", false, 100, ); @@ -233,7 +231,6 @@ mod tests { "MyApp.Controller", "nonexistent", None, - "default", false, 100, ); @@ -256,7 +253,6 @@ mod tests { "nonexistent_module", "index", None, - "default", false, 100, ); @@ -279,7 +275,6 @@ mod tests { "MyApp.Accounts", "get_user", Some(1), - "default", false, 100, ); @@ -307,7 +302,6 @@ mod tests { "MyApp.Controller", "index", Some(5), - "default", false, 100, ); @@ -327,8 +321,8 @@ mod tests { let db = crate::test_utils::surreal_call_graph_db_complex(); // Use wildcard patterns to match all functions - let limit_1 = find_functions(&*db, ".*", ".*", None, "default", true, 1).unwrap(); - let limit_100 = find_functions(&*db, ".*", ".*", None, "default", true, 100).unwrap(); + let limit_1 = find_functions(&*db, ".*", ".*", None, true, 1).unwrap(); + let limit_100 = find_functions(&*db, ".*", ".*", None, true, 100).unwrap(); assert!(limit_1.len() <= 1, "Limit should be respected"); assert!( @@ -342,7 +336,7 @@ mod tests { let db = crate::test_utils::surreal_call_graph_db_complex(); // Test with zero limit (use wildcard patterns) - let result = find_functions(&*db, ".*", ".*", None, "default", true, 0); + let result = find_functions(&*db, ".*", ".*", None, true, 0); assert!(result.is_ok(), "Should handle zero limit"); let functions = result.unwrap(); @@ -354,7 +348,7 @@ mod tests { let db = crate::test_utils::surreal_call_graph_db_complex(); // Test with large limit (larger than fixture size, use wildcard patterns) - let result = find_functions(&*db, ".*", ".*", None, "default", true, 1000000); + let result = find_functions(&*db, ".*", ".*", None, true, 1000000); assert!(result.is_ok(), "Should handle large limit"); let functions = result.unwrap(); @@ -370,7 +364,7 @@ mod tests { let db = crate::test_utils::surreal_call_graph_db_complex(); // Regex pattern that matches all functions - let result = find_functions(&*db, ".*", ".*", None, "default", true, 100); + let result = find_functions(&*db, ".*", ".*", None, true, 100); assert!(result.is_ok(), "Should match all functions with .*"); let functions = result.unwrap(); @@ -389,7 +383,6 @@ mod tests { "MyApp.Accounts", "^(get_user|list_users)", None, - "default", true, 100, ); @@ -409,7 +402,7 @@ mod tests { let db = crate::test_utils::surreal_call_graph_db_complex(); // Test with character class - matches anything starting with 's' in Notifier - let result = find_functions(&*db, "MyApp.Notifier", "^s.*", None, "default", true, 100); + let result = find_functions(&*db, "MyApp.Notifier", "^s.*", None, true, 100); assert!(result.is_ok(), "Should handle character class regex"); let functions = result.unwrap(); @@ -426,7 +419,7 @@ mod tests { let db = crate::test_utils::surreal_call_graph_db_complex(); // Search for functions in MyApp.Controller matching pattern with wildcard function pattern - let result = find_functions(&*db, "MyApp.Controller", ".*", None, "default", true, 100); + let result = find_functions(&*db, "MyApp.Controller", ".*", None, true, 100); assert!(result.is_ok()); let functions = result.unwrap(); @@ -450,7 +443,7 @@ mod tests { let db = crate::test_utils::surreal_call_graph_db_complex(); // Use wildcard patterns to get all functions - let result = find_functions(&*db, ".*", ".*", None, "default", true, 100); + let result = find_functions(&*db, ".*", ".*", None, true, 100); assert!(result.is_ok(), "Query should succeed"); let functions = result.unwrap(); @@ -473,7 +466,6 @@ mod tests { "MyApp.Controller", "index", None, - "default", false, 100, ); @@ -500,7 +492,7 @@ mod tests { let db = crate::test_utils::surreal_call_graph_db_complex(); // Use wildcard patterns to get all functions - let result = find_functions(&*db, ".*", ".*", None, "default", true, 100); + let result = find_functions(&*db, ".*", ".*", None, true, 100); assert!(result.is_ok()); let functions = result.unwrap(); @@ -521,7 +513,7 @@ mod tests { let db = crate::test_utils::surreal_call_graph_db_complex(); // Use wildcard patterns to get all functions - let result = find_functions(&*db, ".*", ".*", None, "default", true, 100); + let result = find_functions(&*db, ".*", ".*", None, true, 100); assert!(result.is_ok()); let functions = result.unwrap(); @@ -545,8 +537,8 @@ mod tests { let db = crate::test_utils::surreal_call_graph_db_complex(); // Multiple calls should return results in consistent order - let result1 = find_functions(&*db, ".*", ".*", None, "default", true, 100).unwrap(); - let result2 = find_functions(&*db, ".*", ".*", None, "default", true, 100).unwrap(); + let result1 = find_functions(&*db, ".*", ".*", None, true, 100).unwrap(); + let result2 = find_functions(&*db, ".*", ".*", None, true, 100).unwrap(); // Results should be identical assert_eq!(result1.len(), result2.len()); @@ -569,7 +561,6 @@ mod tests { "MyApp.Controller", "index", None, - "default", false, 100, ); @@ -578,7 +569,6 @@ mod tests { "MyApp.Controller", "INDEX", None, - "default", false, 100, ); @@ -604,9 +594,9 @@ mod tests { // Search should be case sensitive for module names (use wildcard function pattern) let result_correct = - find_functions(&*db, "MyApp.Controller", ".*", None, "default", true, 100); + find_functions(&*db, "MyApp.Controller", ".*", None, true, 100); let result_lower = - find_functions(&*db, "myapp.controller", ".*", None, "default", true, 100); + find_functions(&*db, "myapp.controller", ".*", None, true, 100); assert!(result_correct.is_ok()); assert!(result_lower.is_ok()); @@ -633,7 +623,7 @@ mod tests { let db = crate::test_utils::surreal_call_graph_db_complex(); // Empty patterns in exact match mode - should match nothing typically - let result = find_functions(&*db, "", "", None, "default", false, 100); + let result = find_functions(&*db, "", "", None, false, 100); assert!(result.is_ok(), "Should handle empty pattern"); let functions = result.unwrap(); @@ -651,7 +641,6 @@ mod tests { "MyApp.Accounts", "get_user", Some(2), - "default", false, 100, ); @@ -676,7 +665,6 @@ mod tests { "MyApp.Accounts", "list_users", Some(0), - "default", false, 100, ); @@ -695,7 +683,7 @@ mod tests { let db = crate::test_utils::surreal_call_graph_db_complex(); // Use wildcard patterns to get all functions - let result = find_functions(&*db, ".*", ".*", None, "default", true, 100); + let result = find_functions(&*db, ".*", ".*", None, true, 100); assert!(result.is_ok()); let functions = result.unwrap(); @@ -711,7 +699,7 @@ mod tests { fn test_find_functions_args_field_present() { let db = crate::test_utils::surreal_call_graph_db_complex(); - let result = find_functions(&*db, "module_a", "foo", None, "default", false, 100); + let result = find_functions(&*db, "module_a", "foo", None, false, 100); assert!(result.is_ok()); let functions = result.unwrap(); diff --git a/db/src/queries/hotspots.rs b/db/src/queries/hotspots.rs index 36e5f16..40c921e 100644 --- a/db/src/queries/hotspots.rs +++ b/db/src/queries/hotspots.rs @@ -43,7 +43,6 @@ pub struct Hotspot { /// Get lines of code per module (sum of function line counts) pub fn get_module_loc( db: &dyn Database, - _project: &str, module_pattern: Option<&str>, use_regex: bool, ) -> Result, Box> { @@ -97,7 +96,6 @@ pub fn get_module_loc( /// Get function count per module pub fn get_function_counts( db: &dyn Database, - _project: &str, module_pattern: Option<&str>, use_regex: bool, ) -> Result, Box> { @@ -160,7 +158,6 @@ pub fn get_function_counts( /// avoiding the need to fetch all function hotspots. pub fn get_module_connectivity( db: &dyn Database, - _project: &str, module_pattern: Option<&str>, use_regex: bool, ) -> Result, Box> { @@ -241,7 +238,6 @@ pub fn find_hotspots( db: &dyn Database, kind: HotspotKind, module_pattern: Option<&str>, - _project: &str, use_regex: bool, limit: u32, _exclude_generated: bool, @@ -402,7 +398,7 @@ mod tests { #[test] fn test_get_function_counts_exact_module_count() { let db = get_db(); - let counts = get_function_counts(&*db, "default", None, false) + let counts = get_function_counts(&*db, None, false) .expect("Query should succeed"); // 9 modules: Controller, Accounts, Service, Repo, Notifier, Logger, Events, Cache, Metrics @@ -412,7 +408,7 @@ mod tests { #[test] fn test_get_function_counts_exact_values_per_module() { let db = get_db(); - let counts = get_function_counts(&*db, "default", None, false) + let counts = get_function_counts(&*db, None, false) .expect("Query should succeed"); // Verify exact function counts per module from fixture @@ -466,7 +462,7 @@ mod tests { #[test] fn test_get_function_counts_total_is_thirtyone() { let db = get_db(); - let counts = get_function_counts(&*db, "default", None, false) + let counts = get_function_counts(&*db, None, false) .expect("Query should succeed"); let total: i64 = counts.values().sum(); @@ -476,7 +472,7 @@ mod tests { #[test] fn test_get_function_counts_controller_pattern() { let db = get_db(); - let counts = get_function_counts(&*db, "default", Some("MyApp.Controller"), false) + let counts = get_function_counts(&*db, Some("MyApp.Controller"), false) .expect("Query should succeed"); assert_eq!(counts.len(), 1, "Should match exactly 1 module"); @@ -490,7 +486,7 @@ mod tests { #[test] fn test_get_function_counts_regex_pattern() { let db = get_db(); - let counts = get_function_counts(&*db, "default", Some("^MyApp\\.Accounts$"), true) + let counts = get_function_counts(&*db, Some("^MyApp\\.Accounts$"), true) .expect("Query should succeed"); assert_eq!(counts.len(), 1, "Should match exactly 1 module"); @@ -504,7 +500,7 @@ mod tests { #[test] fn test_get_function_counts_nonexistent_module() { let db = get_db(); - let counts = get_function_counts(&*db, "default", Some("NonExistent"), false) + let counts = get_function_counts(&*db, Some("NonExistent"), false) .expect("Query should succeed"); assert!(counts.is_empty(), "Should return empty for non-existent module"); @@ -513,7 +509,7 @@ mod tests { #[test] fn test_get_function_counts_invalid_regex() { let db = get_db(); - let result = get_function_counts(&*db, "default", Some("[invalid"), true); + let result = get_function_counts(&*db, Some("[invalid"), true); assert!(result.is_err(), "Should reject invalid regex pattern"); let err = result.unwrap_err(); @@ -532,7 +528,7 @@ mod tests { #[test] fn test_get_module_loc_returns_module_count() { let db = get_db(); - let loc_map = get_module_loc(&*db, "default", None, false) + let loc_map = get_module_loc(&*db, None, false) .expect("Query should succeed"); // 9 modules should have LOC data @@ -542,7 +538,7 @@ mod tests { #[test] fn test_get_module_loc_exact_values() { let db = get_db(); - let loc_map = get_module_loc(&*db, "default", None, false) + let loc_map = get_module_loc(&*db, None, false) .expect("Query should succeed"); // Each clause has LOC=1, so module LOC = number of clauses @@ -561,7 +557,7 @@ mod tests { #[test] fn test_get_module_loc_with_pattern() { let db = get_db(); - let loc_map = get_module_loc(&*db, "default", Some("MyApp.Accounts"), false) + let loc_map = get_module_loc(&*db, Some("MyApp.Accounts"), false) .expect("Query should succeed"); assert_eq!(loc_map.len(), 1, "Should match exactly 1 module"); @@ -571,7 +567,7 @@ mod tests { #[test] fn test_get_module_loc_invalid_regex() { let db = get_db(); - let result = get_module_loc(&*db, "default", Some("[invalid"), true); + let result = get_module_loc(&*db, Some("[invalid"), true); assert!(result.is_err(), "Should reject invalid regex pattern"); } @@ -582,7 +578,7 @@ mod tests { #[test] fn test_get_module_connectivity_exact_module_count() { let db = get_db(); - let connectivity = get_module_connectivity(&*db, "default", None, false) + let connectivity = get_module_connectivity(&*db, None, false) .expect("Query should succeed"); // 9 modules: Controller, Accounts, Service, Repo, Notifier, Logger, Events, Cache, Metrics @@ -592,7 +588,7 @@ mod tests { #[test] fn test_get_module_connectivity_controller_values() { let db = get_db(); - let connectivity = get_module_connectivity(&*db, "default", None, false) + let connectivity = get_module_connectivity(&*db, None, false) .expect("Query should succeed"); // Controller: 1 incoming unique module (Accounts) @@ -613,7 +609,7 @@ mod tests { #[test] fn test_get_module_connectivity_accounts_values() { let db = get_db(); - let connectivity = get_module_connectivity(&*db, "default", None, false) + let connectivity = get_module_connectivity(&*db, None, false) .expect("Query should succeed"); // Accounts: 4 unique incoming modules (Controller, Service, Cache, self) @@ -634,7 +630,7 @@ mod tests { #[test] fn test_get_module_connectivity_service_values() { let db = get_db(); - let connectivity = get_module_connectivity(&*db, "default", None, false) + let connectivity = get_module_connectivity(&*db, None, false) .expect("Query should succeed"); // Service: called by Controller, Repo (insert->get_context) @@ -652,7 +648,7 @@ mod tests { #[test] fn test_get_module_connectivity_repo_values() { let db = get_db(); - let connectivity = get_module_connectivity(&*db, "default", None, false) + let connectivity = get_module_connectivity(&*db, None, false) .expect("Query should succeed"); // Repo: 3 unique incoming modules (Accounts, Logger, self) @@ -670,7 +666,7 @@ mod tests { #[test] fn test_get_module_connectivity_notifier_values() { let db = get_db(); - let connectivity = get_module_connectivity(&*db, "default", None, false) + let connectivity = get_module_connectivity(&*db, None, false) .expect("Query should succeed"); // Notifier: called by Service, Controller, Notifier (self), Cache (store->on_cache_update) @@ -692,7 +688,7 @@ mod tests { fn test_get_module_connectivity_with_pattern() { let db = get_db(); let connectivity = - get_module_connectivity(&*db, "default", Some("MyApp.Controller"), false) + get_module_connectivity(&*db, Some("MyApp.Controller"), false) .expect("Query should succeed"); assert_eq!(connectivity.len(), 1, "Should match exactly 1 module"); @@ -707,7 +703,7 @@ mod tests { fn test_get_module_connectivity_nonexistent_module() { let db = get_db(); let connectivity = - get_module_connectivity(&*db, "default", Some("NonExistent"), false) + get_module_connectivity(&*db, Some("NonExistent"), false) .expect("Query should succeed"); assert!( @@ -719,7 +715,7 @@ mod tests { #[test] fn test_get_module_connectivity_invalid_regex() { let db = get_db(); - let result = get_module_connectivity(&*db, "default", Some("[invalid"), true); + let result = get_module_connectivity(&*db, Some("[invalid"), true); assert!(result.is_err(), "Should reject invalid regex pattern"); } @@ -729,9 +725,9 @@ mod tests { #[test] fn test_function_counts_matches_connectivity_modules() { let db = get_db(); - let counts = get_function_counts(&*db, "default", None, false) + let counts = get_function_counts(&*db, None, false) .expect("Function counts query should succeed"); - let connectivity = get_module_connectivity(&*db, "default", None, false) + let connectivity = get_module_connectivity(&*db, None, false) .expect("Connectivity query should succeed"); // Both queries should return the same set of modules @@ -753,9 +749,9 @@ mod tests { #[test] fn test_all_modules_present_in_both_queries() { let db = get_db(); - let counts = get_function_counts(&*db, "default", None, false) + let counts = get_function_counts(&*db, None, false) .expect("Query should succeed"); - let connectivity = get_module_connectivity(&*db, "default", None, false) + let connectivity = get_module_connectivity(&*db, None, false) .expect("Query should succeed"); let expected_modules = [ @@ -793,7 +789,6 @@ mod tests { &*db, HotspotKind::Incoming, None, - "default", false, 100, false, @@ -810,7 +805,6 @@ mod tests { &*db, HotspotKind::Total, None, - "default", false, 100, false, @@ -851,7 +845,6 @@ mod tests { &*db, HotspotKind::Incoming, None, - "default", false, 100, false, @@ -880,7 +873,6 @@ mod tests { &*db, HotspotKind::Incoming, None, - "default", false, 100, false, @@ -903,7 +895,6 @@ mod tests { &*db, HotspotKind::Outgoing, None, - "default", false, 100, false, @@ -926,7 +917,6 @@ mod tests { &*db, HotspotKind::Total, None, - "default", false, 100, false, @@ -949,7 +939,6 @@ mod tests { &*db, HotspotKind::Ratio, None, - "default", false, 100, false, @@ -974,7 +963,6 @@ mod tests { &*db, HotspotKind::Incoming, None, - "default", false, 5, false, @@ -985,7 +973,6 @@ mod tests { &*db, HotspotKind::Incoming, None, - "default", false, 100, false, @@ -1003,7 +990,6 @@ mod tests { &*db, HotspotKind::Incoming, Some("MyApp.Controller"), - "default", false, 100, false, @@ -1027,7 +1013,6 @@ mod tests { &*db, HotspotKind::Incoming, Some("^MyApp\\.Accounts$"), - "default", true, // use_regex = true 100, false, @@ -1051,7 +1036,6 @@ mod tests { &*db, HotspotKind::Incoming, Some("[invalid"), - "default", true, // use_regex = true 100, false, @@ -1068,7 +1052,6 @@ mod tests { &*db, HotspotKind::Incoming, None, - "default", false, 100, false, @@ -1079,7 +1062,6 @@ mod tests { &*db, HotspotKind::Incoming, None, - "default", false, 100, false, @@ -1107,7 +1089,6 @@ mod tests { &*db, HotspotKind::Incoming, Some("NonExistentModule"), - "default", false, 100, false, @@ -1124,7 +1105,6 @@ mod tests { &*db, HotspotKind::Ratio, None, - "default", false, 100, false, diff --git a/db/src/queries/import.rs b/db/src/queries/import.rs index 3fa47d1..24c22ce 100644 --- a/db/src/queries/import.rs +++ b/db/src/queries/import.rs @@ -66,7 +66,7 @@ pub fn create_schema(db: &dyn Database) -> Result> /// Clear all project data from SurrealDB /// Since SurrealDB is per-project, we delete all records from all tables -pub fn clear_project_data(db: &dyn Database, _project: &str) -> Result<(), Box> { +pub fn clear_project_data(db: &dyn Database) -> Result<(), Box> { let tables = [ "modules", "functions", @@ -93,7 +93,6 @@ pub fn clear_project_data(db: &dyn Database, _project: &str) -> Result<(), Box Result> { // Collect unique modules from all data sources @@ -121,7 +120,6 @@ pub fn import_modules( /// linked via name/arity matching, not imported as separate function records. pub fn import_functions( db: &dyn Database, - _project: &str, graph: &CallGraph, ) -> Result> { use std::collections::HashSet; @@ -169,7 +167,6 @@ pub fn import_functions( /// Import calls to SurrealDB pub fn import_calls( db: &dyn Database, - _project: &str, graph: &CallGraph, ) -> Result> { let mut count = 0; @@ -262,7 +259,6 @@ fn parse_function_ref(func_ref: &str) -> (&str, i64) { /// Import structs to SurrealDB (as fields) pub fn import_structs( db: &dyn Database, - _project: &str, graph: &CallGraph, ) -> Result> { let mut count = 0; @@ -292,7 +288,6 @@ pub fn import_structs( /// Import function locations to SurrealDB (as clauses) pub fn import_function_locations( db: &dyn Database, - _project: &str, graph: &CallGraph, ) -> Result> { let mut count = 0; @@ -351,7 +346,6 @@ pub fn import_function_locations( /// Import specs to SurrealDB with array fields preserved pub fn import_specs( db: &dyn Database, - _project: &str, graph: &CallGraph, ) -> Result> { let mut count = 0; @@ -395,7 +389,6 @@ pub fn import_specs( /// Import types to SurrealDB pub fn import_types( db: &dyn Database, - _project: &str, graph: &CallGraph, ) -> Result> { let mut count = 0; @@ -548,20 +541,19 @@ pub fn create_has_field_relationships( /// This is the core import logic used by both the CLI command and test utilities. pub fn import_graph( db: &dyn Database, - project: &str, graph: &CallGraph, ) -> Result> { let mut result = ImportResult::default(); result.schemas = create_schema(db)?; - result.modules_imported = import_modules(db, project, graph)?; - result.functions_imported = import_functions(db, project, graph)?; + result.modules_imported = import_modules(db, graph)?; + result.functions_imported = import_functions(db, graph)?; // Import function_locations (clauses) BEFORE calls so caller_clause_id lookup works - result.function_locations_imported = import_function_locations(db, project, graph)?; - result.calls_imported = import_calls(db, project, graph)?; - result.structs_imported = import_structs(db, project, graph)?; - result.specs_imported = import_specs(db, project, graph)?; - result.types_imported = import_types(db, project, graph)?; + result.function_locations_imported = import_function_locations(db, graph)?; + result.calls_imported = import_calls(db, graph)?; + result.structs_imported = import_structs(db, graph)?; + result.specs_imported = import_specs(db, graph)?; + result.types_imported = import_types(db, graph)?; // Create relationships create_defines_relationships(db, graph)?; @@ -581,14 +573,13 @@ pub fn import_graph( pub fn import_json_str( db: &dyn Database, content: &str, - project: &str, ) -> Result> { let graph: CallGraph = serde_json::from_str(content).map_err(|e| ImportError::JsonParseFailed { message: e.to_string(), })?; - import_graph(db, project, &graph) + import_graph(db, &graph) } #[cfg(test)] @@ -643,7 +634,7 @@ mod tests { }"#; let graph: CallGraph = serde_json::from_str(json).unwrap(); - let result = import_modules(&*db, "test_project", &graph); + let result = import_modules(&*db, &graph); assert!(result.is_ok(), "Import should succeed: {:?}", result.err()); assert_eq!(result.unwrap(), 2, "Should import exactly 2 modules"); @@ -688,8 +679,8 @@ mod tests { }"#; let graph: CallGraph = serde_json::from_str(json).unwrap(); - import_modules(&*db, "test_project", &graph).unwrap(); - let result = import_functions(&*db, "test_project", &graph); + import_modules(&*db, &graph).unwrap(); + let result = import_functions(&*db, &graph); assert!(result.is_ok()); assert_eq!( result.unwrap(), @@ -734,9 +725,9 @@ mod tests { }"#; let graph: CallGraph = serde_json::from_str(json).unwrap(); - import_modules(&*db, "test_project", &graph).unwrap(); - import_functions(&*db, "test_project", &graph).unwrap(); - let result = import_specs(&*db, "test_project", &graph); + import_modules(&*db, &graph).unwrap(); + import_functions(&*db, &graph).unwrap(); + let result = import_specs(&*db, &graph); assert!( result.is_ok(), "Import specs should succeed: {:?}", @@ -796,7 +787,7 @@ mod tests { }"#; let graph: CallGraph = serde_json::from_str(json).unwrap(); - let result = import_function_locations(&*db, "test_project", &graph); + let result = import_function_locations(&*db, &graph); assert!(result.is_ok()); assert_eq!(result.unwrap(), 1, "Should import 1 clause"); @@ -828,8 +819,8 @@ mod tests { }"#; let graph: CallGraph = serde_json::from_str(json).unwrap(); - import_modules(&*db, "test_project", &graph).unwrap(); - let result = import_structs(&*db, "test_project", &graph); + import_modules(&*db, &graph).unwrap(); + let result = import_structs(&*db, &graph); assert!(result.is_ok()); assert_eq!(result.unwrap(), 2, "Should import 2 fields"); @@ -871,8 +862,8 @@ mod tests { }"#; let graph: CallGraph = serde_json::from_str(json).unwrap(); - import_modules(&*db, "test_project", &graph).unwrap(); - let result = import_types(&*db, "test_project", &graph); + import_modules(&*db, &graph).unwrap(); + let result = import_types(&*db, &graph); assert!(result.is_ok()); assert_eq!(result.unwrap(), 2, "Should import 2 types"); @@ -907,9 +898,9 @@ mod tests { // Clear and set up fresh let db_fresh = crate::open_mem_db().unwrap(); crate::queries::schema::create_schema(&*db_fresh).unwrap(); - import_modules(&*db_fresh, "test_project", &graph).unwrap(); - import_functions(&*db_fresh, "test_project", &graph).unwrap(); - import_types(&*db_fresh, "test_project", &graph).unwrap(); + import_modules(&*db_fresh, &graph).unwrap(); + import_functions(&*db_fresh, &graph).unwrap(); + import_types(&*db_fresh, &graph).unwrap(); let result = create_defines_relationships(&*db_fresh, &graph); assert!( @@ -954,9 +945,9 @@ mod tests { }"#; let graph: CallGraph = serde_json::from_str(json).unwrap(); - import_modules(&*db, "test_project", &graph).unwrap(); - import_functions(&*db, "test_project", &graph).unwrap(); - import_function_locations(&*db, "test_project", &graph).unwrap(); + import_modules(&*db, &graph).unwrap(); + import_functions(&*db, &graph).unwrap(); + import_function_locations(&*db, &graph).unwrap(); let result = create_has_clause_relationships(&*db, &graph); assert!(result.is_ok()); @@ -989,8 +980,8 @@ mod tests { }"#; let graph: CallGraph = serde_json::from_str(json).unwrap(); - import_modules(&*db, "test_project", &graph).unwrap(); - import_structs(&*db, "test_project", &graph).unwrap(); + import_modules(&*db, &graph).unwrap(); + import_structs(&*db, &graph).unwrap(); let result = create_has_field_relationships(&*db, &graph); assert!(result.is_ok()); @@ -1032,9 +1023,9 @@ mod tests { }"#; let graph: CallGraph = serde_json::from_str(json).unwrap(); - import_modules(&*db, "test_project", &graph).unwrap(); - import_functions(&*db, "test_project", &graph).unwrap(); - import_function_locations(&*db, "test_project", &graph).unwrap(); + import_modules(&*db, &graph).unwrap(); + import_functions(&*db, &graph).unwrap(); + import_function_locations(&*db, &graph).unwrap(); // Verify data was imported let query = "SELECT COUNT() FROM modules"; @@ -1045,7 +1036,7 @@ mod tests { ); // Clear data - let clear_result = clear_project_data(&*db, "test_project"); + let clear_result = clear_project_data(&*db); assert!( clear_result.is_ok(), "Clear should succeed: {:?}", @@ -1125,11 +1116,11 @@ mod tests { }"#; let graph: CallGraph = serde_json::from_str(json).unwrap(); - import_modules(&*db, "test_project", &graph).unwrap(); - import_functions(&*db, "test_project", &graph).unwrap(); - import_function_locations(&*db, "test_project", &graph).unwrap(); + import_modules(&*db, &graph).unwrap(); + import_functions(&*db, &graph).unwrap(); + import_function_locations(&*db, &graph).unwrap(); - let result = import_calls(&*db, "test_project", &graph); + let result = import_calls(&*db, &graph); assert!( result.is_ok(), "Import calls should succeed: {:?}", @@ -1191,7 +1182,7 @@ mod tests { }"#; let graph: CallGraph = serde_json::from_str(json).unwrap(); - let result = import_graph(&*db, "test_project", &graph); + let result = import_graph(&*db, &graph); assert!(result.is_ok(), "Import should succeed: {:?}", result.err()); let import_result = result.unwrap(); @@ -1244,7 +1235,7 @@ mod tests { }"#; let graph: CallGraph = serde_json::from_str(json).unwrap(); - let result = import_graph(&*db, "test_project", &graph); + let result = import_graph(&*db, &graph); assert!(result.is_ok(), "Import should succeed: {:?}", result.err()); // Verify call counts were updated during import @@ -1333,10 +1324,10 @@ mod tests { }"#; let graph: CallGraph = serde_json::from_str(json).unwrap(); - import_modules(&*db, "test_project", &graph).unwrap(); - import_functions(&*db, "test_project", &graph).unwrap(); - import_function_locations(&*db, "test_project", &graph).unwrap(); - import_calls(&*db, "test_project", &graph).unwrap(); + import_modules(&*db, &graph).unwrap(); + import_functions(&*db, &graph).unwrap(); + import_function_locations(&*db, &graph).unwrap(); + import_calls(&*db, &graph).unwrap(); // Before update_call_counts, all counts should be 0 // Note: SurrealDB returns columns in alphabetical order, so: @@ -1432,10 +1423,10 @@ mod tests { }"#; let graph: CallGraph = serde_json::from_str(json).unwrap(); - import_modules(&*db, "test_project", &graph).unwrap(); - import_functions(&*db, "test_project", &graph).unwrap(); - import_function_locations(&*db, "test_project", &graph).unwrap(); - import_calls(&*db, "test_project", &graph).unwrap(); + import_modules(&*db, &graph).unwrap(); + import_functions(&*db, &graph).unwrap(); + import_function_locations(&*db, &graph).unwrap(); + import_calls(&*db, &graph).unwrap(); // Run update_call_counts update_call_counts(&*db).unwrap(); @@ -1492,9 +1483,9 @@ mod tests { }"#; let graph: CallGraph = serde_json::from_str(json).unwrap(); - import_modules(&*db, "test_project", &graph).unwrap(); - import_functions(&*db, "test_project", &graph).unwrap(); - import_function_locations(&*db, "test_project", &graph).unwrap(); + import_modules(&*db, &graph).unwrap(); + import_functions(&*db, &graph).unwrap(); + import_function_locations(&*db, &graph).unwrap(); // Run update_call_counts - should not error even with no calls let result = update_call_counts(&*db); diff --git a/db/src/queries/large_functions.rs b/db/src/queries/large_functions.rs index 25ffed3..a2e41e5 100644 --- a/db/src/queries/large_functions.rs +++ b/db/src/queries/large_functions.rs @@ -30,7 +30,6 @@ pub fn find_large_functions( db: &dyn Database, min_lines: i64, module_pattern: Option<&str>, - _project: &str, use_regex: bool, include_generated: bool, limit: u32, @@ -136,7 +135,7 @@ mod tests { #[test] fn test_find_large_functions_returns_results() { let db = get_db(); - let result = find_large_functions(&*db, 0, None, "default", false, true, 100); + let result = find_large_functions(&*db, 0, None, false, true, 100); assert!(result.is_ok(), "Query should succeed: {:?}", result.err()); let functions = result.unwrap(); @@ -146,7 +145,7 @@ mod tests { #[test] fn test_find_large_functions_returns_exact_count() { let db = get_db(); - let functions = find_large_functions(&*db, 0, None, "default", false, true, 100) + let functions = find_large_functions(&*db, 0, None, false, true, 100) .expect("Query should succeed"); // The complex fixture has 44 clauses total with varying sizes @@ -161,7 +160,7 @@ mod tests { #[test] fn test_find_large_functions_calculates_lines_correctly() { let db = get_db(); - let functions = find_large_functions(&*db, 0, None, "default", false, true, 100) + let functions = find_large_functions(&*db, 0, None, false, true, 100) .expect("Query should succeed"); for func in &functions { @@ -177,7 +176,7 @@ mod tests { #[test] fn test_find_large_functions_all_modules_present() { let db = get_db(); - let functions = find_large_functions(&*db, 0, None, "default", false, true, 100) + let functions = find_large_functions(&*db, 0, None, false, true, 100) .expect("Query should succeed"); let modules: std::collections::HashSet<_> = functions.iter().map(|f| f.module.as_str()).collect(); @@ -197,7 +196,7 @@ mod tests { #[test] fn test_find_large_functions_respects_min_lines_threshold() { let db = get_db(); - let functions = find_large_functions(&*db, 10, None, "default", false, true, 100) + let functions = find_large_functions(&*db, 10, None, false, true, 100) .expect("Query should succeed"); for func in &functions { @@ -213,7 +212,7 @@ mod tests { #[test] fn test_find_large_functions_with_moderate_min_lines() { let db = get_db(); - let functions = find_large_functions(&*db, 2, None, "default", false, true, 100) + let functions = find_large_functions(&*db, 2, None, false, true, 100) .expect("Query should succeed"); // Fixture has clauses with 1 line each (start_line == end_line) @@ -227,7 +226,7 @@ mod tests { #[test] fn test_find_large_functions_empty_with_very_high_threshold() { let db = get_db(); - let functions = find_large_functions(&*db, 1000, None, "default", false, true, 100) + let functions = find_large_functions(&*db, 1000, None, false, true, 100) .expect("Query should succeed"); assert!( @@ -245,7 +244,6 @@ mod tests { &*db, 0, Some("MyApp.Controller"), - "default", false, true, 100, @@ -268,7 +266,7 @@ mod tests { #[test] fn test_find_large_functions_with_regex_module_filter() { let db = get_db(); - let functions = find_large_functions(&*db, 0, Some("^MyApp\\.Acc.*"), "default", true, true, 100) + let functions = find_large_functions(&*db, 0, Some("^MyApp\\.Acc.*"), true, true, 100) .expect("Query should succeed"); for func in &functions { @@ -286,7 +284,6 @@ mod tests { &*db, 0, Some("NonExistentModule"), - "default", false, true, 100, @@ -302,7 +299,7 @@ mod tests { #[test] fn test_find_large_functions_regex_pattern_invalid() { let db = get_db(); - let result = find_large_functions(&*db, 0, Some("[invalid"), "default", true, true, 100); + let result = find_large_functions(&*db, 0, Some("[invalid"), true, true, 100); assert!( result.is_err(), @@ -315,9 +312,9 @@ mod tests { #[test] fn test_find_large_functions_include_generated_true() { let db = get_db(); - let with_generated = find_large_functions(&*db, 0, None, "default", false, true, 100) + let with_generated = find_large_functions(&*db, 0, None, false, true, 100) .expect("Query should succeed"); - let without_generated = find_large_functions(&*db, 0, None, "default", false, false, 100) + let without_generated = find_large_functions(&*db, 0, None, false, false, 100) .expect("Query should succeed"); // with_generated should have >= results than without_generated @@ -330,7 +327,7 @@ mod tests { #[test] fn test_find_large_functions_exclude_generated() { let db = get_db(); - let functions = find_large_functions(&*db, 0, None, "default", false, false, 100) + let functions = find_large_functions(&*db, 0, None, false, false, 100) .expect("Query should succeed"); // When include_generated=false, all generated_by should be empty or None @@ -349,11 +346,11 @@ mod tests { #[test] fn test_find_large_functions_respects_limit() { let db = get_db(); - let functions_5 = find_large_functions(&*db, 0, None, "default", false, true, 5) + let functions_5 = find_large_functions(&*db, 0, None, false, true, 5) .expect("Query should succeed"); - let functions_10 = find_large_functions(&*db, 0, None, "default", false, true, 10) + let functions_10 = find_large_functions(&*db, 0, None, false, true, 10) .expect("Query should succeed"); - let functions_100 = find_large_functions(&*db, 0, None, "default", false, true, 100) + let functions_100 = find_large_functions(&*db, 0, None, false, true, 100) .expect("Query should succeed"); assert!(functions_5.len() <= 5, "Should respect limit of 5"); @@ -377,7 +374,7 @@ mod tests { #[test] fn test_find_large_functions_ordered_by_lines_desc() { let db = get_db(); - let functions = find_large_functions(&*db, 0, None, "default", false, true, 100) + let functions = find_large_functions(&*db, 0, None, false, true, 100) .expect("Query should succeed"); // Results should be ordered by lines descending @@ -398,7 +395,7 @@ mod tests { #[test] fn test_find_large_functions_all_fields_populated() { let db = get_db(); - let functions = find_large_functions(&*db, 0, None, "default", false, true, 100) + let functions = find_large_functions(&*db, 0, None, false, true, 100) .expect("Query should succeed"); assert!(!functions.is_empty(), "Should return results"); @@ -417,7 +414,7 @@ mod tests { #[test] fn test_find_large_functions_valid_arity_values() { let db = get_db(); - let functions = find_large_functions(&*db, 0, None, "default", false, true, 100) + let functions = find_large_functions(&*db, 0, None, false, true, 100) .expect("Query should succeed"); // Verify all arities are non-negative @@ -440,7 +437,7 @@ mod tests { #[test] fn test_find_large_functions_controller_functions() { let db = get_db(); - let functions = find_large_functions(&*db, 0, Some("MyApp.Controller"), "default", false, true, 100) + let functions = find_large_functions(&*db, 0, Some("MyApp.Controller"), false, true, 100) .expect("Query should succeed"); // Controller has 3 functions with 3 clauses total in fixture @@ -458,7 +455,7 @@ mod tests { #[test] fn test_find_large_functions_combined_filters() { let db = get_db(); - let functions = find_large_functions(&*db, 5, Some("MyApp.Accounts"), "default", false, true, 100) + let functions = find_large_functions(&*db, 5, Some("MyApp.Accounts"), false, true, 100) .expect("Query should succeed"); // Should apply both min_lines and module filters diff --git a/db/src/queries/location.rs b/db/src/queries/location.rs index 652be54..6ea2eae 100644 --- a/db/src/queries/location.rs +++ b/db/src/queries/location.rs @@ -34,7 +34,6 @@ pub fn find_locations( module_pattern: Option<&str>, function_pattern: &str, arity: Option, - _project: &str, use_regex: bool, limit: u32, ) -> Result, Box> { @@ -161,7 +160,7 @@ mod tests { let db = crate::test_utils::surreal_call_graph_db_complex(); // Invalid regex pattern: unclosed bracket - let result = find_locations(&*db, None, "[invalid", None, "default", true, 100); + let result = find_locations(&*db, None, "[invalid", None, true, 100); assert!(result.is_err(), "Should reject invalid regex"); let err = result.unwrap_err(); @@ -178,7 +177,7 @@ mod tests { let db = crate::test_utils::surreal_call_graph_db_complex(); // Invalid regex in module pattern - let result = find_locations(&*db, Some("[invalid"), "foo", None, "default", true, 100); + let result = find_locations(&*db, Some("[invalid"), "foo", None, true, 100); assert!(result.is_err(), "Should reject invalid regex"); let err = result.unwrap_err(); @@ -200,7 +199,6 @@ mod tests { Some("^module.*$"), "^foo$", None, - "default", true, 100, ); @@ -218,7 +216,7 @@ mod tests { let db = crate::test_utils::surreal_call_graph_db_complex(); // Even invalid regex should work in non-regex mode - let result = find_locations(&*db, Some("[invalid"), "foo", None, "default", false, 100); + let result = find_locations(&*db, Some("[invalid"), "foo", None, false, 100); // Should succeed (no regex validation in non-regex mode) assert!( @@ -240,7 +238,6 @@ mod tests { Some("MyApp.Controller"), "index", None, - "default", false, 100, ); @@ -272,7 +269,6 @@ mod tests { Some("MyApp.Controller"), "nonexistent", None, - "default", false, 100, ); @@ -295,7 +291,6 @@ mod tests { Some("nonexistent_module"), "index", None, - "default", false, 100, ); @@ -318,7 +313,6 @@ mod tests { Some("MyApp.Accounts"), "get_user", Some(1), - "default", false, 100, ); @@ -342,7 +336,6 @@ mod tests { Some("MyApp.Controller"), "index", Some(5), - "default", false, 100, ); @@ -362,7 +355,7 @@ mod tests { let db = crate::test_utils::surreal_call_graph_db_complex(); // Search without module filter - should find all occurrences of get_user - let result = find_locations(&*db, None, "get_user", None, "default", false, 100); + let result = find_locations(&*db, None, "get_user", None, false, 100); assert!(result.is_ok(), "Query should succeed"); let locations = result.unwrap(); @@ -388,7 +381,6 @@ mod tests { Some("MyApp.Notifier"), "send_email", None, - "default", false, 100, ); @@ -415,8 +407,8 @@ mod tests { let db = crate::test_utils::surreal_call_graph_db_complex(); // Use wildcard patterns to match all - let limit_1 = find_locations(&*db, None, ".*", None, "default", true, 1).unwrap(); - let limit_100 = find_locations(&*db, None, ".*", None, "default", true, 100).unwrap(); + let limit_1 = find_locations(&*db, None, ".*", None, true, 1).unwrap(); + let limit_100 = find_locations(&*db, None, ".*", None, true, 100).unwrap(); assert!(limit_1.len() <= 1, "Limit should be respected"); assert!( @@ -430,7 +422,7 @@ mod tests { let db = crate::test_utils::surreal_call_graph_db_complex(); // Test with zero limit - let result = find_locations(&*db, None, ".*", None, "default", true, 0); + let result = find_locations(&*db, None, ".*", None, true, 0); assert!(result.is_ok(), "Should handle zero limit"); let locations = result.unwrap(); @@ -442,7 +434,7 @@ mod tests { let db = crate::test_utils::surreal_call_graph_db_complex(); // Test with large limit (larger than fixture size) - let result = find_locations(&*db, None, ".*", None, "default", true, 1000000); + let result = find_locations(&*db, None, ".*", None, true, 1000000); assert!(result.is_ok(), "Should handle large limit"); let locations = result.unwrap(); @@ -458,7 +450,7 @@ mod tests { let db = crate::test_utils::surreal_call_graph_db_complex(); // Regex pattern that matches all functions - let result = find_locations(&*db, None, ".*", None, "default", true, 100); + let result = find_locations(&*db, None, ".*", None, true, 100); assert!(result.is_ok(), "Should match all functions with .*"); let locations = result.unwrap(); @@ -477,7 +469,6 @@ mod tests { Some("MyApp.Accounts"), "^(get_user|list_users)", None, - "default", true, 100, ); @@ -512,7 +503,6 @@ mod tests { Some("MyApp.Controller"), "^index$", None, - "default", true, 100, ); @@ -533,7 +523,7 @@ mod tests { fn test_find_locations_returns_correct_fields() { let db = crate::test_utils::surreal_call_graph_db_complex(); - let result = find_locations(&*db, None, ".*", None, "default", true, 100); + let result = find_locations(&*db, None, ".*", None, true, 100); assert!(result.is_ok(), "Query should succeed"); let locations = result.unwrap(); @@ -563,7 +553,6 @@ mod tests { Some("MyApp.Controller"), "index", None, - "default", false, 100, ); @@ -593,7 +582,7 @@ mod tests { let db = crate::test_utils::surreal_call_graph_db_complex(); // Use wildcard pattern to get all locations - let result = find_locations(&*db, None, ".*", None, "default", true, 100); + let result = find_locations(&*db, None, ".*", None, true, 100); assert!(result.is_ok()); let locations = result.unwrap(); @@ -622,8 +611,8 @@ mod tests { let db = crate::test_utils::surreal_call_graph_db_complex(); // Multiple calls should return results in consistent order - let result1 = find_locations(&*db, None, ".*", None, "default", true, 100).unwrap(); - let result2 = find_locations(&*db, None, ".*", None, "default", true, 100).unwrap(); + let result1 = find_locations(&*db, None, ".*", None, true, 100).unwrap(); + let result2 = find_locations(&*db, None, ".*", None, true, 100).unwrap(); // Results should be identical assert_eq!(result1.len(), result2.len()); @@ -647,7 +636,6 @@ mod tests { Some("MyApp.Controller"), "index", None, - "default", false, 100, ); @@ -656,7 +644,6 @@ mod tests { Some("MyApp.Controller"), "INDEX", None, - "default", false, 100, ); @@ -686,7 +673,6 @@ mod tests { Some("MyApp.Controller"), ".*", None, - "default", true, 100, ); @@ -695,7 +681,6 @@ mod tests { Some("myapp.controller"), ".*", None, - "default", true, 100, ); @@ -725,7 +710,7 @@ mod tests { let db = crate::test_utils::surreal_call_graph_db_complex(); // Empty patterns in exact match mode - let result = find_locations(&*db, Some(""), "", None, "default", false, 100); + let result = find_locations(&*db, Some(""), "", None, false, 100); assert!(result.is_ok(), "Should handle empty pattern"); let locations = result.unwrap(); @@ -743,7 +728,6 @@ mod tests { Some("MyApp.Controller"), "index", None, - "default", false, 100, ); @@ -773,7 +757,6 @@ mod tests { Some("MyApp.Accounts"), "list_users", None, - "default", false, 100, ); @@ -797,7 +780,7 @@ mod tests { let db = crate::test_utils::surreal_call_graph_db_complex(); // All results should have project field set to "default" - let result = find_locations(&*db, None, ".*", None, "default", true, 100); + let result = find_locations(&*db, None, ".*", None, true, 100); assert!(result.is_ok()); let locations = result.unwrap(); @@ -820,7 +803,6 @@ mod tests { Some("MyApp.Controller"), "index", None, - "default", false, 100, ); @@ -848,7 +830,6 @@ mod tests { Some("MyApp.Controller"), "index", None, - "default", false, 100, ); diff --git a/db/src/queries/many_clauses.rs b/db/src/queries/many_clauses.rs index 82eb20c..2ea4ebd 100644 --- a/db/src/queries/many_clauses.rs +++ b/db/src/queries/many_clauses.rs @@ -30,7 +30,6 @@ pub fn find_many_clauses( db: &dyn Database, min_clauses: i64, module_pattern: Option<&str>, - _project: &str, use_regex: bool, include_generated: bool, limit: u32, @@ -147,7 +146,7 @@ mod tests { #[test] fn test_find_many_clauses_returns_results() { let db = get_db(); - let result = find_many_clauses(&*db, 0, None, "default", false, true, 100); + let result = find_many_clauses(&*db, 0, None, false, true, 100); assert!(result.is_ok(), "Query should succeed: {:?}", result.err()); let clauses = result.unwrap(); @@ -157,7 +156,7 @@ mod tests { #[test] fn test_find_many_clauses_returns_exact_count() { let db = get_db(); - let clauses = find_many_clauses(&*db, 0, None, "default", false, true, 100) + let clauses = find_many_clauses(&*db, 0, None, false, true, 100) .expect("Query should succeed"); // The fixture has 37 functions with 44 clauses total @@ -172,7 +171,7 @@ mod tests { #[test] fn test_find_many_clauses_calculates_clause_count() { let db = get_db(); - let clauses = find_many_clauses(&*db, 0, None, "default", false, true, 100) + let clauses = find_many_clauses(&*db, 0, None, false, true, 100) .expect("Query should succeed"); // Find Controller.index/2 which has 2 clauses in fixture @@ -190,7 +189,7 @@ mod tests { #[test] fn test_find_many_clauses_all_modules_present() { let db = get_db(); - let clauses = find_many_clauses(&*db, 0, None, "default", false, true, 100) + let clauses = find_many_clauses(&*db, 0, None, false, true, 100) .expect("Query should succeed"); let modules: std::collections::HashSet<_> = clauses.iter().map(|c| c.module.as_str()).collect(); @@ -210,7 +209,7 @@ mod tests { #[test] fn test_find_many_clauses_respects_min_clauses_threshold() { let db = get_db(); - let clauses = find_many_clauses(&*db, 2, None, "default", false, true, 100) + let clauses = find_many_clauses(&*db, 2, None, false, true, 100) .expect("Query should succeed"); for clause in &clauses { @@ -226,9 +225,9 @@ mod tests { #[test] fn test_find_many_clauses_high_threshold_reduces_results() { let db = get_db(); - let all_clauses = find_many_clauses(&*db, 0, None, "default", false, true, 100) + let all_clauses = find_many_clauses(&*db, 0, None, false, true, 100) .expect("Query should succeed"); - let high_threshold = find_many_clauses(&*db, 3, None, "default", false, true, 100) + let high_threshold = find_many_clauses(&*db, 3, None, false, true, 100) .expect("Query should succeed"); // Higher threshold should return fewer or equal results @@ -249,7 +248,7 @@ mod tests { #[test] fn test_find_many_clauses_empty_with_very_high_threshold() { let db = get_db(); - let clauses = find_many_clauses(&*db, 1000, None, "default", false, true, 100) + let clauses = find_many_clauses(&*db, 1000, None, false, true, 100) .expect("Query should succeed"); assert!( @@ -267,7 +266,6 @@ mod tests { &*db, 0, Some("MyApp.Controller"), - "default", false, true, 100, @@ -290,7 +288,7 @@ mod tests { #[test] fn test_find_many_clauses_with_regex_module_filter() { let db = get_db(); - let clauses = find_many_clauses(&*db, 0, Some("^MyApp\\.Acc.*"), "default", true, true, 100) + let clauses = find_many_clauses(&*db, 0, Some("^MyApp\\.Acc.*"), true, true, 100) .expect("Query should succeed"); assert!( @@ -313,7 +311,6 @@ mod tests { &*db, 0, Some("NonExistentModule"), - "default", false, true, 100, @@ -329,7 +326,7 @@ mod tests { #[test] fn test_find_many_clauses_regex_pattern_invalid() { let db = get_db(); - let result = find_many_clauses(&*db, 0, Some("[invalid"), "default", true, true, 100); + let result = find_many_clauses(&*db, 0, Some("[invalid"), true, true, 100); assert!( result.is_err(), @@ -342,9 +339,9 @@ mod tests { #[test] fn test_find_many_clauses_include_generated_true() { let db = get_db(); - let with_generated = find_many_clauses(&*db, 0, None, "default", false, true, 100) + let with_generated = find_many_clauses(&*db, 0, None, false, true, 100) .expect("Query should succeed"); - let without_generated = find_many_clauses(&*db, 0, None, "default", false, false, 100) + let without_generated = find_many_clauses(&*db, 0, None, false, false, 100) .expect("Query should succeed"); // with_generated should have >= results than without_generated @@ -357,7 +354,7 @@ mod tests { #[test] fn test_find_many_clauses_exclude_generated() { let db = get_db(); - let clauses = find_many_clauses(&*db, 0, None, "default", false, false, 100) + let clauses = find_many_clauses(&*db, 0, None, false, false, 100) .expect("Query should succeed"); // When include_generated=false, all generated_by should be empty or None @@ -376,11 +373,11 @@ mod tests { #[test] fn test_find_many_clauses_respects_limit() { let db = get_db(); - let clauses_5 = find_many_clauses(&*db, 0, None, "default", false, true, 5) + let clauses_5 = find_many_clauses(&*db, 0, None, false, true, 5) .expect("Query should succeed"); - let clauses_10 = find_many_clauses(&*db, 0, None, "default", false, true, 10) + let clauses_10 = find_many_clauses(&*db, 0, None, false, true, 10) .expect("Query should succeed"); - let clauses_100 = find_many_clauses(&*db, 0, None, "default", false, true, 100) + let clauses_100 = find_many_clauses(&*db, 0, None, false, true, 100) .expect("Query should succeed"); assert!(clauses_5.len() <= 5, "Should respect limit of 5"); @@ -404,7 +401,7 @@ mod tests { #[test] fn test_find_many_clauses_ordered_by_clauses_desc() { let db = get_db(); - let clauses = find_many_clauses(&*db, 0, None, "default", false, true, 100) + let clauses = find_many_clauses(&*db, 0, None, false, true, 100) .expect("Query should succeed"); // Results should be ordered by clause count descending @@ -425,7 +422,7 @@ mod tests { #[test] fn test_find_many_clauses_all_fields_populated() { let db = get_db(); - let clauses = find_many_clauses(&*db, 0, None, "default", false, true, 100) + let clauses = find_many_clauses(&*db, 0, None, false, true, 100) .expect("Query should succeed"); assert!(!clauses.is_empty(), "Should return results"); @@ -444,7 +441,7 @@ mod tests { #[test] fn test_find_many_clauses_valid_arity_values() { let db = get_db(); - let clauses = find_many_clauses(&*db, 0, None, "default", false, true, 100) + let clauses = find_many_clauses(&*db, 0, None, false, true, 100) .expect("Query should succeed"); // Verify all arities are non-negative @@ -471,7 +468,6 @@ mod tests { &*db, 0, Some("MyApp.Controller"), - "default", false, true, 100, @@ -497,7 +493,6 @@ mod tests { &*db, 0, Some("MyApp.Accounts"), - "default", false, true, 100, @@ -519,7 +514,7 @@ mod tests { #[test] fn test_find_many_clauses_combined_filters() { let db = get_db(); - let clauses = find_many_clauses(&*db, 2, Some("MyApp.Accounts"), "default", false, true, 100) + let clauses = find_many_clauses(&*db, 2, Some("MyApp.Accounts"), false, true, 100) .expect("Query should succeed"); // Should apply both min_clauses and module filters @@ -538,7 +533,7 @@ mod tests { #[test] fn test_find_many_clauses_line_range_validity() { let db = get_db(); - let clauses = find_many_clauses(&*db, 0, None, "default", false, true, 100) + let clauses = find_many_clauses(&*db, 0, None, false, true, 100) .expect("Query should succeed"); for clause in &clauses { diff --git a/db/src/queries/path.rs b/db/src/queries/path.rs index 726ca99..b9f34f3 100644 --- a/db/src/queries/path.rs +++ b/db/src/queries/path.rs @@ -41,7 +41,6 @@ pub fn find_paths( to_module: &str, to_function: &str, to_arity: i64, - _project: &str, max_depth: u32, _limit: u32, ) -> Result, Box> { @@ -197,7 +196,6 @@ mod tests { "MyApp.Notifier", "send_email", 2, - "default", 10, 100, ); @@ -232,7 +230,6 @@ mod tests { "MyApp.Repo", "query", 2, - "default", 2, 100, ); @@ -250,7 +247,6 @@ mod tests { "MyApp.Repo", "query", 2, - "default", 5, 100, ); @@ -290,7 +286,6 @@ mod tests { "MyApp.Controller", "index", 2, - "default", 10, 100, ); @@ -313,7 +308,6 @@ mod tests { "MyApp.Accounts", "list_users", 0, - "default", 10, 100, ); @@ -336,7 +330,6 @@ mod tests { "NonExistent", "nonexistent", 1, - "default", 10, 100, ); @@ -360,7 +353,6 @@ mod tests { "MyApp.Repo", "all", 1, - "default", 5, 100, ); @@ -406,7 +398,6 @@ mod tests { "MyApp.Accounts", "list_users", 0, - "default", 10, 100, ); @@ -438,7 +429,6 @@ mod tests { "MyApp.Accounts", "list_users", 0, - "default", 10, 100, ); diff --git a/db/src/queries/returns.rs b/db/src/queries/returns.rs index 00d45fc..9059002 100644 --- a/db/src/queries/returns.rs +++ b/db/src/queries/returns.rs @@ -27,7 +27,6 @@ pub struct ReturnEntry { pub fn find_returns( db: &dyn Database, pattern: &str, - _project: &str, use_regex: bool, module_pattern: Option<&str>, limit: u32, @@ -165,7 +164,7 @@ mod tests { fn test_find_returns_user_type() { let db = crate::test_utils::surreal_accepts_db(); - let result = find_returns(&*db, "user()", "default", false, None, 100); + let result = find_returns(&*db, "user()", false, None, 100); assert!(result.is_ok(), "Query should succeed: {:?}", result.err()); let entries = result.unwrap(); @@ -189,7 +188,7 @@ mod tests { fn test_find_returns_nil_type() { let db = crate::test_utils::surreal_accepts_db(); - let result = find_returns(&*db, "nil", "default", false, None, 100); + let result = find_returns(&*db, "nil", false, None, 100); assert!(result.is_ok()); let entries = result.unwrap(); @@ -217,7 +216,7 @@ mod tests { fn test_find_returns_struct_type() { let db = crate::test_utils::surreal_accepts_db(); - let result = find_returns(&*db, "struct()", "default", false, None, 100); + let result = find_returns(&*db, "struct()", false, None, 100); assert!(result.is_ok()); let entries = result.unwrap(); @@ -234,7 +233,7 @@ mod tests { fn test_find_returns_error_tuple() { let db = crate::test_utils::surreal_accepts_db(); - let result = find_returns(&*db, "{:error", "default", false, None, 100); + let result = find_returns(&*db, "{:error", false, None, 100); assert!(result.is_ok()); let entries = result.unwrap(); @@ -257,7 +256,7 @@ mod tests { fn test_find_returns_ok_tuple() { let db = crate::test_utils::surreal_accepts_db(); - let result = find_returns(&*db, "{:ok", "default", false, None, 100); + let result = find_returns(&*db, "{:ok", false, None, 100); assert!(result.is_ok()); let entries = result.unwrap(); @@ -278,7 +277,7 @@ mod tests { fn test_find_returns_reason_type() { let db = crate::test_utils::surreal_accepts_db(); - let result = find_returns(&*db, "reason()", "default", false, None, 100); + let result = find_returns(&*db, "reason()", false, None, 100); assert!(result.is_ok()); let entries = result.unwrap(); @@ -300,7 +299,7 @@ mod tests { let db = crate::test_utils::surreal_accepts_db(); // Pattern to match return types containing "ok" - let result = find_returns(&*db, "ok", "default", false, None, 100); + let result = find_returns(&*db, "ok", false, None, 100); assert!(result.is_ok(), "Query should succeed: {:?}", result.err()); let entries = result.unwrap(); @@ -324,7 +323,6 @@ mod tests { let result = find_returns( &*db, "user()", - "default", false, Some("MyApp.Accounts"), 100, @@ -350,7 +348,7 @@ mod tests { fn test_find_returns_nonexistent_type() { let db = crate::test_utils::surreal_accepts_db(); - let result = find_returns(&*db, "NonExistent", "default", false, None, 100); + let result = find_returns(&*db, "NonExistent", false, None, 100); assert!(result.is_ok()); let entries = result.unwrap(); @@ -365,7 +363,7 @@ mod tests { fn test_find_returns_empty_pattern() { let db = crate::test_utils::surreal_accepts_db(); - let result = find_returns(&*db, "", "default", false, None, 100); + let result = find_returns(&*db, "", false, None, 100); assert!(result.is_ok()); let entries = result.unwrap(); @@ -382,7 +380,7 @@ mod tests { fn test_find_returns_invalid_regex() { let db = crate::test_utils::surreal_accepts_db(); - let result = find_returns(&*db, "[invalid", "default", true, None, 100); + let result = find_returns(&*db, "[invalid", true, None, 100); assert!( result.is_err(), @@ -394,10 +392,10 @@ mod tests { fn test_find_returns_respects_limit() { let db = crate::test_utils::surreal_accepts_db(); - let limit_3 = find_returns(&*db, "", "default", false, None, 3) + let limit_3 = find_returns(&*db, "", false, None, 3) .unwrap(); - let limit_100 = find_returns(&*db, "", "default", false, None, 100) + let limit_100 = find_returns(&*db, "", false, None, 100) .unwrap(); assert!(limit_3.len() <= 3, "Limit should be respected"); @@ -413,7 +411,7 @@ mod tests { fn test_find_returns_zero_arity_included() { let db = crate::test_utils::surreal_accepts_db(); - let result = find_returns(&*db, "user()", "default", false, None, 100); + let result = find_returns(&*db, "user()", false, None, 100); assert!(result.is_ok()); let entries = result.unwrap(); @@ -432,7 +430,7 @@ mod tests { fn test_find_returns_returns_valid_structure() { let db = crate::test_utils::surreal_accepts_db(); - let result = find_returns(&*db, "", "default", false, None, 100); + let result = find_returns(&*db, "", false, None, 100); assert!(result.is_ok()); let entries = result.unwrap(); @@ -450,7 +448,7 @@ mod tests { fn test_find_returns_preserves_sorting() { let db = crate::test_utils::surreal_accepts_db(); - let result = find_returns(&*db, "", "default", false, None, 100); + let result = find_returns(&*db, "", false, None, 100); assert!(result.is_ok()); let entries = result.unwrap(); diff --git a/db/src/queries/reverse_trace.rs b/db/src/queries/reverse_trace.rs index c5e9386..e653772 100644 --- a/db/src/queries/reverse_trace.rs +++ b/db/src/queries/reverse_trace.rs @@ -34,7 +34,6 @@ pub fn reverse_trace_calls( module_pattern: &str, function_pattern: &str, arity: Option, - project: &str, use_regex: bool, max_depth: u32, limit: u32, @@ -45,7 +44,6 @@ pub fn reverse_trace_calls( module_pattern, function_pattern, arity, - project, use_regex, max_depth, limit, @@ -84,7 +82,7 @@ mod tests { // Complex fixture: Notifier.send_email/2 is called by Service.process_request/2 and Controller.create/2 // Recursive trace will also find Controller.create as depth-2 caller (via Service.process_request) - let result = reverse_trace_calls(&*db, "MyApp.Notifier", "send_email", None, "default", false, 10, 100); + let result = reverse_trace_calls(&*db, "MyApp.Notifier", "send_email", None, false, 10, 100); assert!(result.is_ok(), "Query should succeed: {:?}", result.err()); let steps = result.unwrap(); @@ -127,7 +125,6 @@ mod tests { "NonExistent", "nonexistent", None, - "default", false, 10, 100, @@ -152,7 +149,6 @@ mod tests { "MyApp.Accounts", "list_users", None, - "default", false, 1, 100, @@ -173,7 +169,6 @@ mod tests { "MyApp.Accounts", "list_users", None, - "default", false, 5, 100, @@ -197,7 +192,6 @@ mod tests { "MyApp.Accounts", "list_users", None, - "default", false, 10, 100, @@ -220,7 +214,7 @@ mod tests { fn test_reverse_trace_calls_invalid_regex() { let db = crate::test_utils::surreal_call_graph_db_complex(); - let result = reverse_trace_calls(&*db, "[invalid", "index", None, "default", true, 10, 100); + let result = reverse_trace_calls(&*db, "[invalid", "index", None, true, 10, 100); assert!(result.is_err(), "Should reject invalid regex pattern"); let err = result.unwrap_err(); @@ -241,7 +235,6 @@ mod tests { "MyApp.Accounts", "list_users", Some(0), - "default", false, 10, 100, @@ -257,7 +250,7 @@ mod tests { // Complex fixture: Notifier.send_email/2 calls Notifier.format_message/1 // Reverse trace of format_message should find send_email as the only caller // But trace is recursive, so it will also find callers of send_email - let result = reverse_trace_calls(&*db, "MyApp.Notifier", "format_message", None, "default", false, 10, 100) + let result = reverse_trace_calls(&*db, "MyApp.Notifier", "format_message", None, false, 10, 100) .expect("Query should succeed"); assert!(result.len() >= 1, "Should find at least 1 caller of format_message"); @@ -302,7 +295,6 @@ mod tests { "MyApp.Accounts", "list_users", None, - "default", false, 10, 100, @@ -356,7 +348,6 @@ mod tests { "MyApp.Accounts", "all", None, - "default", false, 10, 1, @@ -368,7 +359,6 @@ mod tests { "MyApp.Accounts", "all", None, - "default", false, 10, 10, @@ -392,7 +382,6 @@ mod tests { "MyApp.Controller", "index", None, - "default", false, 0, 100, @@ -423,7 +412,6 @@ mod tests { "MyApp.Repo", "query", Some(2), // arity 2 - "default", false, 10, // high depth to get all callers 1000, // high limit diff --git a/db/src/queries/search.rs b/db/src/queries/search.rs index e9d72dc..973d3ec 100644 --- a/db/src/queries/search.rs +++ b/db/src/queries/search.rs @@ -16,7 +16,6 @@ pub enum SearchError { /// A module search result #[derive(Debug, Clone, Serialize)] pub struct ModuleResult { - pub project: String, pub name: String, pub source: String, } @@ -24,7 +23,6 @@ pub struct ModuleResult { /// A function search result #[derive(Debug, Clone, Serialize)] pub struct FunctionResult { - pub project: String, pub module: String, pub name: String, pub arity: i64, @@ -34,7 +32,6 @@ pub struct FunctionResult { pub fn search_modules( db: &dyn Database, pattern: &str, - _project: &str, limit: u32, use_regex: bool, ) -> Result, Box> { @@ -52,7 +49,7 @@ pub fn search_modules( let query = format!( r#" - SELECT "default" as project, name, source + SELECT name, source FROM modules {where_clause} ORDER BY name @@ -70,21 +67,14 @@ pub fn search_modules( let mut results = Vec::new(); for row in result.rows() { - // SurrealDB returns columns in alphabetical order: name, project, source - if row.len() >= 3 { + // SurrealDB returns columns in alphabetical order: name, source + if row.len() >= 2 { let Some(name) = extract_string(row.get(0).unwrap()) else { continue; }; - let Some(project) = extract_string(row.get(1).unwrap()) else { - continue; - }; - let source = extract_string_or(row.get(2).unwrap(), ""); + let source = extract_string_or(row.get(1).unwrap(), ""); - results.push(ModuleResult { - project, - name, - source, - }); + results.push(ModuleResult { name, source }); } } @@ -98,7 +88,6 @@ pub fn search_modules( pub fn search_functions( db: &dyn Database, pattern: &str, - _project: &str, limit: u32, use_regex: bool, ) -> Result, Box> { @@ -118,7 +107,7 @@ pub fn search_functions( // We return empty string for return_type to maintain API compatibility let query = format!( r#" - SELECT "default" as project, module_name as module, name, arity + SELECT module_name as module, name, arity FROM functions {where_clause} ORDER BY module_name ASC, name ASC, arity ASC @@ -136,9 +125,9 @@ pub fn search_functions( let mut results = Vec::new(); for row in result.rows() { - // SurrealDB returns columns in alphabetical order: arity, module, name, project + // SurrealDB returns columns in alphabetical order: arity, module, name // Note: return_type is no longer in the schema, we return empty string - if row.len() >= 4 { + if row.len() >= 3 { let arity = extract_i64(row.get(0).unwrap(), 0); let Some(module) = extract_string(row.get(1).unwrap()) else { continue; @@ -146,12 +135,8 @@ pub fn search_functions( let Some(name) = extract_string(row.get(2).unwrap()) else { continue; }; - let Some(project) = extract_string(row.get(3).unwrap()) else { - continue; - }; results.push(FunctionResult { - project, module, name, arity, @@ -181,7 +166,7 @@ mod tests { let db = crate::test_utils::surreal_call_graph_db_complex(); // Valid regex pattern should not error on validation (may or may not find results) - let result = search_modules(&*db, "^module_.*$", "default", 10, true); + let result = search_modules(&*db, "^module_.*$", 10, true); // Should not fail on validation (may return empty results, that's fine) assert!( @@ -196,7 +181,7 @@ mod tests { let db = crate::test_utils::surreal_call_graph_db_complex(); // Invalid regex pattern: unclosed bracket - let result = search_modules(&*db, "[invalid", "default", 10, true); + let result = search_modules(&*db, "[invalid", 10, true); assert!(result.is_err(), "Should reject invalid regex"); let err = result.unwrap_err(); @@ -218,7 +203,7 @@ mod tests { let db = crate::test_utils::surreal_call_graph_db_complex(); // Even invalid regex should work in non-regex mode (treated as literal string) - let result = search_modules(&*db, "[invalid", "default", 10, false); + let result = search_modules(&*db, "[invalid", 10, false); // Should succeed (no regex validation in non-regex mode) assert!( @@ -233,7 +218,7 @@ mod tests { let db = crate::test_utils::surreal_call_graph_db_complex(); // Search for exact module name without regex - let result = search_modules(&*db, "MyApp.Accounts", "default", 10, false); + let result = search_modules(&*db, "MyApp.Accounts", 10, false); assert!(result.is_ok(), "Query should succeed: {:?}", result.err()); let modules = result.unwrap(); @@ -241,7 +226,6 @@ mod tests { // Fixture has MyApp.Accounts, so we should find exactly 1 result assert_eq!(modules.len(), 1, "Should find exactly one module"); assert_eq!(modules[0].name, "MyApp.Accounts"); - assert_eq!(modules[0].project, "default"); assert_eq!(modules[0].source, "unknown"); } @@ -250,7 +234,7 @@ mod tests { let db = crate::test_utils::surreal_call_graph_db_complex(); // Test limit parameter - fixture has 5 modules, limit to 1 - let result = search_modules(&*db, ".*", "default", 1, true); + let result = search_modules(&*db, ".*", 1, true); assert!(result.is_ok(), "Should respect limit parameter"); let modules = result.unwrap(); @@ -265,7 +249,7 @@ mod tests { let db = crate::test_utils::surreal_call_graph_db_complex(); // Valid regex pattern should not error on validation - let result = search_functions(&*db, "^foo.*$", "default", 10, true); + let result = search_functions(&*db, "^foo.*$", 10, true); // Should not fail on validation assert!( @@ -280,7 +264,7 @@ mod tests { let db = crate::test_utils::surreal_call_graph_db_complex(); // Invalid regex pattern: invalid repetition - let result = search_functions(&*db, "*invalid", "default", 10, true); + let result = search_functions(&*db, "*invalid", 10, true); assert!(result.is_err(), "Should reject invalid regex"); let err = result.unwrap_err(); @@ -302,7 +286,7 @@ mod tests { let db = crate::test_utils::surreal_call_graph_db_complex(); // Even invalid regex should work in non-regex mode - let result = search_functions(&*db, "*invalid", "default", 10, false); + let result = search_functions(&*db, "*invalid", 10, false); // Should succeed (no regex validation in non-regex mode) assert!( @@ -317,7 +301,7 @@ mod tests { let db = crate::test_utils::surreal_call_graph_db_complex(); // Search for exact function name without regex - let result = search_functions(&*db, "index", "default", 10, false); + let result = search_functions(&*db, "index", 10, false); assert!(result.is_ok(), "Query should succeed: {:?}", result.err()); let functions = result.unwrap(); @@ -327,7 +311,6 @@ mod tests { assert_eq!(functions[0].name, "index"); assert_eq!(functions[0].module, "MyApp.Controller"); assert_eq!(functions[0].arity, 2); - assert_eq!(functions[0].project, "default"); // Note: return_type is not stored in SurrealDB schema (removed for simplification) } @@ -336,7 +319,7 @@ mod tests { let db = crate::test_utils::surreal_call_graph_db_complex(); // Test limit parameter - search for get_user which has 2 arities, limit to 1 - let result = search_functions(&*db, "get_user", "default", 1, false); + let result = search_functions(&*db, "get_user", 1, false); assert!(result.is_ok(), "Should respect limit parameter"); let functions = result.unwrap(); @@ -352,7 +335,7 @@ mod tests { let db = crate::test_utils::surreal_call_graph_db_complex(); // Get all functions to verify field structure - let result = search_functions(&*db, ".*", "default", 20, true); + let result = search_functions(&*db, ".*", 20, true); assert!(result.is_ok(), "Query should succeed"); let functions = result.unwrap(); @@ -360,7 +343,6 @@ mod tests { // Fixture has 31 functions, limit is 20 so we get 20 assert_eq!(functions.len(), 20); for func in &functions { - assert_eq!(func.project, "default"); assert!(!func.module.is_empty(), "module should not be empty"); assert!(!func.name.is_empty(), "name should not be empty"); assert!(func.arity >= 0, "arity should be non-negative"); @@ -373,7 +355,7 @@ mod tests { let db = crate::test_utils::surreal_call_graph_db_complex(); // Get all modules to verify field structure - let result = search_modules(&*db, ".*", "default", 10, true); + let result = search_modules(&*db, ".*", 10, true); assert!(result.is_ok(), "Query should succeed"); let modules = result.unwrap(); @@ -381,7 +363,6 @@ mod tests { // Fixture has 9 modules, all should have correct fields assert_eq!(modules.len(), 9); for module in &modules { - assert_eq!(module.project, "default"); assert!(!module.name.is_empty(), "name should not be empty"); assert_eq!(module.source, "unknown"); } @@ -392,7 +373,7 @@ mod tests { let db = crate::test_utils::surreal_call_graph_db_complex(); // Test with more complex regex pattern - let result = search_modules(&*db, "^mod.*_[ab]$", "default", 10, true); + let result = search_modules(&*db, "^mod.*_[ab]$", 10, true); assert!(result.is_ok(), "Should handle complex regex: {:?}", result.err()); } @@ -402,7 +383,7 @@ mod tests { let db = crate::test_utils::surreal_call_graph_db_complex(); // Test with more complex regex pattern for functions - let result = search_functions(&*db, "^[a-z]+_.*", "default", 10, true); + let result = search_functions(&*db, "^[a-z]+_.*", 10, true); assert!(result.is_ok(), "Should handle complex regex: {:?}", result.err()); } @@ -412,7 +393,7 @@ mod tests { let db = crate::test_utils::surreal_call_graph_db_complex(); // Search for pattern that doesn't match anything - let result = search_modules(&*db, "xyz_nonexistent_12345", "default", 10, false); + let result = search_modules(&*db, "xyz_nonexistent_12345", 10, false); assert!(result.is_ok(), "Should return empty results instead of error"); let modules = result.unwrap(); @@ -426,7 +407,7 @@ mod tests { let db = crate::test_utils::surreal_call_graph_db_complex(); // Search for pattern that doesn't match anything - let result = search_functions(&*db, "xyz_nonexistent_fn_12345", "default", 10, false); + let result = search_functions(&*db, "xyz_nonexistent_fn_12345", 10, false); assert!(result.is_ok(), "Should return empty results instead of error"); let functions = result.unwrap(); @@ -440,7 +421,7 @@ mod tests { let db = crate::test_utils::surreal_call_graph_db_complex(); // Test with zero limit (should return no results) - let result = search_modules(&*db, ".*", "default", 0, true); + let result = search_modules(&*db, ".*", 0, true); assert!(result.is_ok(), "Should handle zero limit"); let modules = result.unwrap(); @@ -452,7 +433,7 @@ mod tests { let db = crate::test_utils::surreal_call_graph_db_complex(); // Test with zero limit (should return no results) - let result = search_functions(&*db, ".*", "default", 0, true); + let result = search_functions(&*db, ".*", 0, true); assert!(result.is_ok(), "Should handle zero limit"); let functions = result.unwrap(); @@ -464,7 +445,7 @@ mod tests { let db = crate::test_utils::surreal_call_graph_db_complex(); // Test with large limit (larger than result set) - let result = search_modules(&*db, ".*", "default", 1000000, true); + let result = search_modules(&*db, ".*", 1000000, true); assert!(result.is_ok(), "Should handle large limit"); let modules = result.unwrap(); @@ -478,7 +459,7 @@ mod tests { let db = crate::test_utils::surreal_call_graph_db_complex(); // Test with large limit (larger than result set) - let result = search_functions(&*db, ".*", "default", 1000000, true); + let result = search_functions(&*db, ".*", 1000000, true); assert!(result.is_ok(), "Should handle large limit"); let functions = result.unwrap(); @@ -492,7 +473,7 @@ mod tests { let db = crate::test_utils::surreal_call_graph_db_complex(); // Test with empty pattern in exact match mode (no modules named "") - let result = search_modules(&*db, "", "default", 10, false); + let result = search_modules(&*db, "", 10, false); assert!(result.is_ok(), "Should handle empty pattern"); let modules = result.unwrap(); @@ -505,7 +486,7 @@ mod tests { let db = crate::test_utils::surreal_call_graph_db_complex(); // Test with empty pattern in exact match mode (no functions named "") - let result = search_functions(&*db, "", "default", 10, false); + let result = search_functions(&*db, "", 10, false); assert!(result.is_ok(), "Should handle empty pattern"); let functions = result.unwrap(); @@ -518,7 +499,7 @@ mod tests { let db = crate::test_utils::surreal_call_graph_db_complex(); // Test with regex pattern that matches all modules - let result = search_modules(&*db, ".*", "default", 10, true); + let result = search_modules(&*db, ".*", 10, true); assert!(result.is_ok(), "Should match all modules with .*"); let modules = result.unwrap(); @@ -537,7 +518,7 @@ mod tests { let db = crate::test_utils::surreal_call_graph_db_complex(); // Test with regex pattern that matches all functions (limit 20 returns first 20) - let result = search_functions(&*db, ".*", "default", 20, true); + let result = search_functions(&*db, ".*", 20, true); assert!(result.is_ok(), "Should match all functions with .*"); let functions = result.unwrap(); @@ -559,7 +540,7 @@ mod tests { let db = crate::test_utils::surreal_call_graph_db_complex(); // Search for specific module that should exist - let result = search_modules(&*db, "MyApp.Repo", "default", 10, false); + let result = search_modules(&*db, "MyApp.Repo", 10, false); assert!(result.is_ok(), "Should find MyApp.Repo without error"); let modules = result.unwrap(); @@ -567,7 +548,6 @@ mod tests { // Must find exactly the module we're looking for assert_eq!(modules.len(), 1, "Should find exactly one module"); assert_eq!(modules[0].name, "MyApp.Repo"); - assert_eq!(modules[0].project, "default"); } #[test] @@ -575,7 +555,7 @@ mod tests { let db = crate::test_utils::surreal_call_graph_db_complex(); // Search for specific function that should exist - let result = search_functions(&*db, "send_email", "default", 10, false); + let result = search_functions(&*db, "send_email", 10, false); assert!(result.is_ok(), "Should find send_email without error"); let functions = result.unwrap(); @@ -592,7 +572,7 @@ mod tests { let db = crate::test_utils::surreal_call_graph_db_complex(); // Get all modules to verify sorting - let result = search_modules(&*db, ".*", "default", 100, true); + let result = search_modules(&*db, ".*", 100, true); assert!(result.is_ok(), "Query should succeed"); let modules = result.unwrap(); @@ -611,7 +591,7 @@ mod tests { let db = crate::test_utils::surreal_call_graph_db_complex(); // Get all functions to verify sorting - let result = search_functions(&*db, ".*", "default", 100, true); + let result = search_functions(&*db, ".*", 100, true); assert!(result.is_ok(), "Query should succeed"); let functions = result.unwrap(); @@ -638,8 +618,8 @@ mod tests { let db = crate::test_utils::surreal_call_graph_db_complex(); // Search should be case sensitive - let result_correct = search_modules(&*db, "MyApp.Accounts", "default", 10, false); - let result_lower = search_modules(&*db, "myapp.accounts", "default", 10, false); + let result_correct = search_modules(&*db, "MyApp.Accounts", 10, false); + let result_lower = search_modules(&*db, "myapp.accounts", 10, false); assert!(result_correct.is_ok()); assert!(result_lower.is_ok()); @@ -658,8 +638,8 @@ mod tests { let db = crate::test_utils::surreal_call_graph_db_complex(); // Search should be case sensitive - let result_lower = search_functions(&*db, "get_user", "default", 10, false); - let result_upper = search_functions(&*db, "GET_USER", "default", 10, false); + let result_lower = search_functions(&*db, "get_user", 10, false); + let result_upper = search_functions(&*db, "GET_USER", 10, false); assert!(result_lower.is_ok()); assert!(result_upper.is_ok()); @@ -678,14 +658,13 @@ mod tests { let db = crate::test_utils::surreal_call_graph_db_complex(); // Ensure project field is set correctly - let result = search_modules(&*db, ".*", "default", 100, true); + let result = search_modules(&*db, ".*", 100, true); assert!(result.is_ok()); let modules = result.unwrap(); // All results should have project field populated for module in modules { - assert_eq!(module.project, "default", "Project should always be 'default'"); } } @@ -694,14 +673,13 @@ mod tests { let db = crate::test_utils::surreal_call_graph_db_complex(); // Ensure project field is set correctly - let result = search_functions(&*db, ".*", "default", 100, true); + let result = search_functions(&*db, ".*", 100, true); assert!(result.is_ok()); let functions = result.unwrap(); // All results should have project field populated for func in functions { - assert_eq!(func.project, "default", "Project should always be 'default'"); } } @@ -710,7 +688,7 @@ mod tests { let db = crate::test_utils::surreal_call_graph_db_complex(); // Modules don't have arity, just verify structure is correct - let result = search_modules(&*db, ".*", "default", 100, true); + let result = search_modules(&*db, ".*", 100, true); assert!(result.is_ok()); let modules = result.unwrap(); @@ -718,7 +696,6 @@ mod tests { // Check structure of returned modules for module in modules { assert!(!module.name.is_empty(), "Module name should not be empty"); - assert!(!module.project.is_empty(), "Module project should not be empty"); } } @@ -727,7 +704,7 @@ mod tests { let db = crate::test_utils::surreal_call_graph_db_complex(); // Functions should preserve arity information - let result = search_functions(&*db, ".*", "default", 100, true); + let result = search_functions(&*db, ".*", 100, true); assert!(result.is_ok()); let functions = result.unwrap(); @@ -745,7 +722,7 @@ mod tests { let db = crate::test_utils::surreal_call_graph_db_complex(); // Source field should be optional - let result = search_modules(&*db, ".*", "default", 100, true); + let result = search_modules(&*db, ".*", 100, true); assert!(result.is_ok()); let modules = result.unwrap(); @@ -763,7 +740,7 @@ mod tests { let db = crate::test_utils::surreal_call_graph_db_complex(); // Return type should be optional - let result = search_functions(&*db, ".*", "default", 100, true); + let result = search_functions(&*db, ".*", 100, true); assert!(result.is_ok()); let functions = result.unwrap(); @@ -782,7 +759,7 @@ mod tests { let db = crate::test_utils::surreal_call_graph_db_complex(); // Test with pattern containing digits - let result = search_modules(&*db, ".*[0-9].*", "default", 10, true); + let result = search_modules(&*db, ".*[0-9].*", 10, true); assert!(result.is_ok(), "Should handle patterns with digits"); } @@ -792,7 +769,7 @@ mod tests { let db = crate::test_utils::surreal_call_graph_db_complex(); // Test with pattern containing digits - let result = search_functions(&*db, ".*[0-9].*", "default", 10, true); + let result = search_functions(&*db, ".*[0-9].*", 10, true); assert!(result.is_ok(), "Should handle patterns with digits"); } @@ -802,7 +779,7 @@ mod tests { let db = crate::test_utils::surreal_call_graph_db_complex(); // Test with pattern containing underscore - let result = search_modules(&*db, "^[a-z]+_[a-z]$", "default", 10, true); + let result = search_modules(&*db, "^[a-z]+_[a-z]$", 10, true); assert!(result.is_ok(), "Should handle patterns with underscore"); } @@ -812,7 +789,7 @@ mod tests { let db = crate::test_utils::surreal_call_graph_db_complex(); // Test with pattern containing underscore - let result = search_functions(&*db, "^[a-z]+_[a-z]$", "default", 10, true); + let result = search_functions(&*db, "^[a-z]+_[a-z]$", 10, true); assert!(result.is_ok(), "Should handle patterns with underscore"); } @@ -822,7 +799,7 @@ mod tests { let db = crate::test_utils::surreal_call_graph_db_complex(); // Test with pattern containing whitespace (should find nothing typically) - let result = search_modules(&*db, "mod ule", "default", 10, false); + let result = search_modules(&*db, "mod ule", 10, false); assert!(result.is_ok(), "Should handle patterns with whitespace"); } @@ -832,7 +809,7 @@ mod tests { let db = crate::test_utils::surreal_call_graph_db_complex(); // Test with pattern containing whitespace (should find nothing typically) - let result = search_functions(&*db, "fun ction", "default", 10, false); + let result = search_functions(&*db, "fun ction", 10, false); assert!(result.is_ok(), "Should handle patterns with whitespace"); } @@ -842,7 +819,7 @@ mod tests { let db = crate::test_utils::surreal_call_graph_db_complex(); // Test with single character pattern - let result = search_modules(&*db, "a", "default", 10, false); + let result = search_modules(&*db, "a", 10, false); assert!(result.is_ok(), "Should handle single character patterns"); } @@ -852,7 +829,7 @@ mod tests { let db = crate::test_utils::surreal_call_graph_db_complex(); // Test with single character pattern - let result = search_functions(&*db, "o", "default", 10, false); + let result = search_functions(&*db, "o", 10, false); assert!(result.is_ok(), "Should handle single character patterns"); } @@ -862,7 +839,7 @@ mod tests { let db = crate::test_utils::surreal_call_graph_db_complex(); // Test regex alternation pattern - matches modules containing "Repo" or "Service" - let result = search_modules(&*db, ".*(Repo|Service)$", "default", 10, true); + let result = search_modules(&*db, ".*(Repo|Service)$", 10, true); assert!(result.is_ok(), "Should handle regex alternation"); let modules = result.unwrap(); @@ -878,7 +855,7 @@ mod tests { let db = crate::test_utils::surreal_call_graph_db_complex(); // Test regex alternation pattern - matches get, all, or insert functions - let result = search_functions(&*db, "^(get|all|insert)", "default", 10, true); + let result = search_functions(&*db, "^(get|all|insert)", 10, true); assert!(result.is_ok(), "Should handle regex alternation"); let functions = result.unwrap(); diff --git a/db/src/queries/specs.rs b/db/src/queries/specs.rs index 7a754f7..1fbdce6 100644 --- a/db/src/queries/specs.rs +++ b/db/src/queries/specs.rs @@ -32,7 +32,6 @@ pub fn find_specs( module_pattern: &str, function_pattern: Option<&str>, kind_filter: Option<&str>, - _project: &str, use_regex: bool, limit: u32, ) -> Result, Box> { @@ -156,7 +155,7 @@ mod tests { fn test_find_specs_all() { let db = crate::test_utils::surreal_specs_db(); - let result = find_specs(&*db, "", None, None, "default", false, 100); + let result = find_specs(&*db, "", None, None, false, 100); assert!(result.is_ok(), "Query should succeed: {:?}", result.err()); let specs = result.unwrap(); @@ -186,7 +185,7 @@ mod tests { fn test_find_specs_by_module() { let db = crate::test_utils::surreal_specs_db(); - let result = find_specs(&*db, "MyApp.Accounts", None, None, "default", false, 100); + let result = find_specs(&*db, "MyApp.Accounts", None, None, false, 100); assert!(result.is_ok(), "Query should succeed: {:?}", result.err()); let specs = result.unwrap(); @@ -219,7 +218,7 @@ mod tests { fn test_find_specs_by_function() { let db = crate::test_utils::surreal_specs_db(); - let result = find_specs(&*db, "", Some("get_user"), None, "default", false, 100); + let result = find_specs(&*db, "", Some("get_user"), None, false, 100); assert!(result.is_ok(), "Query should succeed: {:?}", result.err()); let specs = result.unwrap(); @@ -241,7 +240,7 @@ mod tests { fn test_find_specs_kind_spec() { let db = crate::test_utils::surreal_specs_db(); - let result = find_specs(&*db, "", None, Some("spec"), "default", false, 100); + let result = find_specs(&*db, "", None, Some("spec"), false, 100); assert!(result.is_ok(), "Query should succeed: {:?}", result.err()); let specs = result.unwrap(); @@ -263,7 +262,7 @@ mod tests { fn test_find_specs_kind_callback() { let db = crate::test_utils::surreal_specs_db(); - let result = find_specs(&*db, "", None, Some("callback"), "default", false, 100); + let result = find_specs(&*db, "", None, Some("callback"), false, 100); assert!(result.is_ok(), "Query should succeed: {:?}", result.err()); let specs = result.unwrap(); @@ -305,7 +304,6 @@ mod tests { "MyApp.Accounts", Some("^get"), None, - "default", true, 100, ); @@ -331,7 +329,7 @@ mod tests { fn test_find_specs_regex_module() { let db = crate::test_utils::surreal_specs_db(); - let result = find_specs(&*db, "MyApp.Accounts", None, None, "default", true, 100); + let result = find_specs(&*db, "MyApp.Accounts", None, None, true, 100); assert!( result.is_ok(), @@ -361,7 +359,6 @@ mod tests { "MyApp.Behaviour", Some("^handle"), None, - "default", true, 100, ); @@ -386,7 +383,7 @@ mod tests { fn test_find_specs_nonexistent_module() { let db = crate::test_utils::surreal_specs_db(); - let result = find_specs(&*db, "NonExistent", None, None, "default", false, 100); + let result = find_specs(&*db, "NonExistent", None, None, false, 100); assert!(result.is_ok()); let specs = result.unwrap(); @@ -401,7 +398,7 @@ mod tests { fn test_find_specs_invalid_regex() { let db = crate::test_utils::surreal_specs_db(); - let result = find_specs(&*db, "[invalid", None, None, "default", true, 100); + let result = find_specs(&*db, "[invalid", None, None, true, 100); assert!(result.is_err(), "Should reject invalid regex pattern"); } @@ -410,9 +407,9 @@ mod tests { fn test_find_specs_respects_limit() { let db = crate::test_utils::surreal_specs_db(); - let limit_3 = find_specs(&*db, "", None, None, "default", false, 3).unwrap(); + let limit_3 = find_specs(&*db, "", None, None, false, 3).unwrap(); - let limit_100 = find_specs(&*db, "", None, None, "default", false, 100).unwrap(); + let limit_100 = find_specs(&*db, "", None, None, false, 100).unwrap(); assert!(limit_3.len() <= 3, "Limit should be respected"); assert_eq!(limit_3.len(), 3, "Should return exactly 3 when limit is 3"); @@ -432,7 +429,6 @@ mod tests { "MyApp.Accounts", Some("get_user"), None, - "default", false, 100, ); @@ -458,7 +454,7 @@ mod tests { fn test_find_specs_preserves_sorting() { let db = crate::test_utils::surreal_specs_db(); - let result = find_specs(&*db, "", None, None, "default", false, 100); + let result = find_specs(&*db, "", None, None, false, 100); assert!(result.is_ok()); let specs = result.unwrap(); @@ -502,7 +498,6 @@ mod tests { "MyApp.Accounts", Some("get_user"), None, - "default", false, 100, ); @@ -531,7 +526,6 @@ mod tests { "MyApp.Accounts", Some("get_user"), None, - "default", false, 100, ); @@ -568,7 +562,6 @@ mod tests { "MyApp.Accounts", Some("list_users"), None, - "default", false, 100, ); @@ -594,7 +587,7 @@ mod tests { fn test_find_specs_returns_valid_structure() { let db = crate::test_utils::surreal_specs_db(); - let result = find_specs(&*db, "", None, None, "default", false, 100); + let result = find_specs(&*db, "", None, None, false, 100); assert!(result.is_ok()); let specs = result.unwrap(); @@ -615,7 +608,7 @@ mod tests { let db = crate::test_utils::surreal_specs_db(); // Use exact match for module name - let result = find_specs(&*db, "MyApp.Behaviour", None, None, "default", false, 100); + let result = find_specs(&*db, "MyApp.Behaviour", None, None, false, 100); assert!(result.is_ok()); let specs = result.unwrap(); diff --git a/db/src/queries/struct_usage.rs b/db/src/queries/struct_usage.rs index 453c592..b329b0d 100644 --- a/db/src/queries/struct_usage.rs +++ b/db/src/queries/struct_usage.rs @@ -28,7 +28,6 @@ pub struct StructUsageEntry { pub fn find_struct_usage( db: &dyn Database, pattern: &str, - _project: &str, use_regex: bool, module_pattern: Option<&str>, limit: u32, @@ -165,7 +164,7 @@ mod tests { fn test_find_struct_usage_user_type() { let db = crate::test_utils::surreal_specs_db(); - let result = find_struct_usage(&*db, "user()", "default", false, None, 100); + let result = find_struct_usage(&*db, "user()", false, None, 100); assert!(result.is_ok(), "Query should succeed: {:?}", result.err()); let entries = result.unwrap(); @@ -192,7 +191,7 @@ mod tests { fn test_find_struct_usage_integer_type() { let db = crate::test_utils::surreal_specs_db(); - let result = find_struct_usage(&*db, "integer()", "default", false, None, 100); + let result = find_struct_usage(&*db, "integer()", false, None, 100); assert!(result.is_ok(), "Query should succeed: {:?}", result.err()); let entries = result.unwrap(); @@ -218,7 +217,7 @@ mod tests { fn test_find_struct_usage_struct_type() { let db = crate::test_utils::surreal_specs_db(); - let result = find_struct_usage(&*db, "struct()", "default", false, None, 100); + let result = find_struct_usage(&*db, "struct()", false, None, 100); assert!(result.is_ok(), "Query should succeed: {:?}", result.err()); let entries = result.unwrap(); @@ -247,7 +246,7 @@ mod tests { fn test_find_struct_usage_combined_keyword() { let db = crate::test_utils::surreal_specs_db(); - let result = find_struct_usage(&*db, "keyword()", "default", false, None, 100); + let result = find_struct_usage(&*db, "keyword()", false, None, 100); assert!(result.is_ok(), "Query should succeed: {:?}", result.err()); let entries = result.unwrap(); @@ -275,7 +274,6 @@ mod tests { let result = find_struct_usage( &*db, "user()", - "default", false, Some("MyApp.Accounts"), 100, @@ -306,7 +304,7 @@ mod tests { let db = crate::test_utils::surreal_specs_db(); // Match patterns starting with "Ecto" - let result = find_struct_usage(&*db, "Ecto", "default", true, None, 100); + let result = find_struct_usage(&*db, "Ecto", true, None, 100); assert!(result.is_ok(), "Regex query should succeed: {:?}", result.err()); let entries = result.unwrap(); @@ -330,7 +328,7 @@ mod tests { fn test_find_struct_usage_nonexistent_type() { let db = crate::test_utils::surreal_specs_db(); - let result = find_struct_usage(&*db, "NonExistent", "default", false, None, 100); + let result = find_struct_usage(&*db, "NonExistent", false, None, 100); assert!(result.is_ok(), "Query should succeed: {:?}", result.err()); let entries = result.unwrap(); @@ -345,7 +343,7 @@ mod tests { fn test_find_struct_usage_invalid_regex() { let db = crate::test_utils::surreal_specs_db(); - let result = find_struct_usage(&*db, "[invalid", "default", true, None, 100); + let result = find_struct_usage(&*db, "[invalid", true, None, 100); assert!(result.is_err(), "Should reject invalid regex pattern"); } @@ -354,8 +352,8 @@ mod tests { fn test_find_struct_usage_respects_limit() { let db = crate::test_utils::surreal_specs_db(); - let limit_3 = find_struct_usage(&*db, "", "default", false, None, 3).unwrap(); - let limit_100 = find_struct_usage(&*db, "", "default", false, None, 100).unwrap(); + let limit_3 = find_struct_usage(&*db, "", false, None, 3).unwrap(); + let limit_100 = find_struct_usage(&*db, "", false, None, 100).unwrap(); assert!(limit_3.len() <= 3, "Limit should be respected"); assert_eq!(limit_3.len(), 3, "Should return exactly 3 when limit is 3"); @@ -370,7 +368,7 @@ mod tests { fn test_find_struct_usage_empty_pattern() { let db = crate::test_utils::surreal_specs_db(); - let result = find_struct_usage(&*db, "", "default", false, None, 100); + let result = find_struct_usage(&*db, "", false, None, 100); assert!(result.is_ok(), "Query should succeed: {:?}", result.err()); let entries = result.unwrap(); @@ -387,7 +385,7 @@ mod tests { fn test_find_struct_usage_returns_valid_structure() { let db = crate::test_utils::surreal_specs_db(); - let result = find_struct_usage(&*db, "", "default", false, None, 100); + let result = find_struct_usage(&*db, "", false, None, 100); assert!(result.is_ok(), "Query should succeed: {:?}", result.err()); let entries = result.unwrap(); @@ -405,7 +403,7 @@ mod tests { fn test_find_struct_usage_preserves_sorting() { let db = crate::test_utils::surreal_specs_db(); - let result = find_struct_usage(&*db, "", "default", false, None, 100); + let result = find_struct_usage(&*db, "", false, None, 100); assert!(result.is_ok(), "Query should succeed: {:?}", result.err()); let entries = result.unwrap(); @@ -445,7 +443,7 @@ mod tests { let db = crate::test_utils::surreal_specs_db(); // String.t() appears in input types only - let result = find_struct_usage(&*db, "String.t()", "default", false, None, 100); + let result = find_struct_usage(&*db, "String.t()", false, None, 100); assert!(result.is_ok(), "Query should succeed: {:?}", result.err()); let entries = result.unwrap(); @@ -474,7 +472,6 @@ mod tests { let result = find_struct_usage( &*db, "Ecto.Queryable.t()", - "default", false, None, 100, @@ -499,7 +496,7 @@ mod tests { let db = crate::test_utils::surreal_specs_db(); // result() appears in return types - let result = find_struct_usage(&*db, "result()", "default", false, None, 100); + let result = find_struct_usage(&*db, "result()", false, None, 100); assert!(result.is_ok(), "Query should succeed: {:?}", result.err()); let entries = result.unwrap(); diff --git a/db/src/queries/structs.rs b/db/src/queries/structs.rs index 1fad281..4be924d 100644 --- a/db/src/queries/structs.rs +++ b/db/src/queries/structs.rs @@ -44,7 +44,6 @@ pub struct FieldInfo { pub fn find_struct_fields( db: &dyn Database, module_pattern: &str, - _project: &str, use_regex: bool, limit: u32, ) -> Result, Box> { @@ -155,7 +154,7 @@ mod tests { #[rstest] fn test_find_struct_fields_returns_results(surreal_db: Box) { - let result = find_struct_fields(&*surreal_db, "", "default", false, 100); + let result = find_struct_fields(&*surreal_db, "", false, 100); assert!(result.is_ok(), "Query should succeed: {:?}", result.err()); let fields = result.unwrap(); assert_eq!( @@ -168,7 +167,7 @@ mod tests { #[rstest] fn test_find_struct_fields_empty_results(surreal_db: Box) { let result = - find_struct_fields(&*surreal_db, "NonExistentModule", "default", false, 100); + find_struct_fields(&*surreal_db, "NonExistentModule", false, 100); assert!(result.is_ok(), "Query should succeed: {:?}", result.err()); let fields = result.unwrap(); assert!( @@ -181,7 +180,7 @@ mod tests { fn test_find_struct_fields_with_exact_module( surreal_db: Box, ) { - let result = find_struct_fields(&*surreal_db, "structs_module", "default", false, 100); + let result = find_struct_fields(&*surreal_db, "structs_module", false, 100); assert!(result.is_ok(), "Query should succeed: {:?}", result.err()); let fields = result.unwrap(); assert_eq!( @@ -199,8 +198,8 @@ mod tests { #[rstest] fn test_find_struct_fields_respects_limit(surreal_db: Box) { - let limit_1 = find_struct_fields(&*surreal_db, "", "default", false, 1).unwrap(); - let limit_100 = find_struct_fields(&*surreal_db, "", "default", false, 100).unwrap(); + let limit_1 = find_struct_fields(&*surreal_db, "", false, 1).unwrap(); + let limit_100 = find_struct_fields(&*surreal_db, "", false, 100).unwrap(); assert_eq!(limit_1.len(), 1, "Should respect limit of 1"); assert_eq!( @@ -214,7 +213,7 @@ mod tests { fn test_find_struct_fields_with_regex_pattern( surreal_db: Box, ) { - let result = find_struct_fields(&*surreal_db, "structs.*", "default", true, 100); + let result = find_struct_fields(&*surreal_db, "structs.*", true, 100); assert!(result.is_ok(), "Query should succeed: {:?}", result.err()); let fields = result.unwrap(); assert_eq!( @@ -235,7 +234,7 @@ mod tests { surreal_db: Box, ) { let result = - find_struct_fields(&*surreal_db, "(structs|other).*", "default", true, 100); + find_struct_fields(&*surreal_db, "(structs|other).*", true, 100); assert!(result.is_ok(), "Query should succeed: {:?}", result.err()); let fields = result.unwrap(); assert_eq!( @@ -247,7 +246,7 @@ mod tests { #[rstest] fn test_find_struct_fields_invalid_regex(surreal_db: Box) { - let result = find_struct_fields(&*surreal_db, "[invalid", "default", true, 100); + let result = find_struct_fields(&*surreal_db, "[invalid", true, 100); assert!(result.is_err(), "Should reject invalid regex"); } @@ -255,7 +254,7 @@ mod tests { fn test_find_struct_fields_returns_valid_structure( surreal_db: Box, ) { - let result = find_struct_fields(&*surreal_db, "", "default", false, 100); + let result = find_struct_fields(&*surreal_db, "", false, 100); assert!(result.is_ok(), "Query should succeed: {:?}", result.err()); let fields = result.unwrap(); assert!(!fields.is_empty(), "Should find at least one field"); @@ -270,7 +269,7 @@ mod tests { fn test_find_struct_fields_project_always_default( surreal_db: Box, ) { - let result = find_struct_fields(&*surreal_db, "", "default", false, 100); + let result = find_struct_fields(&*surreal_db, "", false, 100); assert!(result.is_ok(), "Query should succeed: {:?}", result.err()); let fields = result.unwrap(); for field in &fields { @@ -285,7 +284,7 @@ mod tests { fn test_find_struct_fields_sorted_by_module_then_field( surreal_db: Box, ) { - let result = find_struct_fields(&*surreal_db, "", "default", false, 100); + let result = find_struct_fields(&*surreal_db, "", false, 100); assert!(result.is_ok(), "Query should succeed: {:?}", result.err()); let fields = result.unwrap(); // Verify fields are sorted by module then field name @@ -307,7 +306,7 @@ mod tests { fn test_group_fields_into_structs_from_surrealdb_results( surreal_db: Box, ) { - let fields_result = find_struct_fields(&*surreal_db, "", "default", false, 100); + let fields_result = find_struct_fields(&*surreal_db, "", false, 100); assert!(fields_result.is_ok(), "Should retrieve fields"); let fields = fields_result.unwrap(); diff --git a/db/src/queries/trace.rs b/db/src/queries/trace.rs index 39e825f..e843ecd 100644 --- a/db/src/queries/trace.rs +++ b/db/src/queries/trace.rs @@ -41,7 +41,6 @@ pub(crate) fn trace_calls_impl( module_pattern: &str, function_pattern: &str, arity: Option, - _project: &str, use_regex: bool, max_depth: u32, limit: u32, @@ -286,7 +285,6 @@ pub fn trace_calls( module_pattern: &str, function_pattern: &str, arity: Option, - project: &str, use_regex: bool, max_depth: u32, limit: u32, @@ -296,7 +294,6 @@ pub fn trace_calls( module_pattern, function_pattern, arity, - project, use_regex, max_depth, limit, @@ -319,7 +316,6 @@ mod tests { "MyApp.Controller", "create", None, - "default", false, 10, 100, @@ -382,7 +378,6 @@ mod tests { "NonExistent", "nonexistent", None, - "default", false, 10, 100, @@ -407,7 +402,6 @@ mod tests { "MyApp.Controller", "index", None, - "default", false, 1, 100, @@ -432,7 +426,6 @@ mod tests { "MyApp.Controller", "index", None, - "default", false, 5, 100, @@ -463,7 +456,6 @@ mod tests { "MyApp.Controller", "index", None, - "default", false, 10, 1, @@ -474,7 +466,6 @@ mod tests { "MyApp.Controller", "index", None, - "default", false, 10, 10, @@ -505,7 +496,6 @@ mod tests { "MyApp.Controller", "index", None, - "default", false, 10, 100, @@ -553,7 +543,6 @@ mod tests { "MyApp.Controller", "index", None, - "default", false, 10, 100, @@ -584,7 +573,7 @@ mod tests { fn test_trace_calls_invalid_regex() { let db = crate::test_utils::surreal_call_graph_db_complex(); - let result = trace_calls(&*db, "[invalid", "index", None, "default", true, 10, 100); + let result = trace_calls(&*db, "[invalid", "index", None, true, 10, 100); assert!(result.is_err(), "Should reject invalid regex pattern"); let err = result.unwrap_err(); @@ -605,7 +594,6 @@ mod tests { "MyApp.Controller", "index", Some(2), - "default", false, 10, 100, @@ -623,7 +611,6 @@ mod tests { "MyApp.Controller", "index", None, - "default", false, 10, 100, @@ -662,7 +649,6 @@ mod tests { "MyApp.Controller", "create", None, - "default", false, 10, 100, @@ -734,7 +720,6 @@ mod tests { "MyApp.Controller", "index", None, - "default", false, 0, 100, @@ -755,7 +740,6 @@ mod tests { "MyApp.Controller", "index", None, - "default", false, 10, 100, @@ -840,7 +824,6 @@ mod tests { "MyApp.Controller", "create", None, - "default", false, 5, 100, @@ -896,7 +879,6 @@ mod tests { "MyApp.Service", "process_request", Some(2), - "default", false, 3, 100, @@ -918,7 +900,6 @@ mod tests { "MyApp.Service", "process_request", None, - "default", false, 10, 1, @@ -942,7 +923,6 @@ mod tests { "MyApp.NonExistent", "nonexistent", None, - "default", false, 10, 100, @@ -968,7 +948,6 @@ mod tests { "MyApp\\..*", // Regex: matches MyApp.Controller, MyApp.Accounts, etc. ".*", // Regex: matches any function name None, - "default", true, // Enable regex (uses string::matches) 10, 1000, // High limit to get all paths diff --git a/db/src/queries/types.rs b/db/src/queries/types.rs index 187e111..b64982e 100644 --- a/db/src/queries/types.rs +++ b/db/src/queries/types.rs @@ -30,7 +30,6 @@ pub fn find_types( module_pattern: &str, name_filter: Option<&str>, kind_filter: Option<&str>, - _project: &str, use_regex: bool, limit: u32, ) -> Result, Box> { @@ -157,7 +156,7 @@ mod tests { let db = crate::test_utils::surreal_type_db(); // Invalid regex pattern: unclosed bracket - let result = find_types(&*db, "[invalid", None, None, "default", true, 100); + let result = find_types(&*db, "[invalid", None, None, true, 100); assert!(result.is_err(), "Should reject invalid regex"); let err = result.unwrap_err(); @@ -179,7 +178,6 @@ mod tests { "module_a", Some("*invalid"), None, - "default", true, 100, ); @@ -199,7 +197,7 @@ mod tests { let db = crate::test_utils::surreal_type_db(); // Valid regex pattern should not error on validation - let result = find_types(&*db, "^module.*$", None, None, "default", true, 100); + let result = find_types(&*db, "^module.*$", None, None, true, 100); // Should not fail on validation assert!( @@ -214,7 +212,7 @@ mod tests { let db = crate::test_utils::surreal_type_db(); // Even invalid regex should work in non-regex mode (treated as literal string) - let result = find_types(&*db, "[invalid", None, None, "default", false, 100); + let result = find_types(&*db, "[invalid", None, None, false, 100); // Should succeed (no regex validation in non-regex mode) assert!( @@ -231,7 +229,7 @@ mod tests { let db = crate::test_utils::surreal_type_db(); // Search for exact type name without regex - let result = find_types(&*db, "module_a", None, None, "default", false, 100); + let result = find_types(&*db, "module_a", None, None, false, 100); assert!(result.is_ok(), "Query should succeed: {:?}", result.err()); let types = result.unwrap(); @@ -254,7 +252,6 @@ mod tests { "module_a", Some("NonExistent"), None, - "default", false, 100, ); @@ -277,7 +274,6 @@ mod tests { "nonexistent_module", None, None, - "default", false, 100, ); @@ -300,7 +296,6 @@ mod tests { "module_a", None, Some("struct"), - "default", false, 100, ); @@ -323,7 +318,7 @@ mod tests { let db = crate::test_utils::surreal_type_db(); // Search for type with wrong kind (User is a struct, search for enum) - let result = find_types(&*db, "module_a", None, Some("enum"), "default", false, 100); + let result = find_types(&*db, "module_a", None, Some("enum"), false, 100); assert!(result.is_ok()); let types = result.unwrap(); @@ -335,8 +330,8 @@ mod tests { let db = crate::test_utils::surreal_type_db(); // Query with low limit - let limit_1 = find_types(&*db, "module_", None, None, "default", false, 1).unwrap(); - let limit_100 = find_types(&*db, "module_", None, None, "default", false, 100).unwrap(); + let limit_1 = find_types(&*db, "module_", None, None, false, 1).unwrap(); + let limit_100 = find_types(&*db, "module_", None, None, false, 100).unwrap(); assert!(limit_1.len() <= 1, "Limit should be respected"); assert!( @@ -350,7 +345,7 @@ mod tests { let db = crate::test_utils::surreal_type_db(); // Search for modules matching regex pattern - let result = find_types(&*db, "^module_.*$", None, None, "default", true, 100); + let result = find_types(&*db, "^module_.*$", None, None, true, 100); assert!(result.is_ok(), "Query should succeed"); let types = result.unwrap(); @@ -368,7 +363,7 @@ mod tests { let db = crate::test_utils::surreal_type_db(); // Search for specific type name - let result = find_types(&*db, "module_a", Some("User"), None, "default", false, 100); + let result = find_types(&*db, "module_a", Some("User"), None, false, 100); assert!(result.is_ok(), "Query should succeed"); let types = result.unwrap(); @@ -384,7 +379,7 @@ mod tests { let db = crate::test_utils::surreal_type_db(); // Search for type names matching regex - let result = find_types(&*db, "module_a", Some("^User$"), None, "default", true, 100); + let result = find_types(&*db, "module_a", Some("^User$"), None, true, 100); assert!(result.is_ok(), "Query should succeed"); let types = result.unwrap(); @@ -407,7 +402,6 @@ mod tests { "module_a", None, Some("struct"), - "default", false, 100, ); @@ -432,7 +426,6 @@ mod tests { "module_a", Some("User"), Some("struct"), - "default", false, 100, ); @@ -452,7 +445,7 @@ mod tests { let db = crate::test_utils::surreal_type_db(); // Query all types - let result = find_types(&*db, "", None, None, "default", false, 100); + let result = find_types(&*db, "", None, None, false, 100); assert!(result.is_ok()); let types = result.unwrap(); @@ -474,7 +467,7 @@ mod tests { fn test_find_types_module_a_finds_user() { let db = crate::test_utils::surreal_type_db(); - let result = find_types(&*db, "module_a", None, None, "default", false, 100); + let result = find_types(&*db, "module_a", None, None, false, 100); assert!(result.is_ok(), "Query should succeed"); let types = result.unwrap(); @@ -490,7 +483,7 @@ mod tests { fn test_find_types_module_b_finds_post() { let db = crate::test_utils::surreal_type_db(); - let result = find_types(&*db, "module_b", None, None, "default", false, 100); + let result = find_types(&*db, "module_b", None, None, false, 100); assert!(result.is_ok(), "Query should succeed"); let types = result.unwrap(); @@ -507,7 +500,7 @@ mod tests { let db = crate::test_utils::surreal_type_db(); // Search for all types across all modules - let result = find_types(&*db, "", None, None, "default", false, 100); + let result = find_types(&*db, "", None, None, false, 100); assert!(result.is_ok(), "Query should succeed"); let types = result.unwrap(); @@ -525,7 +518,7 @@ mod tests { let db = crate::test_utils::surreal_type_db(); // Search for all types to verify sorting - let result = find_types(&*db, "", None, None, "default", false, 100); + let result = find_types(&*db, "", None, None, false, 100); assert!(result.is_ok(), "Query should succeed"); let types = result.unwrap(); @@ -549,7 +542,7 @@ mod tests { let db = crate::test_utils::surreal_type_db(); // Empty module pattern should match all modules - let result = find_types(&*db, "", None, None, "default", false, 100); + let result = find_types(&*db, "", None, None, false, 100); assert!(result.is_ok(), "Query should succeed"); let types = result.unwrap(); @@ -569,7 +562,7 @@ mod tests { let db = crate::test_utils::surreal_type_db(); // Search with non-existent project - let result = find_types(&*db, "", None, None, "nonexistent", false, 100); + let result = find_types(&*db, "", None, None, false, 100); assert!(result.is_ok()); let types = result.unwrap(); diff --git a/db/src/queries/unused.rs b/db/src/queries/unused.rs index 3d0e79e..e4625a1 100644 --- a/db/src/queries/unused.rs +++ b/db/src/queries/unused.rs @@ -44,7 +44,6 @@ const GENERATED_PATTERNS: &[&str] = &[ pub fn find_unused_functions( db: &dyn Database, module_pattern: Option<&str>, - _project: &str, use_regex: bool, private_only: bool, public_only: bool, @@ -190,7 +189,7 @@ mod tests { #[test] fn test_find_unused_functions_returns_exactly_16() { let db = get_db(); - let unused = find_unused_functions(&*db, None, "default", false, false, false, false, 100) + let unused = find_unused_functions(&*db, None, false, false, false, false, 100) .expect("Query should succeed"); // Exactly 16 unused functions in fixture (10 original + 6 for duplicates) @@ -209,7 +208,7 @@ mod tests { #[test] fn test_find_unused_functions_contains_expected_functions() { let db = get_db(); - let unused = find_unused_functions(&*db, None, "default", false, false, false, false, 100) + let unused = find_unused_functions(&*db, None, false, false, false, false, 100) .expect("Query should succeed"); // Build a set of expected unused function signatures (16 total) @@ -247,7 +246,7 @@ mod tests { #[test] fn test_find_unused_functions_first_result_is_accounts_generated() { let db = get_db(); - let unused = find_unused_functions(&*db, None, "default", false, false, false, false, 100) + let unused = find_unused_functions(&*db, None, false, false, false, false, 100) .expect("Query should succeed"); // Ordered by module, name, arity - first should be MyApp.Accounts.__generated__/0 @@ -265,7 +264,7 @@ mod tests { #[test] fn test_find_unused_functions_validate_email_details() { let db = get_db(); - let unused = find_unused_functions(&*db, None, "default", false, false, false, false, 100) + let unused = find_unused_functions(&*db, None, false, false, false, false, 100) .expect("Query should succeed"); let validate_email = unused.iter().find(|f| f.name == "validate_email"); @@ -283,7 +282,7 @@ mod tests { #[test] fn test_find_unused_functions_transform_data_details() { let db = get_db(); - let unused = find_unused_functions(&*db, None, "default", false, false, false, false, 100) + let unused = find_unused_functions(&*db, None, false, false, false, false, 100) .expect("Query should succeed"); let transform_data = unused.iter().find(|f| f.name == "transform_data"); @@ -301,7 +300,7 @@ mod tests { #[test] fn test_find_unused_functions_controller_index_details() { let db = get_db(); - let unused = find_unused_functions(&*db, None, "default", false, false, false, false, 100) + let unused = find_unused_functions(&*db, None, false, false, false, false, 100) .expect("Query should succeed"); let index = unused.iter().find(|f| f.name == "index"); @@ -321,7 +320,7 @@ mod tests { #[test] fn test_find_unused_functions_private_only_returns_exactly_3() { let db = get_db(); - let unused = find_unused_functions(&*db, None, "default", false, true, false, false, 100) + let unused = find_unused_functions(&*db, None, false, true, false, false, 100) .expect("Query should succeed"); // Exactly 3 unused private functions: validate_email/1, debug/1, transform_data/1 @@ -362,7 +361,7 @@ mod tests { #[test] fn test_find_unused_functions_public_only_returns_exactly_13() { let db = get_db(); - let unused = find_unused_functions(&*db, None, "default", false, false, true, false, 100) + let unused = find_unused_functions(&*db, None, false, false, true, false, 100) .expect("Query should succeed"); // Exactly 13 unused public functions (16 total - 3 private: validate_email, debug, transform_data) @@ -391,7 +390,7 @@ mod tests { #[test] fn test_find_unused_functions_private_only_validate_email() { let db = get_db(); - let unused = find_unused_functions(&*db, None, "default", false, true, false, false, 100) + let unused = find_unused_functions(&*db, None, false, true, false, false, 100) .expect("Query should succeed"); let validate_email = unused.iter().find(|f| f.name == "validate_email"); @@ -408,7 +407,7 @@ mod tests { #[test] fn test_find_unused_functions_private_only_transform_data() { let db = get_db(); - let unused = find_unused_functions(&*db, None, "default", false, true, false, false, 100) + let unused = find_unused_functions(&*db, None, false, true, false, false, 100) .expect("Query should succeed"); let transform_data = unused.iter().find(|f| f.name == "transform_data"); @@ -425,9 +424,9 @@ mod tests { #[test] fn test_find_unused_functions_private_and_public_sum_to_total() { let db = get_db(); - let private = find_unused_functions(&*db, None, "default", false, true, false, false, 100) + let private = find_unused_functions(&*db, None, false, true, false, false, 100) .expect("Query should succeed"); - let public = find_unused_functions(&*db, None, "default", false, false, true, false, 100) + let public = find_unused_functions(&*db, None, false, false, true, false, 100) .expect("Query should succeed"); // Private (3) + Public (13) = Total (16) @@ -446,7 +445,7 @@ mod tests { fn test_find_unused_functions_exclude_generated_returns_exactly_13() { let db = get_db(); let without_generated = - find_unused_functions(&*db, None, "default", false, false, false, true, 100) + find_unused_functions(&*db, None, false, false, false, true, 100) .expect("Query should succeed"); // 16 total unused - 3 generated (__struct__, __generated__ x2) = 13 @@ -466,10 +465,10 @@ mod tests { fn test_find_unused_functions_exclude_generated_removes_struct() { let db = get_db(); let with_generated = - find_unused_functions(&*db, None, "default", false, false, false, false, 100) + find_unused_functions(&*db, None, false, false, false, false, 100) .expect("Query should succeed"); let without_generated = - find_unused_functions(&*db, None, "default", false, false, false, true, 100) + find_unused_functions(&*db, None, false, false, false, true, 100) .expect("Query should succeed"); // With generated should have __struct__ and __generated__, without should not @@ -507,7 +506,7 @@ mod tests { fn test_find_unused_functions_exclude_generated_no_dunder_names() { let db = get_db(); let without_generated = - find_unused_functions(&*db, None, "default", false, false, false, true, 100) + find_unused_functions(&*db, None, false, false, false, true, 100) .expect("Query should succeed"); for func in &without_generated { @@ -527,7 +526,6 @@ mod tests { let unused = find_unused_functions( &*db, Some("MyApp.Controller"), - "default", false, false, false, @@ -565,7 +563,6 @@ mod tests { let unused = find_unused_functions( &*db, Some("MyApp.Accounts"), - "default", false, false, false, @@ -602,7 +599,6 @@ mod tests { let unused = find_unused_functions( &*db, Some("MyApp.Repo"), - "default", false, false, false, @@ -628,7 +624,6 @@ mod tests { let unused = find_unused_functions( &*db, Some("MyApp.Service"), - "default", false, false, false, @@ -657,7 +652,6 @@ mod tests { let unused = find_unused_functions( &*db, Some("MyApp.Notifier"), - "default", false, false, false, @@ -681,7 +675,6 @@ mod tests { let unused = find_unused_functions( &*db, Some("NonExistentModule"), - "default", false, false, false, @@ -702,7 +695,6 @@ mod tests { let unused = find_unused_functions( &*db, Some("^MyApp\\.Controller$"), - "default", true, false, false, @@ -724,7 +716,6 @@ mod tests { let result = find_unused_functions( &*db, Some("[invalid"), - "default", true, false, false, @@ -740,7 +731,7 @@ mod tests { #[test] fn test_find_unused_functions_limit_2_returns_2() { let db = get_db(); - let unused = find_unused_functions(&*db, None, "default", false, false, false, false, 2) + let unused = find_unused_functions(&*db, None, false, false, false, false, 2) .expect("Query should succeed"); assert_eq!(unused.len(), 2, "Limit 2 should return exactly 2 results"); @@ -749,7 +740,7 @@ mod tests { #[test] fn test_find_unused_functions_limit_5_returns_5() { let db = get_db(); - let unused = find_unused_functions(&*db, None, "default", false, false, false, false, 5) + let unused = find_unused_functions(&*db, None, false, false, false, false, 5) .expect("Query should succeed"); assert_eq!(unused.len(), 5, "Limit 5 should return exactly 5 results"); @@ -758,7 +749,7 @@ mod tests { #[test] fn test_find_unused_functions_limit_0_returns_empty() { let db = get_db(); - let unused = find_unused_functions(&*db, None, "default", false, false, false, false, 0) + let unused = find_unused_functions(&*db, None, false, false, false, false, 0) .expect("Query should succeed"); assert!(unused.is_empty(), "Limit 0 should return empty results"); @@ -767,7 +758,7 @@ mod tests { #[test] fn test_find_unused_functions_limit_100_returns_all_16() { let db = get_db(); - let unused = find_unused_functions(&*db, None, "default", false, false, false, false, 100) + let unused = find_unused_functions(&*db, None, false, false, false, false, 100) .expect("Query should succeed"); assert_eq!( @@ -782,7 +773,7 @@ mod tests { #[test] fn test_find_unused_functions_ordered_by_module_name_arity() { let db = get_db(); - let unused = find_unused_functions(&*db, None, "default", false, false, false, false, 100) + let unused = find_unused_functions(&*db, None, false, false, false, false, 100) .expect("Query should succeed"); // Results should be ordered by module_name, then name, then arity @@ -822,7 +813,7 @@ mod tests { #[test] fn test_find_unused_functions_private_and_exclude_generated() { let db = get_db(); - let unused = find_unused_functions(&*db, None, "default", false, true, false, true, 100) + let unused = find_unused_functions(&*db, None, false, true, false, true, 100) .expect("Query should succeed"); // Private (3) - none are generated = 3 @@ -841,7 +832,7 @@ mod tests { #[test] fn test_find_unused_functions_public_and_exclude_generated() { let db = get_db(); - let unused = find_unused_functions(&*db, None, "default", false, false, true, true, 100) + let unused = find_unused_functions(&*db, None, false, false, true, true, 100) .expect("Query should succeed"); // Public (13) - 3 generated (__struct__, __generated__ x2) = 10 @@ -872,7 +863,6 @@ mod tests { let unused = find_unused_functions( &*db, Some("MyApp.Controller"), - "default", false, true, false, @@ -894,7 +884,6 @@ mod tests { let unused = find_unused_functions( &*db, Some("MyApp.Accounts"), - "default", false, false, false, @@ -922,7 +911,6 @@ mod tests { let result_lower = find_unused_functions( &*db, Some("myapp.controller"), - "default", false, false, false, @@ -940,7 +928,7 @@ mod tests { #[test] fn test_find_unused_functions_result_uniqueness() { let db = get_db(); - let unused = find_unused_functions(&*db, None, "default", false, false, false, false, 100) + let unused = find_unused_functions(&*db, None, false, false, false, false, 100) .expect("Query should succeed"); let mut seen = std::collections::HashSet::new(); diff --git a/db/src/test_utils.rs b/db/src/test_utils.rs index e74d036..1fdebdc 100644 --- a/db/src/test_utils.rs +++ b/db/src/test_utils.rs @@ -30,9 +30,9 @@ pub fn create_temp_json_file(content: &str) -> NamedTempFile { /// This is the standard setup for execute tests: create an in-memory DB, /// import test data, return the DB instance for command execution. #[cfg(any(test, feature = "test-utils"))] -pub fn setup_test_db(json_content: &str, project: &str) -> Box { +pub fn setup_test_db(json_content: &str) -> Box { let db = open_mem_db().expect("Failed to create in-memory DB"); - import_json_str(&*db, json_content, project).expect("Import should succeed"); + import_json_str(&*db, json_content).expect("Import should succeed"); db } @@ -56,24 +56,24 @@ use crate::fixtures; /// Use for: trace, reverse_trace, calls_from, calls_to, path, hotspots, /// unused, depends_on, depended_by #[cfg(any(test, feature = "test-utils"))] -pub fn call_graph_db(project: &str) -> Box { - setup_test_db(fixtures::CALL_GRAPH, project) +pub fn call_graph_db() -> Box { + setup_test_db(fixtures::CALL_GRAPH) } /// Create a test database with type signature data. /// /// Use for: search (functions kind), function #[cfg(any(test, feature = "test-utils"))] -pub fn type_signatures_db(project: &str) -> Box { - setup_test_db(fixtures::TYPE_SIGNATURES, project) +pub fn type_signatures_db() -> Box { + setup_test_db(fixtures::TYPE_SIGNATURES) } /// Create a test database with struct definitions. /// /// Use for: struct command #[cfg(any(test, feature = "test-utils"))] -pub fn structs_db(project: &str) -> Box { - setup_test_db(fixtures::STRUCTS, project) +pub fn structs_db() -> Box { + setup_test_db(fixtures::STRUCTS) } // ============================================================================= diff --git a/docs/GIT_HOOKS.md b/docs/GIT_HOOKS.md index 1342fc6..3a3924a 100644 --- a/docs/GIT_HOOKS.md +++ b/docs/GIT_HOOKS.md @@ -53,20 +53,6 @@ This will: The hook works out of the box without any configuration. However, you can optionally customize: -#### Multi-Project Databases - -If you want to namespace multiple projects in the same database: - -```bash -code_search setup --install-hooks --project-name my_app -``` - -Or configure later: - -```bash -git config code-search.project-name my_app -``` - #### Mix Environment To use a different Mix environment (default: `dev`): @@ -238,7 +224,7 @@ mix compile --debug-info ex_ast --git-diff HEAD~1 --format json --output changes.json # Import -code_search --db call_graph.db import --file changes.json --project my_app +code_search --db call_graph.db import --file changes.json ``` Or for a different git reference: @@ -260,7 +246,7 @@ The same approach works in CI/CD pipelines. Example GitHub Actions workflow: run: | mix compile --debug-info ex_ast --git-diff HEAD~1 --format json --output changes.json - code_search --db call_graph.db import --file changes.json --project ${{ github.repository }} + code_search --db call_graph.db import --file changes.json ``` ## Performance Characteristics diff --git a/docs/TESTING_STRATEGY.md b/docs/TESTING_STRATEGY.md index 4548d9e..76afc29 100644 --- a/docs/TESTING_STRATEGY.md +++ b/docs/TESTING_STRATEGY.md @@ -46,10 +46,10 @@ Tests that a specific CLI option sets a field correctly. crate::cli_option_test! { command: "search", variant: Search, - test_name: test_with_project, - args: ["--pattern", "User", "--project", "my_app"], - field: project, - expected: "my_app", + test_name: test_with_limit, + args: ["User", "--limit", "50"], + field: common.limit, + expected: 50, } ``` diff --git a/docs/examples/cli_tests.rs.example b/docs/examples/cli_tests.rs.example index 5ed8de4..f465bd8 100644 --- a/docs/examples/cli_tests.rs.example +++ b/docs/examples/cli_tests.rs.example @@ -42,15 +42,6 @@ mod tests { } // Test with multiple options - crate::cli_option_test! { - command: "", - variant: , - test_name: test_with_project, - args: ["--module", "MyApp", "--project", "my_app"], - field: project, - expected: "my_app", - } - // Test boolean flags crate::cli_option_test! { command: "", diff --git a/templates/agents/code-search-explorer.md b/templates/agents/code-search-explorer.md index 7c2a85d..2a44679 100644 --- a/templates/agents/code-search-explorer.md +++ b/templates/agents/code-search-explorer.md @@ -29,7 +29,6 @@ When asked to explore a codebase: 2. **Execute queries efficiently**: - Always use `--format toon` for token-efficient output - Use `--limit` to control result size - - Use `--project` to filter by project - Chain multiple queries when needed 3. **Interpret results**: diff --git a/templates/hooks/post-commit b/templates/hooks/post-commit index 2899618..c9d471a 100644 --- a/templates/hooks/post-commit +++ b/templates/hooks/post-commit @@ -12,15 +12,13 @@ # cp hooks/post-commit .git/hooks/post-commit # chmod +x .git/hooks/post-commit # -# Configuration (via git config, all optional): -# git config code-search.project-name # Project name (for multi-project databases) +# Configuration (via git config, optional): # git config code-search.mix-env # Mix environment (default: dev) # # Database path is auto-resolved to .code_search/surrealdb.rocksdb in the project root # -# Get configuration from git config (all optional) -PROJECT_NAME=$(git config code-search.project-name || echo "") +# Get configuration from git config (optional) MIX_ENV=$(git config code-search.mix-env || echo "dev") # Color output helpers @@ -105,20 +103,11 @@ fi # Step 3: Import data into database (will upsert existing records) # Database path will be auto-resolved to .code_search/surrealdb.rocksdb -if [ -n "${PROJECT_NAME}" ]; then - info "Importing data (project: ${PROJECT_NAME})..." - if code_search import --file "${TEMP_JSON}" --project "${PROJECT_NAME}" 2>&1; then - info "Database updated successfully!" - else - error "Database import failed" - exit 1 - fi +info "Importing data..." + +if code_search import --file "${TEMP_JSON}" 2>&1; then + info "Database updated successfully!" else - info "Importing data..." - if code_search import --file "${TEMP_JSON}" 2>&1; then - info "Database updated successfully!" - else - error "Database import failed" - exit 1 - fi + error "Database import failed" + exit 1 fi diff --git a/templates/skills/accepts/SKILL.md b/templates/skills/accepts/SKILL.md index 7d91bc2..2eef4ca 100644 --- a/templates/skills/accepts/SKILL.md +++ b/templates/skills/accepts/SKILL.md @@ -30,7 +30,6 @@ code_search --format toon accepts [MODULE] [OPTIONS] |--------|-------------|---------| | `-r, --regex` | Treat patterns as regex | false | | `-l, --limit ` | Max results (1-1000) | 100 | -| `--project ` | Project to search in | `default` | ## Examples diff --git a/templates/skills/boundaries/SKILL.md b/templates/skills/boundaries/SKILL.md index 13974b8..d241643 100644 --- a/templates/skills/boundaries/SKILL.md +++ b/templates/skills/boundaries/SKILL.md @@ -31,7 +31,6 @@ code_search --format toon boundaries [MODULE] [OPTIONS] | `--min-ratio ` | Minimum ratio (incoming/outgoing) to be considered a boundary | 2.0 | | `-r, --regex` | Treat patterns as regex | false | | `-l, --limit ` | Max results (1-1000) | 100 | -| `--project ` | Project to search in | `default` | ## Examples diff --git a/templates/skills/browse-module/SKILL.md b/templates/skills/browse-module/SKILL.md index b90a00a..94f3297 100644 --- a/templates/skills/browse-module/SKILL.md +++ b/templates/skills/browse-module/SKILL.md @@ -31,7 +31,6 @@ code_search --format toon browse-module [OPTIONS] | `-n, --name ` | Filter by definition name (substring or regex with --regex) | none | | `-r, --regex` | Treat patterns as regular expressions | false | | `-l, --limit ` | Max results (1-1000) | 100 | -| `--project ` | Project to search in | `default` | ## Output Fields (toon format) diff --git a/templates/skills/calls-from/skill.md b/templates/skills/calls-from/skill.md index 1df06b9..84aa705 100644 --- a/templates/skills/calls-from/skill.md +++ b/templates/skills/calls-from/skill.md @@ -55,4 +55,3 @@ This shows what happens when an error is caught - the error handling chain. | `[ARITY]` | Function arity (optional) | all arities | | `-r, --regex` | Treat patterns as regular expressions | false | | `-l, --limit ` | Max results (1-1000) | 100 | -| `--project ` | Project to search in | `default` | diff --git a/templates/skills/calls-to/skill.md b/templates/skills/calls-to/skill.md index 4305b55..3af24e8 100644 --- a/templates/skills/calls-to/skill.md +++ b/templates/skills/calls-to/skill.md @@ -61,4 +61,3 @@ Each call shows: | `[ARITY]` | Function arity (optional) | all arities | | `-r, --regex` | Treat patterns as regular expressions | false | | `-l, --limit ` | Max results (1-1000) | 100 | -| `--project ` | Project to search in | `default` | diff --git a/templates/skills/clusters/SKILL.md b/templates/skills/clusters/SKILL.md index fd9ace7..7da595a 100644 --- a/templates/skills/clusters/SKILL.md +++ b/templates/skills/clusters/SKILL.md @@ -31,7 +31,6 @@ code_search --format toon clusters [MODULE] [OPTIONS] | `--show-dependencies` | Show cross-namespace dependencies | false | | `-r, --regex` | Treat patterns as regex | false | | `-l, --limit ` | Max results (1-1000) | 100 | -| `--project ` | Project to search in | `default` | ## Examples diff --git a/templates/skills/code-search-explorer/SKILL.md b/templates/skills/code-search-explorer/SKILL.md index 113b19d..f4ce3a9 100644 --- a/templates/skills/code-search-explorer/SKILL.md +++ b/templates/skills/code-search-explorer/SKILL.md @@ -198,7 +198,7 @@ code_search --db /path/to/db.rocksdb 2. **Use context**: "Trace calls from the Phoenix controller" helps narrow results 3. **Iterate**: Start broad, then drill down based on findings 4. **Verify**: Ask agent to read source files for details after finding locations -5. **Use filters**: `--project`, `--module`, `--limit` help focus results +5. **Use filters**: `--module`, `--limit` help focus results ## Limitations @@ -223,7 +223,7 @@ code_search browse-module MyApp.Module code_search calls-to --function process code_search trace MyModule process --depth 2 code_search depends-on MyApp.Core -code_search unused --project my_app +code_search unused code_search hotspots --kind incoming --limit 20 code_search god-modules ``` @@ -278,7 +278,7 @@ code_search god-modules - **Solution**: Try broader search terms or remove filters **Issue**: "Too many results" -- **Solution**: Use `--limit`, `--project`, or `--module` to narrow results +- **Solution**: Use `--limit` or `--module` to narrow results - **Solution**: Be more specific in function/module names **Issue**: "Function not found but I know it exists" diff --git a/templates/skills/code-search-explorer/reference.md b/templates/skills/code-search-explorer/reference.md index 07e365d..e7b7bb4 100644 --- a/templates/skills/code-search-explorer/reference.md +++ b/templates/skills/code-search-explorer/reference.md @@ -31,7 +31,7 @@ code_search boundaries # Identify architectural boundaries ### Code Quality ```bash -code_search unused [--project NAME] # Find unused functions +code_search unused # Find unused functions code_search hotspots --kind # Find coupling hotspots code_search god-modules # Find overly large modules code_search complexity # Find complex functions @@ -57,7 +57,6 @@ code_search struct-usage # Where is struct used? ## Common Filter Flags ```bash ---project # Filter by project --module # Filter by module pattern (regex) --regex # Treat module pattern as regex --limit # Limit results @@ -144,10 +143,9 @@ code_search hotspots --kind total --limit 15 1. **Start broad, then narrow**: Begin with `search` or `browse-module`, then drill down 2. **Use --format toon for agents**: More efficient for LLM processing -3. **Filter by project**: Use `--project` when working with umbrella apps -4. **Limit results**: Add `--limit` for large codebases -5. **Check database first**: Run `describe` to see what's available -6. **Use regex for patterns**: Add `--regex` flag for complex module patterns +3. **Limit results**: Add `--limit` for large codebases +4. **Check database first**: Run `describe` to see what's available +5. **Use regex for patterns**: Add `--regex` flag for complex module patterns ## Setup & Import diff --git a/templates/skills/complexity/SKILL.md b/templates/skills/complexity/SKILL.md index 71f1b34..3bc5b62 100644 --- a/templates/skills/complexity/SKILL.md +++ b/templates/skills/complexity/SKILL.md @@ -32,7 +32,6 @@ code_search --format toon complexity [MODULE] [OPTIONS] | `--exclude-generated` | Exclude macro-generated functions | false | | `-r, --regex` | Treat patterns as regex | false | | `-l, --limit ` | Max results (1-1000) | 100 | -| `--project ` | Project to search in | `default` | ## Examples diff --git a/templates/skills/cycles/SKILL.md b/templates/skills/cycles/SKILL.md index 8801c15..fd7fd18 100644 --- a/templates/skills/cycles/SKILL.md +++ b/templates/skills/cycles/SKILL.md @@ -31,7 +31,6 @@ code_search --format toon cycles [MODULE] [OPTIONS] | `--involving ` | Only show cycles involving this module (substring match) | none | | `-r, --regex` | Treat patterns as regex | false | | `-l, --limit ` | Max results (1-1000) | 100 | -| `--project ` | Project to search in | `default` | ## Examples diff --git a/templates/skills/depended-by/skill.md b/templates/skills/depended-by/skill.md index 93933d8..5e903a0 100644 --- a/templates/skills/depended-by/skill.md +++ b/templates/skills/depended-by/skill.md @@ -50,4 +50,3 @@ If many modules depend on Repo, it's a central piece of the architecture. | `` | Module name (exact match or pattern with --regex) | required | | `-r, --regex` | Treat patterns as regular expressions | false | | `-l, --limit ` | Max results (1-1000) | 100 | -| `--project ` | Project to search in | `default` | diff --git a/templates/skills/depends-on/skill.md b/templates/skills/depends-on/skill.md index 4ae7f1b..948f71e 100644 --- a/templates/skills/depends-on/skill.md +++ b/templates/skills/depends-on/skill.md @@ -44,4 +44,3 @@ This reveals: | `` | Module name (exact match or pattern with --regex) | required | | `-r, --regex` | Treat patterns as regular expressions | false | | `-l, --limit ` | Max results (1-1000) | 100 | -| `--project ` | Project to search in | `default` | diff --git a/templates/skills/duplicates/SKILL.md b/templates/skills/duplicates/SKILL.md index cd82959..ae2d9f6 100644 --- a/templates/skills/duplicates/SKILL.md +++ b/templates/skills/duplicates/SKILL.md @@ -32,7 +32,6 @@ code_search --format toon duplicates [MODULE] [OPTIONS] | `--exclude-generated` | Exclude macro-generated functions | false | | `-r, --regex` | Treat patterns as regex | false | | `-l, --limit ` | Max results (1-1000) | 100 | -| `--project ` | Project to search in | `default` | ## Examples diff --git a/templates/skills/function/skill.md b/templates/skills/function/skill.md index 912b743..0fe31c8 100644 --- a/templates/skills/function/skill.md +++ b/templates/skills/function/skill.md @@ -48,4 +48,3 @@ Note: This data comes from @spec definitions. Functions without specs won't appe | `-a, --arity ` | Filter by specific arity | all arities | | `-r, --regex` | Treat patterns as regular expressions | false | | `-l, --limit ` | Max results (1-1000) | 100 | -| `--project ` | Project to search in | `default` | diff --git a/templates/skills/god-modules/SKILL.md b/templates/skills/god-modules/SKILL.md index 439c407..294ee3a 100644 --- a/templates/skills/god-modules/SKILL.md +++ b/templates/skills/god-modules/SKILL.md @@ -32,7 +32,6 @@ code_search --format toon god-modules [MODULE] [OPTIONS] | `--min-total ` | Minimum total connectivity (incoming + outgoing) | 10 | | `-r, --regex` | Treat patterns as regex | false | | `-l, --limit ` | Max results (1-1000) | 100 | -| `--project ` | Project to search in | `default` | ## Examples diff --git a/templates/skills/hotspots/skill.md b/templates/skills/hotspots/skill.md index dc6386b..8e5d5ce 100644 --- a/templates/skills/hotspots/skill.md +++ b/templates/skills/hotspots/skill.md @@ -82,4 +82,3 @@ code_search --format toon hotspots --kind ratio -l 10 | `--exclude-generated` | Exclude macro-generated functions | false | | `-r, --regex` | Treat patterns as regular expressions | false | | `-l, --limit ` | Max results (1-1000) | 100 | -| `--project ` | Project to search in | `default` | diff --git a/templates/skills/import/skill.md b/templates/skills/import/skill.md index 6d46270..8343679 100644 --- a/templates/skills/import/skill.md +++ b/templates/skills/import/skill.md @@ -18,15 +18,6 @@ structs_imported: 164 types_imported: 27 ``` -## Import with Project Namespace - -Useful for comparing multiple codebases or versions: - -```bash -code_search --format toon import --file phoenix_v1.json --project phoenix_v1 -code_search --format toon import --file phoenix_v2.json --project phoenix_v2 -``` - ## Clear and Re-import Replace all existing data: diff --git a/templates/skills/large-functions/SKILL.md b/templates/skills/large-functions/SKILL.md index c3b7723..e6f6860 100644 --- a/templates/skills/large-functions/SKILL.md +++ b/templates/skills/large-functions/SKILL.md @@ -31,7 +31,6 @@ code_search --format toon large-functions [MODULE] [OPTIONS] | `--include-generated` | Include macro-generated functions (excluded by default) | false | | `-r, --regex` | Treat patterns as regex | false | | `-l, --limit ` | Max results (1-1000) | 100 | -| `--project ` | Project to search in | `default` | ## Examples diff --git a/templates/skills/location/skill.md b/templates/skills/location/skill.md index 8109828..b59f7fc 100644 --- a/templates/skills/location/skill.md +++ b/templates/skills/location/skill.md @@ -57,4 +57,3 @@ Each location shows: | `-a, --arity ` | Filter by specific arity | all arities | | `-r, --regex` | Treat patterns as regular expressions | false | | `-l, --limit ` | Max results (1-1000) | 100 | -| `--project ` | Project to search in | `default` | diff --git a/templates/skills/many-clauses/SKILL.md b/templates/skills/many-clauses/SKILL.md index 4eae603..aefdfd3 100644 --- a/templates/skills/many-clauses/SKILL.md +++ b/templates/skills/many-clauses/SKILL.md @@ -31,7 +31,6 @@ code_search --format toon many-clauses [MODULE] [OPTIONS] | `--include-generated` | Include macro-generated functions (excluded by default) | false | | `-r, --regex` | Treat patterns as regex | false | | `-l, --limit ` | Max results (1-1000) | 100 | -| `--project ` | Project to search in | `default` | ## Examples diff --git a/templates/skills/path/skill.md b/templates/skills/path/skill.md index 69cdaf7..3d5971b 100644 --- a/templates/skills/path/skill.md +++ b/templates/skills/path/skill.md @@ -68,4 +68,3 @@ Each path is a list of `[module, function, arity]` tuples showing the call chain | `--to-arity ` | Target function arity | all arities | | `--depth ` | Maximum depth to search (1-20) | 10 | | `-l, --limit ` | Max paths to return (1-1000) | 100 | -| `--project ` | Project to search in | `default` | diff --git a/templates/skills/returns/SKILL.md b/templates/skills/returns/SKILL.md index e67af77..3725c4e 100644 --- a/templates/skills/returns/SKILL.md +++ b/templates/skills/returns/SKILL.md @@ -30,7 +30,6 @@ code_search --format toon returns [MODULE] [OPTIONS] |--------|-------------|---------| | `-r, --regex` | Treat patterns as regex | false | | `-l, --limit ` | Max results (1-1000) | 100 | -| `--project ` | Project to search in | `default` | ## Examples diff --git a/templates/skills/reverse-trace/skill.md b/templates/skills/reverse-trace/skill.md index c891293..d3c5eaa 100644 --- a/templates/skills/reverse-trace/skill.md +++ b/templates/skills/reverse-trace/skill.md @@ -52,4 +52,3 @@ Traces backward to find all controller actions or API endpoints that eventually | `--depth ` | Maximum depth to traverse (1-20) | 5 | | `-r, --regex` | Treat patterns as regular expressions | false | | `-l, --limit ` | Max results (1-1000) | 100 | -| `--project ` | Project to search in | `default` | diff --git a/templates/skills/search/skill.md b/templates/skills/search/skill.md index a13ff8f..96b1ce5 100644 --- a/templates/skills/search/skill.md +++ b/templates/skills/search/skill.md @@ -8,12 +8,12 @@ code_search --format toon search Phoenix Output: ``` -modules[69]{name,project}: - Inspect.Phoenix.Socket.Message,default - Mix.Phoenix,default - Phoenix,default - Phoenix.Channel,default - Phoenix.Controller,default +modules[69]{name,source}: + Inspect.Phoenix.Socket.Message,unknown + Mix.Phoenix,unknown + Phoenix,unknown + Phoenix.Channel,unknown + Phoenix.Controller,unknown ... ``` @@ -25,9 +25,9 @@ code_search --format toon search render --kind functions Output: ``` -functions[12]{args,module,name,project,return_type}: - "Plug.Conn.t(), Keyword.t() | map() | binary() | atom()",Phoenix.Controller,render/2,default,"Plug.Conn.t()" - "Plug.Conn.t(), binary() | atom(), Keyword.t() | map()",Phoenix.Controller,render/3,default,"Plug.Conn.t()" +functions[12]{arity,module,name,return_type}: + 2,Phoenix.Controller,render,"" + 3,Phoenix.Controller,render,"" ... ``` @@ -39,10 +39,10 @@ code_search --format toon search '^Phoenix\.Channel' --regex Output: ``` -modules[3]{name,project}: - Phoenix.Channel,default - Phoenix.Channel.Server,default - Phoenix.ChannelTest,default +modules[3]{name,source}: + Phoenix.Channel,unknown + Phoenix.Channel.Server,unknown + Phoenix.ChannelTest,unknown ``` ## Search with Limit @@ -51,12 +51,6 @@ modules[3]{name,project}: code_search --format toon search Controller --limit 5 ``` -## Search in Specific Project - -```bash -code_search --format toon search User --project my_app -``` - ## Options Reference | Option | Description | Default | @@ -64,4 +58,3 @@ code_search --format toon search User --project my_app | `-k, --kind ` | What to search for: `modules` or `functions` | `modules` | | `-r, --regex` | Treat pattern as regular expression | false | | `-l, --limit ` | Max results (1-1000) | 100 | -| `--project ` | Project to search in | `default` | diff --git a/templates/skills/struct-usage/SKILL.md b/templates/skills/struct-usage/SKILL.md index 9d02916..b8ab9bc 100644 --- a/templates/skills/struct-usage/SKILL.md +++ b/templates/skills/struct-usage/SKILL.md @@ -31,7 +31,6 @@ code_search --format toon struct-usage [MODULE] [OPTIONS] | `--by-module` | Aggregate results by module (show counts instead of function details) | false | | `-r, --regex` | Treat patterns as regex | false | | `-l, --limit ` | Max results (1-1000) | 100 | -| `--project ` | Project to search in | `default` | ## Examples diff --git a/templates/skills/trace/skill.md b/templates/skills/trace/skill.md index 55710af..b4a950a 100644 --- a/templates/skills/trace/skill.md +++ b/templates/skills/trace/skill.md @@ -53,4 +53,3 @@ This reveals the full error handling pipeline: catch → instrument → render | `--depth ` | Maximum depth to traverse (1-20) | 5 | | `-r, --regex` | Treat patterns as regular expressions | false | | `-l, --limit ` | Max results (1-1000) | 100 | -| `--project ` | Project to search in | `default` | diff --git a/templates/skills/unused/skill.md b/templates/skills/unused/skill.md index 0714c11..1b25a44 100644 --- a/templates/skills/unused/skill.md +++ b/templates/skills/unused/skill.md @@ -62,4 +62,3 @@ code_search --format toon unused MyApp.Accounts | `-x, --exclude-generated` | Exclude compiler-generated functions (__struct__, __info__, etc.) | false | | `-r, --regex` | Treat patterns as regular expressions | false | | `-l, --limit ` | Max results (1-1000) | 100 | -| `--project ` | Project to search in | `default` |