Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Static Analysis with ruby-lint

Static Analysis with ruby-lint

A lightning talk at the 2016-11-10 Prague Ruby Meetup

Avatar for Martin Vidner

Martin Vidner

November 10, 2016
Tweet

More Decks by Martin Vidner

Other Decks in Programming

Transcript

  1. Problem • stupid bugs – misspelled identifier – too many/few

    arguments – missing namespace – wrong receiver for method – sloppy refactoring
  2. Solution • Static analysis of code • "No can do

    - Ruby is dynamic" • Still, there is much code that contains no metaprogramming magic and can be analyzed • ruby-lint.gem
  3. Example Output • ruby-lint-readme.rb: warning: line 2, column 18: unused

    argument name • ruby-lint-readme.rb: error: line 7, column 22: undefined instance variable @name • ruby-lint-readme.rb: warning: line 12, column 1: unused local variable greeting • ruby-lint-readme.rb: error: line 14, column 1: wrong number of arguments for 'greet' (expected 0 but got 1)
  4. And they linted happily ever after • Right? • Wrong

    • There are false positives • Thousands of false positives for every actual bug found
  5. Alternatives? • Write tests • Use RuboCop • Type Hints

    PEP484 oops, that's Python • Duck inference Ruby 3
  6. Alternatives? • Write tests • Use RuboCop • Type Hints

    PEP484 oops, that's Python • Duck inference Ruby 3 „you have to wait for years“ (matz, 2016-09)
  7. Alternatives? • Write tests • Use RuboCop • Type Hints

    PEP484 oops, that's Python • Duck inference Ruby 3 „you have to wait for years“ (matz, 2016-09) • Fix ruby-lint