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

やさしいコーディング規約の導入

fortkle
January 13, 2016

 やさしいコーディング規約の導入

fortkle

January 13, 2016
Tweet

More Decks by fortkle

Other Decks in Technology

Transcript

  1. ࣗݾ঺հ • @fortkle • Connehito גࣜձࣾʢϚϚ޲͚αʔϏε mamariʣ • ୲౰ྖҬ͸ϑϩϯτʙαʔόʔαΠυ •

    ࠷ۙͷझຯ͸ɺvimʹlintܥϓϥάΠϯΛೖΕ· ͬͯ͘ϓϥάΠϯʹౖΒΕ·͘Δ͜ͱ
  2. STEP2. νΣοΫπʔϧΛ༻ҙ • StyleCI΍ScrutinizerͳͲͷSaas΋͋Δ͕
 ͓ೃછΈ phpcs (PHP CodeSniffer) ͕͓͢͢Ί •

    ΧελϚΠζੑͷߴ͞ɺແྉɺ(ރΕͯΔ) • ͨͩ͠ී௨ʹ΍ͬͯ΋্ख͘ߦ͔ͳ͍
  3. STEP2. νΣοΫπʔϧΛ༻ҙ • phpcs͸xmlͰن໿ΛΧελϚΠζͰ͖Δ • STEP1ͰܾΊͨن໿Λܧঝ͚ͨͩ͠ͷϑΝΠ ϧ phpcs.xmlΛͭ͘Δ // phpcs.xml

    <?xml version="1.0"?> <ruleset name="Owl_PSR2"> <description>Owl standard Based on PSR2</description> <rule ref="PSR2" /> </ruleset>
  4. STEP2. νΣοΫπʔϧΛ༻ҙ • Τϥʔʹͳͬͨن໿ΛҰ౓શͯআ֎ (phpcs.xmlʹ௥ه) <?xml version="1.0"?> <ruleset name="Owl_PSR2"> <description>Owl

    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>
  5. STEP2. νΣοΫπʔϧΛ༻ҙ • ࡉ͔͘ϑΣʔζΛ෼͚ͯ1ͭ1ͭআ֎ϧʔϧΛফ ͍ͯ͘͠ => ͍͔ͭࣗવͱ໨ඪͷن໿ʹͳΔʂ <?xml version="1.0"?> <ruleset

    name="Owl_PSR2"> <description>Owl standard Based on PSR2</description> <rule ref="PSR2"> <!-- Կ΋ͳ͘ͳΔͱPSR-2ͱಉ༷ͷϧʔϧͱͳΔʂ --> </rule> </ruleset>
  6. STEP3. CIʹ૊ΈࠐΈࣗಈ࣮ߦ // .travis.yml ~ུ~ before_script: # full clone -

    git fetch --unshallow - git fetch origin master:refs/remotes/origin/ master # setup application - sh ./setup_app.sh # exec codeSniffer - git diff --name-only --diff-filter=ACMR origin/master...HEAD | grep ".php" | xargs vendor/bin/phpcs --standard=./phpcs.xml PSJHJONBTUFSͱ )&"%Λൺֱͯࠩ͠෼͚ͩ νΣοΫ