Save 37% off PRO during our Black Friday Sale! »

rubocop-headquarters-2018.pdf

 rubocop-headquarters-2018.pdf

Rails Developers Meetup 2018 Day 3 Extreme (https://techplay.jp/event/679666)

023b04c98f39cc041293d780352432ff?s=128

Koichi ITO

July 14, 2018
Tweet

Transcript

  1.  4BU 3VCP$PQ )FBERVBSUFST 3BJMT%FWFMPQFST.FFUVQ%BZ&YUSFNF %3&$0.$P -UE The road to

    RuboCop 1.0 after RubyKaigi 2018 ,PJDIJ*50FTN
  2. !LPJD w 3VCP$PQDPNNJUUFS w "30SBDMFFOIBODFE BEBQUFSDPNNJUUFS w &JXB4ZTUFN .BOBHFNFOU *OD

  3. !FTNJOD -VODI4QPOTPS )FSF

  4. 3BJMTENBOENF

  5. 3BJMTEN

  6. 3BJMTEN

  7. 3BJMTENEBZ

  8. 3BJMTENEBZ

  9. None
  10. None
  11. None
  12. 3BJMTίϛϡχςΟҭͪͷࢹ఺

  13.  4BU 3VCP$PQ )FBERVBSUFST 3BJMT%FWFMPQFST.FFUVQ%BZ&YUSFNF %3&$0.$P -UE The road to

    RuboCop 1.0 after RubyKaigi 2018 ,PJDIJ*50FTN
  14. ࠓ೔ͷ࿩

  15. IUUQTTQFBLFSEFDLDPNLBLVUBOJBHJMFNBOJGFTUPEFDBEF TMJEF !LBLVUBOJ

  16. w"CPVU3VCP$PQ)2 w5IFSPBEUP 3VCP$PQBGUFS 3VCZ,BJHJ "HFOEB

  17. 1FPQMF 1SPEVDU

  18. 1FPQMF

  19. w ೥݄೔ʹདྷ೔͍ͯͨ͠ !CCBUTPWʹΑͬͯެ։͞ΕΔ w (JU)VC্ʹ෼ࢄ͍ͯͨ͠(BOH PG3VCP$PQΛ౷ׅ͍ͯ͠Δ (JU)VCPSHBOJ[BUJPO w "OFX044DPNNVOJUZ 3VCP$PQ)FBERVBSUFST

  20. HJUIVCDPNSVCPDPQIR

  21. None
  22. 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
  23. w ෼ࢄͨ͠ෳ਺ͷݸਓϦϙδτϦ͔Β ͍ͪίϛϡχςΟͷϦϙδτϦ΁ w ݸਓϦϙδτϦͷਓ͕ͨͪ)2ʹू ·͖ͬͯͨ 044ίϛϡχςΟͷৢ଄

  24. w 3VCP$PQ$PSFΛத৺ʹؔ৺ͷ͋ Δϝϯόʔɺ3VCP$PQ34QFDΛ த৺ʹ׆ಈ͍ͯ͠Δϝϯόʔ w ͢΂ͯͷϦϙδτϦʹίϛοτݖ͕͋ ΔΘ͚Ͱ͸ͳ͍ w ྫ͑͹ࢲ͸$PSF1FSGPSNBODF 3BJMT+1

    ϝϯόʔ͝ͱͷྖҬͷҧ͍
  25. w $PSF͸CCBUTPWSVCPDPQͩͬ ͨ΋ͷͰɺ͍ΘΏΔ3VCP$PQͱݺ ͹Ε͍ͯΔ΋ͷͷத৺ w 3VCP$PQ34QFDͳͲ֦ு$PQ͕ ґଘ͍ͯ͠Δ֦ுݩ(FNͷଆ໘ w $PSFͰܧঝʹؔ͢ΔΠϯλϑΣʔε ͕มΘΔͱ֦ு$PQ͸ӨڹΛड͚Δ

    ֦ுݩ$PQͱͯ͠ͷ$PSF
  26. w ͜͜Ұ೥ͷഁյతมߋͱͯ͠͸ /PEF1BUUFSOͷOJM ΁ͷมߋ΍ 3VCP$PQ$PQ͔Βͷ 3BOHF)FMQϞδϡʔϧ੾Γग़͠ ͕͋Δ ֤֦ு(FN͸௥ਵ͕ඞཁ  w

    ؔ৺ͷ͋Δϝϯόʔ͕)2ʹू·ͬ ͨͷ͸ྑ͍࿩ ҟͳΔϓϩδΣΫτؒͰͷಉظ
  27. w ίϯτϦϏϡʔλʹൺ΂ͯ΍ΕΔ͜ ͱ͕૿͑Δ w ίϛολʔʹͳͬͯվΊͯࢥͬͨ͜ Ε·Ͱͱ͜Ε͔Β w (JU)VCϕʔεͷ3BJMTίϛϡχ ςΟͱൺֱ )2ઃཱͱಉ࣌ʹίϛολʔʹͳͬͨ

  28. 044ίϛϡχςΟʹΑΔҧ͍ SBJMTSBJMT CCBUTPWSVCPDPQ 3FWJFX ؔ৺Λ࣋ͬͨਓ ؔ৺Λ࣋ͬͨਓ $MPTF JTTVF *TTVFνʔϜɺίϛολʔɺί Ξϝϯόʔ

    ίϛολʔ .FSHF13 ίϛολʔɺίΞϝϯόʔ ΄΅ϦϙδτϦΦʔφʔ NBTUFS QVTI ίϛολʔɺίΞϝϯόʔ ϦϙδτϦΦʔφʔͷΈ ؍ଌൣғ 3FMFBTF ϦϦʔεϚωʔδϟ ϦϙδτϦΦʔφʔ
  29. ࢲ͕ۙະདྷʹඳ͘3VCP$PQ)2ͷੈք؍ SBJMTSBJMT SVCPDPQIRSVCPDPQ 3FWJFX ؔ৺Λ࣋ͬͨਓ ؔ৺Λ࣋ͬͨਓ $MPTF JTTVF *TTVFνʔϜɺίϛολʔɺί Ξϝϯόʔ

    ίϛολʔ .FSHF13 ίϛολʔɺίΞϝϯόʔ ίϛολʔ NBTUFS QVTI ίϛολʔɺίΞϝϯόʔ ίϛολʔ 3FMFBTF ϦϦʔεϚωʔδϟ ϔουϝϯςφʔ 0S
  30. SVCPDPQIRSVCPDPQ %SPQTVQQPSUGPS.3*

  31. w HJUQVTIPSJHJONBTUFSʹͭ ͍ͯ w جຊ͸1VMM3FRVFTUΛ։͘ w ໌നͳ$PTNFUJDDIBOHF͸ NBTUFSQVTIͰྑ͍ͷͰ͸ʁ ίϛολʔͷݖརͱن཯

  32. None
  33. w ΍ͬͯΈͤ HJUQVTIPSJHJONBTUFS git push origin master

  34. SVCPDPQIRSVCPDPQ!GGBF 'JY$)"/(-0(NE

  35. None
  36. None
  37. IUUQTUXJUUFSDPNLPJDTUBUVT

  38. w lNBTUFSQVTI͢Δͱ͖͸13Λ ૹΔͱ͖ΑΓ΋৻ॏʹ΍͍ͬͯΔz w l࣌ؒʹ௥ΘΕͯΔͱ͖͸΍Βͳ͍z w l ϛεͨ͋͠ͱ NBTUFSQVTIͷ จԽΛ࡞ΔͳΒઆ໌͸͏·͍͜ͱ͢

    Δඞཁ͕͋Δz 3BJMTίϛολʔ͔Βͷॿݴ
  39. None
  40. None
  41. ͔͜͜Βগ͠ ৽ͨͳࢀೖ΁ͷώϯτ

  42. ਓࡐ͸༗ݶͰ ͋Γྲྀಈ͢Δ IUUQTHJUIVCDPNSVCPDPQIRSVCPDPQJTTVFTJTTVFDPNNFOU

  43. w 5IF3BJMT%PDUSJOF w ҟͳΔࢹ఺ɺ৽ͨͳίϛϡχςΟϝ ϯόʔΛܴ͑ೖΕΔ w HPPEpSTUJTTVF w 3VCP$PQ+1 l1VTIVQBCJHUFOUz

  44. None
  45. HPPEpSTUJTTVF

  46. lHPPEpSTUJTTVFz

  47. 3VCP$PQ+1

  48. None
  49. w ͍͖ͳΓ೉͍͠໰୊Λղ͜͏ͱ͠ͳ͍ w lHPPEpSTUTUFQz͸͸͡ΊͷҰา΁ ͷΦεεϝͷϥϕϧ w ِཅੑ΍Τϥʔʹ͍ͭͯΠγϡʔΛ։͘ ͜ͱʹΑͬͯࢀՃ͢Δͱ͍͏Ұา໨ w ΠγϡʔςϯϓϨʔτʹ४͡Δͱ(PPE

    044ίϛϡχςΟ΁ͷࢀՃͷҰา
  50. QPDLF .ZHPBMGPSUIJTPSHBOJ[BUJPOJTUPCFDPNFUIF DFOUSBMIVCGPSBMMUIFDPSF3VCP$PQSFMBUFE BDUJWJUJFT*XBOUVTUPCVJMEBCJHHFSDPSFUFBN TOJQ  *UIBTO`UCFFOBQFSTPOBMQSPKFDUPGNJOFGPSRVJUF BXIJMF*GTPNBOZQFPQMFBSFVTJOHJU JGTPNBOZ UIJOHTBSFOFFEFEUPCFEPOF

    UIJTCFMPOHTUPUIF DPNNVOJUZ IUUQTCMPHTJEFDJDPNJOUFSWJFXXJUICP[IJEBSCBUTPWCCGEB :FTUFSEBZ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3BJMT෦ॺʹ͍ͭͯ ελϒʹͯ͠ɺSVCPDPQSBJMT HFNͷ௥ՃΛଅ͢ϩάΛग़ྗ͢Δ w ͋Δ͍͸3VCP$PQ3BJMTʹ ϑΥʔϧόοΫ͢Δ 3VCP$PQ3BJMT΁ͷҠߦ

  67. SVCPDPQIRSVCPDPQ &YUSBDU1FSGPSNBODF$PQTJOUPBTFQBSBUFHFN

  68. None
  69. w ύϑΥʔϚϯεޮ཰ʹ͍ͭͯ.3* ʹಛԽͨ͠಺༰ʹͳ͍ͬͯΔ w 3VCP$PQ͸+3VCZ΋αϙʔτ ͍ͯ͠Δ w 3VCP$PQ$PSFͱͯ͠͸ॲཧܥ ʹґଘ͠ͳ͍ܗΛࢦ޲͍ͯ͠Δ 5-%3

  70. None
  71. w ࣮ࡍͷޮՌʹ͍ͭͯ͸ɺެࣜυΩϡ ϝϯτͷϦϑΝϨϯεʹه͞Ε͍ͯ Δ৔߹͕͋Δ w ࠾୒Λ೰Μͩ࣌͸Ұಡ͔ͯ͠Β࣮ߦ ΛࢼΈͯ΋ྑͦ͞͏ 5JQTPG1FSGPSNBODFDPQ

  72. 1FSGPSNBODF4BNQMF

  73. +VBOJUP'BUBTGBTUSVCZ

  74. SBJMTSBJMT

  75. CFODINBSLJQT

  76. $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
  77. w !DPNQPTFSJOUFSBMJB͕ਐΊͯ ͘Ε͍ͯΔ w 3VCP$PQʹ޲͚ͯ 3VCP$PQ3BJMTಉ༷ਐḿ͍ͯ͠Δ w ͠͹Β͘3VCP$PQ$PSFͱͷಉ ظ͕৬ਓͷԹ͔ͳख࡞ۀ 1FSGPSNBODFDPQTͷநग़ঢ়گ

  78. SVCPDPQIRSVCPDPQ &YUFOEDPQNFUBEBUB

  79. None
  80. w ͓ͦΒ͘3VCP$PQͷ໨ۄ w 3VCP$PQΛΞοϓάϨʔυͨ͠ࡍʹ ރΕ͍ͯͳ͍$PQͰͷ໰୊͕͋ͬͨΓ CSFBLJOHDIBOHFͨ͠Γͷ൵͠Έ ͷ͓ศΓ΁ͷػೳ w SVCPDPQZNM EFGBVMUZNM

    ΁ͷ ϝλσʔλͷ௥Ճ 5-%3
  81. w 7FSTJPO"EEFEʜ$PQ͕௥Ճ͞Εͨόʔδϣ ϯ w 7FSTJPO$IBOHFEʜϢʔβʔʹӨڹͷ͋Δόʔ δϣϯ ৽͍͠ઃఆɺσϑΥϧτͷมߋ  w 7FSTJPO3FNPWFEʜ࡟আ͞Εͨόʔδϣϯ

    w 4BGFʜِཅੑͳͲͳ͘ઃܭͲ͓Γʹ৴པͰ͖Δ w 4BGF"VUP$PSSFDUʜࣗಈमਖ਼ͰյΕ͍ͯͳ͍ ͭͷϝλσʔλ
  82. w 4BGFΦϓγϣϯͷΈ࣮ߦ͢Δ w 4BGF"VUP$PSSFDUͷΈ࣮ߦ͢Δ w σϑΥϧτͰ͸͢΂ͯ4BGFѻ͍ w ࠷৽όʔδϣϯͷ$PQΛআ֎ͯ͠ ࣮ߦ͢Δ ࣮ߦΦϓγϣϯͷީิ

  83. w 4BGFͱ4BGF"VUP$PSSFDUͷ൑ ఆʹ͍ͭͯͲ͏͢Δ͔ w طଘΠγϡʔ͕͋Δ͔͕ͻͱͭͷࢦඪ ʹͳΓͦ͏ ެ։͞Εͨ۩ମతඪຊ  w ໰୊͕͋Ε͹3VCP$PQ$PSF͔

    3VCP$PQ+1·Ͱ͓ศΓΛ ݒ೦఺
  84. w HPPEpSTUJTTVFͱͯ͠ਐΜͰ ͍Δ ঢ়گ

  85. SVCPDPQIRSVCPDPQ *OUSPEVDFOFXDPQTXJUIBTQFDJBMTUBUVT JOTUFBEPGFOBCMFEEJTBCMFE

  86. None
  87. w طଘͷFOBCMFEEJTBCMFE΁ ͷ֦ுͱղऍͰ͖Δ w ৽ͨʹ/FX ͋Δ͍͸OJM Λ༻ҙ ͯ͠ɺͦͷ஋ͷ৔߹͸৽ͨͳ$PQ Λ࢖͏͔Ϣʔβʔʹ༗ޮແޮΛΏ ͩͶΔܯࠂΛදࣔ͢Δ

    5-%3
  88. w ΞοϓάϨʔυ࣌ʹ໰୊ʹͳΔͷ͸ރ Ε͍ͯͳ͍৽͍͠$PQͷέʔε͕ଟ ͍ ϦάϨογϣϯΑΓͪ͜Β͕ଟ͍  w ϝλσʔλͷ7FSTJPO"EEFEɺ͋ Δ͍͸&OBCMFEͷ/FXΛݩʹͯ͠ ࠷৽ͷόʔδϣϯͰ௥Ճ͞Εͨ$PQ

    Λআ֎͢Ε͹ޡݕ஌ΛݮΒͤͦ͏ *.0ΞοϓάϨʔυ΁ͷ҆৺ͷ޲্
  89. w ݱঢ়ͷ3VCP$PQͰແޮʹ͍ͨ͠ $PQ͸Enabled: falseͱͯ͠ ରॲͰ͖Δ͕ɺԿ͔ͷҙਤ͕͋ͬͯ EJTBCMFEʹͨ͠ͷ͔ɺόʔδϣ ϯΞοϓ࣌ͷރΕ͍ͯͳ͍$PQͩ ͔Βແޮʹ͍ͯ͠Δͷ͔ͷঢ়ଶ۠ผ ͕͔ͭͳ͍ ৽ͨͳϥϕϦϯά

  90. SVCPDPQIRSVCPDPQ *NQMFNFOUPQUJPOTUPSVOPOMZTBGFDPQT BOETBGFBVUPDPSSFDUT

  91. None
  92. w SVCPDPQίϚϯυ΁ͷΦϓγϣ ϯΛ௥Ճ͢Δ 5-%3

  93. w --safeΦϓγϣϯʜ4BGFͷ$PQ ͷΈ࣮ߦ͢Δ w --safe-auto-correctΦϓγϣϯʜ 4BGF"VUP$PSSFDUͷ$PQͷΈ࣮ߦ ͢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