squentin / gmusicbrowser

jukebox for large collections of music
http://gmusicbrowser.org
GNU General Public License v3.0
194 stars 42 forks source link

Increase the usage of combined assignment operators #225

Open elfring opened 2 years ago

elfring commented 2 years ago

:eyes: Some source code analysis tools can help to find opportunities for improving software components. :thought_balloon: I propose to increase the usage of combined operators accordingly.

diff --git a/gmusicbrowser.pl b/gmusicbrowser.pl
index bc85b57..44575b2 100755
--- a/gmusicbrowser.pl
+++ b/gmusicbrowser.pl
@@ -9456,7 +9456,7 @@ sub new
    my $unit0;
    $unit0= $1 if $val=~s/([a-zA-Z]+)$//;
    ::setlocale(::LC_NUMERIC, 'C');
-   $val= $val+0;   #make sure "." is used as the decimal separator
+   $val += 0;  #make sure "." is used as the decimal separator
    ::setlocale(::LC_NUMERIC, '');
    my $spin= $self->{spin}= Gtk3::SpinButton->new( Gtk3::Adjustment->new($val, $min, $max, $step, $page, 0) ,1,$digits );
    $spin->set_numeric(1);
diff --git a/gmusicbrowser_layout.pm b/gmusicbrowser_layout.pm
index 454105a..1cc6ae3 100644
--- a/gmusicbrowser_layout.pm
+++ b/gmusicbrowser_layout.pm
@@ -2256,8 +2256,8 @@ sub new
    }
    %children_opt=( %children_opt, %{$opt->{children_opt}} ) if $opt->{children_opt};
    $self->InitLayout($layout,\%children_opt);
-   $self->{tabicon}=  $self->{tabicon}  || $def->{Icon};
-   $self->{tabtitle}= $self->{tabtitle} || $def->{Title} || $def->{Name} || $layout;
+   $self->{tabicon} ||= $def->{Icon};
+   $self->{tabtitle} ||= $def->{Title} || $def->{Name} || $layout;
    $self->show_all;
    return $self;
 }
@@ -5134,8 +5134,8 @@ sub change_zoom
 {  my ($self,$zoom,$x,$y)=@_;
    return unless $self->{pixbuf};
    if (defined $x) # translate event coordinates to image coordinates
-   {   $x= $x - $self->{x1}; $x= $self->{x2} if $x>$self->{x2};
-       $y= $y - $self->{y1}; $y= $self->{y2} if $y>$self->{y2};
+   {   $x -= $self->{x1}; $x = $self->{x2} if $x>$self->{x2};
+       $y -= $self->{y1}; $y = $self->{y2} if $y>$self->{y2};
    }
    else # no zoom coordinates => zoom on center
    {   $x= $self->{x2}/2;
diff --git a/gmusicbrowser_list.pm b/gmusicbrowser_list.pm
index 63aa25d..51f77c5 100644
--- a/gmusicbrowser_list.pm
+++ b/gmusicbrowser_list.pm
@@ -517,7 +517,7 @@ sub CommonSave

    #save options as default for new SongTree/SongList of same type
    my $name= $self->isa('SongTree') ? 'songtree_' : 'songlist_';
-   $name= $name.$self->{name}; $name=~s/\d+$//;
+   $name .= $self->{name}; $name = ~s/\d+$//;
    $::Options{"DefaultOptions_$name"}={%$opt};

    if ($self->{type} eq 'L' && defined(my $n= $self->{array}->GetName)) { $opt->{type}='L'; $opt->{songarray}=$n; }
diff --git a/mp3header.pm b/mp3header.pm
index 0ace6ef..22c4af2 100644
--- a/mp3header.pm
+++ b/mp3header.pm
@@ -690,7 +690,7 @@ sub make
        $tagstring.=$field.sprintf('%05d',length $v).$v;
    }
    if ($tagstring ne 'LYRICSBEGIN') #not empty
-   {   $tagstring=$tagstring.sprintf('%06d',length $tagstring).'LYRICS200';
+   {   $tagstring .= sprintf('%06d',length $tagstring).'LYRICS200';
    }
    return \$tagstring;
 }
diff --git a/plugins/albuminfo.pm b/plugins/albuminfo.pm
index ff3cac4..322cc3d 100644
--- a/plugins/albuminfo.pm
+++ b/plugins/albuminfo.pm
@@ -755,9 +755,9 @@ sub save_review {
    my $text = "";
    for my $key (sort {lc $a cmp lc $b} keys %{$fields}) { # Sort fields alphabetically
        if ($key =~ m/genre|mood|style|theme/) {
-           $text = $text . "<$key>".join(", ", @{$fields->{$key}})."</$key>\n";
+           $text .= "<$key>".join(", ", @{$fields->{$key}})."</$key>\n";
        } else {
-           $text = $text . "<$key>".$fields->{$key}."</$key>\n";
+           $text .= "<$key>".$fields->{$key}."</$key>\n";
        }
    }
    my $format = $::Options{OPT.'PathFile'};