Writing Lint for Ruby
summary
Explains how to build Ruby linters that actually find bugs by parsing code into an AST and walking it, with concrete use of parser gem vs Ripper and demo code that flags an integer literal directly in an if condition. Shows a minimal runnable linter (bug.rb) that parses files, traverses nodes with an AST traverser + visitor pattern, and emits warnings; demonstrates adding rules to RuboCop via its generator, matchers and config. Notes limits: no runtime info, redefined methods and local-variable flow cause false negatives; recommends RuboCop plugins for most cases and a standalone tool when VCS or runtime data is needed.
AI-written summary · about
chapters (9)
- 0:00Introduction to linting
- 2:10What is a linter
- 5:17How linters work internally
- 9:35Traversing the AST
- 13:40Limitations of linters
- 18:06What linters can do
- 19:34Adding rules to RuboCop
- 27:33Building custom lint tools
- 32:20Q&A session
related talks
29mAnalyzing an analyzer - A dive into how RuboCop works
35mRuboCop Sent You a Friend Request
31mHow GitHub uses linters
32mParsing Ruby
32mSAST and Sensibility: A Rubyist’s Guide to Static...
27mSquashing Security Bugs with Rubocop
43mGrammars, Parsers, and Interpreters, In Ruby
50mLaser: Static Analysis for Ruby, in Ruby
