NAME
App::GHGen::Fixer - Auto-fix workflow issues
SYNOPSIS
use App::GHGen::Fixer qw(apply_fixes);
my $fixed = apply_fixes($workflow, \@issues);
FUNCTIONS
can_auto_fix($issue)
Determine whether a given issue can be automatically resolved.
Purpose
Act as a capability gate before calling apply_fixes. Returns true only for the four issue types that the Fixer knows how to handle.
Arguments
$issue(HashRef, required)-
An issue hash with at least a
typekey. Recognised types areperformance,security,cost, andmaintenance.
Returns
1 (true) when the issue type is auto-fixable; 0 (false) otherwise.
Side Effects
None. Pure predicate.
Usage Example
if (can_auto_fix($issue)) {
apply_fixes($workflow, [$issue]);
}
API SPECIFICATION
Input
{ issue => { type => 'hashref', required => 1 } }
Output
{ type => 'scalar' } # boolean: 1 or 0
FORMAL SPECIFICATION
can_auto_fix : Issue → 𝔹
FixableTypes ≔ { performance, security, cost, maintenance }
can_auto_fix(i) ≡ i.type ∈ FixableTypes
apply_fixes($workflow, $issues)
Apply all auto-fixable changes from $issues directly to $workflow.
Purpose
Iterate over $issues, skip issues that are not auto-fixable, and call the appropriate internal fix routine for each fixable type/message combination. Modifies $workflow in place.
Arguments
$workflow(HashRef, required)-
The parsed workflow hash to be mutated.
$issues(ArrayRef[HashRef], required)-
The issues to process. Each must have
typeandmessagekeys.
Returns
The number of individual fix operations applied (an integer ≥ 0).
Side Effects
Modifies $workflow in place.
Usage Example
my $n = apply_fixes($workflow, \@issues);
say "$n fix(es) applied.";
API SPECIFICATION
Input
{
workflow => { type => 'hashref', required => 1 },
issues => { type => 'arrayref', required => 1 },
}
Output
{ type => 'scalar' } # non-negative integer
FORMAL SPECIFICATION
apply_fixes : Workflow × seq Issue → ℕ
applied ≔ ∑ { fix(w, i) ∣ i ∈ issues, can_auto_fix(i) }
result ≔ applied
Mutates w by applying each fix in sequence.
fix_workflow($file, $issues)
Load a workflow YAML file, apply fixes, and write it back to disk.
Purpose
Persist the results of apply_fixes by reading the workflow from $file with YAML::XS::LoadFile, calling apply_fixes, and rewriting the file with YAML::XS::DumpFile when at least one fix was applied.
Arguments
$file(Str, required)-
Path to a YAML workflow file. Passed directly to
YAML::XS::LoadFile. $issues(ArrayRef[HashRef], required)-
Issues to fix, each with
typeandmessagekeys.
Returns
The number of fixes applied (an integer ≥ 0). The file is only rewritten when the count is greater than zero.
Side Effects
Reads $file from disk; rewrites $file in place when fixes are applied.
Usage Example
my $n = fix_workflow('.github/workflows/ci.yml', \@issues);
say "$n fix(es) written to ci.yml.";
API SPECIFICATION
Input
{
file => { type => 'scalar', required => 1 },
issues => { type => 'arrayref', required => 1 },
}
Output
{ type => 'scalar' } # non-negative integer
FORMAL SPECIFICATION
fix_workflow : Path × seq Issue → ℕ
w ≔ LoadFile(file)
fixes ≔ apply_fixes(w, issues)
fixes > 0 → DumpFile(file, w)
result ≔ fixes
AUTHOR
Nigel Horne <njh@nigelhorne.com>
COPYRIGHT AND LICENSE
Copyright 2025-2026 Nigel Horne.
Usage is subject to license terms.
The license terms of this software are as follows:
1 POD Error
The following errors were encountered while parsing the POD:
- Around line 76:
Non-ASCII character seen before =encoding in '→'. Assuming UTF-8