Slide 1

Slide 1 text

։ԋ·Ͱͷؒ ژ౎ͷࣸਅΛ ָ͓͠Έ͍ͩ͘͞ IUUQQIPUPTBOPHSBQIJYOFU 14೥8݄30೔౔༵೔

Slide 2

Slide 2 text

IUUQQIPUPTBOPHSBQIJYOFU ։ԋ·Ͱͷؒ ژ౎ͷࣸਅΛ ָ͓͠Έ͍ͩ͘͞ 14೥8݄30೔౔༵೔

Slide 3

Slide 3 text

IUUQQIPUPTBOPHSBQIJYOFU ։ԋ·Ͱͷؒ ژ౎ͷࣸਅΛ ָ͓͠Έ͍ͩ͘͞ 14೥8݄30೔౔༵೔

Slide 4

Slide 4 text

IUUQQIPUPTBOPHSBQIJYOFU ։ԋ·Ͱͷؒ ژ౎ͷࣸਅΛ ָ͓͠Έ͍ͩ͘͞ 14೥8݄30೔౔༵೔

Slide 5

Slide 5 text

IUUQQIPUPTBOPHSBQIJYOFU ։ԋ·Ͱͷؒ ژ౎ͷࣸਅΛ ָ͓͠Έ͍ͩ͘͞ 14೥8݄30೔౔༵೔

Slide 6

Slide 6 text

IUUQQIPUPTBOPHSBQIJYOFU ։ԋ·Ͱͷؒ ژ౎ͷࣸਅΛ ָ͓͠Έ͍ͩ͘͞ 14೥8݄30೔౔༵೔

Slide 7

Slide 7 text

1FSMͷ੩తղੳ ೖ໳ͱ1FSM ϦϑΝΫλϦϯά πʔϧ "QQ135 ͷ͝঺հ IJUPEF 14೥8݄30೔౔༵೔

Slide 8

Slide 8 text

IJUPEF झຯ͸ϚϦϯεϙʔπͰ͢ 14೥8݄30೔౔༵೔

Slide 9

Slide 9 text

14೥8݄30೔౔༵೔

Slide 10

Slide 10 text

14೥8݄30೔౔༵೔

Slide 11

Slide 11 text

΋͘͡ 14೥8݄30೔౔༵೔

Slide 12

Slide 12 text

΋͘͡ ϦϑΝΫλϦϯάʹ͍ͭͯ 1FSMͷϦϑΝΫλϦϯά ੩తղੳೖ໳ ੩తղੳ࿅श ϦϑΝΫλϦϯάπʔϧͷ঺հ ϦϑΝΫλϦϯά࿅श ࣄྫ঺հ 14೥8݄30೔౔༵೔

Slide 13

Slide 13 text

4&&"-40 14೥8݄30೔౔༵೔

Slide 14

Slide 14 text

Perl::Lint - Yet Another Perl Source Code Linter 14೥8݄30೔౔༵೔

Slide 15

Slide 15 text

΋͘͡ ϦϑΝΫλϦϯάʹ͍ͭͯ 1FSMͷϦϑΝΫλϦϯά ੩తղੳೖ໳ ੩తղੳ࿅श ϦϑΝΫλϦϯάπʔϧͷ঺հ ϦϑΝΫλϦϯά࿅श ࣄྫ঺հ 14೥8݄30೔౔༵೔

Slide 16

Slide 16 text

14೥8݄30೔౔༵೔

Slide 17

Slide 17 text

΋͘͡ ϦϑΝΫλϦϯάʹ͍ͭͯ 1FSMͷϦϑΝΫλϦϯά ੩తղੳೖ໳ ੩తղੳ࿅श ϦϑΝΫλϦϯάπʔϧͷ঺հ ϦϑΝΫλϦϯά࿅श ࣄྫ঺հ 14೥8݄30೔౔༵೔

Slide 18

Slide 18 text

ϦϑΝΫλϦϯά 14೥8݄30೔౔༵೔

Slide 19

Slide 19 text

14೥8݄30೔౔༵೔

Slide 20

Slide 20 text

ϦϑΝΫλϦϯάͱ͸ɺι ϑτ΢ΣΞͷ֎෦తৼΔక ͍Λอͬͨ··Ͱɺ಺෦ͷ ߏ଄Λվળ͍ͯ͘͠࡞ۀΛ ࢦ͠·͢ɻ 14೥8݄30೔౔༵೔

Slide 21

Slide 21 text

ৼ෣͍Λม͑ͣʹ ίʔυΛ͖Ε͍ʹ 14೥8݄30೔౔༵೔

Slide 22

Slide 22 text

ѱ໊͍લΛม͑Δ 14೥8݄30೔౔༵೔

Slide 23

Slide 23 text

࣮૷Λྑ͍৔ॴʹҠ͢ 14೥8݄30೔౔༵೔

Slide 24

Slide 24 text

࡞ઓߟ͑Δͷ͸೉͍͠ ࡞ۀࣗମ͸؆୯ 14೥8݄30೔౔༵೔

Slide 25

Slide 25 text

ϦϑΝΫλϦϯάࣗମͷ ࿩͸͠·ͤΜ 14೥8݄30೔౔༵೔

Slide 26

Slide 26 text

14೥8݄30೔౔༵೔

Slide 27

Slide 27 text

δϟό 14೥8݄30೔౔༵೔

Slide 28

Slide 28 text

IUUQTUBDLPWFSqPXDPNRVFTUJPOTDIBOHFOBNFPGBQBDLBHFBGUFSJGJUJTDSFBUFEBOEIBWFDMBTTFTJOFDMJQTFQPT 14೥8݄30೔౔༵೔

Slide 29

Slide 29 text

1FSMͷ৔߹ 14೥8݄30೔౔༵೔

Slide 30

Slide 30 text

1FSMͷ৔߹ ͕Μ͹Δ 14೥8݄30೔౔༵೔

Slide 31

Slide 31 text

ιʔείʔυΛΤσΟλͰ ॻ͖׵͑Δ ݺͼग़͠ݩ΋ॻ͖׵͑Δ ςετ͋Ε͹࣮ߦ ಈ͚͹ϥοΩʔ 14೥8݄30೔౔༵೔

Slide 32

Slide 32 text

ͳΜ͔ͳͷ͍ͷ͔ 14೥8݄30೔౔༵೔

Slide 33

Slide 33 text

1BESF UIF1FSM*%& 1FSM༻ͷ*%& ม਺໊มߋͰ͖Δ ͏·͘ಈ͔ͳ͔ͬͨ ͙͢Ϋϥογϡ͢Δ 14೥8݄30೔౔༵೔

Slide 34

Slide 34 text

%FWFM3FGBDUPS my $refactory = Devel::Refactor->new; $refactory->rename_subroutine( './path/to/dir', 'oldSubName','newSubName' ); ೥ͷϞδϡʔϧ αϒϧʔνϯͷϦωʔϜ 14೥8݄30೔౔༵೔

Slide 35

Slide 35 text

%FWFM3FGBDUPS my $regex1 = '(\W)(' . $old_name . ')(\W)'; my $regex2 = "^$old_name(" . '\W)'; while (<$fh>) { $line_number++; if (/$regex1/o or /$regex2/o) { my $new_line = $_; $new_line =~ s/$regex1/$1$new_name$3/g; $new_line =~ s/$regex2/$new_name$1/; ਖ਼نදݱͰஔ׵ 14೥8݄30೔౔༵೔

Slide 36

Slide 36 text

%FWFM3FGBDUPS sub _syntax_check{ my $self = shift; my $tmp; my $eval_stmt = "my (". join ', ', @{$self->{parms}}; $eval_stmt .= ");\n"; $eval_stmt .= $self->get_sub_call(); $eval_stmt .= $self->get_new_code(); $self->{eval_code} = $eval_stmt; eval " $eval_stmt "; if ($@) { $self->{eval_err} = $@; FWBMͯ͠੒ޭ͔ͨ͠ݟΔ ͱʹ͔͘ϫΠϧυ 14೥8݄30೔౔༵೔

Slide 37

Slide 37 text

"QQ&EJUPS5PPMT &NBDT7JN༻ϓϥάΠϯίϚϯυ ϑΝΠϧ໊͔ΒQBDLBHF໊ਪଌͯ͠ೖྗ ม਺໊มߋ બ୒ൣғΛม਺ʹ͘͘Γग़͠ ͳ͔ͳ͔Α͍͚Ͳ΋͏ͪΐͬͱ 14೥8݄30೔౔༵೔

Slide 38

Slide 38 text

5SZJOHUPSFGBDUPS 1FSMDPEF 14೥8݄30೔౔༵೔

Slide 39

Slide 39 text

ͦ΋ͦ΋ ϦϑΝΫλϦϯά ͢Δʹ͸ 14೥8݄30೔౔༵೔

Slide 40

Slide 40 text

TFE 14೥8݄30೔౔༵೔

Slide 41

Slide 41 text

14೥8݄30೔౔༵೔

Slide 42

Slide 42 text

จࣈྻૢ࡞Ͱ͸ਫ਼౓ѱ͍ 14೥8݄30೔౔༵೔

Slide 43

Slide 43 text

14೥8݄30೔౔༵೔

Slide 44

Slide 44 text

TFE͸ਫ਼౓௿͍ my $blog = shift; print $blog->{id}; print $blog->{user_id}; my $blog = shift; print $blog->{article_id}; print $blog->{user_article_id}; sed -e “s/id/article_id/” 14೥8݄30೔౔༵೔

Slide 45

Slide 45 text

ͦ͜Ͱ੩తղੳ 14೥8݄30೔౔༵೔

Slide 46

Slide 46 text

੩తղੳ ϓϩάϥϜΛ࣮ߦͤͣʹௐ΂Δ ࣮ߦ͢ΔͱಈతղੳʹͳΔ 14೥8݄30೔౔༵೔

Slide 47

Slide 47 text

͍ͭ੩తղੳ͢Δͷ γϯλοΫεϋΠϥΠτ ߏจνΣοΫ ίʔσΟϯάن໿ʹԊͬͯΔ͔ ੬ऑੑΛ୳͢ ϦϑΝΫλϦϯά 14೥8݄30೔౔༵೔

Slide 48

Slide 48 text

ࡶͳ੩తղੳ ϓϩάϥϜΛ࣮ߦͤͣʹ ϓϩάϥϜͷੑ࣭Λௐ΂͍ͯΔ DBUMJC1MBDLQNcXDM 14೥8݄30೔౔༵೔

Slide 49

Slide 49 text

؆୯Ͱ͠ΐ ߦ਺͡Όͳ໋ͯ͘ྩ਺஌Γ͍ͨ 14೥8݄30೔౔༵೔

Slide 50

Slide 50 text

;ͭ͏ͷ੩తղੳ 14೥8݄30೔౔༵೔

Slide 51

Slide 51 text

;ͭ͏ͷ੩తղੳ ߏจ໦Λ࡞ͬͯௐ΂Δ 14೥8݄30೔౔༵೔

Slide 52

Slide 52 text

print (1 * 2) + 3; ߏจ໦ 14೥8݄30೔౔༵೔

Slide 53

Slide 53 text

‘;’ ߏจ໦ ‘print’ ‘ ‘ List ‘ ‘ ‘ ‘ ‘1’ ‘ ‘ ‘*’ ‘ ‘ ‘2’ ‘+’ ‘3’ Statement Document print (1 * 2) + 3; 14೥8݄30೔౔༵೔

Slide 54

Slide 54 text

ߏจ໦ print "(1 * 2) + 3"; 14೥8݄30೔౔༵೔

Slide 55

Slide 55 text

‘;’ ߏจ໦ ‘print’ ‘ ‘ Statement Document print "(1 * 2) + 3"; ‘"(1 * 2) + 3"’ 14೥8݄30೔౔༵೔

Slide 56

Slide 56 text

͜ΕͳΒ҆৺ 14೥8݄30೔౔༵೔

Slide 57

Slide 57 text

ߏจ໦Ͳ͏΍ͬͯ࡞Δͷ 14೥8݄30೔౔༵೔

Slide 58

Slide 58 text

11* 14೥8݄30೔౔༵೔

Slide 59

Slide 59 text

11* 1FSMղੳͯ͘͠ΕΔϞδϡʔϧ 1FSM%PDVNFOU0CKFDU.PEFM 1FSMύʔε͢Δͷ͸೉͍͠ͷͰ͍͢͝ 14೥8݄30೔౔༵೔

Slide 60

Slide 60 text

ࡶஊ $PNQJMFS-FYFS͍ͬͯ͏ ଎͍ͷ΋͋Δ͚Ͳͦͷ࿩͸͠·ͤΜ ࡢ೔ͷNP[OJPOͷൃදݟͯ 14೥8݄30೔౔༵೔

Slide 61

Slide 61 text

11*Ͱ༡΅͏ 14೥8݄30೔౔༵೔

Slide 62

Slide 62 text

11*Ͱߏจ໦ݟ͍ͨ print (1 * 2) + 3; 11*%PDVNFOU 11*4UBUFNFOU 11*5PLFO8PSEQSJOU 11*5PLFO8IJUFTQBDF 11*4USVDUVSF-JTU 11*4UBUFNFOU&YQSFTTJPO 11*5PLFO/VNCFS 11*5PLFO8IJUFTQBDF 11*5PLFO0QFSBUPS 11*5PLFO8IJUFTQBDF 11*5PLFO/VNCFS 11*5PLFO8IJUFTQBDF 11*5PLFO0QFSBUPS 11*5PLFO8IJUFTQBDF 11*5PLFO/VNCFS 11*5PLFO4USVDUVSF 11*5PLFO8IJUFTQBDFaO use PPI; use PPI::Dumper; my $document = PPI::Document->new($ARGV[0]); my $dumper = PPI::Dumper->new($document); $dumper->print; 14೥8݄30೔౔༵೔

Slide 63

Slide 63 text

‘;’ Ͱ͖ͨ ‘print’ ‘ ‘ List ‘ ‘ ‘ ‘ ‘1’ ‘ ‘ ‘*’ ‘ ‘ ‘2’ ‘+’ ‘3’ Statement Document print (1 * 2) + 3; 14೥8݄30೔౔༵೔

Slide 64

Slide 64 text

11*Ͱ໋ྩ਺ݟ͍ͨ my $document = PPI::Document->new($ARGV[0]); my $statements = $document->find('PPI::Statement'); my $statement_count = @$statements; say "count: $statement_count"; 14೥8݄30೔౔༵೔

Slide 65

Slide 65 text

11*Ͱ'J[[#V[[Λഁյ͍ͨ͠ use PPI; my $path = $ARGV[0]; my $document = PPI::Document->new($path); my $tokens = $document->find('PPI::Token'); for my $token (@$tokens) { if (ref $token eq 'PPI::Token::Number') { $token->set_content($token->content * 2); } } $document->save("broken-$path"); 14೥8݄30೔౔༵೔

Slide 66

Slide 66 text

11*Ͱ'J[[#V[[Λഁյ͍ͨ͠ use PPI; my $path = $ARGV[0]; my $document = PPI::Document->new($path); my $tokens = $document->find('PPI::Token'); for my $token (@$tokens) { if (ref $token eq 'PPI::Token::Number') { $token->set_content($token->content * 2); } } $document->save("broken-$path"); ਺ࣈΛݟ͚ͭͨΒ ͱΓ͋͑ͣഒʹ͢Δ 14೥8݄30೔౔༵೔

Slide 67

Slide 67 text

͜Ε͕ use strict; use warnings; for my $i (1..20) { my $message = ""; $message .= "Fizz" unless $i % 3; $message .= "Buzz" unless $i % 5; $message = $i unless $message; print "$message\n"; } 14೥8݄30೔౔༵೔

Slide 68

Slide 68 text

͜͏ use strict; use warnings; for my $i (2..40) { my $message = ""; $message .= "Fizz" unless $i % 6; $message .= "Buzz" unless $i % 10; $message = $i unless $message; print "$message\n"; } 14೥8݄30೔౔༵೔

Slide 69

Slide 69 text

-(5. 'J[[ #V[[ 'J[[ 'J[[ #V[[ 'J[[ 'J[[#V[[ 'J[[ 14೥8݄30೔౔༵೔

Slide 70

Slide 70 text

'J[[#V[[ʹݶΒͣ ഁյͰ͖Δ 14೥8݄30೔౔༵೔

Slide 71

Slide 71 text

΢ΣϒΞϓϦέʔγϣϯΛഁյ 14೥8݄30೔౔༵೔

Slide 72

Slide 72 text

my $app = sub { return [ 200, [ 'Content-Type' => 'text/plain' ], [ 'Hello World' ] ]; }; 14೥8݄30೔౔༵೔

Slide 73

Slide 73 text

my $app = sub { return [ 400, [ 'Content-Type' => 'text/plain' ], [ 'Hello World' ] ]; }; 14೥8݄30೔౔༵೔

Slide 74

Slide 74 text

my $app = sub { return [ 400, [ 'Content-Type' => 'text/plain' ], [ 'Hello World' ] ]; }; ഒ 14೥8݄30೔౔༵೔

Slide 75

Slide 75 text

ϙΠϯτ 14೥8݄30೔౔༵೔

Slide 76

Slide 76 text

ϙΠϯτ ߏจ໦Λॻ͖׵͑ͯอଘ 14೥8݄30೔౔༵೔

Slide 77

Slide 77 text

ศརͳྫ 14೥8݄30೔౔༵೔

Slide 78

Slide 78 text

HJUHSFQͷ͍͍΍ͭ 14೥8݄30೔౔༵೔

Slide 79

Slide 79 text

HJUHSFQͷ͍͍΍ͭ "QQ(JU(SFQ1FSM4UBUFNFOU git grep-perl-statement finalize t/ τʔΫϯ୯ҐͰݕࡧ εςʔτϝϯτ୯ҐͰදࣔ 14೥8݄30೔౔༵೔

Slide 80

Slide 80 text

HJUHSFQͷ͍͍΍ͭ HJUHSFQͰϑΝΠϧ୳͢ Ϛονͨ͠ϑΝΠϧͷߏจ໦࡞Δ TUBUFNFOUΛݸͣͭݟΔ TUBUFNFOU͕୳ͯ͠ΔUPLFOΛؚΊ͹දࣔ 14೥8݄30೔౔༵೔

Slide 81

Slide 81 text

งғؾ my $doc = PPI::Document->new($file); my $statements = $doc->find('PPI::Statement'); grep { my $tokens = [ $_->children ]; any { $_ eq $self->word; } @$tokens; } @$statements; 14೥8݄30೔౔༵೔

Slide 82

Slide 82 text

ίʔσΟϯάελΠϧ ௐ΂Δ΍ͭ 14೥8݄30೔౔༵೔

Slide 83

Slide 83 text

1FSM$SJUJD ίʔσΟϯάελΠϧௐ΂ͯ͘ΕΔ νʔϜ಺ͰελΠϧ౷Ұ͢Δͷʹศར 14೥8݄30೔౔༵೔

Slide 84

Slide 84 text

Ұൠతͳ1FSMϞδϡʔϧ ͷελΠϧΛνΣοΫͯ͠ Έ·͠ΐ͏ 14೥8݄30೔౔༵೔

Slide 85

Slide 85 text

package Antipop; use strict; use warnings; our $VERSION = '0.01'; sub talk { return q{ҿΈʹߦͧ͘!!1}; } !!1; __END__ 14೥8݄30೔౔༵೔

Slide 86

Slide 86 text

QFSMDSJUJD"OUJQPQQN 14೥8݄30೔౔༵೔

Slide 87

Slide 87 text

QFSMDSJUJD"OUJQPQQN .PEVMFEPFTOPUFOEXJUIBUMJOF DPMVNO .VTUFOEXJUIBSFDPHOJ[BCMFUSVFWBMVF 4FWFSJUZ 14೥8݄30೔౔༵೔

Slide 88

Slide 88 text

QFSMDSJUJD"OUJQPQQN .PEVMFEPFTOPUFOEXJUIBUMJOF DPMVNO .VTUFOEXJUIBSFDPHOJ[BCMFUSVFWBMVF 4FWFSJUZ !!1; 14೥8݄30೔౔༵೔

Slide 89

Slide 89 text

1FSM$SJUJD1PMJDZ.PEVMFT3FRVJSF&OE8JUI0OF sub violates { my ( $self, $elem, $doc ) = @_; # Last statement should be just "1;" my @significant = grep { _is_code($_) } $doc->schildren(); my $match = $significant[-1]; return if !$match; return if ((ref $match) eq 'PPI::Statement' && $match =~ m{\A 1 \s* ; \z}xms ); # Must be a violation... return $self->violation( $DESC, $EXPL, $match ); } 14೥8݄30೔౔༵೔

Slide 90

Slide 90 text

੩తղੳͰ ͠ΐ΅͍෺͔Β ෳࡶͳ෺·Ͱ 14೥8݄30೔౔༵೔

Slide 91

Slide 91 text

੩తղੳͷ࿩͓ΘΓ 14೥8݄30೔౔༵೔

Slide 92

Slide 92 text

ϦϑΝΫλϦϯάπʔϧͷ࿩ 14೥8݄30೔౔༵೔

Slide 93

Slide 93 text

"QQ135 14೥8݄30೔౔༵೔

Slide 94

Slide 94 text

"QQ135 1FSM 3FGBDUPSJOH 5PPM 14೥8݄30೔౔༵೔

Slide 95

Slide 95 text

"QQ135 1FSM 3FGBDUPSJOH 5PPM ࡞ͬͯ·͢ 14೥8݄30೔౔༵೔

Slide 96

Slide 96 text

ϦϑΝΫλϦϯά͍ͨ͠ͱ ͖ʹ͋ΔΑ͋͘Δૢ࡞Λ· ͱΊͨπʔϧ 14೥8݄30೔౔༵೔

Slide 97

Slide 97 text

ίϚϯυϥΠϯ͔Β࣮ߦ ιʔείʔυॻ͖׵͑ͯอଘ 14೥8݄30೔౔༵೔

Slide 98

Slide 98 text

Ͱ͖Δ͜ͱ 14೥8݄30೔౔༵೔

Slide 99

Slide 99 text

Ͱ͖Δ͜ͱ τʔΫϯͷஔ׵ ΫϥεͷϦωʔϜ ωʔϜεϖʔεͷϦωʔϜ ϝιουͷ࡟আ ΫϥεϝιουͷҠಈ 14೥8݄30೔౔༵೔

Slide 100

Slide 100 text

࿅श 14೥8݄30೔౔༵೔

Slide 101

Slide 101 text

࿅श༻ʹ༻ҙͨ͠ ΫιίʔυΛ ϦϑΝΫλϦϯά ͯ͠Έ·͠ΐ͏ 14೥8݄30೔౔༵೔

Slide 102

Slide 102 text

͓Έ͘͡ΞϓϦέʔγϣϯ ͷϦϑΝΫλϦϯά IUUQTHJUIVCDPNIJUPEFPNJLVKJ 14೥8݄30೔౔༵೔

Slide 103

Slide 103 text

QFSMPNJLVKJQM த٢ QFSMPNJLVKJQM த٢ QFSMPNJLVKJQM େ٢ QFSMEPVCVUV@PNJLVKJQM ޕ QFSMEPVCVUV@PNJLVKJQM ਃ 14೥8݄30೔౔༵೔

Slide 104

Slide 104 text

0NJLVKJ VSBOBV VSBOBXBOBJ 0NJLVKJ%PVCVUV VSBOBV 0NJLVKJ6UJM DIPJTF MVDLZ ˚ ܧঝ ར༻ 14೥8݄30೔౔༵೔

Slide 105

Slide 105 text

VSBOBVϝιουΛ ϦωʔϜͯ͠ΈΔ prt replace_token uranau tell 14೥8݄30೔౔༵೔

Slide 106

Slide 106 text

prt replace_token uranau tell ίϚϯυ αϒίϚϯυ Ҿ਺ 14೥8݄30೔౔༵೔

Slide 107

Slide 107 text

0NJLVKJ UFMM VSBOBXBOBJ 0NJLVKJ%PVCVUV UFMM 0NJLVKJ6UJM DIPJTF MVDLZ ˚ ܧঝ ར༻ 14೥8݄30೔౔༵೔

Slide 108

Slide 108 text

0NJLVKJ6UJMMVDLZϝιουΛ -VDLZΫϥεʹҠಈͯ͠ΈΔ prt move_class_method ‘Omikuji::Util#lucky’ ‘Omikuji::Lucky#get_lucky’ 14೥8݄30೔౔༵೔

Slide 109

Slide 109 text

0NJLVKJ UFMM VSBOBXBOBJ 0NJLVKJ%PVCVUV UFMM 0NJLVKJ6UJM DIPJTF ˚ ܧঝ ར༻ 0NJLVKJ-VDLZ HFU@MVDLZ 14೥8݄30೔౔༵೔

Slide 110

Slide 110 text

0NJLVKJ6UJMΫϥεΛ 0NJLVKJ-JTUΫϥεʹ ϦωʔϜ prt rename_class Omikuji::Util Omikuji::List 14೥8݄30೔౔༵೔

Slide 111

Slide 111 text

0NJLVKJ UFMM VSBOBXBOBJ 0NJLVKJ%PVCVUV UFMM 0NJLVKJ-JTU DIPJTF ˚ ܧঝ ར༻ 0NJLVKJ-VDLZ HFU@MVDLZ 14೥8݄30೔౔༵೔

Slide 112

Slide 112 text

0NJLVKJΫϥεΛ -PUΫϥεʹϦωʔϜ prt rename_class Omikuji Lot 14೥8݄30೔౔༵೔

Slide 113

Slide 113 text

-PU UFMM VSBOBXBOBJ 0NJLVKJ%PVCVUV UFMM 0NJLVKJ-JTU DIPJTF ˚ ܧঝ ར༻ 0NJLVKJ-VDLZ HFU@MVDLZ 14೥8݄30೔౔༵೔

Slide 114

Slide 114 text

0NJLVKJҎԼΛશͯ -PUʹϦωʔϜ prt rename_name_space Omikuji Lot 14೥8݄30೔౔༵೔

Slide 115

Slide 115 text

-PU UFMM VSBOBXBOBJ -PU%PVCVUV UFMM -PU-JTU DIPJTF ˚ ܧঝ ར༻ -PU-VDLZ HFU@MVDLZ 14೥8݄30೔౔༵೔

Slide 116

Slide 116 text

ϦϑΝΫλϦϯά੒ޭ 14೥8݄30೔౔༵೔

Slide 117

Slide 117 text

΋͏ͪΐͬͱ େ͖͍ΞϓϦέʔγϣϯͰ ࿅श 14೥8݄30೔౔༵೔

Slide 118

Slide 118 text

1MBDL3FRVFTUΛ 1MBDL,VEBTBJʹ 14೥8݄30೔౔༵೔

Slide 119

Slide 119 text

prt rename_class Plack::Request Plack::Kudasai 14೥8݄30೔౔༵೔

Slide 120

Slide 120 text

ϦϑΝΫλϦϯά੒ޭ 14೥8݄30೔౔༵೔

Slide 121

Slide 121 text

໊લΛؾܰʹ ͋ͱ͔Βม͑ΒΕΔͷ͸ ศར 14೥8݄30೔౔༵೔

Slide 122

Slide 122 text

ϦϥοΫεͰ͖Δ 14೥8݄30೔౔༵೔

Slide 123

Slide 123 text

͏·͘࢖͏ίπ 14೥8݄30೔౔༵೔

Slide 124

Slide 124 text

ର৅ϑΝΠϧΛߜΔ prt rename_token foo bar $(git grep --name-only foo) ର৅ϑΝΠϧ͕ݮΔͱ଎͍ͧ 14೥8݄30೔౔༵೔

Slide 125

Slide 125 text

ςετ௨͔ͯ͠Βίϛοτ ςετ௨͔ͬͯΒ ίϛοτ͢Δͱ҆৺Ͱ͖Δͧ 14೥8݄30೔౔༵೔

Slide 126

Slide 126 text

ϦϑΝΫλϦϯά͠΍͘͢อͭ ϝλϓϩάϥϛϯάΛආ͚Δ จࣈྻ࿈݁ͰQBDLBHF໊࡞Δͱ೉͍͠ KPJObz b0NJLVKJ` b6UJM` 14೥8݄30೔౔༵೔

Slide 127

Slide 127 text

ࣄྫ঺հ 14೥8݄30೔౔༵೔

Slide 128

Slide 128 text

ࣄྫ঺հ ͸ͯͳϒϩάશࣗಈϦϑΝΫλϦϯά 14೥8݄30೔౔༵೔

Slide 129

Slide 129 text

എܠ 4FSWJDFΫϥεʹ DPOUFYUΦϒδΣΫτΛ౉ͯͨ͠ Service::User->find_user_by_name($r, $name); 14೥8݄30೔౔༵೔

Slide 130

Slide 130 text

എܠ 4FSWJDFΫϥεʹ DPOUFYUΦϒδΣΫτΛ౉ͯͨ͠ EC͚ͩ౉͢ͱ͜Ζ΋ Service::User->find_user_by_name($r, $name); Service::Blog->find_blog_by_uri($r->db, $uri); 14೥8݄30೔౔༵೔

Slide 131

Slide 131 text

എܠ 4FSWJDFΫϥεʹ DPOUFYUΦϒδΣΫτΛ౉ͯͨ͠ EC͚ͩ౉͢ͱ͜Ζ΋ ౷Ұ͞Εͯͳͯ͘ΧΦε ΫϥεɼݸҎ্ͷϝιου Service::User->find_user_by_name($c, $name); Service::Blog->find_blog_by_uri($c->db, $uri); 14೥8݄30೔౔༵೔

Slide 132

Slide 132 text

എܠ 4FSWJDFΫϥεʹ DPOUFYUΦϒδΣΫτΛ౉ͯͨ͠ EC͚ͩ౉͢ͱ͜Ζ΋ ౷Ұ͞Εͯͳͯ͘ΧΦε ΫϥεɼݸҎ্ͷϝιου खͰͪ·ͪ·௚ͦ͏ͱ͢Δ΋࠳ં Service::User->find_user_by_name($c, $name); Service::Blog->find_blog_by_uri($c->db, $uri); 14೥8݄30೔౔༵೔

Slide 133

Slide 133 text

શࣗಈνϟϯε 14೥8݄30೔౔༵೔

Slide 134

Slide 134 text

΍Γ͍ͨ͜ͱ 14೥8݄30೔౔༵೔

Slide 135

Slide 135 text

Service::User->find_user_by_name($r, $name); sub find_user_by_name { my ($class, $r, $name) = @_; $r->db->select(..., $name); } CFGPSF 14೥8݄30೔౔༵೔

Slide 136

Slide 136 text

Service::User->find_user_by_name($r->db, $name); sub find_user_by_name { my ($class, $db, $name) = @_; $db->select(..., $name); } BGUFS 14೥8݄30೔౔༵೔

Slide 137

Slide 137 text

࡞ઓ 14೥8݄30೔౔༵೔

Slide 138

Slide 138 text

Service::User->find_user_by_name($r->db, $name); sub find_user_by_name { my ($class, $db, $name) = @_; $db->select(..., $name); } ݺͼग़͠ݩͰ $r → $r->db ݺͼग़͠ઌͰ $r → $db $r->db → $db 14೥8݄30೔౔༵೔

Slide 139

Slide 139 text

ॻ͖׵͑ͯ͸͍͚ͳ͍৔߹ 14೥8݄30೔౔༵೔

Slide 140

Slide 140 text

sub aaa { my ($class, $r = @_; AnotherService->bbb($r); $r->db->select(..., $user->name); } ΄͔ͷϝιουʹS౉ͯ͠Δ 14೥8݄30೔౔༵೔

Slide 141

Slide 141 text

sub aaa { my ($class, $r) = @_; AnotherService->bbb($r->db); $r->db->select(..., $user->name); } ΄͔ͷϝιουʹS౉ͯ͠Δ ઌʹ"OPUIFS4FSWJDFΛ ϦϑΝΫλϦϯά 14೥8݄30೔౔༵೔

Slide 142

Slide 142 text

sub aaa { my ($class, $db) = @_; AnotherService->bbb($db); $db->select(..., $user->name); } ΄͔ͷϝιουʹS౉ͯ͠Δ ઌʹ"OPUIFS4FSWJDFΛ ϦϑΝΫλϦϯά ϝιου಺͕શͯSECͳΒॻ͖׵͑ΒΕΔ 14೥8݄30೔౔༵೔

Slide 143

Slide 143 text

sub aaa { my ($class, $r) = @_; my $user = $r->user; $r->db->select(..., $user->name); } ECҎ֎΋࢖ͬͯΔ 14೥8݄30೔౔༵೔

Slide 144

Slide 144 text

sub aaa { my ($class, $r, $user) = @_; $r->db->select(..., $user->name); } ECҎ֎΋࢖ͬͯΔ VTFS΋ड͚औΔ ͜Ε͸ػցతʹ͸Ͱ͖ͳ͍ͷͰख࡞ۀ 14೥8݄30೔౔༵೔

Slide 145

Slide 145 text

࡞ઓ wιʔείʔυશϑΝΠϧॱ൪ʹݟΔ wSΛड͚औͬͯΔϝιουΛ୳͢ w҆શʹॻ͖׵͑ΒΕΔ wϝιουఆٛΛॻ͖׵͑ˠݺͼग़͠ݩ΋ॻ͖׵͑ wมߋՕॴͷςετ࣮ߦ w௨ͬͨΒDPNNJUQVTIͯ͠࠷ॳʹ໭Δ wམͪͨΒεΫϦϓτऴྃͯ͠ਓؒΛݺͿ w҆શ͡Όͳ͔ͬͨΒ࣍ͷϝιουʹߦ͘ wԿ΋ॻ͖׵͑ͣશϑΝΠϧݟऴΘͬͨΒਓؒΛݺͿ 14೥8݄30೔౔༵೔

Slide 146

Slide 146 text

ݟͲ͜Ζ 14೥8݄30೔౔༵೔

Slide 147

Slide 147 text

ࢦఆ͞ΕͨϑΝΠϧ ॱ൪ʹݟΔ sub replace_all { for my $file (@ARGV) { my $document = PPI::Document->new($file); my $package = $document->find_first( 'PPI::Statement::Package' ); my $package_name = $package->namespace; my $methods = $document->find( 'PPI::Statement::Sub' ); for my $method (@$methods) { my $document = PPI::Document->new($file); ...; } } } 14೥8݄30೔౔༵೔

Slide 148

Slide 148 text

SECΛECʹஔ׵ sub r_db_to_db { my ($statement) = @_; my $tokens = [$statement->children]; for my $token (@$tokens) { if ($token eq '$r') { if ($token->next_token eq '->') { if ($token->next_token->next_token eq 'db') { $token->set_content('$db'); $token->next_token->set_content(''); $token->next_token->next_token->set_content(''); } else { die "->@{[ $token->next_token->next_token ]}"; } } else { die "@{[ $token->next_token ]}"; } } } } 14೥8݄30೔౔༵೔

Slide 149

Slide 149 text

ݺͼग़͠ݩͷมߋ $command = 'prt replace_token \'' . $package_name . '->' . $method_name . '($r\' \'' . $package_name . '->' . $method_name . '($r->db\' --in- statement ' . $method_name . ' $(git grep --name-only ' . $method_name . ')'; system $command; 14೥8݄30೔౔༵೔

Slide 150

Slide 150 text

Ϋϥε಺Ͱͷݺͼग़͠มߋ $command = 'prt replace_token \'$class' . '->' . $method_name . '($r\' \'$class' . '->' . $method_name . '($r->db\' --in- statement ' . $method_name . ' ' . $file; system $command; 14೥8݄30೔౔༵೔

Slide 151

Slide 151 text

มߋՕॴΛςετͯ͠ίϛοτ if (`git diff --name-only t/**.t`) { system('carton exec -- prove $(git diff -- name-only t/**.t)') and die "test failed"; } else { warn 'skip test'; } system "git commit -am '$package_name\ͷ $method_name\Λ\$db Λड͚औΔΑ͏ʹมߋ'"; system "git push"; 14೥8݄30೔౔༵೔

Slide 152

Slide 152 text

ॻ͖׵͑ଓ͚Δ my $success = 1; while($success) { $success = replace_all(); } 14೥8݄30೔౔༵೔

Slide 153

Slide 153 text

൒೔ޙ 14೥8݄30೔౔༵೔

Slide 154

Slide 154 text

250+ Commits 281 Files changed +2,004 −1,927 14೥8݄30೔౔༵೔

Slide 155

Slide 155 text

ϦϑΝΫλϦϯά੒ޭ 14೥8݄30೔౔༵೔

Slide 156

Slide 156 text

஌ݟ 14೥8݄30೔౔༵೔

Slide 157

Slide 157 text

஌ݟ ҙ֎ͱͳΜͱ͔ͳΔ 14೥8݄30೔౔༵೔

Slide 158

Slide 158 text

஌ݟ ҙ֎ͱͳΜͱ͔ͳΔ ϨϏϡϫʔ͔Θ͍ͦ͏ 14೥8݄30೔౔༵೔

Slide 159

Slide 159 text

஌ݟ ҙ֎ͱͳΜͱ͔ͳΔ ϨϏϡϫʔ͔Θ͍ͦ͏ ௕೥ͷٕज़తෛ࠴Λٕज़Ͱղܾͨ͠ 14೥8݄30೔౔༵೔

Slide 160

Slide 160 text

Ҏ্ 14೥8݄30೔౔༵೔

Slide 161

Slide 161 text

·ͱΊ ϦϑΝΫλϦϯάʹ͍ͭͯ 1FSMͷϦϑΝΫλϦϯά ੩తղੳೖ໳ ੩తղੳ࿅श ϦϑΝΫλϦϯάπʔϧͷ঺հ ϦϑΝΫλϦϯά࿅श ࣄྫ঺հ 14೥8݄30೔౔༵೔

Slide 162

Slide 162 text

׬ 14೥8݄30೔౔༵೔

Slide 163

Slide 163 text

ҰॹʹϦϑΝΫλϦϯά͠·͠ΐ͏ ʲॕʳTPOHNV͞Μೖࣾ 14೥8݄30೔౔༵೔