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

RuboCop Philosophy

Koichi ITO
February 25, 2023

RuboCop Philosophy

プログラミング言語Ruby 30周年イベント ライトニングトーク
https://30.ruby.or.jp/

Koichi ITO

February 25, 2023
Tweet

More Decks by Koichi ITO

Other Decks in Programming

Transcript

  1. 3VCP$PQϝϯςφʔ͙͠͞

    RuboCop Philosophy
    ϓϩάϥϛϯάݴޠ3VCZप೥ه೦Πϕϯτ
    4BU

    ҏ౻ߒҰ&4. *OD

    View Slide

  2. େࣄͳ͜ͱ
    ͸࠷ॳʹ

    View Slide

  3. ॕप೥🎉

    View Slide

  4. @koic
    w044ϓϩάϥϚʔ
    w3VCP$PQίΞνʔϜ
    wגࣜձࣾӬ࿨γεςϜϚωδϝϯτ &4. *OD

    ΤϯδχΞϦϯάϚωʔδϟʔ݉
    σΟεςΟϯάΠογϡυΤϯδχΞ

    View Slide

  5. View Slide

  6. 044ίϛϡχςΟͱͷڞੜΛࢧԉ
    3BJMT044ύονձ
    #esm_oss

    View Slide

  7. View Slide

  8. w +BWB4DSJQU1SFUUJFS &4-JOU
    w (P(PGNU
    w 3VTU3VTUGNU $MJQQZ
    w 3VCZ3VCP$PQ 4UBOEBSE BOE
    PUIFST
    ϦϯλʔϑΥʔϚολʔͷੈք

    View Slide

  9. View Slide

  10. .F

    View Slide

  11. IUUQTSBJMTIPTUJOHDPNXIJDISVCZHFNTEPZPVMPWF

    View Slide

  12. IUUQTSBJMTIPTUJOHDPNXIJDISVCZHFNTGSVTUSBUFZPVUIFNPTU

    View Slide

  13. View Slide

  14. ࠓ೔ͷ࿩

    View Slide

  15. 3VCP$PQDPSFEFWFMPQFST
    +0900
    UTC+0200 +0300 +0800 -0400
    ։ൃऀʹΑͬͯߟ͑΍޷Έͷҧ͍͕͋Δ
    ͳͷͰ͜ͷൃද͸ࢲݸਓͷݟղͰ͢

    View Slide

  16. View Slide

  17. ໨࣍
    ஀ੜͱ఩ֶ
    ϐϥϛουͱࣗಈԽ
    ϝϯςφʔ͙͠͞

    View Slide


  18. ஀ੜͱ఩ֶ

    View Slide

  19. w 3VCZ೥݄೔ੜ·Ε
    w IUUQTCMBEFSVCZMBOHPSHSVCZMJTU
    w 3BJMT೥݄೔ʹΞφ΢ϯε
    w IUUQTCMBEFSVCZMBOHPSHSVCZUBML
    w 3VCP$PQ೥݄೔ʹTUίϛοτ
    w IUUQTHJUIVCDPNSVCPDPQSVCPDPQDPNNJUBGCFBE
    3VCZ 3BJMT 3VCP$PQͷ஀ੜ

    View Slide

  20. w 3VCZ͸प೥
    w ॊೈͳදݱྗΛඋ͑ͯɺϓϩάϥϛϯάΛ
    ָ͘͢͠Δ 3VCZJTUʹ޾ͤΛ͸͜Ϳ
    ݴޠ
    w 3VCP$PQ͸ࡢ೥प೥
    w 3VCZͱ͓Αͦࡀࠩ
    3VCZͱ3VCP$PQ

    View Slide

  21. ೥Λ౿·͑ͨެࣜ఩ֶ
    IUUQTEPDTSVCPDPQPSHSVCPDPQJOEFYIUNMQIJMPTPQIZ

    View Slide

  22. w 3VCP$PQ͸3VCZ4UZMF(VJEFͷϥϯλΠϜ࣮૷
    w ॳظʹ໨ࢦͨ͠ͷ͸HPGNUతͳେ౷ҰϑΥϚολʔ
    w 3VCZίϛϡχςΟʹ͸ڝ߹͢ΔελΠϧ΍޷Έ͕͋Δ͜
    ͱʹؾͮ͘ FHμϒϧΫΥʔτɺγϯάϧΫΥʔτ

    w ҰൠతͳελΠϧΛߏ੒Մೳʹ͢ΔΑ͏ʹͳΔ
    w ελΠϧΨΠυΛσϑΥϧτͱͭͭ͠ɺ޷Έͷҧ͍Λड
    ͚ೖΕΔͱ͍͏఩ֶʹجͮ͘Α͏ʹͳΔ
    3VCP$PQͷ఩ֶαϚϦʔ

    View Slide

  23. ޷Έͷҧ͍Λड͚
    ೖΕΔͱ͍͏఩ֶ

    View Slide


  24. ϐϥϛουͱࣗಈԽ

    View Slide

  25. 3VCZίϛϡχςΟͱ
    ίʔσΟϯάελΠϧ

    View Slide

  26. ੜ஀೥ͷϢʔβʔ
    ϕςϥϯ͔Β
    ϏΪφʔ·Ͱ෯޿͍૚

    View Slide

  27. ࢲ ͨͪ
    ͷߟ͑ͨ
    ࠷ڧ͋Δ͍͸࠷Ѫͷ
    ελΠϧଟ਺

    View Slide

  28. ڷʹೖΕ͹
    ڷʹै͑
    ίʔσΟϯάελΠϧʹ΋ݴ͑Δ͜ͱ

    View Slide

  29. ಛʹ࢓ࣄͰ͸େਓ
    ʹͳΔඞཁ͕͋Δ

    View Slide

  30. ϓϩδΣΫτ
    ࢓ࣄ
    ελΠϧϐϥϛου
    ݖҖͷελΠϧΨΠυ
    ࣗ෼ͷελΠϧ
    ϓϩδΣΫτͷελΠϧ͕͓͔͔ͬͨ͠ΒԼࠀ্͕ى͖͏Δ
    ͋͑ͯϧʔϧΛઃ͚ͳ͍PSߟྀ͞Εͣ
    Ѫ৘
    ܟҙ
    कഁ
    ཭PSແ
    ϑϦʔμϜ
    δϟεςΟε ϓϩδΣΫτϧʔϧ༏ઌͰ
    ϧʔϧ͕ͳ͚Ε͹
    ϑΥʔϧόοΫ͞Ε͍ͯ͘
    $IBPT
    -BX

    View Slide

  31. ͞Γ͸͞Γͱͯ1SPCMFNWT64
    IUUQTUXJUUFSDPNPOLTUBUVT

    View Slide

  32. View Slide

  33. IUUQTSBJMTIPTUJOHDPNXIJDISVCZHFNTEPZPVMPWF

    View Slide

  34. IUUQTSBJMTIPTUJOHDPNXIJDISVCZHFNTGSVTUSBUFZPVUIFNPTU

    View Slide

  35. σϑΥϧτ͕࢖͍
    ͮΒ͍͕ߏ੒͢Δ
    ͷ͸໘౗ͱ͍͏੠

    View Slide

  36. w σϑΥϧτ͕ݫ͗͢͠Δ
    w ݫ͍͠కΊ෇͚͕ྑ͍ͱ͍͏੠΋͋Δ
    w σϑΥϧτͰબ୒͞ΕͨελΠϧ͕͋Θͳ͍
    w ରۃ͕࣠͋Δ΋ͷ͸೉͍͠ɻྫ͑͹γϯάϧΫΥʔτ೿ͱμϒϧ
    ΫΥʔτ೿ͷ߅૪͸ऴΘΒͳ͍ɻ3VCZ͕޷͖ͳͷ͸Θ͔ͬͨɻ
    w σϑΥϧτͰ༗ޮͷϧʔϧ͕ଟ͗͢Δ
    w ͜Ε͸ͦ͏ɻؤுͬͯݮΒ͢׆ಈΛ͍ͯ͠Δ͕ɺ͍ͨ΁Μɻ
    σϑΥϧτ΁ͷݱ࣮ͷ੠

    View Slide

  37. ͍ͪͲσϑΥϧτʹ
    ͳͬͨ΋ͷ͸खڧ͍

    View Slide

  38. View Slide


  39. ϝϯςφʔ͙͠͞

    View Slide

  40. ."/"48"/
    ΁ͷෛ୲ΛݮΒ͢
    ඞཁҎ্ͷΧελϚΠζઃఆ

    View Slide

  41. w ཧ૝ͱ͢ΔσϑΥϧτ͸5IF3BJMT%PDUSJOF
    ͷʮ5IFNFOVJTPNBLBTFʯͷੈք؍
    w ͍͍ͩͨͷ৔߹͸σϑΥϧτͰ͏·͍͘͘
    w ͨ·ʹ
    ͋Θͳ͍෦෼͸ΧελϚΠζͰ͖Δ
    શͯԕ͖ཧ૝ڷ

    View Slide

  42. Ͳ͏͍͏ߟ͑ํʹ
    ࢲ͸ج͍ͮͯΔʁ

    View Slide

  43. w ίϯτϦϏϡʔλ΁ͷ Ϛʔδ΁ͷ
    ຬ଍ײ
    Ͱ͸ͳ͘ɺϓϩμΫτ΁ͷϢʔβʔͷ࢖͍উ
    खΛॏࢹ͢Δ
    w ͨͱ͑͹ಛఆͷϓϩδΣΫτͷ޷Έ͕σϑΥ
    ϧτ޲͖ͱ͸ݶΒͳ͍
    $PQDPQͱ͍͏ϝλ׆ಈ🚨
    Ϋϩʔζ͸৺ॏ͍Ͱ͕͢Ϣʔβʔͷ൵໐Λ๷͙ͷΛ༏ઌ

    View Slide

  44. ఩ਓدΓʁࢻਓدΓʁ
    ఩ਓ ࢻਓ
    w νʔϜ։ൃ
    w ݎ͍ن໿
    w ౷Ұੑͷ९क
    w ݸਓ։ൃ
    w ؇͍ن໿
    w ଟ༷ͷड͚ೖΕ
    ౓߹͍

    View Slide

  45. ࢲࣗ਎ͷࣗݾ෼ੳ
    ఩ਓ ࢻਓ
    w νʔϜ։ൃ
    w ݎ͍ن໿
    w ౷Ұੑͷ९क
    w ݸਓ։ൃ
    w ؇͍ن໿
    w ଟ༷ͷड͚ೖΕ
    ౓߹͍

    View Slide

  46. ࢲͷ఩ֶ
    ఩ਓ ࢻਓ
    w ΋ͬͱࣗ༝౓͕͋Δͱࣗવຯ ָ͠͞
    ͋Δ
    w σϑΥϧτϧʔϧ͸΋ͬͱ؇ͯ͘ྑ͍
    w ʮݫ͗͢͠ͳʯϧʔϧͷఏҊ͸͓فΓ͢Δ
    ౓߹͍

    View Slide

  47. w ϧʔϧͱͯ͠ݫ͗͢͠Δ
    w ಠࣗϧʔϧײ͕ڧ͍
    w ِཅੑ͕ଟ͍͜ͱ͕ࣗ໌ͳ΋ͷ
    w ϚʔδޙʹϢʔβʔͷ൵໐͕େ͖ͦ͏ͳ΋ͷ
    ίΞʹड͚ೖΕʹ͍͘ϧʔϧ
    ίΞͰ͸ͳ͘SEύʔςΟʔͰͷެ։Λ঑Ί͍ͯΔ

    View Slide

  48. େ౷ҰͰ͖Δ͔໰୊
    ఩ਓ ࢻਓ
    w ελΠϧͰ޷Έ͕෼͔ΕΔ
    w ఩ਓࢻਓͷ౓߹͍͕։ൃऀ͝ͱʹҟͳΔ
    w ͳΜͳΒ3VCZίϛολʔͰ΋ҟͳ͍ͬͯͨ
    ౓߹͍

    View Slide

  49. 3VCP$PQDPSFEFWFMPQFST
    +0900
    UTC+0200 +0300 +0800 -0400
    ։ൃऀʹΑΔߟ͑΍޷Έͷҧ͍Λௐఀ͢Δ
    3VCZJTUͷ਺͚ͩελΠϧͷ޷Έ͕ੜ·ΕΔ

    View Slide

  50. View Slide

  51. "
    ࠷ߴͷ$PQΛٻΊͯ

    View Slide

  52. w ϓϩάϥϚʔͷϝϞϦ؅ཧ͔ॲཧܥͷ($ͷ
    ୒Ͱͳ͘ɺίϯύΠϥͰϝϞϦ؅ཧΛղܾ
    ͢Δ3VTUͷಓ
    w ੩తܕ෇͚ͷܕԸܙ͔ಈతܕ෇͚ͷखܰ͞ͷ
    ୒Ͱͳ͘ɺܕఆٛϑΝΠϧͰ྆औΓΛ໨ࢦ
    ͢3#4ͷಓ
    ୈࡾͷղܾ

    View Slide

  53. w HPGNUͷΑ͏ͳ୒ҰϑΥʔϚοτͱϢʔβʔ
    ΧελϜͷߏ੒ͷ୒Ͱ͸ͳ͘ɺͳΜͱͳ͘
    ೲಘײͷ͋Δʮ͍͍ͩͨ͏·͍͘͘ߏ੒ʯ
    w 3VCP$PQͰݕ౼͞ΕͯΔϓϦηοτ͕ͦΕ
    ʹ͍͕ۙʮ୭͔ͷዞҙੑʯ͔Βൈ͚ग़ͤͳ͍
    3VCP$PQͰ΋ୈࡾͷղܾ

    View Slide

  54. Ѫ৘͋Δዞҙੑ͕
    ղܾ΁ͷಓʁ

    View Slide

  55. w ίϛϡχςΟͷҙࢥܾఆͱผʹ༏͍͠ಠࡋऀͷΑ
    ͏ͳݸਓʹΑΔҙࢥܾఆϞσϧ
    w ੨໦ๆ࿠͞Μͷʮ3VCZͷίʔσΟϯάελΠϧʯ
    w લాमޗ͞Μͷʮ3VCZίʔσΟϯάن໿ʯ
    w ۩ମతͳʮಛఆͷ୭͔ʯॏཁͰ͸ʁ FH0OL$PQ

    ଥ౰ͦ͏ͳʮ୭͔ʯϧʔϧʁ

    View Slide

  56. w ͍͍ͩͨ͏·͍͖ͦ͘͏ʁ
    .BU[$PQ

    View Slide

  57. w ·ͭ΋ͱ͞Μ؂म

    w 3VCZͷ਌ͱ͍͏͜ͱ͸Ѫ৘͸ੈքҰ

    w DisabledByDefault: trueϕʔεͷ֦ுHFN
    w ϧʔϧ $PQ
    ͸ແݶʹ૿͍͍͑ͯͬͯΔͷͰɺ
    ϛχϚϜͷελʔλʔΩοτΑ͏ͳ΋ͷʹͳΓ
    ͦ͏
    .BU[$PQͷ͝ఏҊ

    View Slide

  58. w େਓʹͳͬͨ3VCZΛݟकΔ.BU[$PQͷΑ͏ͳݖ
    ҖͷσϑΥϧτ͕͋Δͱ޾ͤͳ3VCZJTU͸͍ͦ͏
    w ͱ͸͍͑ϧʔϧͷऔࣺબ୒͕͍ͨ΁Μͦ͏
    w 3VCP$PQϓϩμΫτͱͯ͠͸αϙʔτελΠϧ
    ͷͻͱͭͱݟ၏͠3VCP$PQͷ఩ֶΛຬ଍ͤ͞Β
    ΕΔ
    प೥ͷઌʹ޲͚ۭͨ૝

    View Slide

  59. ͦΕͧΕͷՖ͋Γ
    ͯͦ͜໺͸ָ͠💐

    View Slide

  60. ॕप೥🎉

    View Slide