Bug 8458 - $stemmed_operand in C4::Search _build_stemmed_operand is not initialized.
Summary: $stemmed_operand in C4::Search _build_stemmed_operand is not initialized.
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Searching (show other bugs)
Version: 3.8
Hardware: All All
: P5 - low normal (vote)
Assignee: M. Tompsett
QA Contact: Mason James
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-07-17 12:42 UTC by M. Tompsett
Modified: 2013-12-05 20:01 UTC (History)
4 users (show)

See Also:
Change sponsored?: ---
Patch complexity: ---
Who signed the patch off:
Text to go in the release notes:
Version(s) released in:


Attachments
Initialized $stemmed_operand to q{} (perl critic friendly empty string) (934 bytes, patch)
2012-07-17 12:59 UTC, M. Tompsett
Details | Diff | Splinter Review
Bug 8458 - $stemmed_operand in C4::Search _build_stemmed_operand is not initialized. Added =q{} to initialize it to the empty string at declaration time. (946 bytes, patch)
2012-07-17 17:46 UTC, Kyle M Hall
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description M. Tompsett 2012-07-17 12:42:56 UTC
Summary says it all.
Found this while reading my git clone's code.
Comment 1 M. Tompsett 2012-07-17 12:59:18 UTC Comment hidden (obsolete)
Comment 2 Kyle M Hall 2012-07-17 14:02:10 UTC
perlcritic does not report this as a PBP violation. Running perlcritic on C4/Search.pm in master results in:
C4/Search.pm source OK

PBP does recommend using
    my $string = q{};
instead of 
    my $string = "";
or
    my $string = '';

but does not make a judgement on
    my $string;

I believe this rule applies to re-initializing a previously used variable to an empty string, no initializing it to begin with.
Comment 3 Jared Camins-Esakov 2012-07-17 14:04:30 UTC
This is a valid bug. The perlcritic friendly bit is using q{} instead of ''.
Comment 4 Kyle M Hall 2012-07-17 17:45:26 UTC
I'm guessing that the point of this bug is that the variable is concatenated with itself, even though it is undef, which will result in a warning. In that case, I see how this is a valid bug, but the description of the bug did not describe that.
Comment 5 Kyle M Hall 2012-07-17 17:46:43 UTC
Created attachment 10910 [details] [review]
Bug 8458 - $stemmed_operand in C4::Search _build_stemmed_operand is not initialized. Added =q{} to initialize it to the empty string at declaration time.

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Comment 6 Mason James 2012-07-18 02:19:56 UTC
(In reply to comment #5)
> Created attachment 10910 [details] [review]
> Bug 8458 - $stemmed_operand in C4::Search _build_stemmed_operand is not
> initialized. Added =q{} to initialize it to the empty string at declaration
> time.
> 
> Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>

passing QA, nice spotting!

------------
$ koha-qa.pl
- d0ec5cf Bug 8458 - $stemmed_operand in C4::Search _build_stemmed_operand is not initialized. Added =q{} to initialize it to the empty string at declaration time.
        C4/Search.pm
- perlcritic-progressive tests... OK
- perl -c syntax tests... OK
Comment 7 Chris Cormack 2012-07-24 01:36:45 UTC
Pushed to 3.8.x will be in 3.8.4