Actually, this is a general trick to understand any code: Find a concrete question -> get source code -> add breakpoints -> mess around -> observe the stacktrace…
rubocop codebase is huge, what if I want to know how it works by observing one cop?
follow the steps bellow:
- clone the repo and cd into repo
- add breakpoint in source code, e.g.: add
require 'pry'; binding.pryto lib/rubocop/cop/lint/shadowed_exception.rb
- find the executable of the gem, in this case
exe/rubocop --only Lint/ShadowedException tmp/shawdowed_exception.rband mess around with that breakpoint
caller.grep /rubocop/to see stacktrace
btw, go ahead to see spec/tests is also a good option.
Have fun reading source code
exe/rubocop --cache false --only Lint/ShadowedException tmp/shawdowed_exception.rb to avoid odd behaviors while debugging