Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
やさしいコーディング規約の導入
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
fortkle
January 13, 2016
Technology
4.7k
10
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
やさしいコーディング規約の導入
fortkle
January 13, 2016
More Decks by fortkle
See All by fortkle
無駄な物をなるべく作らないリプレイス戦略 / replace-strategy-phperkaigi2021
fortkle
1
2.7k
フルリモート時代のカンバン運用 / kanban-operation-in-remote
fortkle
0
800
GitHub Actionsで始めるPHPアプリケーションのCI実践入門 / ga-phperkaigi2020
fortkle
3
7.2k
余裕を生み出すコードレビュー 〜レビュイー編〜 / code-review-phpcon-2019
fortkle
8
7.6k
「設計振り返り」を始めてみようと思っている話 / architecture reflection
fortkle
3
650
「ママ向けNo.1アプリ」の 更なる成長を支える仕組み / startup-engineer-night-connehito
fortkle
2
370
良いテストデータ、悪いテストデータ / testdata-antipattern
fortkle
4
7k
BackstopJSで始める CSSリグレッションテスト / backstopjs-css-test
fortkle
0
1.6k
PhpStorm導入アンチパターン / phpstorm-anti-pattern
fortkle
0
2.2k
Other Decks in Technology
See All in Technology
Post AI時代のリファクタリング実践記 / Refactoring in the post AI era
kaminashi
1
220
Claude Code本は、どのように執筆チームで書かれたか
oikon48
1
370
パッチ更新でterraform initが落ちた日
grimoh
1
140
FOSS4Gを活用した自治体業務DXの試み
470715
0
160
サブエージェントと Claude Mods で作る独自 Advisor ツールの話
kenichiodo
2
150
Local CI × GitHub Actions
gogutan
2
140
M5Stackで作る BLEマウス GPSログの世界
tomokusaba
0
390
パスキーの自動テストはどこまでいけるのか
teamlab
PRO
0
140
宣言型部分更新は何を解決しどこへ向かうのか
shuta13
1
430
Conditional PED-ANOVA: Hyperparameter Importance in Hierarchical & Dynamic Search Spaces
pfn
PRO
0
130
Getting Started with Google Antigravity
glaforge
0
280
その Valkey 使いこなしていますか?
onk
PRO
5
1.2k
Featured
See All Featured
Keith and Marios Guide to Fast Websites
keithpitt
413
23k
Stewardship and Sustainability of Urban and Community Forests
pwiseman
0
550
Reality Check: Gamification 10 Years Later
codingconduct
0
2.3k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
35
2.6k
Odyssey Design
rkendrick25
PRO
2
870
Git: the NoSQL Database
bkeepers
PRO
433
67k
Utilizing Notion as your number one productivity tool
mfonobong
4
620
The SEO Collaboration Effect
kristinabergwall1
1
590
Test your architecture with Archunit
thirion
2
2.4k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
25
2.1k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
46
3k
Mind Mapping
helmedeiros
1
400
Transcript
͍͞͠ ίʔσΟϯάنͷಋೖ ߴ ߊ @fortkle - PHP BLT #2
ࣗݾհ • @fortkle • Connehito גࣜձࣾʢϚϚ͚αʔϏε mamariʣ • ୲ྖҬϑϩϯτʙαʔόʔαΠυ •
࠷ۙͷझຯɺvimʹlintܥϓϥάΠϯΛೖΕ· ͬͯ͘ϓϥάΠϯʹౖΒΕ·͘Δ͜ͱ
None
ޚࣾͷίʔσΟϯάنɺ ػೳͯ͠·͔͢ʁ 143 143 ΦϨΦϨ ;FOE $BLF1)1 4ZNGPOZ
None
ίʔσΟϯάن͕ͳ͍ͱਏ͍ • ίʔυϨϏϡʔͷࡍʹࠣࡉͳΓऔΓ͕ൃੜ (εϖʔεɺΠϯσϯτɺվߦҐஔ) • ίʔυελΠϧ͕౷Ұ͞Εͳ͘ͳΓอकੑͷ Լ • ଞਓ͕ॻ͍ͨίʔυͷՄಡੑ͕Լ͕Δ
ͳΜͱ͔͠ͳ͍ͱ…!
3STEPͰίʔσΟϯάنΛ खʹೖΕΔ
ͨͱ͑…͜ΜͳPJT • طʹ։ൃ͕͔ͳΓਐΜͰ͍ΔPJT • ίʔσΟϯάنࠓͷͱ͜Ζͳ͍ • ނʹphpcsͳͲΛී௨ʹ͏ͱΤϥʔ͕େྔ ʹग़ͯਏ͍ => Ͳ͏ͬͯίʔσΟϯάنΛ࡞Δ͔ʁ
STEP1. ࠾༻͢ΔنΛܾΊΔ • ࠓ͔Β৽͘͠ίʔσΟϯάنΛ࠾༻͢Δͱ ͨ͠ΒPSR-2 • ࣍Ͱ༻͍ͯ͠ΔFWಠࣗͷن(ex. Cake)
STEP2. νΣοΫπʔϧΛ༻ҙ • StyleCIScrutinizerͳͲͷSaas͋Δ͕ ͓ೃછΈ phpcs (PHP CodeSniffer) ͕͓͢͢Ί •
ΧελϚΠζੑͷߴ͞ɺແྉɺ(ރΕͯΔ) • ͨͩ͠ී௨ʹ্ͬͯख͘ߦ͔ͳ͍
ී௨ʹΔͱ͜͏ͳΔ Τϥʔग़ྗߦ 65,000…….. ࣮ߦ࣌ؒ 27ඵ… ※ Vender/ Plugin/ ԼؚΜͰ͍ΔͷͰ࣮ࡍͬͱগͳ͘ͳΓ·͢ʢͬͨʣ
None
͏·͍͘͘phpcs
STEP2. νΣοΫπʔϧΛ༻ҙ • pearͰͳ͘composerͰΠϯετʔϧ // Πϯετʔϧ $ composer require “squizlabs/php_codesniffer=*"
--dev // ֬ೝʢར༻Ͱ͖ΔنΛදࣔʣ $ vendor/bin/phpcs -i
STEP2. νΣοΫπʔϧΛ༻ҙ • phpcsxmlͰنΛΧελϚΠζͰ͖Δ • STEP1ͰܾΊͨنΛܧঝ͚ͨͩ͠ͷϑΝΠ ϧ phpcs.xmlΛͭ͘Δ // phpcs.xml
<?xml version="1.0"?> <ruleset name="Owl_PSR2"> <description>Owl standard Based on PSR2</description> <rule ref="PSR2" /> </ruleset>
STEP2. νΣοΫπʔϧΛ༻ҙ • ͓ΉΖʹɺԼهίϚϯυΛΞϓϦέʔγϣϯ શମ (./app) ʹର࣮ͯ͠ߦ $ vendor/bin/phpcs -s
--report=source --standard=./ phpcs.xml ./app
STEP2. νΣοΫπʔϧΛ༻ҙ • Τϥʔͱͯ͠ݕग़͞ΕͨنͱΤϥʔ͕݅ ιʔτ͞Εͯදࣔ͞ΕΔʢศར..!ʣ
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>
STEP2. νΣοΫπʔϧΛ༻ҙ • ࠶phpcsΛ࣮ߦ͢ΔͱΤϥʔ͕ग़ͳ͘ͳΔɻ ˠ ʮ؇͍CodeSnifferʯͷ $ vendor/bin/phpcs -s --report=source
--standard=./ phpcs.xml ./app $ // Τϥʔ͕ͳ͍ͷͰ࣮ߦͯ͠Կදࣔ͞Εͳ͍
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>
STEP2. νΣοΫπʔϧΛ༻ҙ • STEP2·ͱΊ 1. ඪ(͜͜ͰPSR2)ΛϕʔεʹΤϥʔͱͳ͍ͬͯΔ ϧʔϧΛআ֎͠ɺʮ؇͍نʯΛ࡞Δ 2. ϑΣʔζຖʹϧʔϧͷআ֎ΛΊ͍͖ͯɺ গͣͭ͠ඪʹ͚͍ۙͮͯ͘
3. શͯͷϧʔϧͷআ֎ΛΊͨ࣌ɺඪͱಉ͡نͱͳΔ
STEP3. CIʹΈࠐΈࣗಈ࣮ߦ • TravisCIΛ͍ͬͯͨ߹ • .travis.ymlʹॲཧΛՃࣗ͠ಈͰ࣮ߦ͞ΕΔΑ ͏ʹ͢Δ • νΣοΫରΛίϛοτ͞ΕͨϑΝΠϧͷ͏ͪ phpϑΝΠϧͷΈʹݶఆ͢Δ
(shʹ·ͱΊͯྑ͍)
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ͱ )&"%Λൺֱ͚ͯࠩͩ͠ νΣοΫ
STEP3. CIʹΈࠐΈࣗಈ࣮ߦ shͰ·ͱΊɺϝοηʔδΛදࣔ͢ΕΑΓɻ Τϥʔ͕͋ͬͨ߹Ϗϧυ͕ࣦഊ͢Δɻ
·ͱΊ • ؇͍ϧʔϧ͔Β࢝Ίͯඪ(PSR-2)ʹ͍͍ۙͮͯ͘ Ξϓϩʔν͕Φεεϝ • ίϛοτͨ͠ϑΝΠϧͷΈΛphpcsͷݕࠪରͱ ͠ɺTravisͰࣗಈ࣮ߦ͢Δͱָ • ࠓ·ͰίʔσΟϯάنΛఘΊ͍ͯͨ͋ͷPJT ͍͔ͭPSR-2ʹ४ڌͰ͖Δ͔ʁ
͓͠·͍