Slide 1

Slide 1 text

Re:valua t ion https://fril.jp/ L ead & Delight User F irst Ownership Fail Smart 4PSCFUΛ৮ͬͯΈͨ࿩

Slide 2

Slide 2 text

3BLVNB4FSWJDF%FWFMPQNFOU(SPVQ 3BLVUFO JOD "CPVUNF ௕୩෦྄)BTFCF3ZP !%FBS@ZPV@DSZ ܦྺ ˝/55ܥ4*FSʢۚ༥൚༻ػ೥ʣ ˝ݹΊͷϕϯνϟʔʢ8FCडୗ೥ʣ ˝৽͠Ίͷϕϯνϟʔʢਓࣄ࿑຿ܥ4BB4೥ʣ ⾣ָఱʢʙʣ

Slide 3

Slide 3 text

No content

Slide 4

Slide 4 text

ੵۃ࠾༻தʂ

Slide 5

Slide 5 text

4PSCFUͬͯʁ

Slide 6

Slide 6 text

"CPVU4PSCFU • Ruby޲͚ܕνΣοΧʔ • ࡶʹݴ͏ͱɺrubocopͷܕόʔδϣϯ • srb/sorbet-runtimeͰߏ੒͞ΕΔ • srb: CLI/੩తνΣοΫ/ηοτΞοϓ • sorbet-runtime: T::Sig(ޙड़)/ಈతνΣοΫ

Slide 7

Slide 7 text

ܕΛνΣοΫͰ͖Δͱɺͳʹ͕ྑ͍ʁ

Slide 8

Slide 8 text

͜͜ʹ͸λΠτϧΛೖྗ͠·͢ɻ ܕΛνΣοΫͰ͖Δͱ ιʔείʔυͷϝϯςφϯεੑ͕޲্͢Δ

Slide 9

Slide 9 text

ྫ͑͹ class Hoge def add(a,b) a + b end end Hoge.new.add(1,2) => 3 # ظ଴௨Γ Hoge.new.add('1','2') => “12" # ͜ͷϨϕϧͳΒྑ͍͚Ͳɺ ෳࡶ౓͕૿ͨ͠ίʔυΛԿਓ΋ͷਓ͕ݟΔͱ ඞͣೝࣝͷᴥᴪ͕ൃੜͯ͠͠·͏

Slide 10

Slide 10 text

4PSCFU͸Կ͕Ͱ͖Δ͔

Slide 11

Slide 11 text

͜͜ʹ͸λΠτϧΛೖྗ͠·͢ɻ ܕʹىҼ͢ΔϛεΛ࣮ߦલʹݕ஌Ͱ͖Δ ɾҾ਺ͷܕ͕ҧ͏ ɾϝιου໊ͷλΠϙ

Slide 12

Slide 12 text

͜͜ʹ͸λΠτϧΛೖྗ͠·͢ɻ class A # ϝιου஫ऍʹ࢖༻͢ΔɺsigϝιουΛ࢖͑ΔΑ͏ʹ͢Δ extend T::Sig # sigΛ࢖ͬͯҾ਺ͱฦΓ஋ͷܕΛఆٛ͢Δ sig {params(x: Integer).returns(String)} def bar(x) x.to_s end end def main A.new.barr(91) # error: Typo! A.new.bar("91") # error: Type mismatch! end editor.rb:11: Method barr does not exist on A https://srb.help/7003 11 | A.new.barr(91) # error: Typo! ^^^^^^^^^^^^^^ Autocorrect: Use `-a` to autocorrect editor.rb:11: Replace with bar 11 | A.new.barr(91) # error: Typo! ^^^^ editor.rb:12: Expected Integer but found String("91") for argument x https://srb.help/7002 12 | A.new.bar("91") # error: Type mismatch! ^^^^^^^^^^^^^^^ editor.rb:4: Method A#bar has specified x as Integer 4 | sig {params(x: Integer).returns(String)} ^ Got String("91") originating from: editor.rb:12: 12 | A.new.bar("91") # error: Type mismatch! ^^^^ Errors: 2

Slide 13

Slide 13 text

ಋೖ

Slide 14

Slide 14 text

͜͜ʹ͸λΠτϧΛೖྗ͠·͢ɻ # -- Gemfile -- gem 'sorbet', :group => :development gem 'sorbet-runtime' › bundle install

Slide 15

Slide 15 text

͜͜ʹ͸λΠτϧΛೖྗ͠·͢ɻ › bundle exec srb init ্هίϚϯυͰ
 ɾsorbetϑΥϧμ͕࡞੒͞ΕΔ ɾطଘίʔυͷ্෦ʹ # typed: strict ͱ͔͕ ɹૠೖ͞ΕΔʢܕνΣοΫͷݫີ౓ΛઃఆͰ͖Δʣ

Slide 16

Slide 16 text

͜͜ʹ͸λΠτϧΛೖྗ͠·͢ɻ # typed: strict class UsersController < ApplicationController skip_before_action :require_sign_in, only: [:new, :create] ignore: ͢΂ͯແࢹ͢Δʢݕࠪ͠ͳ͍ʣ false: ߏจΤϥʔͱsig sͷਖ਼֬ੑ͚ͩใࠂʢσϑΥϧτʣ true: ଘࡏ͠ͳ͍ϝιου/Ҿ਺Χ΢ϯτ/ม਺ͷܕͷໃ६౳Λใࠂ strict: ͢΂ͯͷϝιουʹsig͕ඞཁ/͢΂ͯͷఆ਺ͱΠϯελϯεఆ਺ʹܕ ࢦఆ͕ඞཁ strong: sorbet͕ϑΝΠϧ಺ͷ͢΂ͯͷϝιουίʔϧʹରͯ͠ܕΛ೺Ѳͯ͠ ͍Δ͜ͱΛٻΊΔʢΊͬͨʹ࢖༻͠ͳ͍ʣ

Slide 17

Slide 17 text

͜͜ʹ͸λΠτϧΛೖྗ͠·͢ɻ sorbet/ ├── config └── rbi/ └── ··· config: Sorbet͕ಡΈऔΔઃఆϑΝΠϧ rbi: RBIϑΝΠϧʢܕγάωνϟʣΛؚΉϑΥϧμ ɹɹRBIʢRuby InterfaceʣϑΝΠϧ͸ɺSorbet͔Β͸ݟ͑ͳ͍
 ɹɹRubyͷΫϥεɺϞδϡʔϧɺఆ਺ɺ͓ΑͼϝιουΛSorbetʹ
 ɹɹએݴ͢Δ

Slide 18

Slide 18 text

͜͜ʹ͸λΠτϧΛೖྗ͠·͢ɻ › bundle exec srb tc ্هίϚϯυͰ
 ɾશιʔείʔυͷํνΣοΫΛߦ͏ ɾ͜ͷஈ֊Ͱ͸ɺ͢΂ͯͷΤϥʔΛແࢹ͢Δ ɹɹɾrubocopಋೖ࣌ͷ.rubocop_todo.ymlΈ͍ͨͳײ͡

Slide 19

Slide 19 text

σϞ

Slide 20

Slide 20 text

·ͱΊ

Slide 21

Slide 21 text

͜͜ʹ͸λΠτϧΛೖྗ͠·͢ɻ Good - RubyͰܕΛνΣοΫͰ͖ɺϝϯςφϯεੑ͕૿͢
 - ஈ֊తʹಋೖͰ͖ΔʢϑΝΠϧ୯ҐͰݫີੑΛࢦఆʣ Bad
 - ίʔυͷݟ௨͕͠ѱ͘ͳΔ - 1.0͕ग़ͯͳ͍ʢ࠷৽͸0.4.4782ʣͷͰϦεΫ༗

Slide 22

Slide 22 text

͜͜ʹ͸λΠτϧΛೖྗ͠·͢ɻ ΋͠ϓϩμΫτίʔυʹSorbetΛಋೖ͢Δͱͨ͠Β… ܾࡁॲཧ෦෼ͷΑ͏ʹɺόάࠞೖͷϦεΫΛԼ͍͛ͨ ՕॴʹϐϯϙΠϯτͰಋೖ͢Δͷ͕ྑͦ͞͏

Slide 23

Slide 23 text

5IBOLZPVGPSMJTUFOJOH