Upgrade to Pro — share decks privately, control downloads, hide ads and more …

やさしいコーディング規約の導入〜その後〜 / yasashii-sonogo

fortkle
November 03, 2016

やさしいコーディング規約の導入〜その後〜 / yasashii-sonogo

fortkle

November 03, 2016
Tweet

More Decks by fortkle

Other Decks in Technology

Transcript

  1. ͜͏͍͏ίʔυɺͲ͏ࢥ͍·͔͢ʁ <?php class Hoge{ public function fuga() { echo 'fuga!';

    } public function piyo($isPiyo = true) { if($isPiyo){ echo 'piyo!'; }else{ echo 'fuga!'; } } }
  2. ͜͏͍͏ίʔυɺͲ͏ࢥ͍·͔͢ʁ <?php class Hoge{ public function fuga() { echo 'fuga!';

    } public function piyo($isPiyo = true) { if($isPiyo){ echo 'piyo!'; }else{ echo 'fuga!'; } } }
  3. ͜͏͍͏ίʔυɺͲ͏ࢥ͍·͔͢ʁ <?php class Hoge{ public function fuga() { echo 'fuga!';

    } public function piyo($isPiyo = true) { if($isPiyo){ echo 'piyo!'; }else{ echo 'fuga!'; } } }
  4. <?php class Hoge{ public function fuga() { echo 'fuga!'; }

    public function piyo($isPiyo = true) { if($isPiyo){ echo 'piyo!'; }else{ echo 'fuga!'; } } } ˞͜͜ͷߦ͚ͩΠϯσϯτ͕λϒͰ͢ ͜͏͍͏ίʔυɺͲ͏ࢥ͍·͔͢ʁ
  5. w TRVJ[MBCT1)1@$PEF4OJ⒎FS w ίʔσΟϯάن໿ΛνΣοΫ͢Δπʔϧ w W͔Β͸QIQDCGίϚϯυͰमਖ਼΋Մೳ w ద༻͢Δن໿͸ඪ४Ͱ1&"3 143ɾ ;FOEͳͲαϙʔτ

    w YNMܗࣜͰ؆୯ʹΧελϜن໿Λ࡞Δ͜ͱ΋Մೳ w MJOUͷ݁ՌΛ༷ʑͳܗࣜͰग़ྗͰ͖Δ w DIFDLTUZMF YNM TVNNBSZͳͲ ͦ͜Ͱ1)1@$PEF4OJ⒎FS ͦ͜Ͱ1)1@$PEF4OJ⒎FS
  6. ݸ௒͑ͷΤϥʔɾɾɾ 1)1@$PEF4OJ⒎FSΛద༻ $ phpcs --standard=PSR2 ./app ---------------------------------------------------------------- A TOTAL OF

    1364 ERRORS AND 290 WARNINGS WERE FOUND IN 80 FILES ----------------------------------------------------------------
  7. ΍͍͞͠ن໿Λ࡞Δ ---------------------------------------------------------------------- SOURCE COUNT ---------------------------------------------------------------------- [x] Generic.WhiteSpace.DisallowTabIndent.TabsUsed 629 [x] Squiz.Functions.MultiLineFunctionDeclaration.BraceOnSameLin

    342 ʙུʙ [x] PSR2.Files.EndFileNewline.NoneFound 1 [ ] Squiz.Functions.FunctionDeclaration 1 ---------------------------------------------------------------------- A TOTAL OF 1654 SNIFF VIOLATIONS WERE FOUND IN 40 SOURCES ---------------------------------------------------------------------- ʮ΍͘͞͠ʯಋೖ͢Δ Τϥʔͱͯ͠ݕग़͞Εͨن໿ͱΤϥʔ݅਺͕
 ιʔτ͞Εͯදࣔ͞ΕΔ
  8.  ͜͜Ͱ͓΋ΉΖʹΤϥʔʹͳͬͨن໿Λશͯআ֎͢Δ
 ۩ମతʹ͸QIQDTYNMʹFYDMVEFͱͯ͠௥ه ΍͍͞͠ن໿Λ࡞Δ <?xml version="1.0"?> <ruleset name="Custom_PSR2"> <description>Custom standard

    Based on PSR2</description> <rule ref="PSR2"> <exclude name="Generic.WhiteSpace.DisallowTabIndent.TabsUsed"/> <!-- 145 --> <exclude name="Squiz.WhiteSpace.SuperfluousWhitespace.EndLine"/> <!-- 21 --> <exclude name="PSR2.Classes.ClassDeclaration.OpenBraceNewLine"/> <!-- 18 --> <exclude name="Generic.Files.LineLength.TooLong"/> <!-- 17 --> <exclude name="PSR2.Classes.ClassDeclaration.CloseBraceAfterBody"/> <!-- 16 --> <exclude name="Squiz.ControlStructures.ControlSignature.SpaceAfterKeyword"/> <!-- 9 --> <exclude name="Squiz.Functions.MultiLineFunctionDeclaration"/> <!-- 1 --> <exclude name="Generic.WhiteSpace.ScopeIndent.Incorrect"/> <!-- 1 --> </rule> </ruleset> ʮ΍͘͞͠ʯಋೖ͢Δ
  9.  5SBWJT্ͰQIQDTΛ࣮ߦ͠ɺͦͷ݁ՌΛSFWJFXEPHʹ౉͢ मਖ਼Օॴ͚ͩͷࢦఠͱ$*ʹΑΔࣗಈ࣮ߦ env: global: secure: xxxxxxxxxxxxx install: - curl

    -fSL https://github.com/haya14busa/reviewdog/releases/download/ 0.9.2/reviewdog_linux_amd64 -o reviewdog && chmod +x ./reviewdog script: - >- phpcs --report=emacs --standard=./phpcs.xml ./app | reviewdog 
 -f=checkstyle -diff="git diff master” -ci=travis ʮ΍͘͞͠ʯಋೖ͢Δ