~/talk

Ensuring code-correctness with custom lint checks

Talkat droidcon Berlin 2023 · 2023-07-05..07-07· [testing, developer-experience]
slides:none on file

A small custom lint module named checks detects unit test classes that have methods annotated with @TestId but lack the class-level @TestReporter, reports an error on the class in the IDE, and offers a quickfix that inserts @TestReporter. Implementation uses Lint Issue + IssueRegistry, a SourceCodeScanner with UElementHandler and JavaContext, unit tests with annotation stubs to assert one error, and a lint.xml rule to ignore androidTest sources. The rule runs in the IDE and via the lint CLI and works as expected, surfacing and auto-fixing missing annotations.

AI-written summary · about

  1. 0:00Introduction to talk
  2. 0:48What are lint checks
  3. 2:58Problem with test reporter
  4. 3:41Creating a lint issue
  5. 5:03Writing the detector
  6. 6:07Verifying annotations
  7. 8:55Testing the lint check
  8. 10:39Making lint visible to IDE
  9. 11:46Quick demo of the check
  10. 12:48Handling Android tests
  11. 14:12Resources and references
  12. 16:19Closing and Q&A
~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.