Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Thank you perl critic #53

Closed
wants to merge 14 commits into from

Conversation

moregan
Copy link
Collaborator

@moregan moregan commented Mar 8, 2014

Many small changes in response to Perl::Critic warnings.

@adamkennedy
Copy link
Collaborator

Beware the slavish use of critic, they are recommendations that can be
wrong in some cases.

Example, grep is often faster than any because it is built in. At least
until n gets pay a certain average threshold.

Check for a potential old commit that removed a previous any and replaced
with help.

And the file_content change seems a bit flippant...

Adam
On Mar 7, 2014 11:34 PM, "moregan" notifications@github.com wrote:

Many small changes in response to Perl::Critic warnings.

You can merge this Pull Request by running

git pull https://github.com/moregan/PPI thank-you-perl-critic

Or view, comment on, or merge it at:

#53
Commit Summary

  • don't rely on error global after eval
  • don't reuse variable names in scope
  • more checking return of eval
  • remove unneeded initializations
  • dead code
  • remove unused variables
  • use regex with split
  • trailing comma instead of semicolon
  • fix punctuation and formatting
  • use any instead of grep when all we're looking for is the first one
  • Issue PPI::Token::Prototype::__TOKENIZER__on_char uses capture var in undefined state #50: illusion of use of $1 after failed match
  • use three-arg open(), not two-arg
  • use strict
  • change foreach to map

File Changes

Patch Links:

Reply to this email directly or view it on GitHubhttps://github.com//pull/53
.

@moregan
Copy link
Collaborator Author

moregan commented Mar 9, 2014

Point taken on grep vs. any. In this context, any is taking 20% longer (on 5.16.3) than grep if they both process the same number of items. Since not processing the same number of items is an error condition for the method, you can it assume it almost never happens, so any doesn't help. That said, the any is more clear about intent, the grep on my machine takes on the order of 2 microseconds, and one could expect that merge() does not get used intensively, so I'd say it's a toss-up whether to revert the change.

$source was renamed because that name was already in use earlier in the same function.

@wchristian
Copy link
Member

Went through them, and added those i agreed with, after some tidying. I think the only one i didn't agree with was the any, since it didn't actually speed things up.

Will be included in the next release.

@wchristian wchristian added this to the 1.219 milestone Nov 1, 2014
@wchristian wchristian closed this Nov 1, 2014
@moregan moregan deleted the thank-you-perl-critic branch November 10, 2014 13:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants