Refactor/Options.pm

filter: Statementstmt 100% 53 / 53 Branchbran 78.1% 25 / 32 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 8 / 8 Podpod 50.0% 1 / 2 totaltotal 91.5% 87 / 95 CC 18 SCAR 23.9
CC
18
Cov
92%
BUILD
16.1
to_review_options
3.1
BEGIN
1.0
CRAP 10.9
« Refactor.pm ↑ Summary Refactor/Result.pm »
1 package Claude::Agent::Code::Refactor::Options;
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 my @VALID_SEVERITIES = qw(critical high medium low info);
10 5 my @VALID_CATEGORIES = qw(bugs security style performance maintainability);
11  
12 5 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
13 5 Object::Proto::define('Claude::Agent::Code::Refactor::Options',
14 'max_iterations:Int:default(5)',
15 'max_turns_per_fix:Int:default(20)',
16 'stop_on_critical:Bool:default(1)',
17 'min_severity:Str:default(low)',
18 'categories:builder(_build_categories)',
19 'fix_one_at_a_time:Bool:default(0)',
20 'dry_run:Bool:default(0)',
21 'create_backup:Bool:default(0)',
22 'perlcritic:default(0)',
23 'perlcritic_severity:Int:default(4)',
24 'filter_false_positives:Bool:default(1)',
25 'model',
26 'effort:Str:predicate',
27 'permission_mode:Str:default(acceptEdits)',
28 );
29 }
30  
31 34 ▶sub _build_categories {
Subroutine _build_categories: called CC=1 SCAR=0.0
32 34 return [@VALID_CATEGORIES];
33 }
34  
35 49 ▶sub BUILD {
Subroutine BUILD: called CC=16 SCAR=27.8
Pod undocumented
36 49 my ($self) = @_;
37  
38 49 ▶ if (defined $self->min_severity) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->min_severity) 49 0 49
39 49 my $sev = $self->min_severity;
40 49 ▶ unless (grep { $_ eq $sev } @VALID_SEVERITIES) {
Branch: 1 branch
BranchTrueFalseTotal
unless (grep {$_ eq $sev;} @VALID_SEVERITIES) 3 46 49
41 3 my $safe_sev = $sev =~ s/[^a-zA-Z0-9_-]//gr;
42 3 die "Invalid min_severity '$safe_sev'. Must be one of: " . join(', ', @VALID_SEVERITIES);
43 }
44 }
45  
46 46 ▶ if (defined $self->categories) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->categories) 46 0 46
47 46 ▶ unless (ref $self->categories eq 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $self->categories eq "ARRAY") 1 45 46
48 1 die "Categories must be an array reference";
49 }
50 45 ▶ unless (@{$self->categories}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (@{$self->categories;}) 2 43 45
51 2 die "Categories cannot be empty";
52 }
53 43 for my $cat (@{$self->categories}) {
54 176 ▶ unless (grep { $_ eq $cat } @VALID_CATEGORIES) {
Branch: 1 branch
BranchTrueFalseTotal
unless (grep {$_ eq $cat;} @VALID_CATEGORIES) 2 174 176
55 2 my $safe_cat = $cat =~ s/[^a-zA-Z0-9_-]//gr;
56 2 die "Invalid category '$safe_cat'. Must be one of: " . join(', ', @VALID_CATEGORIES);
57 }
58 }
59 }
60  
61 41 ▶ if (defined $self->max_iterations) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->max_iterations) 41 0 41
62 41 ▶ if ($self->max_iterations < 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->max_iterations < 1) 2 39 41
63 2 die "max_iterations must be >= 1";
64 }
65 39 ▶ if ($self->max_iterations > 100) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->max_iterations > 100) 1 38 39
66 1 die "max_iterations must be <= 100 to prevent resource exhaustion";
67 }
68 }
69  
70 38 ▶ if (defined $self->max_turns_per_fix) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->max_turns_per_fix) 38 0 38
71 38 ▶ if ($self->max_turns_per_fix < 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->max_turns_per_fix < 1) 2 36 38
72 2 die "max_turns_per_fix must be >= 1";
73 }
74 36 ▶ if ($self->max_turns_per_fix > 100) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->max_turns_per_fix > 100) 1 35 36
75 1 die "max_turns_per_fix must be <= 100 to prevent resource exhaustion";
76 }
77 }
78  
79 35 ▶ if (defined $self->perlcritic_severity) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->perlcritic_severity) 35 0 35
80 35 my $sev = $self->perlcritic_severity;
81 35 ▶ unless ($sev =~ /^[1-5]$/) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($sev =~ /^[1-5]$/u) 3 32 35
82 3 die "Invalid perlcritic_severity '$sev'. Must be 1-5";
83 }
84 }
85 }
86  
87 1 ▶sub to_review_options {
Subroutine to_review_options: called CC=3 SCAR=11.4
Pod documented
88 1 my ($self) = @_;
89  
90 1 require Claude::Agent::Code::Review::Options;
91  
92 1 my $review_perm_mode = 'default';
93  
94 1 ▶ return Claude::Agent::Code::Review::Options->new(
Branch: 2 branches
BranchTrueFalseTotal
$self->model ? : 1 0 1
$self->has_effort ? : 0 1 1
95 severity => $self->min_severity,
96 categories => $self->categories,
97 perlcritic => $self->perlcritic,
98 perlcritic_severity => $self->perlcritic_severity,
99 filter_false_positives => $self->filter_false_positives,
100 permission_mode => $review_perm_mode,
101 ($self->model ? (model => $self->model) : ()),
102 ($self->has_effort ? (effort => $self->effort) : ()),
103 );
104 }
105  
106  
107 5 1;
108  
109 __END__
« Refactor.pm ↑ Summary Refactor/Result.pm »