« lib/Perl/Critic/Policy/InputOutput/RequireCheckedClose.pm
↑ Summary
lib/Perl/Critic/Policy/Subroutines/ProhibitExcessComplexity.pm »
| 1 | package Perl::Critic::Policy::InputOutput::RequireCheckedOpen; | ||||||||||
| 2 | |||||||||||
| 3 | 40 | ▶ | use 5.010001; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 40 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 40 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 40 | ▶ | use Readonly; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | |||||||||||
| 8 | 40 | ▶ | use Perl::Critic::Utils qw{ :severities :classification }; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | 40 | ▶ | use parent 'Perl::Critic::Policy'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | |||||||||||
| 11 | 40 | our $VERSION = '1.156'; | |||||||||
| 12 | |||||||||||
| 13 | #----------------------------------------------------------------------------- | ||||||||||
| 14 | |||||||||||
| 15 | 40 | Readonly::Scalar my $DESC => q{Return value of "open" ignored}; | |||||||||
| 16 | 40 | Readonly::Scalar my $EXPL => q{Check the return value of "open" for success}; | |||||||||
| 17 | |||||||||||
| 18 | #----------------------------------------------------------------------------- | ||||||||||
| 19 | |||||||||||
| 20 | 91 | ▶ | sub supported_parameters { | ||||||||
|
Subroutine
supported_parameters: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 21 | return ( | ||||||||||
| 22 | { | ||||||||||
| 23 | 91 | name => 'autodie_modules', | |||||||||
| 24 | description => 'Modules which export autodie.', | ||||||||||
| 25 | default_string => 'autodie', | ||||||||||
| 26 | behavior => 'string list', | ||||||||||
| 27 | }, | ||||||||||
| 28 | ); | ||||||||||
| 29 | } | ||||||||||
| 30 | |||||||||||
| 31 | 74 | ▶ | sub default_severity { return $SEVERITY_MEDIUM } | ||||||||
|
Subroutine
default_severity: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 32 | 73 | ▶ | sub default_themes { return qw( core maintenance certrule ) } | ||||||||
|
Subroutine
default_themes: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 33 | 31 | ▶ | sub applies_to { return 'PPI::Token::Word' } | ||||||||
|
Subroutine
applies_to: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 34 | |||||||||||
| 35 | #----------------------------------------------------------------------------- | ||||||||||
| 36 | |||||||||||
| 37 | 332 | ▶ | sub violates { | ||||||||
|
Subroutine
violates: called CC=3 SCAR=17.3
Pod
documented
| |||||||||||
| 38 | 332 | my ( $self, $elem, undef ) = @_; | |||||||||
| 39 | |||||||||||
| 40 | 332 | ▶ | return if $elem->content() ne 'open'; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 41 | 0 | ▶ | return if ! is_unchecked_call( $elem, [ keys %{ $self->{_autodie_modules} } ] ); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 42 | |||||||||||
| 43 | 0 | return $self->violation( $DESC, $EXPL, $elem ); | |||||||||
| 44 | |||||||||||
| 45 | } | ||||||||||
| 46 | |||||||||||
| 47 | |||||||||||
| 48 | 40 | 1; | |||||||||
| 49 | |||||||||||
| 50 | __END__ | ||||||||||