run

Presents fixable findings, prompts (or auto-applies in non-interactive mode), and calls each selected fix coderef. Returns the count of fixes applied.

NAME

App::Project::Doctor::Fixer - Interactive fix application loop

VERSION

0.01

SYNOPSIS

use App::Project::Doctor::Fixer;

my $fixer = App::Project::Doctor::Fixer->new(
    report  => $report,
    context => $ctx,
);
my $count = $fixer->run;

DESCRIPTION

Presents fixable findings from a report, reads the user's choice from STDIN (Y all, n none, or 1,3 index list), and calls each selected finding's fix coderef with the current context.

Set non_interactive => 1 to apply all fixes without prompting (--fix mode).

CONSTRUCTOR

new( %args )

API SPECIFICATION

Input

report          : App::Project::Doctor::Report   required (blessed, isa Report)
context         : App::Project::Doctor::Context  required (blessed, isa Context)
non_interactive : Bool                           default 0

Output

Blessed hashref of type App::Project::Doctor::Fixer.

ACCESSORS

report, context, non_interactive -- read-only.

METHODS

run

API SPECIFICATION

Input

None.

Output

Integer -- number of fixes successfully applied.

MESSAGES

Code | Trigger               | Resolution
-----|-----------------------|---------------------------------------
F001 | A fix coderef throws  | Fix skipped; error logged via carp

FORMAL SPECIFICATION

run : Fixer -> N
run fixer ==
  let fixable = { f in findings (report fixer) | is_fixable f }
  in  if non_interactive fixer
      then apply_all fixable
      else apply_chosen fixable (prompt fixable)

LIMITATIONS

Reads from STDIN; use non_interactive => 1 in automated pipelines.

Encapsulation of _interactive_loop, _apply_all, and _print_fix_list is enforced by convention only; a future migration to Sub::Private in enforce mode is tracked as a TODO.

AUTHOR

Nigel Horne <njh@nigelhorne.com>

LICENSE

Copyright (C) 2026 Nigel Horne. This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.