Do you use a linter with Ruby?



Continuing the discussion from Overzealous Linter?:

It looks like ruby-lint is no longer maintained. Now I am wondering what linters others are using. Is there even a good, maintained ruby linter out there?

I’ve just turned of ruby-lint in my syntax checker and have mri and rubocop.

What linter, if any, are you using with ruby?


RuboCop is very popular and still in active development.

You said you’ve already started using it. So, good choice, stick with rubocop! :grin:


RoboCop mostly checks for stylistic errors afaik. I would like something to check for programmatic errors as well.


Can you clarify what you mean by programmatic errors? As in, will it compile? I think the best way to do that is just by running tests. You can also use an IDE like RubyMine, but I am not personally a fan. Plenty of people do really enjoy RubyMine and if you want features like you are describing, it might be a great option.


I’m just used to Go, where the linter would highlight errors as you type or save. Errors would be: unused variables, unused imports, missing operators, and other “compile” errors.

I would like runtime errors to show up on save. So a linter that could check that would be ideal. I wouldn’t be using it all the time though, it starts to get annoying. I’m using vim.


Hmm I have not seen a runtime error linter for Ruby, but maybe someone else will have a good suggestion?


I have to say that, after working with Ruby (and knowledgeable coworkers) for a few years, I don’t know of anything better than @jennifer’s suggestion of writing tests to cover your code, if you want to find run-time errors.

Rubocop does have some lint checks, and can identify unused variables, assignments in conditional statements, syntax errors, etc. when you run it, but the suite of linting checks that it runs may appear minimal in comparison with a compiled language like Go. It does at least cover some of the cases you highlighted as being of interest to you, so I’m not sure if that’s helpful.

I would love to hear about a tool that could identify run-time errors for Ruby, though, if anyone knows of one.


So maybe, it’s not as necessary with an interpreted language? In that case I’m happy just writing tests.


You can use ruby -c file.rb to check for syntax errors.