| 1 | package Claude::Agent::Code::Refactor::Result; | ||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||
| 3 | 5 | ▶ | use 5.020; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 4 | 5 | ▶ | use strict; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 5 | 5 | ▶ | use warnings; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||
| 7 | 5 | ▶ | use Object::Proto (); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||
| 9 | 5 | ▶ | BEGIN { | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 10 | 5 | Object::Proto::define('Claude::Agent::Code::Refactor::Result', | |||||||||||||||||||||||||||||||
| 11 | 'success:Bool:default(0)', | ||||||||||||||||||||||||||||||||
| 12 | 'iterations:Int:default(0)', | ||||||||||||||||||||||||||||||||
| 13 | 'initial_issues:Int:default(0)', | ||||||||||||||||||||||||||||||||
| 14 | 'final_issues:Int:default(0)', | ||||||||||||||||||||||||||||||||
| 15 | 'fixes_applied:Int:default(0)', | ||||||||||||||||||||||||||||||||
| 16 | 'files_modified:ArrayRef:default([])', | ||||||||||||||||||||||||||||||||
| 17 | 'history:ArrayRef:default([])', | ||||||||||||||||||||||||||||||||
| 18 | 'final_report', | ||||||||||||||||||||||||||||||||
| 19 | 'duration_ms:Num:default(0)', | ||||||||||||||||||||||||||||||||
| 20 | 'error', | ||||||||||||||||||||||||||||||||
| 21 | ); | ||||||||||||||||||||||||||||||||
| 22 | } | ||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||
| 24 | 10 | ▶ | sub is_clean { | ||||||||||||||||||||||||||||||
|
Subroutine
is_clean: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 25 | 10 | my ($self) = @_; | |||||||||||||||||||||||||||||||
| 26 | 10 | ▶ | return $self->success && $self->final_issues == 0; | ||||||||||||||||||||||||||||||
|
Condition100%3/3
$self->success && $self->final_issues == 0
MC/DC100%2/2
$self->success && $self->final_issues == 0
$self->success
$self->final_issues == 0
Truth table100%3/3
A && B
A= $self->successB= $self->final_issues == 0
| |||||||||||||||||||||||||||||||||
| 27 | } | ||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||
| 29 | 13 | ▶ | sub has_error { | ||||||||||||||||||||||||||||||
|
Subroutine
has_error: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 30 | 13 | my ($self) = @_; | |||||||||||||||||||||||||||||||
| 31 | 13 | ▶ | return defined $self->error && length $self->error; | ||||||||||||||||||||||||||||||
|
Condition100%3/3
defined $self->error && length $self->error
MC/DC100%2/2
defined $self->error && length $self->error
defined $self->error
length $self->error
Truth table100%3/3
A && B
A= defined $self->errorB= length $self->error
| |||||||||||||||||||||||||||||||||
| 32 | } | ||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||
| 34 | 17 | ▶ | sub issues_fixed { | ||||||||||||||||||||||||||||||
|
Subroutine
issues_fixed: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 35 | 17 | my ($self) = @_; | |||||||||||||||||||||||||||||||
| 36 | 17 | my $fixed = $self->initial_issues - $self->final_issues; | |||||||||||||||||||||||||||||||
| 37 | 17 | ▶ | return $fixed > 0 ? $fixed : 0; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||
| 40 | 16 | ▶ | sub fix_rate { | ||||||||||||||||||||||||||||||
|
Subroutine
fix_rate: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 41 | 16 | my ($self) = @_; | |||||||||||||||||||||||||||||||
| 42 | 16 | ▶ | return 100 if $self->initial_issues == 0; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 43 | 11 | return int(($self->issues_fixed / $self->initial_issues) * 100); | |||||||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||
| 46 | 12 | ▶ | sub add_iteration { | ||||||||||||||||||||||||||||||
|
Subroutine
add_iteration: called CC=8 SCAR=20.8
Pod
documented
| |||||||||||||||||||||||||||||||||
| 47 | 12 | my ($self, %args) = @_; | |||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||
| 49 | 12 | my $iteration = scalar(@{$self->history}) + 1; | |||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||
| 51 | 12 | ▶ | push @{$self->history}, { | ||||||||||||||||||||||||||||||
|
Condition100%6/6
$args{"issues_found"} // 0
$args{"issues_fixed"} // 0
$args{"files_modified"} // []
MC/DC100%1/1
$args{"issues_found"} // 0
$args{"issues_found"}
MC/DC100%1/1
$args{"issues_fixed"} // 0
$args{"issues_fixed"}
MC/DC100%1/1
$args{"files_modified"} // []
$args{"files_modified"}
Truth table100%2/2
A
A= $args{"issues_found"}
Truth table100%2/2
A
A= $args{"issues_fixed"}
Truth table100%2/2
A
A= $args{"files_modified"}
| |||||||||||||||||||||||||||||||||
| 52 | iteration => $iteration, | ||||||||||||||||||||||||||||||||
| 53 | issues_found => $args{issues_found} // 0, | ||||||||||||||||||||||||||||||||
| 54 | issues_fixed => $args{issues_fixed} // 0, | ||||||||||||||||||||||||||||||||
| 55 | 12 | files_modified => $args{files_modified} // [], | |||||||||||||||||||||||||||||||
| 56 | }; | ||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||
| 58 | 12 | ▶ | $self->fixes_applied($self->fixes_applied + ($args{issues_fixed} // 0)); | ||||||||||||||||||||||||||||||
|
Condition100%2/2
$args{"issues_fixed"} // 0
MC/DC100%1/1
$args{"issues_fixed"} // 0
$args{"issues_fixed"}
Truth table100%2/2
A
A= $args{"issues_fixed"}
| |||||||||||||||||||||||||||||||||
| 59 | 12 | $self->iterations($iteration); | |||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||
| 61 | 12 | my %seen = map { $_ => 1 } @{$self->files_modified}; | |||||||||||||||||||||||||||||||
| 62 | 12 | ▶ | for my $file (@{$args{files_modified} // []}) { | ||||||||||||||||||||||||||||||
|
Condition100%2/2
$args{"files_modified"} // []
MC/DC100%1/1
$args{"files_modified"} // []
$args{"files_modified"}
Truth table100%2/2
A
A= $args{"files_modified"}
| |||||||||||||||||||||||||||||||||
| 63 | 14 | ▶ | push @{$self->files_modified}, $file unless $seen{$file}++; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||
| 66 | 12 | return; | |||||||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||
| 69 | 4 | ▶ | sub as_text { | ||||||||||||||||||||||||||||||
|
Subroutine
as_text: called CC=7 SCAR=19.5
Pod
documented
| |||||||||||||||||||||||||||||||||
| 70 | 4 | my ($self) = @_; | |||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||
| 72 | 4 | my @lines; | |||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||
| 74 | 4 | push @lines, "=" x 60; | |||||||||||||||||||||||||||||||
| 75 | 4 | push @lines, "REFACTOR RESULT"; | |||||||||||||||||||||||||||||||
| 76 | 4 | push @lines, "=" x 60; | |||||||||||||||||||||||||||||||
| 77 | 4 | push @lines, ""; | |||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||
| 79 | 4 | ▶ | if ($self->has_error) { | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||
| 80 | 1 | push @lines, "Status: FAILED"; | |||||||||||||||||||||||||||||||
| 81 | 1 | push @lines, "Error: " . $self->error; | |||||||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||||||
| 83 | elsif ($self->is_clean) { | ||||||||||||||||||||||||||||||||
| 84 | 2 | push @lines, "Status: SUCCESS - All issues resolved"; | |||||||||||||||||||||||||||||||
| 85 | } | ||||||||||||||||||||||||||||||||
| 86 | else { | ||||||||||||||||||||||||||||||||
| 87 | 1 | push @lines, "Status: INCOMPLETE - Some issues remain"; | |||||||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||
| 90 | 4 | push @lines, ""; | |||||||||||||||||||||||||||||||
| 91 | 4 | push @lines, "Iterations: " . $self->iterations; | |||||||||||||||||||||||||||||||
| 92 | 4 | push @lines, "Initial issues: " . $self->initial_issues; | |||||||||||||||||||||||||||||||
| 93 | 4 | push @lines, "Final issues: " . $self->final_issues; | |||||||||||||||||||||||||||||||
| 94 | 4 | push @lines, "Fixes applied: " . $self->fixes_applied; | |||||||||||||||||||||||||||||||
| 95 | 4 | push @lines, "Fix rate: " . $self->fix_rate . "%"; | |||||||||||||||||||||||||||||||
| 96 | 4 | push @lines, "Duration: " . sprintf("%.1f", $self->duration_ms / 1000) . "s"; | |||||||||||||||||||||||||||||||
| 97 | 4 | push @lines, ""; | |||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||
| 99 | 4 | ▶ | if (@{$self->files_modified}) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 100 | 2 | push @lines, "Files modified:"; | |||||||||||||||||||||||||||||||
| 101 | 2 | for my $file (@{$self->files_modified}) { | |||||||||||||||||||||||||||||||
| 102 | 2 | push @lines, " - $file"; | |||||||||||||||||||||||||||||||
| 103 | } | ||||||||||||||||||||||||||||||||
| 104 | 2 | push @lines, ""; | |||||||||||||||||||||||||||||||
| 105 | } | ||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||
| 107 | 4 | ▶ | if (@{$self->history}) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 108 | 1 | push @lines, "History:"; | |||||||||||||||||||||||||||||||
| 109 | 1 | for my $iter (@{$self->history}) { | |||||||||||||||||||||||||||||||
| 110 | push @lines, sprintf(" Iteration %d: found %d, fixed %d", | ||||||||||||||||||||||||||||||||
| 111 | $iter->{iteration}, | ||||||||||||||||||||||||||||||||
| 112 | $iter->{issues_found}, | ||||||||||||||||||||||||||||||||
| 113 | $iter->{issues_fixed}, | ||||||||||||||||||||||||||||||||
| 114 | 1 | ); | |||||||||||||||||||||||||||||||
| 115 | } | ||||||||||||||||||||||||||||||||
| 116 | } | ||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||
| 118 | 4 | push @lines, ""; | |||||||||||||||||||||||||||||||
| 119 | 4 | push @lines, "=" x 60; | |||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||
| 121 | 4 | return join("\n", @lines) . "\n"; | |||||||||||||||||||||||||||||||
| 122 | } | ||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||
| 124 | 3 | ▶ | sub to_hash { | ||||||||||||||||||||||||||||||
|
Subroutine
to_hash: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 125 | 3 | my ($self) = @_; | |||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||
| 127 | return { | ||||||||||||||||||||||||||||||||
| 128 | 3 | ▶ | success => $self->success ? 1 : 0, | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||
| 129 | iterations => $self->iterations, | ||||||||||||||||||||||||||||||||
| 130 | initial_issues => $self->initial_issues, | ||||||||||||||||||||||||||||||||
| 131 | final_issues => $self->final_issues, | ||||||||||||||||||||||||||||||||
| 132 | fixes_applied => $self->fixes_applied, | ||||||||||||||||||||||||||||||||
| 133 | fix_rate => $self->fix_rate, | ||||||||||||||||||||||||||||||||
| 134 | files_modified => $self->files_modified, | ||||||||||||||||||||||||||||||||
| 135 | history => $self->history, | ||||||||||||||||||||||||||||||||
| 136 | duration_ms => $self->duration_ms, | ||||||||||||||||||||||||||||||||
| 137 | ($self->has_error ? (error => $self->error) : ()), | ||||||||||||||||||||||||||||||||
| 138 | }; | ||||||||||||||||||||||||||||||||
| 139 | } | ||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||
| 142 | 5 | 1; | |||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||
| 144 | __END__ | ||||||||||||||||||||||||||||||||