[[PageOutline(2-4)]] [wiki:Plugins <-plug-ins] = {{{Padre::Plugin::Fix}}} == Usage * install Padre-Plugin-Fix * enable in Plug-in Manager * {{{Tools/Fix/Simplify}}} ---- == TODO * Create a '''Suggestions table panel''' that contains the following columns: * Suggestion * Path * Line * Run all suggestion checkers in the background and populate the '''Suggestions table panel'''. * Provide a way to specify which suggestions are enabled for the current project. (Maybe read custom entries from '''padre.yml''') * Fix ticket:829 * Fix ticket:992 * Fix ticket:1200 * Fix ticket:502 * Move beginner checks from Padre here: {{{ Padre::Document::Perl::Beginner }}} * Move {{{::QuickFix}}} from Padre here: {{{ Padre::QuickFix Padre::Document::Perl::QuickFix Padre::Document::Perl::QuickFix::StrictWarnings Padre::Document::Perl::QuickFix::IncludeModule }}} * Revisit syntax errors in [http://szabgab.com/scalar-found-where-operator-expected.html Scalar found where operator expected] * Use [https://metacpan.org/module/PPI::Transform PPI::Transform API]? ---- Uses PPI to identify and transform stuff from form A to B. * Convert constant to uppercase {{{#!perl use constant pi => 3.14; # OR use constant { pi => 3.14, }; }}} to this {{{#!perl use constant PI => 3.14; # OR use constant { PI => 3.14, }; }}} * From ticket:502, Find code between subs: {{{#!perl sub a { } die "hello world"; sub b { } }}} * From ticket:1200, Replace one or all occurrences of indirect notations such as this: {{{#!perl new Something("bla"); }}} should become {{{#!perl Something->new("bla"); }}} * Over selection text range, provide the ability to quote it and choose qq{} or q{} * Negate if block form with unless and vice versa {{{#!perl if(defined $fh) { say "File is open"; } else { say "File is not open!"; } }}} should become {{{#!perl unless(defined $fh) { say "File is not open!"; } else { say "File is open"; } }}} * Transform if single statement into postfix form and vice versa: {{{#!perl if(defined $fh) { print "File is open"; } }}} should become {{{#!perl print "File is open" if defined $fh; }}} * Add forgotten else clause to if block * Transform qq{string} where string does not contain escape sequences into q{string} or 'string' * if {{{use v5.10;}}} or greater is used, then {{{print "something\n"}}} can be transformed into {{{say "something"}}} * Transform {{{my $param1 = shift}}} into {{{my ($param1) = @_; }}} and vice versa * if-elsif-else transformation into given-when. Please see [http://perldoc.perl.org/perlsyn.html#Switch-statements Switch statements] {{{#!perl if($type eq 'a') { } elsif($type eq 'b') { } else { } }}} should become {{{#!perl given($type) { when ('a') { } when ('b') { } default { } } }}} * Add ''{{{Padre::Document::Perl::Beginner}}}'' checks and convert them to '''PPI''' [[Image(PadrePluginFix.png)]] ---- == Test Sample * assuming modern perl {{{#!perl #!/usr/bin/env perl use 5.014; use strict; use warnings; use Carp; # Turn on $OUTPUT_AUTOFLUSH $| = 1; use feature 'unicode_strings'; #1, the following " -> ' try for your self open ( my $filehandle, "<:utf8", "test.bin") or die $!; #2, food for thought only #before open ( my $filehandle, "<:utf8", "test.bin") or die $!; #after use Carp; #after my $filehandle = undef; #after open ( $filehandle, '<:encoding(UTF-8)', 'test.bin') or croak $!; my $word = readline $filehandle; #3, food for thought only #before print "word = $word\n"; #after say 'word ='.$word; #4, food for thought only, an evil null if =~ fails #before my ($untainted) = $word =~ /^(\w+)$/; #after my $untainted = undef; #after $untainted = $word =~ /^(\w+)$/; say "untainted = $untainted"; if ($untainted) { # It passed the regex, so it is "safe". system "echo $untainted"; } 1; __END__ }}} == Resources **{{{__END__}}}** [wiki:Plugins <-plug-ins]