Lint/Rule/MissingTimeout.pm untested

filter: Statementstmt 0.0% 0 / 21 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 9 Podpod 0.0% 0 / 5 totaltotal 0.0% 0 / 37 CC 2 SCAR 10.3
CC
2
Cov
0%
check_job
6.0
id
2.0
description
2.0
CRAP 2.8
1 package App::Workflow::Lint::Rule::MissingTimeout;
2  
3 use strict;
4 use warnings;
5 use Carp qw(croak carp);
6  
7 # Inherit the DSL from the base rule class
8 use parent 'App::Workflow::Lint::Rule';
9  
10 #----------------------------------------------------------------------
11 # Metadata
12 #----------------------------------------------------------------------
13  
14 sub id { 'missing-timeout' }
15 sub description { 'Jobs should define timeout-minutes' }
16 sub applies_to { 'job' }
17 sub level { 'warning' }
18  
19 #----------------------------------------------------------------------
20 # Rule logic
21 #----------------------------------------------------------------------
22  
23 sub check_job {
24 my ($self, $job, $ctx) = @_;
25  
26 # If the job already has a timeout, nothing to report
27 return () if exists $job->{'timeout-minutes'};
28  
29 # Otherwise return a diagnostic
30 return $self->diag(
31 message => "Job '$ctx->{job_name}' is missing timeout-minutes",
32 path => "/jobs/$ctx->{job_name}",
33 file => $ctx->{file},
34 fix => sub {
35 my ($wf) = @_;
36 $wf->{jobs}{$ctx->{job_name}}{'timeout-minutes'} = 10;
37 },
38 );
39 }
40  
41 1;
42