Class: Soba::Services::WorkflowIntegrityChecker
- Inherits:
-
Object
- Object
- Soba::Services::WorkflowIntegrityChecker
- Defined in:
- lib/soba/services/workflow_integrity_checker.rb
Constant Summary collapse
- ACTIVE_LABELS =
%w( soba:queued soba:planning soba:doing soba:reviewing soba:revising ).freeze
- INTERMEDIATE_LABELS =
%w( soba:review-requested soba:requires-changes ).freeze
Instance Attribute Summary collapse
-
#github_client ⇒ Object
readonly
Returns the value of attribute github_client.
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
Instance Method Summary collapse
- #check_and_fix(repository, issues:, dry_run: false) ⇒ Object
-
#initialize(github_client:, logger: nil) ⇒ WorkflowIntegrityChecker
constructor
A new instance of WorkflowIntegrityChecker.
Constructor Details
#initialize(github_client:, logger: nil) ⇒ WorkflowIntegrityChecker
Returns a new instance of WorkflowIntegrityChecker.
23 24 25 26 |
# File 'lib/soba/services/workflow_integrity_checker.rb', line 23 def initialize(github_client:, logger: nil) @github_client = github_client @logger = logger || SemanticLogger["WorkflowIntegrityChecker"] end |
Instance Attribute Details
#github_client ⇒ Object (readonly)
Returns the value of attribute github_client.
21 22 23 |
# File 'lib/soba/services/workflow_integrity_checker.rb', line 21 def github_client @github_client end |
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
21 22 23 |
# File 'lib/soba/services/workflow_integrity_checker.rb', line 21 def logger @logger end |
Instance Method Details
#check_and_fix(repository, issues:, dry_run: false) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 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 72 73 |
# File 'lib/soba/services/workflow_integrity_checker.rb', line 28 def check_and_fix(repository, issues:, dry_run: false) logger.info("Checking workflow integrity for #{repository}") violations = detect_violations(issues) if violations.empty? logger.info("No workflow integrity violations found") return { violations_found: false, fixed_count: 0, violations: [], dry_run: dry_run, } end logger.warn("Found #{violations.size} workflow integrity violations") violations.each do |violation| logger.warn(" Issue ##{violation[:issue_number]}: #{violation[:label]} (#{violation[:action]})") end fixed_count = 0 failed_fixes = 0 if dry_run logger.info("Dry run mode - no fixes applied") else violations.each do |violation| if fix_violation(repository, violation) fixed_count += 1 else failed_fixes += 1 end end if fixed_count > 0 || failed_fixes > 0 logger.info("Fixed #{fixed_count} violations, #{failed_fixes} failed") end end { violations_found: true, fixed_count: fixed_count, failed_fixes: failed_fixes, violations: violations, dry_run: dry_run, } end |