Skip to content

Commit

Permalink
Remove dead code
Browse files Browse the repository at this point in the history
The if condition already covers the cases that are supposed to be
handled by the following elsif condition. The two branches are also
doing the same work except for the text of the debug message.
  • Loading branch information
ferki committed Aug 28, 2020
1 parent b50fa63 commit fbb76d6
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions lib/Rex/Resource/Common.pm
Original file line number Diff line number Diff line change
Expand Up @@ -96,19 +96,16 @@ sub resource {
if (!$class->can($name)
&& $name_save =~ m/^[a-zA-Z_][a-zA-Z0-9_]+$/ )
{
Rex::Logger::debug("Registering resource: ${class}::$name_save");
if ( $class ne "main" && $class ne "Rex::CLI" ) {

# if not in main namespace, register the task as a sub
Rex::Logger::debug(
"Registering resource (not main namespace): ${class}::$name_save");
}
else {
Rex::Logger::debug("Registering resource: ${class}::$name_save");
}

my $code = $_[-2];
my $ref_to_resource = qualify_to_ref( $name_save, $class );
*{$ref_to_resource} = $func;
}
elsif ( ( $class ne "main" && $class ne "Rex::CLI" )
&& !$class->can($name_save)
&& $name_save =~ m/^[a-zA-Z_][a-zA-Z0-9_]+$/ )
{
# if not in main namespace, register the task as a sub
Rex::Logger::debug(
"Registering resource (not main namespace): ${class}::$name_save");
my $code = $_[-2];
my $ref_to_resource = qualify_to_ref( $name_save, $class );
*{$ref_to_resource} = $func;
Expand Down

0 comments on commit fbb76d6

Please sign in to comment.