Class: CodeSage::Reviewer
- Inherits:
-
Object
- Object
- CodeSage::Reviewer
- Defined in:
- lib/code_sage/reviewer.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Reviewer
constructor
A new instance of Reviewer.
- #review ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Reviewer
Returns a new instance of Reviewer.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/code_sage/reviewer.rb', line 7 def initialize( = {}) @options = { branch: 'main', files: nil, format: 'console', format_explicit: false, config_path: nil, verbose: false, enable_rag: false, # Отключаем RAG по умолчанию auto_fix: false, confirm_fixes: true }.merge() # Load configuration first @config = @options[:config_path] ? Config.new(@options[:config_path]) : Config.new # Show config info in verbose mode if @options[:verbose] @config.show_config_info end # Determine output format: CLI explicit > config > CLI default output_format = if @options[:format_explicit] @options[:format] else @config.data['output']['format'] || @options[:format] end @git_analyzer = GitAnalyzer.new(@options) @formatter = ReportFormatter.new(output_format) @llm_chain = setup_llm_chain end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
5 6 7 |
# File 'lib/code_sage/reviewer.rb', line 5 def @options end |
Instance Method Details
#review ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/code_sage/reviewer.rb', line 40 def review puts "🔍 Analyzing code changes..." if @options[:verbose] changes = @git_analyzer.get_changes if changes.empty? return { success: true, message: "No changes to review" } end puts "📝 Found #{changes.length} changed files" if @options[:verbose] reviews = [] changes.each do |change| puts "Reviewing #{change[:file]}..." if @options[:verbose] review = review_file(change) reviews << review if review end report = generate_report(reviews) output_report(report) # Apply auto-fixes if requested if @options[:auto_fix] apply_fixes(reviews) end { success: true, reviews: reviews, report: report } rescue => e { success: false, error: e. } end |