Where can I find an actively developed lint tool for Ruby?

后端 未结 9 893
别跟我提以往
别跟我提以往 2020-12-12 19: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

相关标签:
9条回答
  • 2020-12-12 20:04

    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...

    0 讨论(0)
  • 2020-12-12 20:05

    Have a look at RuboCop. It is a Ruby code style checker based on the Ruby Style Guide. It's maintained pretty actively and supports all major Ruby implementations. It works well with Ruby 1.9 and 2.0 and has great Emacs integration.

    0 讨论(0)
  • 2020-12-12 20:12
    avdi@lazarus:~$ irb
    >> a = 20
    => 20
    >> b = 30
    => 30
    >> puts c
    NameError: undefined local variable or method `c' for main:Object
            from (irb):3
    >>
    

    There ya go, the tool is called "IRB". Do I get the bounty?

    I'm only half joking. I wrote this second answer to hopefully drive home the point that in Ruby, if you want to know that something is defined or not, you have to run the code.

    0 讨论(0)
提交回复
热议问题