Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
rubocop-headquarters-2018.pdf
Search
Koichi ITO
July 14, 2018
Programming
3
5.6k
rubocop-headquarters-2018.pdf
Rails Developers Meetup 2018 Day 3 Extreme (
https://techplay.jp/event/679666
)
Koichi ITO
July 14, 2018
Tweet
Share
More Decks by Koichi ITO
See All by Koichi ITO
Beyond the RuboCop Defaults
koic
3
2.7k
Minify Ruby Code
koic
2
2.1k
Permanent Agility
koic
37
7.5k
RuboCop: LSP and Prism
koic
3
4.1k
Organizational Pattern Hatching
koic
0
1.5k
A Practitioner's Journey from Ruby 1.8 to Present
koic
1
2k
A Story Featuring Right Hand Archetype
koic
0
1.1k
Without Practice, No Emergence
koic
4
2.4k
The Resurrection of the Fast Parallel Test Runner
koic
1
6.2k
Other Decks in Programming
See All in Programming
Pinia Colada が実現するスマートな非同期処理
naokihaba
4
220
OnlineTestConf: Test Automation Friend or Foe
maaretp
0
110
「今のプロジェクトいろいろ大変なんですよ、app/services とかもあって……」/After Kaigi on Rails 2024 LT Night
junk0612
5
2.1k
WebフロントエンドにおけるGraphQL(あるいはバックエンドのAPI)との向き合い方 / #241106_plk_frontend
izumin5210
4
1.4k
.NET のための通信フレームワーク MagicOnion 入門 / Introduction to MagicOnion
mayuki
1
1.5k
どうして僕の作ったクラスが手続き型と言われなきゃいけないんですか
akikogoto
1
120
AWS IaCの注目アップデート 2024年10月版
konokenj
3
3.3k
色々なIaCツールを実際に触って比較してみる
iriikeita
0
330
型付き API リクエストを実現するいくつかの手法とその選択 / Typed API Request
euxn23
8
2.2k
TypeScript Graph でコードレビューの心理的障壁を乗り越える
ysk8hori
2
1.1k
タクシーアプリ『GO』のリアルタイムデータ分析基盤における機械学習サービスの活用
mot_techtalk
4
1.4k
Jakarta EE meets AI
ivargrimstad
0
530
Featured
See All Featured
Documentation Writing (for coders)
carmenintech
65
4.4k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
26
1.4k
Docker and Python
trallard
40
3.1k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
232
17k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
280
13k
It's Worth the Effort
3n
183
27k
Designing Experiences People Love
moore
138
23k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
28
2k
How to train your dragon (web standard)
notwaldorf
88
5.7k
Automating Front-end Workflow
addyosmani
1366
200k
Designing for Performance
lara
604
68k
Six Lessons from altMBA
skipperchong
27
3.5k
Transcript
4BU 3VCP$PQ )FBERVBSUFST 3BJMT%FWFMPQFST.FFUVQ%BZ&YUSFNF %3&$0.$P -UE The road to
RuboCop 1.0 after RubyKaigi 2018 ,PJDIJ*50FTN
!LPJD w 3VCP$PQDPNNJUUFS w "30SBDMFFOIBODFE BEBQUFSDPNNJUUFS w &JXB4ZTUFN .BOBHFNFOU *OD
!FTNJOD -VODI4QPOTPS )FSF
3BJMTENBOENF
3BJMTEN
3BJMTEN
3BJMTENEBZ
3BJMTENEBZ
None
None
None
3BJMTίϛϡχςΟҭͪͷࢹ
4BU 3VCP$PQ )FBERVBSUFST 3BJMT%FWFMPQFST.FFUVQ%BZ&YUSFNF %3&$0.$P -UE The road to
RuboCop 1.0 after RubyKaigi 2018 ,PJDIJ*50FTN
ࠓͷ
IUUQTTQFBLFSEFDLDPNLBLVUBOJBHJMFNBOJGFTUPEFDBEF TMJEF !LBLVUBOJ
w"CPVU3VCP$PQ)2 w5IFSPBEUP 3VCP$PQBGUFS 3VCZ,BJHJ "HFOEB
1FPQMF 1SPEVDU
1FPQMF
w ݄ʹདྷ͍ͯͨ͠ !CCBUTPWʹΑͬͯެ։͞ΕΔ w (JU)VC্ʹࢄ͍ͯͨ͠(BOH PG3VCP$PQΛ౷ׅ͍ͯ͠Δ (JU)VCPSHBOJ[BUJPO w "OFX044DPNNVOJUZ 3VCP$PQ)FBERVBSUFST
HJUIVCDPNSVCPDPQIR
None
w 3VCP$PQ$PSF w 3VCP$PQ1FSGPSNBODF w 3VCP$PQ3BJMT w 3VCP$PQ34QFD w 3VCZ4UZMF(VJEF
w 3BJMT4UZMF(VJEF w 3VCP$PQ+1 w FUD 3VCP$PQ)2ͷSFQP
w ࢄͨ͠ෳͷݸਓϦϙδτϦ͔Β ͍ͪίϛϡχςΟͷϦϙδτϦ w ݸਓϦϙδτϦͷਓ͕ͨͪ)2ʹू ·͖ͬͯͨ 044ίϛϡχςΟͷৢ
w 3VCP$PQ$PSFΛத৺ʹؔ৺ͷ͋ Δϝϯόʔɺ3VCP$PQ34QFDΛ த৺ʹ׆ಈ͍ͯ͠Δϝϯόʔ w ͯ͢ͷϦϙδτϦʹίϛοτݖ͕͋ ΔΘ͚Ͱͳ͍ w ྫ͑ࢲ$PSF1FSGPSNBODF 3BJMT+1
ϝϯόʔ͝ͱͷྖҬͷҧ͍
w $PSFCCBUTPWSVCPDPQͩͬ ͨͷͰɺ͍ΘΏΔ3VCP$PQͱݺ Ε͍ͯΔͷͷத৺ w 3VCP$PQ34QFDͳͲ֦ு$PQ͕ ґଘ͍ͯ͠Δ֦ுݩ(FNͷଆ໘ w $PSFͰܧঝʹؔ͢ΔΠϯλϑΣʔε ͕มΘΔͱ֦ு$PQӨڹΛड͚Δ
֦ுݩ$PQͱͯ͠ͷ$PSF
w ͜͜Ұͷഁյతมߋͱͯ͠ /PEF1BUUFSOͷOJM ͷมߋ 3VCP$PQ$PQ͔Βͷ 3BOHF)FMQϞδϡʔϧΓग़͠ ͕͋Δ ֤֦ு(FNਵ͕ඞཁ w
ؔ৺ͷ͋Δϝϯόʔ͕)2ʹू·ͬ ͨͷྑ͍ ҟͳΔϓϩδΣΫτؒͰͷಉظ
w ίϯτϦϏϡʔλʹൺͯΕΔ͜ ͱ͕૿͑Δ w ίϛολʔʹͳͬͯվΊͯࢥͬͨ͜ Ε·Ͱͱ͜Ε͔Β w (JU)VCϕʔεͷ3BJMTίϛϡχ ςΟͱൺֱ )2ઃཱͱಉ࣌ʹίϛολʔʹͳͬͨ
044ίϛϡχςΟʹΑΔҧ͍ SBJMTSBJMT CCBUTPWSVCPDPQ 3FWJFX ؔ৺Λ࣋ͬͨਓ ؔ৺Λ࣋ͬͨਓ $MPTF JTTVF *TTVFνʔϜɺίϛολʔɺί Ξϝϯόʔ
ίϛολʔ .FSHF13 ίϛολʔɺίΞϝϯόʔ ΄΅ϦϙδτϦΦʔφʔ NBTUFS QVTI ίϛολʔɺίΞϝϯόʔ ϦϙδτϦΦʔφʔͷΈ ؍ଌൣғ 3FMFBTF ϦϦʔεϚωʔδϟ ϦϙδτϦΦʔφʔ
ࢲ͕ۙະདྷʹඳ͘3VCP$PQ)2ͷੈք؍ SBJMTSBJMT SVCPDPQIRSVCPDPQ 3FWJFX ؔ৺Λ࣋ͬͨਓ ؔ৺Λ࣋ͬͨਓ $MPTF JTTVF *TTVFνʔϜɺίϛολʔɺί Ξϝϯόʔ
ίϛολʔ .FSHF13 ίϛολʔɺίΞϝϯόʔ ίϛολʔ NBTUFS QVTI ίϛολʔɺίΞϝϯόʔ ίϛολʔ 3FMFBTF ϦϦʔεϚωʔδϟ ϔουϝϯςφʔ 0S
SVCPDPQIRSVCPDPQ %SPQTVQQPSUGPS.3*
w HJUQVTIPSJHJONBTUFSʹͭ ͍ͯ w جຊ1VMM3FRVFTUΛ։͘ w ໌നͳ$PTNFUJDDIBOHF NBTUFSQVTIͰྑ͍ͷͰʁ ίϛολʔͷݖརͱن
None
w ͬͯΈͤ HJUQVTIPSJHJONBTUFS git push origin master
SVCPDPQIRSVCPDPQ!GGBF 'JY$)"/(-0(NE
None
None
IUUQTUXJUUFSDPNLPJDTUBUVT
w lNBTUFSQVTI͢Δͱ͖13Λ ૹΔͱ͖ΑΓ৻ॏʹ͍ͬͯΔz w l࣌ؒʹΘΕͯΔͱ͖Βͳ͍z w l ϛεͨ͋͠ͱ NBTUFSQVTIͷ จԽΛ࡞ΔͳΒઆ໌͏·͍͜ͱ͢
Δඞཁ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WOS)K7$V7T("
&YUSBDU3BJMT$PQTJOBTFQBSBUF &YUSBDU1FSGPSNBODF$PQTJOUPB TFQBSBUFHFN &YUFOEDPQNFUBEBUB *OUSPEVDFOFXDPQTXJUIBTQFDJBMTUBUVT JOTUFBEPGFOBCMFEEJTBCMFE
*NQMFNFOUPQUJPOTUPSVOPOMZTBGFDPQT BOETBGFBVUPDPSSFDUT #JHNJMFTUPOFUP3VCP$PQ
SVCPDPQIRSVCPDPQ &YUSBDU3BJMT$PQTJOBTFQBSBUF
None
w 3VCP$PQࣗମϑϨʔϜϫʔΫ ϥΠϒϥϦϥϯλΠϜʹґଘͤͣ 3VCZʹϑΥʔΧε͍ͨ͠ w ࡞ऀͱͯ͠ɺ͍·3BJMTΛ͋·Γ ͍ͬͯͳ͍Β͍͠ w ͨͷ·Ε·ͨ͠ 5-%3
w SVCPDPQSBJMTͱ͍͏HFN طʹଘࡏ͍ͯ͠Δ ΤίγεςϜ্ͷ՝
None
None
w SBJMTSBJMTͷSVCPDPQZNMΛө͠ ͨSEQBSUZDPQ w 3VCZ,BJHJͰCCBUTPW͞Μʹ ZBIPOEB͞Μ͕Λͯ͘͠Εͨ w 3VCZ,BJHJޙʹ%SFONJ͞ΜΒ͔Βϝ ϯγϣϯ͕͋Δ w
13Λૹ͍ͬͯͨࢲʹҾ͖ܧ͗ ྲྀΕ
None
None
None
None
!UPTIJNBSV͞Μ͋Γ͕ͱ͏͍͟͝·͢ʂ
w 3VCP$PQͷ3BJMT෦ॺʹ͍ͭͯ ελϒʹͯ͠ɺSVCPDPQSBJMT HFNͷՃΛଅ͢ϩάΛग़ྗ͢Δ w ͋Δ͍3VCP$PQ3BJMTʹ ϑΥʔϧόοΫ͢Δ 3VCP$PQ3BJMTͷҠߦ
SVCPDPQIRSVCPDPQ &YUSBDU1FSGPSNBODF$PQTJOUPBTFQBSBUFHFN
None
w ύϑΥʔϚϯεޮʹ͍ͭͯ.3* ʹಛԽͨ͠༰ʹͳ͍ͬͯΔ w 3VCP$PQ+3VCZαϙʔτ ͍ͯ͠Δ w 3VCP$PQ$PSFͱͯ͠ॲཧܥ ʹґଘ͠ͳ͍ܗΛࢦ͍ͯ͠Δ 5-%3
None
w ࣮ࡍͷޮՌʹ͍ͭͯɺެࣜυΩϡ ϝϯτͷϦϑΝϨϯεʹه͞Ε͍ͯ Δ߹͕͋Δ w ࠾ΛΜͩ࣌Ұಡ͔ͯ͠Β࣮ߦ ΛࢼΈͯྑͦ͞͏ 5JQTPG1FSGPSNBODFDPQ
1FSGPSNBODF4BNQMF
+VBOJUP'BUBTGBTUSVCZ
SBJMTSBJMT
CFODINBSLJQT
$PNQBSJTPO % ruby -v shuffle-first-vs-sample.rb ruby 2.5.1p57 (2018-03-29 revision 63029)
[x86_64- darwin17] Warming up -------------------------------------- Array#shuffle.first 35.171k i/100ms Array#sample 229.945k i/100ms Calculating ------------------------------------- Array#shuffle.first 400.180k (± 5.9%) i/s - 2.005M in 5.026934s Array#sample 6.407M (± 6.4%) i/s - 31.962M in 5.010117s Comparison: Array#sample: 6407183.3 i/s Array#shuffle.first: 400180.2 i/s - 16.01x slower
w !DPNQPTFSJOUFSBMJB͕ਐΊͯ ͘Ε͍ͯΔ w 3VCP$PQʹ͚ͯ 3VCP$PQ3BJMTಉ༷ਐḿ͍ͯ͠Δ w ͠Β͘3VCP$PQ$PSFͱͷಉ ظ͕৬ਓͷԹ͔ͳख࡞ۀ 1FSGPSNBODFDPQTͷநग़ঢ়گ
SVCPDPQIRSVCPDPQ &YUFOEDPQNFUBEBUB
None
w ͓ͦΒ͘3VCP$PQͷۄ w 3VCP$PQΛΞοϓάϨʔυͨ͠ࡍʹ ރΕ͍ͯͳ͍$PQͰͷ͕͋ͬͨΓ CSFBLJOHDIBOHFͨ͠Γͷ൵͠Έ ͷ͓ศΓͷػೳ w SVCPDPQZNM EFGBVMUZNM
ͷ ϝλσʔλͷՃ 5-%3
w 7FSTJPO"EEFEʜ$PQ͕Ճ͞Εͨόʔδϣ ϯ w 7FSTJPO$IBOHFEʜϢʔβʔʹӨڹͷ͋Δόʔ δϣϯ ৽͍͠ઃఆɺσϑΥϧτͷมߋ w 7FSTJPO3FNPWFEʜআ͞Εͨόʔδϣϯ
w 4BGFʜِཅੑͳͲͳ͘ઃܭͲ͓Γʹ৴པͰ͖Δ w 4BGF"VUP$PSSFDUʜࣗಈमਖ਼ͰյΕ͍ͯͳ͍ ͭͷϝλσʔλ
w 4BGFΦϓγϣϯͷΈ࣮ߦ͢Δ w 4BGF"VUP$PSSFDUͷΈ࣮ߦ͢Δ w σϑΥϧτͰͯ͢4BGFѻ͍ w ࠷৽όʔδϣϯͷ$PQΛআ֎ͯ͠ ࣮ߦ͢Δ ࣮ߦΦϓγϣϯͷީิ
w 4BGFͱ4BGF"VUP$PSSFDUͷ ఆʹ͍ͭͯͲ͏͢Δ͔ w طଘΠγϡʔ͕͋Δ͔͕ͻͱͭͷࢦඪ ʹͳΓͦ͏ ެ։͞Εͨ۩ମతඪຊ w ͕͋Ε3VCP$PQ$PSF͔
3VCP$PQ+1·Ͱ͓ศΓΛ ݒ೦
w HPPEpSTUJTTVFͱͯ͠ਐΜͰ ͍Δ ঢ়گ
SVCPDPQIRSVCPDPQ *OUSPEVDFOFXDPQTXJUIBTQFDJBMTUBUVT JOTUFBEPGFOBCMFEEJTBCMFE
None
w طଘͷFOBCMFEEJTBCMFE ͷ֦ுͱղऍͰ͖Δ w ৽ͨʹ/FX ͋Δ͍OJM Λ༻ҙ ͯ͠ɺͦͷͷ߹৽ͨͳ$PQ Λ͏͔Ϣʔβʔʹ༗ޮແޮΛΏ ͩͶΔܯࠂΛදࣔ͢Δ
5-%3
w ΞοϓάϨʔυ࣌ʹʹͳΔͷރ Ε͍ͯͳ͍৽͍͠$PQͷέʔε͕ଟ ͍ ϦάϨογϣϯΑΓͪ͜Β͕ଟ͍ w ϝλσʔλͷ7FSTJPO"EEFEɺ͋ Δ͍&OBCMFEͷ/FXΛݩʹͯ͠ ࠷৽ͷόʔδϣϯͰՃ͞Εͨ$PQ
Λআ֎͢ΕޡݕΛݮΒͤͦ͏ *.0ΞοϓάϨʔυͷ҆৺ͷ্
w ݱঢ়ͷ3VCP$PQͰແޮʹ͍ͨ͠ $PQEnabled: falseͱͯ͠ ରॲͰ͖Δ͕ɺԿ͔ͷҙਤ͕͋ͬͯ EJTBCMFEʹͨ͠ͷ͔ɺόʔδϣ ϯΞοϓ࣌ͷރΕ͍ͯͳ͍$PQͩ ͔Βແޮʹ͍ͯ͠Δͷ͔ͷঢ়ଶ۠ผ ͕͔ͭͳ͍ ৽ͨͳϥϕϦϯά
SVCPDPQIRSVCPDPQ *NQMFNFOUPQUJPOTUPSVOPOMZTBGFDPQT BOETBGFBVUPDPSSFDUT
None
w SVCPDPQίϚϯυͷΦϓγϣ ϯΛՃ͢Δ 5-%3
w --safeΦϓγϣϯʜ4BGFͷ$PQ ͷΈ࣮ߦ͢Δ w --safe-auto-correctΦϓγϣϯʜ 4BGF"VUP$PSSFDUͷ$PQͷΈ࣮ߦ ͢Δ w ͜ΕΒΛSVCPDPQZNMͰઃఆͰ͖ ΔΑ͏ʹ͢Δ
৽ͨͳ࣮ߦΦϓγϣϯ
QPDLF *UIJOLUIBUUIPTFBSFUIFLFZQPJOUT*EPO`UXBOU VTUPIBWFTPNFIVHFSPBENBQGPS*XBOUVT UPIBWFTPNFUIJOHUIBUXFDBOBDUVBMMZSFBDIJOB GFXNPOUIT IUUQTCMPHTJEFDJDPNJOUFSWJFXXJUICP[IJEBSCBUTPWCCGEB $BOZPVUFMMVTUIFSPBENBQPG3VCP$PQJO NPSFEFUBJMT CCBUTPW *OUFSWJFXXJUI#P[IJEBS#BUTPW
1SFTFOUFECZ4JEFS5FBN
͓ΘΓʹ
w 3BJMTͱ1FSGPSNBODF$PSF͔ Β֎ΕΔ $PSFͷϝϯςφϯεੑ w 3VCP$PQϝλσʔλΛͬͯ ҆৺͕͓͚ͦ͏ͳ$PQͱͦ͏Ͱͳ͍ $PQΛ৭͚Δ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