diff --git a/lib/NGCP/Panel/Role/API/Capabilities.pm b/lib/NGCP/Panel/Role/API/Capabilities.pm index 95cd9ef122..d2ceb6bd4b 100644 --- a/lib/NGCP/Panel/Role/API/Capabilities.pm +++ b/lib/NGCP/Panel/Role/API/Capabilities.pm @@ -92,7 +92,7 @@ sub _item_rs { my $profile = $c->user->voip_subscriber_profile; if($profile) { my $attrs = [ map { $_->attribute->attribute } $profile->profile_attributes->all ]; - if(grep(/^fax_server$/, @{ $attrs })) { + if(grep { /^fax_server$/ } @{ $attrs }) { $faxserver &= 1; } else { $faxserver = 0; diff --git a/lib/NGCP/Panel/Utils/Prosody.pm b/lib/NGCP/Panel/Utils/Prosody.pm index c7623712e3..806f2a9b6c 100644 --- a/lib/NGCP/Panel/Utils/Prosody.pm +++ b/lib/NGCP/Panel/Utils/Prosody.pm @@ -73,8 +73,8 @@ sub _load_servers { my $host_rs = $c->model('DB')->resultset('xmlgroups') ->search_rs({name => 'xmpp'}) ->search_related('xmlhostgroups')->search_related('host'); - return [map +{ip => $_->ip, port => $_->port, path => $_->path, - id => $_->id}, $host_rs->all]; + return [map { +{ip => $_->ip, port => $_->port, path => $_->path, + id => $_->id} } $host_rs->all]; } 1; diff --git a/lib/NGCP/Panel/Utils/XMLDispatcher.pm b/lib/NGCP/Panel/Utils/XMLDispatcher.pm index 556f7c8a78..285119fab8 100644 --- a/lib/NGCP/Panel/Utils/XMLDispatcher.pm +++ b/lib/NGCP/Panel/Utils/XMLDispatcher.pm @@ -20,8 +20,9 @@ sub dispatch { my $host_rs = $schema->resultset('xmlgroups') ->search_rs({name => $target}) ->search_related('xmlhostgroups')->search_related('host', {}, { order_by => 'id' }); - $hosts = [map +{ip => $_->ip, port => $_->port, path => $_->path, - id => $_->id}, $host_rs->all]; + $hosts = [map { +{ip => $_->ip, port => $_->port, path => $_->path, + id => $_->id} } $host_rs->all]; + use DDP; p $hosts; } use Data::Dumper; diff --git a/t/api-rest/api-billingnetworks.t b/t/api-rest/api-billingnetworks.t index 36b023d540..118a939b0f 100644 --- a/t/api-rest/api-billingnetworks.t +++ b/t/api-rest/api-billingnetworks.t @@ -62,8 +62,8 @@ $ua = Test::Collection->new()->ua(); my @hopts = split /\s*,\s*/, $res->header('Allow'); ok(exists $opts->{methods} && ref $opts->{methods} eq "ARRAY", "check for valid 'methods' in body"); foreach my $opt(qw( GET HEAD OPTIONS POST )) { - ok(grep(/^$opt$/, @hopts), "check for existence of '$opt' in Allow header"); - ok(grep(/^$opt$/, @{ $opts->{methods} }), "check for existence of '$opt' in body"); + ok(grep { /^$opt$/ } @hopts, "check for existence of '$opt' in Allow header"); + ok(grep { /^$opt$/ } @{ $opts->{methods} }, "check for existence of '$opt' in body"); } } diff --git a/t/api-rest/api-billingprofiles.t b/t/api-rest/api-billingprofiles.t index 99b61829e1..add170c35c 100644 --- a/t/api-rest/api-billingprofiles.t +++ b/t/api-rest/api-billingprofiles.t @@ -22,8 +22,8 @@ $ua = Test::Collection->new()->ua(); my @hopts = split /\s*,\s*/, $res->header('Allow'); ok(exists $opts->{methods} && ref $opts->{methods} eq "ARRAY", "check for valid 'methods' in body"); foreach my $opt(qw( GET HEAD OPTIONS POST )) { - ok(grep(/^$opt$/, @hopts), "check for existence of '$opt' in Allow header"); - ok(grep(/^$opt$/, @{ $opts->{methods} }), "check for existence of '$opt' in body"); + ok(grep { /^$opt$/ } @hopts, "check for existence of '$opt' in Allow header"); + ok(grep { /^$opt$/ } @{ $opts->{methods} }, "check for existence of '$opt' in body"); } } @@ -160,12 +160,12 @@ my @allprofiles = (); my $opts = JSON::from_json($res->decoded_content); ok(exists $opts->{methods} && ref $opts->{methods} eq "ARRAY", "check for valid 'methods' in body"); foreach my $opt(qw( GET HEAD OPTIONS PUT PATCH )) { - ok(grep(/^$opt$/, @hopts), "check for existence of '$opt' in Allow header"); - ok(grep(/^$opt$/, @{ $opts->{methods} }), "check for existence of '$opt' in body"); + ok(grep { /^$opt$/ } @hopts, "check for existence of '$opt' in Allow header"); + ok(grep { /^$opt$/ } @{ $opts->{methods} }, "check for existence of '$opt' in body"); } foreach my $opt(qw( POST DELETE )) { - ok(!grep(/^$opt$/, @hopts), "check for absence of '$opt' in Allow header"); - ok(!grep(/^$opt$/, @{ $opts->{methods} }), "check for absence of '$opt' in body"); + ok(!grep { /^$opt$/ } @hopts, "check for absence of '$opt' in Allow header"); + ok(!grep { /^$opt$/ } @{ $opts->{methods} }, "check for absence of '$opt' in body"); } $req = HTTP::Request->new('GET', $uri.'/'.$firstprofile); diff --git a/t/api-rest/api-contracts.t b/t/api-rest/api-contracts.t index 6d054fe0ce..466f356be5 100644 --- a/t/api-rest/api-contracts.t +++ b/t/api-rest/api-contracts.t @@ -27,8 +27,8 @@ $ua = Test::Collection->new()->ua(); my @hopts = split /\s*,\s*/, $res->header('Allow'); ok(exists $opts->{methods} && ref $opts->{methods} eq "ARRAY", "check for valid 'methods' in body"); foreach my $opt(qw( GET HEAD OPTIONS POST )) { - ok(grep(/^$opt$/, @hopts), "check for existence of '$opt' in Allow header"); - ok(grep(/^$opt$/, @{ $opts->{methods} }), "check for existence of '$opt' in body"); + ok(grep { /^$opt$/ } @hopts, "check for existence of '$opt' in Allow header"); + ok(grep { /^$opt$/ } @{ $opts->{methods} }, "check for existence of '$opt' in body"); } } @@ -242,12 +242,12 @@ my @allcontracts = (); my $opts = JSON::from_json($res->decoded_content); ok(exists $opts->{methods} && ref $opts->{methods} eq "ARRAY", "check for valid 'methods' in body"); foreach my $opt(qw( GET HEAD OPTIONS PUT PATCH )) { - ok(grep(/^$opt$/, @hopts), "check for existence of '$opt' in Allow header"); - ok(grep(/^$opt$/, @{ $opts->{methods} }), "check for existence of '$opt' in body"); + ok(grep { /^$opt$/ } @hopts, "check for existence of '$opt' in Allow header"); + ok(grep { /^$opt$/ } @{ $opts->{methods} }, "check for existence of '$opt' in body"); } foreach my $opt(qw( POST DELETE )) { - ok(!grep(/^$opt$/, @hopts), "check for absence of '$opt' in Allow header"); - ok(!grep(/^$opt$/, @{ $opts->{methods} }), "check for absence of '$opt' in body"); + ok(!grep { /^$opt$/ } @hopts, "check for absence of '$opt' in Allow header"); + ok(!grep { /^$opt$/ } @{ $opts->{methods} }, "check for absence of '$opt' in body"); } $req = HTTP::Request->new('GET', $uri.'/'.$firstcontract); diff --git a/t/api-rest/api-customercontacts.t b/t/api-rest/api-customercontacts.t index b2f8c9c343..5fa6985a04 100644 --- a/t/api-rest/api-customercontacts.t +++ b/t/api-rest/api-customercontacts.t @@ -21,8 +21,8 @@ $ua = Test::Collection->new()->ua(); my @hopts = split /\s*,\s*/, $res->header('Allow'); ok(exists $opts->{methods} && ref $opts->{methods} eq "ARRAY", "check for valid 'methods' in body"); foreach my $opt(qw( GET HEAD OPTIONS POST )) { - ok(grep(/^$opt$/, @hopts), "check for existence of '$opt' in Allow header"); - ok(grep(/^$opt$/, @{ $opts->{methods} }), "check for existence of '$opt' in body"); + ok(grep { /^$opt$/ } @hopts, "check for existence of '$opt' in Allow header"); + ok(grep { /^$opt$/ } @{ $opts->{methods} }, "check for existence of '$opt' in body"); } } @@ -160,12 +160,12 @@ my @allcontacts = (); my $opts = JSON::from_json($res->decoded_content); ok(exists $opts->{methods} && ref $opts->{methods} eq "ARRAY", "check for valid 'methods' in body"); foreach my $opt(qw( GET HEAD OPTIONS PUT PATCH DELETE )) { - ok(grep(/^$opt$/, @hopts), "check for existence of '$opt' in Allow header"); - ok(grep(/^$opt$/, @{ $opts->{methods} }), "check for existence of '$opt' in body"); + ok(grep { /^$opt$/ } @hopts, "check for existence of '$opt' in Allow header"); + ok(grep { /^$opt$/ } @{ $opts->{methods} }, "check for existence of '$opt' in body"); } my $opt = 'POST'; - ok(!grep(/^$opt$/, @hopts), "check for absence of '$opt' in Allow header"); - ok(!grep(/^$opt$/, @{ $opts->{methods} }), "check for absence of '$opt' in body"); + ok(!grep { /^$opt$/ } @hopts, "check for absence of '$opt' in Allow header"); + ok(!grep { /^$opt$/ } @{ $opts->{methods} }, "check for absence of '$opt' in body"); $req = HTTP::Request->new('GET', $uri.'/'.$firstcontact); $res = $ua->request($req); diff --git a/t/api-rest/api-customers.t b/t/api-rest/api-customers.t index e33cbb7c37..ecf07cbaaa 100644 --- a/t/api-rest/api-customers.t +++ b/t/api-rest/api-customers.t @@ -28,8 +28,8 @@ $ua = Test::Collection->new()->ua(); my @hopts = split /\s*,\s*/, $res->header('Allow'); ok(exists $opts->{methods} && ref $opts->{methods} eq "ARRAY", "check for valid 'methods' in body"); foreach my $opt(qw( GET HEAD OPTIONS POST )) { - ok(grep(/^$opt$/, @hopts), "check for existence of '$opt' in Allow header"); - ok(grep(/^$opt$/, @{ $opts->{methods} }), "check for existence of '$opt' in body"); + ok(grep { /^$opt$/ } @hopts, "check for existence of '$opt' in Allow header"); + ok(grep { /^$opt$/ } @{ $opts->{methods} }, "check for existence of '$opt' in body"); } } @@ -272,12 +272,12 @@ my @allcustomers = (); my $opts = JSON::from_json($res->decoded_content); ok(exists $opts->{methods} && ref $opts->{methods} eq "ARRAY", "check for valid 'methods' in body"); foreach my $opt(qw( GET HEAD OPTIONS PUT PATCH )) { - ok(grep(/^$opt$/, @hopts), "check for existence of '$opt' in Allow header"); - ok(grep(/^$opt$/, @{ $opts->{methods} }), "check for existence of '$opt' in body"); + ok(grep { /^$opt$/ } @hopts, "check for existence of '$opt' in Allow header"); + ok(grep { /^$opt$/ } @{ $opts->{methods} }, "check for existence of '$opt' in body"); } foreach my $opt(qw( POST DELETE )) { - ok(!grep(/^$opt$/, @hopts), "check for absence of '$opt' in Allow header"); - ok(!grep(/^$opt$/, @{ $opts->{methods} }), "check for absence of '$opt' in body"); + ok(!grep { /^$opt$/ } @hopts, "check for absence of '$opt' in Allow header"); + ok(!grep { /^$opt$/ } @{ $opts->{methods} }, "check for absence of '$opt' in body"); } $req = HTTP::Request->new('GET', $uri.'/'.$firstcustomer); diff --git a/t/api-rest/api-journals.t b/t/api-rest/api-journals.t index 4005c4b6c4..4b1c285c76 100644 --- a/t/api-rest/api-journals.t +++ b/t/api-rest/api-journals.t @@ -2369,8 +2369,8 @@ sub _test_journal_options_head { my @hopts = split /\s*,\s*/, $res->header('Allow'); ok(exists $opts->{methods} && ref $opts->{methods} eq "ARRAY", "check for valid 'methods' in body"); foreach my $opt(qw( GET HEAD OPTIONS )) { - ok(grep(/^$opt$/, @hopts), "check for existence of '$opt' in Allow header"); - ok(grep(/^$opt$/, @{ $opts->{methods} }), "check for existence of '$opt' in body"); + ok(grep { /^$opt$/ } @hopts, "check for existence of '$opt' in Allow header"); + ok(grep { /^$opt$/ } @{ $opts->{methods} }, "check for existence of '$opt' in body"); } $req = HTTP::Request->new('HEAD', $url); $res = $ua->request($req); diff --git a/t/api-rest/api-profilepackages.t b/t/api-rest/api-profilepackages.t index ae17667e18..323e265c03 100644 --- a/t/api-rest/api-profilepackages.t +++ b/t/api-rest/api-profilepackages.t @@ -27,8 +27,8 @@ $ua = Test::Collection->new()->ua(); my @hopts = split /\s*,\s*/, $res->header('Allow'); ok(exists $opts->{methods} && ref $opts->{methods} eq "ARRAY", "check for valid 'methods' in body"); foreach my $opt(qw( GET HEAD OPTIONS POST )) { - ok(grep(/^$opt$/, @hopts), "check for existence of '$opt' in Allow header"); - ok(grep(/^$opt$/, @{ $opts->{methods} }), "check for existence of '$opt' in body"); + ok(grep { /^$opt$/ } @hopts, "check for existence of '$opt' in Allow header"); + ok(grep { /^$opt$/ } @{ $opts->{methods} }, "check for existence of '$opt' in body"); } } diff --git a/t/api-rest/api-resellers.t b/t/api-rest/api-resellers.t index bdd47e58e4..a9e951024b 100644 --- a/t/api-rest/api-resellers.t +++ b/t/api-rest/api-resellers.t @@ -22,8 +22,8 @@ $ua = Test::Collection->new()->ua(); my @hopts = split /\s*,\s*/, $res->header('Allow'); ok(exists $opts->{methods} && ref $opts->{methods} eq "ARRAY", "check for valid 'methods' in body"); foreach my $opt(qw( GET HEAD OPTIONS POST )) { - ok(grep(/^$opt$/, @hopts), "check for existence of '$opt' in Allow header"); - ok(grep(/^$opt$/, @{ $opts->{methods} }), "check for existence of '$opt' in body"); + ok(grep { /^$opt$/ } @hopts, "check for existence of '$opt' in Allow header"); + ok(grep { /^$opt$/ } @{ $opts->{methods} }, "check for existence of '$opt' in body"); } } @@ -248,12 +248,12 @@ my @allresellers = (); my $opts = JSON::from_json($res->decoded_content); ok(exists $opts->{methods} && ref $opts->{methods} eq "ARRAY", "check for valid 'methods' in body"); foreach my $opt(qw( GET HEAD OPTIONS PUT PATCH )) { - ok(grep(/^$opt$/, @hopts), "check for existence of '$opt' in Allow header"); - ok(grep(/^$opt$/, @{ $opts->{methods} }), "check for existence of '$opt' in body"); + ok(grep { /^$opt$/ } @hopts, "check for existence of '$opt' in Allow header"); + ok(grep { /^$opt$/ } @{ $opts->{methods} }, "check for existence of '$opt' in body"); } foreach my $opt(qw( POST DELETE )) { - ok(!grep(/^$opt$/, @hopts), "check for absence of '$opt' in Allow header"); - ok(!grep(/^$opt$/, @{ $opts->{methods} }), "check for absence of '$opt' in body"); + ok(!grep { /^$opt$/ } @hopts, "check for absence of '$opt' in Allow header"); + ok(!grep { /^$opt$/ } @{ $opts->{methods} }, "check for absence of '$opt' in body"); } $req = HTTP::Request->new('GET', $uri.'/'.$firstreseller); diff --git a/t/api-rest/api-root.t b/t/api-rest/api-root.t index dc784ecc81..f775e72f3f 100644 --- a/t/api-rest/api-root.t +++ b/t/api-rest/api-root.t @@ -27,12 +27,12 @@ $ua = Test::Collection->new()->ua(); my @hopts = split /\s*,\s*/, $res->header('Allow'); ok(exists $opts->{methods} && ref $opts->{methods} eq "ARRAY", "check for valid 'methods' in body"); foreach my $opt(qw( GET HEAD OPTIONS )) { - ok(grep(/^$opt$/, @hopts), "check for existence of '$opt' in Allow header"); - ok(grep(/^$opt$/, @{ $opts->{methods} }), "check for existence of '$opt' in body"); + ok(grep { /^$opt$/ } @hopts, "check for existence of '$opt' in Allow header"); + ok(grep { /^$opt$/ } @{ $opts->{methods} }, "check for existence of '$opt' in body"); } foreach my $opt(qw( PUT POST DELETE )) { - ok(!grep(/^$opt$/, @hopts), "check for non-existence of '$opt' in Allow header"); - ok(!grep(/^$opt$/, @{ $opts->{methods} }), "check for non-existence of '$opt' in body"); + ok(!grep { /^$opt$/ } @hopts, "check for non-existence of '$opt' in Allow header"); + ok(!grep { /^$opt$/ } @{ $opts->{methods} }, "check for non-existence of '$opt' in body"); } my @links = $res->header('Link'); diff --git a/t/api-rest/api-systemcontacts.t b/t/api-rest/api-systemcontacts.t index 6de4078019..89712ab866 100644 --- a/t/api-rest/api-systemcontacts.t +++ b/t/api-rest/api-systemcontacts.t @@ -23,8 +23,8 @@ $ua = Test::Collection->new()->ua(); my @hopts = split /\s*,\s*/, $res->header('Allow'); ok(exists $opts->{methods} && ref $opts->{methods} eq "ARRAY", "check for valid 'methods' in body"); foreach my $opt(qw( GET HEAD OPTIONS POST )) { - ok(grep(/^$opt$/, @hopts), "check for existence of '$opt' in Allow header"); - ok(grep(/^$opt$/, @{ $opts->{methods} }), "check for existence of '$opt' in body"); + ok(grep { /^$opt$/ } @hopts, "check for existence of '$opt' in Allow header"); + ok(grep { /^$opt$/ } @{ $opts->{methods} }, "check for existence of '$opt' in body"); } } @@ -123,12 +123,12 @@ my @allcontacts = (); my $opts = JSON::from_json($res->decoded_content); ok(exists $opts->{methods} && ref $opts->{methods} eq "ARRAY", "check for valid 'methods' in body"); foreach my $opt(qw( GET HEAD OPTIONS PUT PATCH DELETE )) { - ok(grep(/^$opt$/, @hopts), "check for existence of '$opt' in Allow header"); - ok(grep(/^$opt$/, @{ $opts->{methods} }), "check for existence of '$opt' in body"); + ok(grep { /^$opt$/ } @hopts, "check for existence of '$opt' in Allow header"); + ok(grep { /^$opt$/ } @{ $opts->{methods} }, "check for existence of '$opt' in body"); } my $opt = 'POST'; - ok(!grep(/^$opt$/, @hopts), "check for absence of '$opt' in Allow header"); - ok(!grep(/^$opt$/, @{ $opts->{methods} }), "check for absence of '$opt' in body"); + ok(!grep { /^$opt$/ } @hopts, "check for absence of '$opt' in Allow header"); + ok(!grep { /^$opt$/ } @{ $opts->{methods} }, "check for absence of '$opt' in body"); $req = HTTP::Request->new('GET', $uri.'/'.$firstcontact); $res = $ua->request($req); diff --git a/t/lib/NGCP/Test/Resource.pm b/t/lib/NGCP/Test/Resource.pm index b555801266..6db5ff61f0 100644 --- a/t/lib/NGCP/Test/Resource.pm +++ b/t/lib/NGCP/Test/Resource.pm @@ -331,9 +331,9 @@ sub test_allowed_methods { $self->_inc_test_count; while((my $opt = shift @{ $expected })) { - ok(grep(/^$opt$/, @hopts), "$name - '$opt' in Allow header"); + ok(grep { /^$opt$/ } @hopts, "$name - '$opt' in Allow header"); $self->_inc_test_count; - ok(grep(/^$opt$/, @{ $methods }), "$name - '$opt' in body"); + ok(grep { /^$opt$/ } @{ $methods }, "$name - '$opt' in body"); $self->_inc_test_count; } is(@{ $expected }, 0, "$name - no leftover in allowed methods"); @@ -521,7 +521,7 @@ sub _test_item { $self->_test_fields($args->{skip_test_fields}, $args->{expected_fields}, $ref, $item, $name); my %links = map { $_ => 0 } @{ $args->{expected_links} }; foreach my $link(keys %{ $item->{_links} }) { - next if(grep(/^$link$/, qw/self curies profile collection/)); + next if(grep { /^$link$/ } qw/self curies profile collection/); ok(exists $links{$link}, "$name - existence of link $link in reference"); $self->_inc_test_count; delete $links{$link}; diff --git a/t/lib/Test/Collection.pm b/t/lib/Test/Collection.pm index b92885cf25..82390a1f3a 100644 --- a/t/lib/Test/Collection.pm +++ b/t/lib/Test/Collection.pm @@ -824,11 +824,11 @@ sub check_methods{ ok(exists $opts->{methods} && ref $opts->{methods} eq "ARRAY", "$self->{name}: check for valid 'methods' in body"); foreach my $opt(keys %{$self->methods->{$area}->{all}} ) { if(exists $self->methods->{$area}->{allowed}->{$opt}){ - ok(grep(/^$opt$/, @hopts), "$self->{name}: check for existence of '$opt' in Allow header"); - ok(grep(/^$opt$/, @{ $opts->{methods} }), "$self->{name}: check for existence of '$opt' in body"); + ok(grep { /^$opt$/ } @hopts, "$self->{name}: check for existence of '$opt' in Allow header"); + ok(grep { /^$opt$/ } @{ $opts->{methods} }, "$self->{name}: check for existence of '$opt' in body"); }else{ - ok(!grep(/^$opt$/, @hopts), "$self->{name}: check for absence of '$opt' in Allow header"); - ok(!grep(/^$opt$/, @{ $opts->{methods} }), "$self->{name}: check for absence of '$opt' in body"); + ok(!grep { /^$opt$/ } @hopts, "$self->{name}: check for absence of '$opt' in Allow header"); + ok(!grep { /^$opt$/ } @{ $opts->{methods} }, "$self->{name}: check for absence of '$opt' in body"); } } } diff --git a/tools_bin/create_testusers.pl b/tools_bin/create_testusers.pl index 23bdc83ff4..43b7b2d7e6 100755 --- a/tools_bin/create_testusers.pl +++ b/tools_bin/create_testusers.pl @@ -205,7 +205,7 @@ say "Processing done, collecting final status..."; if($pid > 0) { my $last_kids = @kids; while((my $child_pid = wait()) > 0 && @kids) { - @kids = grep(!/^$child_pid$/, @kids); + @kids = grep { !/^$child_pid$/ } @kids; if(@kids == $last_kids) { sleep 1; }