Slide 1

Slide 1 text

Crafting Custom Lint Rules: Elevating Android Code Quality @_kibetheophilus

Slide 2

Slide 2 text

Software Engineer @Kyosk Theophilus Kibet @_kibetheophilus

Slide 3

Slide 3 text

Lint @_kibetheophilus

Slide 4

Slide 4 text

a static code analysis tool used to flag programming errors, bugs, stylistic errors and suspicious constructs @_kibetheophilus

Slide 5

Slide 5 text

a static code analysis tool used to flag programming errors, bugs, stylistic errors and suspicious constructs @_kibetheophilus

Slide 6

Slide 6 text

@_kibetheophilus Examples

Slide 7

Slide 7 text

@_kibetheophilus ktLint detekt compose-rules android lint Examples

Slide 8

Slide 8 text

@_kibetheophilus ktLint detekt compose-rules android lint Examples

Slide 9

Slide 9 text

@_kibetheophilus Issue Detector Scanner Issue Registry Core Principles of lint

Slide 10

Slide 10 text

@_kibetheophilus Issue Detector Scanner Issue Registry Core Principles of lint

Slide 11

Slide 11 text

@_kibetheophilus Is a type of problem that you want to find and show the user(dev) Issue

Slide 12

Slide 12 text

@_kibetheophilus registered in an IssueRegistry reported by a detector has certain attributes: id, briefDescription, explanation, category, priority, implementation,severity Issue

Slide 13

Slide 13 text

@_kibetheophilus registered in an IssueRegistry reported by a detector has certain attributes: id, briefDescription, explanation, category, priority, implementation, severity Issue

Slide 14

Slide 14 text

@_kibetheophilus

Slide 15

Slide 15 text

@_kibetheophilus Issue Detector Scanner Issue Registry Core Principles of lint

Slide 16

Slide 16 text

@_kibetheophilus Is responsible for scanning and analysing code, finding incidents and reporting them. Detector

Slide 17

Slide 17 text

@_kibetheophilus implementation of a lint rule reports issues implements scanner Detector

Slide 18

Slide 18 text

@_kibetheophilus

Slide 19

Slide 19 text

@_kibetheophilus Issue Detector Scanner Issue Registry Core Principles of lint

Slide 20

Slide 20 text

@_kibetheophilus Specialized interfaces implemented by detectors to indicate that it supports specific set of callbacks. Scanner

Slide 21

Slide 21 text

@_kibetheophilus SourceCodeScanner XmlScanner GradleScanner ResourceFolderScanner BinaryResourceScanner OtherFileScanner Scanner

Slide 22

Slide 22 text

@_kibetheophilus Issue Detector Scanner Issue Registry Core Principles of lint

Slide 23

Slide 23 text

@_kibetheophilus provides a list of issues to lint. points to IssueRegistry using the META- INF service loader mechanism. IssueRegistry

Slide 24

Slide 24 text

@_kibetheophilus

Slide 25

Slide 25 text

@_kibetheophilus

Slide 26

Slide 26 text

@_kibetheophilus Demo https://bit.ly/dcke-demo or

Slide 27

Slide 27 text

@_kibetheophilus You can write custom rules for detekt and ktlint with almost the same steps, just use apis provided by respective library. N/B:

Slide 28

Slide 28 text

@_kibetheophilus Questions?

Slide 29

Slide 29 text

@_kibetheophilus https://googlesamples.github.io/android-custom-lint-rules/api- guide.html - Official Documentation https://github.com/android/nowinandroid/tree/main/lint - Custom rules using android lint https://github.com/mrmans0n/compose-rules - Custom rules using ktlint and detekt https://github.com/droidconKE/chai/tree/main/chailinter - Custom rules using android lint https://www.kodeco.com/24470020-integrating-detekt-in-the- workflow?page=3#toc-anchor-012 - Article by Harun Wangereka on writing custom rules for detekt Resources

Slide 30

Slide 30 text

Thank You! @_kibetheophilus Theophilus Kibet kibettheophilus