Write ruby code analyzer tool by yourself, extracted by rails_best_practices gem
code_analyzer gem is extracted from rails_best_practices , its aim is to provide a simple way to build your own ruby code analyzer tool. Quick Start 1. create ruby file you want to analyze. Let's create a simple ruby file test_class.rb , its content is as follow. class TestClass # bad def TestClass.some_method # body omitted end # good def self.some_other_method # body omitted end end The code is picked from github ruby styleguide , let's write a code analyzer script to detect bad style. TestClass.some_method 2. understand the corresponding sexp you need to analyze. code_analyzer is analyzing sexp which is generated by ruby ripper, you should have a basic idea of what sexp is. I have built a website try-ripper , which helps you easily understand sexp. Copy the source code of test_class.rb to "Ruby Code" textarea, and click "Convert" button, then you will see the correspond...