[Koha-bugs] [Bug 5453] New: Variables declaration should not occur in conditionals

bugzilla-daemon at bugs.koha-community.org bugzilla-daemon at bugs.koha-community.org
Mon Nov 29 11:13:10 CET 2010


http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=5453

           Summary: Variables declaration should not occur in conditionals
 Change sponsored?: ---
           Product: Koha
           Version: HEAD
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P5
         Component: Architecture, internals, and plumbing
        AssignedTo: gmcharlt at gmail.com
        ReportedBy: colin.campbell at ptfs-europe.com
         QAContact: koha-bugs at lists.koha-community.org
   Estimated Hours: 0.0


This is an antipattern in a lot of Koha code.

my $x = Z() if $y;

it obscures code and can cause hard to track bugs. What does it say of the
value of $x if not $y? Is someone maintaining the code liable to make
unwarrantable assumptions about the definedness or value of $x. ( the use of
postfix if is also a problem as in reading actual code it is often easy to miss
that an assignment is in a conditional because the postfix if has disappeared
off the right of your screen. Postfix ifs give a reader very little visual clue
that a conditional is occurring.

The above cde should be rewritten as
my $x;
if ($y) {
    $x = Z();
}

Bug opened to record such patches against

-- 
Configure bugmail: http://bugs.koha-community.org/bugzilla3/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.


More information about the Koha-bugs mailing list