В наш час мало просто писати код, його треба писати красиво і "правильно". Так як ці поняття вельми різняться від людини до людини, то в якийсь момент команди приходять до того, щоб формалізувати красивість і правильність. Деякі команди, втомившись лаятись в pull-request'ах через некрасиво оформлений код, йдуть далі та налаштовують автоматичні перевірки. Хтось навіть довіряє інстументам настільки, що дозволяє змінювати і виправляти код.
У цій доповіді я розповім про бібліотеки та інструменти, метою яких є робота з кодом. Розглянемо освновні відмінності бібліотек та області їх застосування. Після доповіді ви нарешті будете відрізняти SourceKit від SourceKitten, libSwiftSyntax від Swift Syntax.
http://uamobile.org/uk/topics/b%D1%96bl%D1%96oteki-ta-%D1%96nstrumenti-na-storozh%D1%96-kodu
Mobile Application Development-Components and Layouts
Бібліотеки та Інструменти на сторожі коду - UA Mobile 2019
1. On guard
of the Source Code
On guard of the Source Code, by Paul Taykalo, MacPaw 1
2. When just writing a code is not enough
On guard of the Source Code, by Paul Taykalo, MacPaw 2
3. A lot of source - not a problem
4 Code style
❓
4 Documentation
❓
4 Refactoring
❓
4 Code generation
❓
4 Error detection
❓
4 Obsfuscation
❓
On guard of the Source Code, by Paul Taykalo, MacPaw 3
16. Rules
disabled_rules: # rule identifiers to exclude from running
- colon
- comma
- control_statement
opt_in_rules: # some rules are only opt-in
- empty_count
# Find all the available rules by running:
# swiftlint rules
included: # paths to include during linting. `--path` is ignored if present.
- Source
excluded: # paths to ignore during linting. Takes precedence over `included`.
- Carthage
- Pods
- Source/ExcludedFolder
- Source/ExcludedFile.swift
- Source/*/ExcludedFile.swift # Exclude files with a wildcard
On guard of the Source Code, by Paul Taykalo, MacPaw 16
17. Tools for processing Code
On guard of the Source Code, by Paul Taykalo, MacPaw 17
18. Tools for processing Code
Regex-based solutions
4 IR: Strings
4 Somewhat unreliable
On guard of the Source Code, by Paul Taykalo, MacPaw 18
19. Tools for processing Code
Custom Parser Solutions
4 IR: (DSL)
4 Trying to parse code on its own
4 Using own AST
On guard of the Source Code, by Paul Taykalo, MacPaw 19
20. Tools for processing Code
Sourcekit based solutions
4 IR: AST, Binary, JSON*
4 Using Sourcekit library
4 Always up to date
On guard of the Source Code, by Paul Taykalo, MacPaw 20
25. SourceKit is...
Welcome to SourceKit! SourceKit is a framework for
supporting IDE features like indexing, syntax-coloring,
code-completion, etc. In general it provides the
infrastructure that an IDE needs for excellent language
support.
SourceKit currently only supports the Swift language.
On guard of the Source Code, by Paul Taykalo, MacPaw 25
26. SourceKit
4 Code Completion
4 Cursor Info
4 Demangling/Demangling
4 Documentation
4 Module interface generation
4 Indexing*
On guard of the Source Code, by Paul Taykalo, MacPaw 26
27. SourceKit options
4 C Interface
4 sourcekitd.framework
4 libsourcekitdInProc.dylib
4 Official Python Binding
4 Unofficial Swift Binding: SourceKitten
On guard of the Source Code, by Paul Taykalo, MacPaw 27
30. Tools with Sourcekitten
4
✅
SwiftLint: Swift style and conventions.
4
✅
Jazzy: Docs for Swift & Objective-C.
4
✅
Sourcery: Meta-programming for Swift
4
✅
Cuckoo: Mocking framework for Swift.
On guard of the Source Code, by Paul Taykalo, MacPaw 30
31. Tools with Sourcekitten
4
✅
SwiftyMocky: Framework for mock genertion.
4
✅
SourceKittenDaemon: Auto Completions .
4
✅
SourceDocs: Markdown documentation.
4
✅
Taylor: Measure Swift code metrics
On guard of the Source Code, by Paul Taykalo, MacPaw 31