Subject: | LoadFile() has unreachable code |
In the course of my work on boosting YAML-Tiny's code coverage I have come to believe that there is unreachable code in LoadFile() -- code which therefore can be and should be deleted.
633 sub LoadFile {
634 my $self = YAML::Tiny->read($_[0]);
635 unless ( $self ) {
636 Carp::croak("Failed to load YAML document from '" . ($_[0] || '') . "'");
637 }
The croak at line 636 only happens if $self is Perl-false. $self can only be false if YAML::Tiny->read() manages to run to completion without triggering any of several error conditions and still manage to return false.
The final statement in read() is:
92 $class->read_string( $contents );
This can only be false if read_string() evaluates to Perl-false. Let's assume that read_string runs to completion, avoiding any of several conditions therewithin. In that case, we reach its final statement:
164 return $self;
read_string() can only return false if the YAML::Tiny object has somehow become false or undefined within the method. There does not appear to be anything inside read_string() which would cause this to happen.
If so, then read_string() can never return false. In that case, if read() reaches its final statement, it can never return false, either. And in that case, inside LoadFile() at line 635, $self can never be false and the block at line 636 can never be reached. The entire 'unless block from 635 to 637 is deletable.
See: http://thenceforward.net/YAML-Tiny/coverage/blib-lib-YAML-Tiny-pm.html