|
| 1 | +//! Code analysis subcommands. |
| 2 | +
|
| 3 | +use clap::Subcommand; |
| 4 | +use enum_dispatch::enum_dispatch; |
| 5 | + |
| 6 | +use super::{ |
| 7 | + AcceptsCmd, BoundariesCmd, BrowseModuleCmd, CallsFromCmd, CallsToCmd, ClustersCmd, |
| 8 | + ComplexityCmd, CyclesCmd, DependedByCmd, DependsOnCmd, DuplicatesCmd, FunctionCmd, |
| 9 | + GodModulesCmd, HotspotsCmd, ImportCmd, LargeFunctionsCmd, LocationCmd, ManyClausesCmd, |
| 10 | + PathCmd, ReturnsCmd, ReverseTraceCmd, SearchCmd, StructUsageCmd, TraceCmd, UnusedCmd, |
| 11 | +}; |
| 12 | + |
| 13 | +#[derive(Subcommand, Debug)] |
| 14 | +#[enum_dispatch(CommandRunner)] |
| 15 | +pub enum CodeCommand { |
| 16 | + /// Import a call graph JSON file into the database |
| 17 | + Import(ImportCmd), |
| 18 | + /// Browse all definitions in a module or file |
| 19 | + BrowseModule(BrowseModuleCmd), |
| 20 | + /// Search for modules or functions by name pattern |
| 21 | + Search(SearchCmd), |
| 22 | + /// Find where a function is defined (file:line_start:line_end) |
| 23 | + Location(LocationCmd), |
| 24 | + /// Show what a module/function calls (outgoing edges) |
| 25 | + CallsFrom(CallsFromCmd), |
| 26 | + /// Show what calls a module/function (incoming edges) |
| 27 | + CallsTo(CallsToCmd), |
| 28 | + /// Analyze module connectivity using namespace-based clustering |
| 29 | + Clusters(ClustersCmd), |
| 30 | + /// Display complexity metrics for functions |
| 31 | + Complexity(ComplexityCmd), |
| 32 | + /// Detect circular dependencies between modules |
| 33 | + Cycles(CyclesCmd), |
| 34 | + /// Show function signature (args, return type) |
| 35 | + Function(FunctionCmd), |
| 36 | + /// Trace call chains from a starting function (forward traversal) |
| 37 | + Trace(TraceCmd), |
| 38 | + /// Trace call chains backwards - who calls the callers of a target |
| 39 | + ReverseTrace(ReverseTraceCmd), |
| 40 | + /// Find a call path between two functions |
| 41 | + Path(PathCmd), |
| 42 | + /// Find functions accepting a specific type pattern |
| 43 | + Accepts(AcceptsCmd), |
| 44 | + /// Find functions returning a specific type pattern |
| 45 | + Returns(ReturnsCmd), |
| 46 | + /// Find functions that accept or return a specific type pattern |
| 47 | + StructUsage(StructUsageCmd), |
| 48 | + /// Show what modules a given module depends on (outgoing module dependencies) |
| 49 | + DependsOn(DependsOnCmd), |
| 50 | + /// Show what modules depend on a given module (incoming module dependencies) |
| 51 | + DependedBy(DependedByCmd), |
| 52 | + /// Find functions that are never called |
| 53 | + Unused(UnusedCmd), |
| 54 | + /// Find functions with identical or near-identical implementations |
| 55 | + Duplicates(DuplicatesCmd), |
| 56 | + /// Find functions with the most incoming/outgoing calls |
| 57 | + Hotspots(HotspotsCmd), |
| 58 | + /// Find boundary modules - modules with high fan-in but low fan-out |
| 59 | + Boundaries(BoundariesCmd), |
| 60 | + /// Find god modules - modules with high function count and high connectivity |
| 61 | + GodModules(GodModulesCmd), |
| 62 | + /// Find large functions that may need refactoring |
| 63 | + LargeFunctions(LargeFunctionsCmd), |
| 64 | + /// Find functions with many pattern-matched heads |
| 65 | + ManyClauses(ManyClausesCmd), |
| 66 | +} |
0 commit comments