Class: Aidp::Analyze::RubyMaatIntegration
- Inherits:
-
Object
- Object
- Aidp::Analyze::RubyMaatIntegration
- Includes:
- MessageDisplay
- Defined in:
- lib/aidp/analyze/ruby_maat_integration.rb
Constant Summary
Constants included from MessageDisplay
Instance Method Summary collapse
-
#analyze_authorship(git_log_file = nil) ⇒ Object
Run RubyMaat analysis for authorship.
-
#analyze_churn(git_log_file = nil) ⇒ Object
Run RubyMaat analysis for code churn.
-
#analyze_coupling(git_log_file = nil) ⇒ Object
Run RubyMaat analysis for coupling.
-
#analyze_summary(git_log_file = nil) ⇒ Object
Run RubyMaat analysis for summary.
-
#generate_git_log(output_file = nil) ⇒ Object
Generate Git log for RubyMaat analysis.
-
#get_high_churn_files(threshold = 10) ⇒ Object
Get high-churn files for prioritization.
-
#get_knowledge_silos ⇒ Object
Get knowledge silos (files with single author).
-
#get_tightly_coupled_files(threshold = 5) ⇒ Object
Get tightly coupled files.
-
#initialize(project_dir = Dir.pwd, prompt: TTY::Prompt.new) ⇒ RubyMaatIntegration
constructor
A new instance of RubyMaatIntegration.
-
#run_chunked_analysis(git_log_file) ⇒ Object
Run analysis on large repositories using chunking.
-
#run_comprehensive_analysis ⇒ Object
Run comprehensive RubyMaat analysis.
-
#run_full_analysis(git_log_file) ⇒ Object
Run full analysis on smaller repositories.
Methods included from MessageDisplay
#display_message, #in_test_environment?, included, #message_display_prompt, #suppress_display_message?
Constructor Details
#initialize(project_dir = Dir.pwd, prompt: TTY::Prompt.new) ⇒ RubyMaatIntegration
Returns a new instance of RubyMaatIntegration.
13 14 15 16 |
# File 'lib/aidp/analyze/ruby_maat_integration.rb', line 13 def initialize(project_dir = Dir.pwd, prompt: TTY::Prompt.new) @project_dir = project_dir @prompt = prompt end |
Instance Method Details
#analyze_authorship(git_log_file = nil) ⇒ Object
Run RubyMaat analysis for authorship
54 55 56 57 58 59 60 |
# File 'lib/aidp/analyze/ruby_maat_integration.rb', line 54 def (git_log_file = nil) git_log_file ||= File.join(@project_dir, "git.log") output_file = File.join(@project_dir, "authorship.csv") run_ruby_maat("authorship", git_log_file, output_file) (output_file) end |
#analyze_churn(git_log_file = nil) ⇒ Object
Run RubyMaat analysis for code churn
36 37 38 39 40 41 42 |
# File 'lib/aidp/analyze/ruby_maat_integration.rb', line 36 def analyze_churn(git_log_file = nil) git_log_file ||= File.join(@project_dir, "git.log") output_file = File.join(@project_dir, "churn.csv") run_ruby_maat("churn", git_log_file, output_file) parse_churn_results(output_file) end |
#analyze_coupling(git_log_file = nil) ⇒ Object
Run RubyMaat analysis for coupling
45 46 47 48 49 50 51 |
# File 'lib/aidp/analyze/ruby_maat_integration.rb', line 45 def analyze_coupling(git_log_file = nil) git_log_file ||= File.join(@project_dir, "git.log") output_file = File.join(@project_dir, "coupling.csv") run_ruby_maat("coupling", git_log_file, output_file) parse_coupling_results(output_file) end |
#analyze_summary(git_log_file = nil) ⇒ Object
Run RubyMaat analysis for summary
63 64 65 66 67 68 69 |
# File 'lib/aidp/analyze/ruby_maat_integration.rb', line 63 def analyze_summary(git_log_file = nil) git_log_file ||= File.join(@project_dir, "git.log") output_file = File.join(@project_dir, "summary.csv") run_ruby_maat("summary", git_log_file, output_file) parse_summary_results(output_file) end |
#generate_git_log(output_file = nil) ⇒ Object
Generate Git log for RubyMaat analysis
21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/aidp/analyze/ruby_maat_integration.rb', line 21 def generate_git_log(output_file = nil) output_file ||= File.join(@project_dir, "git.log") raise "Not a Git repository. RubyMaat requires a Git repository for analysis." unless git_repository? cmd = TTY::Command.new(printer: :null) result = cmd.run("git", "log", '--pretty=format:"%h|%an|%ad|%aE|%s"', "--date=short", "--numstat", chdir: @project_dir) raise "Failed to generate Git log: #{result.err}" unless result.success? File.write(output_file, result.out) output_file end |
#get_high_churn_files(threshold = 10) ⇒ Object
Get high-churn files for prioritization
131 132 133 134 135 |
# File 'lib/aidp/analyze/ruby_maat_integration.rb', line 131 def get_high_churn_files(threshold = 10) churn_data = analyze_churn churn_data[:files].select { |file| file[:changes] > threshold } .sort_by { |file| -file[:changes] } end |
#get_knowledge_silos ⇒ Object
Get knowledge silos (files with single author)
145 146 147 148 149 |
# File 'lib/aidp/analyze/ruby_maat_integration.rb', line 145 def get_knowledge_silos = [:files].select { |file| file[:authors].length == 1 } .sort_by { |file| -file[:changes] } end |
#get_tightly_coupled_files(threshold = 5) ⇒ Object
Get tightly coupled files
138 139 140 141 142 |
# File 'lib/aidp/analyze/ruby_maat_integration.rb', line 138 def get_tightly_coupled_files(threshold = 5) coupling_data = analyze_coupling coupling_data[:couplings].select { |coupling| coupling[:shared_changes] > threshold } .sort_by { |coupling| -coupling[:shared_changes] } end |
#run_chunked_analysis(git_log_file) ⇒ Object
Run analysis on large repositories using chunking
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/aidp/analyze/ruby_maat_integration.rb', line 86 def run_chunked_analysis(git_log_file) ("Large repository detected. Running chunked analysis...", type: :info) # Split analysis into chunks chunks = create_analysis_chunks(git_log_file) results = { churn: {files: [], total_files: 0, total_changes: 0}, coupling: {couplings: [], total_couplings: 0, average_coupling: 0}, authorship: {files: [], total_files: 0, files_with_multiple_authors: 0, files_with_single_author: 0}, summary: {summary: {}} } chunks.each_with_index do |chunk, index| ("Processing chunk #{index + 1}/#{chunks.length}...", type: :info) chunk_results = analyze_chunk(chunk) # Merge results merge_analysis_results(results, chunk_results) end # Generate consolidated report generate_consolidated_report(results) results end |
#run_comprehensive_analysis ⇒ Object
Run comprehensive RubyMaat analysis
72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/aidp/analyze/ruby_maat_integration.rb', line 72 def run_comprehensive_analysis # Generate Git log if not exists git_log_file = File.join(@project_dir, "git.log") generate_git_log(git_log_file) unless File.exist?(git_log_file) # Check if repository is large and needs chunking if large_repository?(git_log_file) run_chunked_analysis(git_log_file) else run_full_analysis(git_log_file) end end |
#run_full_analysis(git_log_file) ⇒ Object
Run full analysis on smaller repositories
115 116 117 118 119 120 121 122 123 124 125 126 127 128 |
# File 'lib/aidp/analyze/ruby_maat_integration.rb', line 115 def run_full_analysis(git_log_file) # Run all analyses results = { churn: analyze_churn(git_log_file), coupling: analyze_coupling(git_log_file), authorship: (git_log_file), summary: analyze_summary(git_log_file) } # Generate consolidated report generate_consolidated_report(results) results end |