Where can I find an actively developed lint tool f

2019-01-21 06:27发布

Most of the code I write is in Ruby, and every once in a while, I make some typo which only gets caught after a while. This is irritating when I have my scripts running long tasks, and return to find I had a typo.

Is there an actively developed lint tool for Ruby that could help me overcome this? Would it be possible to use it across a system that works with a lot of source files, some of them loaded dynamically?

Take this snippet as an example:

a = 20
b = 30
puts c

To win bounty, show me a tool that will detect the c variable as not created/undefined.

9条回答
趁早两清
2楼-- · 2019-01-21 07:27
  • ruby -c myfile.rb will check for correct Ruby syntax.
  • Reek checks Ruby code for common code smells.
  • Roodi checks Ruby code for common object-oriented design issues.
  • Flog can warn you about unusually complex code.

[Plug] If your project is in a public Github repository, Caliper can run the latter three tools and others on your code every time you commit. (Disclaimer: I work on Caliper)

查看更多
成全新的幸福
3楼-- · 2019-01-21 07:28

Yes. Test::Unit

Ok, I know you already know this and that in some sense this is a non-helpful answer, but you do bring up the negative consequence of duck typing, that there kind of is (at this time) no way around just writing more tests than something like Java might need.

So, for the record, see Test::Unit in the Ruby Standard Library or one of the other test frameworks.

Having unit tests that you can run and rerun is the best way to catch errors, and you do need more of them (tests, not errors :-) in dynamic languages like Ruby...

查看更多
不美不萌又怎样
4楼-- · 2019-01-21 07:28

Pelusa is nice, but is working in rubinius only. This shouln't be a proplem for people familar with RVM though.

查看更多
登录 后发表回答