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
SwiftLint実践入門
Search
akatsuki174
October 02, 2017
Programming
1k
7
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
SwiftLint実践入門
2017/10/02 俺コン Day. 1
※2017/10/03 17時頃に資料を上げ直しています。
akatsuki174
October 02, 2017
More Decks by akatsuki174
See All by akatsuki174
逆向きUIの世界 〜iOSアプリのRTL言語対応〜
akatsuki174
1
730
逆向きUIの世界〜AndroidアプリのRTL言語対応〜
akatsuki174
1
1.2k
私が変えてきたこと、変えなかったこと
akatsuki174
2
1.1k
最近読んでいる本-読書シェア会vol.1
akatsuki174
2
300
SwiftUI、UIKitでキャプチャを撮ろう!
akatsuki174
1
160
Appleにおけるプライバシーの全容を把握する
akatsuki174
0
6.4k
近年のAppleにおける位置情報とプライバシー
akatsuki174
3
530
オフライン勉強会ぼっち対策
akatsuki174
1
750
Xcode 15の新機能
akatsuki174
0
2.9k
Other Decks in Programming
See All in Programming
AI Agent時代のリアーキテクチャ戦略と実践
hokaccha
9
5.2k
[ハンズオン]AIへの指示だけで「五目並べ」を作ってみよう
satoshi256kbyte
1
310
JAWS-UG 東京支部が始める、JAWS-UG支部コラボ / JAWS-UG lunchtime LT Collaboration
y0hgi
0
170
Security issues being discussed on Web Platforms
petamoriken
0
1.4k
Augmenting AI with the Power of Jakarta EE
ivargrimstad
0
380
Herb in Rails 8.2: Your ERB views, now HTML-aware @ Rails World 2026, Austin, Texas
marcoroth
0
140
AHC070解法紹介
eijirou
0
150
App Intentsのビルドプロセスを支える技術
kntkymt
0
490
難しいけど、読めた。- OSSの入口に立った話。
sts11142
0
130
GitHubハンズオン講座 — 実務レベルのチーム開発のフローを身につけよう
junhat6
0
110
巨大モノリシックアプリ モダン化大作戦
ktcryomm
1
1.2k
UnityでSystem.Net.WebSocketsなWebSocketサーバが動かないのでUnity Monoのコードを覗いてみた / about implementing websocket server with unity mono
drumath2237
1
510
Featured
See All Featured
How Fast Is Fast Enough? [PerfNow 2025]
tammyeverts
3
910
Exploring the relationship between traditional SERPs and Gen AI search
raygrieselhuber
PRO
3
4.3k
Stewardship and Sustainability of Urban and Community Forests
pwiseman
0
530
Jess Joyce - The Pitfalls of Following Frameworks
techseoconnect
PRO
1
420
Designing for Performance
lara
611
70k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
666
130k
Faster Mobile Websites
deanohume
310
32k
Navigating Weather and Climate Data
rabernat
0
540
How to Get Subject Matter Experts Bought In and Actively Contributing to SEO & PR Initiatives.
livdayseo
0
200
Measuring & Analyzing Core Web Vitals
bluesmoon
9
1k
Imperfection Machines: The Place of Print at Facebook
scottboms
270
14k
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
10
1.4k
Transcript
SwiftLint࣮ફೖ @akatsuki174
ࣗݾհ • ਢ౻ຘ • iOSΤϯδχΞ • גࣜձࣾZaimॴଐ • Twitter, Qiita,
SlideShare, Github, SpeakerDeck →akatsuki174
None
એ 10/13(ۚ)ɺ10/20(ۚ)ͷ2days 19:20ʙ
͓ئ͍ iOSDCશମɺτʔΫʹର͢ΔΞϯέʔτͷ ճΛΑΖ͓͘͠ئ͍͠·͢ʂ
ࠓͷτʔΫ
ࠓͷτʔΫ جૅলུɻ࣮ͰͲ͏͏ͷ͕ ͍͍͔ʹ͍ͭͯ͠·͢ɻ
ࠓͷτʔΫ ࢀՃܕͷτʔΫʹͳΓ·͢ʂ͓खݩʹ ࣗͷ.swiftlint.ymlΛஔ͍͍͚ͯͨͩΔͱɻ
ɾSwiftLintͷ࠷৽ͷใʹ͍ͭͯհ ɾΈͳ͞ΜͲͷϧʔϧΛͲͷΑ͏ʹ ɹ࠾༻ͯ͠·͔͢ʁ ɾࢲ͕ߟ͑Δ࠷ڧͷ.swiftlint.yml ɾCIपΓͷ ࠓͷ֓ཁ
SwiftLintͷ࠷৽ใ
ɾϧʔϧ૯105 ɾ2015/05/18ʹॳϦϦʔε ɾɾҎ߱ɺ42ճͷϦϦʔεΛॏͶ͍ͯΔ ɾStar7,700 SwiftLintͷࠓ ※͜͜Ͱͷใ2017/10/02࣌ͰͷใͰ͢
SwiftLint 1.0.0ʁ
SwiftLint0.22 ʢݱࡏͷ࠷৽verʣ
ɾωετ͞Εͨconfigͷѻ͍ͷมߋ ɾɾωετ͞Εͨࢠconfig·Δͬͱ ɹɹconfigͱஔ͖ΘΔͷͰͳ͘ɺ ɹɹͷconfigͱϚʔδ͞ΕΔ SwiftLint 0.22ͷओཁͳมߋ
ɾωετ͞Εͨconfigͷѻ͍ͷมߋ ɾɾωετ͞Εͨࢠconfig·Δͬͱ ɹɹconfigͱஔ͖ΘΔͷͰͳ͘ɺ ɹɹͷconfigͱϚʔδ͞ΕΔ SwiftLint 0.22ͷओཁͳมߋ ʁ
ɾલఏ ɾɾҟͳΔ.swiftlint.ymlΛɺҟͳΔ ɹɹσΟϨΫτϦ֊ʹஔ͘͜ͱͰ ɹɹͦΕͧΕʹ߹ͬͨϧʔϧΛద༻͢Δ ɹɹ͜ͱ͕Ͱ͖ͨ ωετ͞Εͨconfig
ɾ ᵓᴷᴷ ViewController.swift ᵓᴷᴷ .swiftlint.yml ᵋᴷᴷ Tests ᵋᴷᴷ Test.swift ᵋᴷᴷ
.swiftlint.yml ਤղ line_length: 110 disabled_rules: - force_cast - force_try
σΟϨΫτϦͱࢠσΟϨΫτϦ྆ํʹ .swiftlint.yml͕͋ͬͨ߹ ɾࠓ·Ͱ ɾɾࢠσΟϨΫτϦͰࢠσΟϨΫτϦͷ ɹɹ.swiftlint.yml͔͠ద༻͞Εͳ͔ͬͨ ωετ͞Εͨconfig
ਤղʢैདྷʣ TestsσΟϨΫτϦͰద༻͞ΕΔϧʔϧ TestsҎԼʹॻ͔Ε͍ͯΔϧʔϧͷΈ ɾ ᵓᴷᴷ ViewController.swift ᵓᴷᴷ .swiftlint.yml ᵋᴷᴷ Tests
ᵋᴷᴷ Test.swift ᵋᴷᴷ .swiftlint.yml line_length: 110 disabled_rules: - force_cast - force_try
ɾ0.22Ҏ߱ ɾɾࢠσΟϨΫτϦͱσΟϨΫτϦͷ ɹɹ.swiftlint.yml͕Ϛʔδ͞Εͨͷ͕ ɹɹࢠσΟϨΫτϦͰద༻͞ΕΔ ωετ͞Εͨconfig
ਤղʢ0.22Ҏ߱ʣ ɾ ᵓᴷᴷ ViewController.swift ᵓᴷᴷ .swiftlint.yml ᵋᴷᴷ Tests ᵋᴷᴷ Test.swift
ᵋᴷᴷ .swiftlint.yml line_length: 110 line_length: 110 disabled_rules: - force_cast - force_try Ϛʔδʂ ࢠσΟϨΫτϦͰσΟϨΫτϦͰ ࢦఆ͍ͯ͠Δϧʔϧద༻͞ΕΔ
ɾmessageͷͳ͍XCTFailڐ༰͠ͳ͍ ɾɾxctfail_message ɾ༨ͳdisableίϚϯυ͕ͳ͍͔νΣοΫ ɾɾsuperfluous_disable_command ɾɾʮ// swiftlint:disableʯΛͬͯΔ͚Ͳ ɹɹҾ͔͔ͬΔίʔυ͕ͳ͍࣌ʹΤϥʔ SwiftLint 0.22ͷओཁͳมߋ
SwiftLint0.21 ʢ࠷৽verͷ1ͭखલʣ
ɾରԠόʔδϣϯͷมߋ ɾɾXcode 8.3Ҏ্ɺSwift 3.1Ҏ্͕ඞਢ ɾϧʔϧΛੜ͢ΔίϚϯυͷՃ ɾɾswiftlint generate-docs SwiftLint 0.21ͷओཁͳมߋ
ɾΞΫηεम০ࢠʹؔ͢ΔϧʔϧͷՃ ɾɾprivate_over_fileprivate ɾɾɾTopLevelʹ͋Δfileprivateprivate ɾɾstrict_fileprivate ɾɾɾશͯͷfileprivateΛνΣοΫ ɾɾɾSwift4Ͱʹཱͭ SwiftLint 0.21ͷओཁͳมߋ
ɾઃఆΦϑʹͳ͍ͬͯΔϧʔϧҰཡΛग़ྗ͢Δ ɾɾswiftlint rules - - disabled ɾ৽͍͠ܗࣜͷKVOํࣜͰॻ͍͍ͯΔ͔ ɾɾblock_based_kvo ɾɾʮWhat's New
in Cocoa TouchʯͰ৽͍͠ ɹɹϒϩοΫϕʔεͷه๏͕հ͞Εͨ SwiftLint 0.21ͷओཁͳมߋ
ɾconfigͰڥม͕͑ΔΑ͏ʹ ɾɾ${ԿΒ͔ͷม}ͱॻ͚OK SwiftLint 0.21ͷओཁͳมߋ
ΈΜͳͷSwiftLintࣄ
ɾσϑΥϧτͰ༗ޮʹͳ͍ͬͯΔϧʔϧ ɾσϑΥϧτͰ120ӽ͑ͨΒܯࠂɺ200 ɹӽ͑ͨΒΤϥʔ ٞ̍ɿline_length
AppDelegateͷ༷͝ࢠ ٞ̍ɿline_length
ίϝϯτ͗ͯ͢Τϥʔൃੜ ٞ̍ɿline_length Έͳ͞ΜͲ͏ͯ͠·͔͢ʁ
ɾͲΜͳͱ͜ΖͰҾ͔͔ͬͬͯΔʁ ɾɾσϑΥͰೖ͍ͬͯΔίϝϯτ ɾɾඪ४ͷϝιου໊ ɾͲΜͳ࣌ʹ͍ίʔυΛॻ͍ͯ͠·͏ʁ ɾɾifͳͲͰ݅Λෳฒͨ࣌ ɾɾifͱreturnΛ1ߦͰ·ͱΊͨ࣌ ٞ̍ɿline_length
ɾࢲͷதͰͷ݁ ɾɾඪ४ϝιουͰҾ͔͔ͬΔͳΒ ɹɹແཧʹकΒͳ͍͍ͯ͘ͷͰʁ ɾɾ120ӽ͑Δ͘Β͍ͷίʔυΛॻ͍ͯ ɹɹ͠·ͬͨΒࣗͰదٓվߦ ɾɾline_lengthdisableͰ͍͍ͷͰʁ ٞ̍ɿline_length
ɾσϑΥϧτͰ༗ޮʹͳ͍ͬͯΔϧʔϧ ɾߦʹ༨ܭͳλϒɺۭനจࣈ͕ೖͬͯͨΒ ɹܯࠂ͕ग़Δ ٞ̎ɿtrailing_whitespace
ʢXcodeͷઃఆʹΑΔ͕ʣվߦ࣌ʹࣗಈ Ͱૠೖ͞ΕΔλϒʹ͍͍͍ͭͯͪͪ ݴΘΕΔͷ͏͍͟ʢʈωʈ#ʣűƅŝűƅŝ ٞ̎ɿtrailing_whitespace Έͳ͞ΜͲ͏ͯ͠·͔͢ʁ
ɾࢲͷதͰͷ݁ ɾɾશۭ֯നจࣈʮInvalid charactor in ɹɹsource fileʯΤϥʔ͕ग़Δͦ͠Μͳ ɹɹࠔΔ͜ͱͳ͍ͷͰʁ ɾɾtrailing_whitespacedisableͰ͍͍ʁ ٞ̎ɿtrailing_whitespace
ࢲ͕ߟ͑ͨ࠷ڧͷ .swiftlint.yml
͝ΊΜͳ͍͞ ؒʹ߹ͬͯͳ͍Ͱ͢
શ൛ޙQiitaͰ ΞΧϯτ@akatsuki174Ͱ͢
ࠓద༻ج४ͷ ͚ͩ͠·͢
ɾॻ͘ਓʹΑͬͯΒ͖͕ͭग़ͦ͏ͳ ɹࠣࡉͳ෦ϧʔϧΛద༻ͯ͠Χόʔ ɾɾcolon, comma, empty_parameters etc. ɾ୯ͳΔೖྗϛεͬΆ͍ͱ͜ΖΛࢦఠͯ͠ ɹ͘ΕΔϧʔϧద༻ ɾɾclosing_brace, closure_spacing
etc. ద༻ج४
ɾద༻͞Εͯͳ͍ͱෆ֨ͳϧʔϧద༻ ɾɾclosure_end_indentation, ɹɹclosure_parameter_position etc. ɾ߹ʹΑΔͷෆద༻ɺ͘͠ ɹ݅Λ͚Δ ɾɾforce_cast, identifier_name etc. ద༻ج४
ɾΓ͗͢͡ΌͶʁͬͯࢥͬͨΒෆద༻ ɾɾline_length, ɹɹconditional_returns_on_newline etc. ద༻ج४
CIपΓͷ
ɾPRΛग़ͨ࣌͠ʹDanger͕.swiftlint.ymlʹ ɹҾ͔͔ͬͬͯͳ͍͔νΣοΫ ɾɾҾ͔͔͍ͬͬͯͨΒ༰ࣻͳ͘ίϝϯτ ฐࣾͷ߹
ɾSwiftLintͷREADME.mdʹfastlaneͷ ɹactionͱͯ͑͠Δͱॻ͔Ε͍ͯΔ fastlane
SwiftLintΛͬͯ όϦόϦշద։ൃ͠·͠ΐ͏ʂ
͋Γ͕ͱ͏͍͟͝·ͨ͠ʂ