aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Somerville <matthew-github@dracos.co.uk>2019-01-14 10:19:50 +0000
committerMatthew Somerville <matthew-github@dracos.co.uk>2019-01-14 11:24:20 +0000
commit799cd59b1d05fee1b98c83b3a39f12917ded9a91 (patch)
tree377d595e46ee4d682b7650d79e502fbafdd68f60
parent018da215a8c056f680202f128e0355c662b74c7f (diff)
Remove any use of `my $x if $foo`.
As perlsyn says, "NOTE: The behaviour of a `my`, `state`, or `our` modified with a statement modifier conditional or loop construct (for example, `my $x if ...`) is undefined. The value of the `my` variable may be `undef`, any previously assigned value, or possibly anything else."
-rw-r--r--CHANGELOG.md1
-rw-r--r--perllib/FixMyStreet/App/Controller/Photo.pm2
-rw-r--r--perllib/FixMyStreet/Cobrand/Default.pm2
-rw-r--r--perllib/FixMyStreet/Roles/Abuser.pm3
-rw-r--r--perllib/FixMyStreet/Script/Reports.pm4
5 files changed, 8 insertions, 4 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 8ce52292e..8bf5b21ea 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,6 +4,7 @@
- Bugfixes
- Check cached reports do still have photos before being shown.
- Delete cache photos upon photo moderation.
+ - Remove any use of `my $x if $foo`.
* v2.5 (21st December 2018)
- Front end improvements:
diff --git a/perllib/FixMyStreet/App/Controller/Photo.pm b/perllib/FixMyStreet/App/Controller/Photo.pm
index 5712350ed..7b536a292 100644
--- a/perllib/FixMyStreet/App/Controller/Photo.pm
+++ b/perllib/FixMyStreet/App/Controller/Photo.pm
@@ -82,7 +82,7 @@ sub output : Private {
# Save to file
path(FixMyStreet->path_to('web', 'photo', 'c'))->mkpath;
my $out = FixMyStreet->path_to('web', $c->req->path);
- my $symlink_exists = symlink($photo->{symlink}, $out) if $photo->{symlink};
+ my $symlink_exists = $photo->{symlink} ? symlink($photo->{symlink}, $out) : undef;
path($out)->spew_raw($photo->{data}) unless $symlink_exists;
$c->res->content_type( $photo->{content_type} );
diff --git a/perllib/FixMyStreet/Cobrand/Default.pm b/perllib/FixMyStreet/Cobrand/Default.pm
index 88d208c85..6c91da640 100644
--- a/perllib/FixMyStreet/Cobrand/Default.pm
+++ b/perllib/FixMyStreet/Cobrand/Default.pm
@@ -530,7 +530,7 @@ sub find_closest {
my $problem = $data->{problem};
my $lat = $problem ? $problem->latitude : $data->{latitude};
my $lon = $problem ? $problem->longitude : $data->{longitude};
- my $j = $problem->geocode if $problem;
+ my $j = $problem ? $problem->geocode : undef;
if (!$j) {
$j = FixMyStreet::Geocode::Bing::reverse( $lat, $lon,
diff --git a/perllib/FixMyStreet/Roles/Abuser.pm b/perllib/FixMyStreet/Roles/Abuser.pm
index e2e9eb19e..7510e6bc2 100644
--- a/perllib/FixMyStreet/Roles/Abuser.pm
+++ b/perllib/FixMyStreet/Roles/Abuser.pm
@@ -14,7 +14,8 @@ sub is_from_abuser {
my $self = shift;
my $email = $self->user->email;
- my ($domain) = $email =~ m{ @ (.*) \z }x if $email;
+ my $domain;
+ ($domain) = $email =~ m{ @ (.*) \z }x if $email;
my $phone = $self->user->phone;
# search for an entry in the abuse table
diff --git a/perllib/FixMyStreet/Script/Reports.pm b/perllib/FixMyStreet/Script/Reports.pm
index 5cadd4fa2..c1c4ab3f1 100644
--- a/perllib/FixMyStreet/Script/Reports.pm
+++ b/perllib/FixMyStreet/Script/Reports.pm
@@ -140,7 +140,9 @@ sub send(;$) {
}
$reporters{ $sender } ||= $sender->new();
- my $inspection_required = $sender_info->{contact}->get_extra_metadata('inspection_required') if $sender_info->{contact};
+ my $inspection_required = $sender_info->{contact}
+ ? $sender_info->{contact}->get_extra_metadata('inspection_required')
+ : undef;
if ( $inspection_required ) {
my $reputation_threshold = $sender_info->{contact}->get_extra_metadata('reputation_threshold') || 0;
my $reputation_threshold_met = 0;