Looking for coding check tools for Ruby and Rails

Asked 2 years ago, Updated 2 years ago, 30 views

When I was using C# and Perl, I automatically checked the code with StyleCop, FxCop, Perl::Critic, Perlty, etc.

Do Ruby and Rails have similar tools?

I searched on Google, but I couldn't find a tool.

Note: This question is a transcription of a previously posted question in English. https://stackoverflow.com/questions/9103874/coding-style-checker-or-code-formatter-for-ruby-rails

ruby ruby-on-rails

2022-09-29 22:18

7 Answers

RuboCop is recommended.Rails-specific checkers are also included.


2022-09-29 22:18

Rails-like code can be checked by using the railsbp/rails_best_practices.


2022-09-29 22:18

IDE IntelliJ (RubyMine) allows you to view coding style issues in the editor.


2022-09-29 22:18

For projects on GitHub, HoundCI is easy.If you submit a Pull Request normally, you will leave a comment on GitHub about the coding style issues as follows:

HoundCI Comments

HoundCI uses RuboCop as its style checker.So the check items are basically the same as RuboCop

.

One caveat is that the HoundCI coding convention is slightly different from the RuboCop default setting.For example:

  • RuboCop:"foobar" characters that do not have expression extensions such as
  • RuboCop:"foobar" should be written.
  • HoundCI: If there is no single quote in the string, make it write "foobar".

This is the coding convention for thoughbot that provides the HoundCI.


2022-09-29 22:18

Sign up for online services to automatically check and report code that is not limited to simple formatting. Rubocop is also used internally, but it is easy because it does not require setup.


2022-09-29 22:18

There is a service called sideCI that checks security checks and Rails-best-practice to see if the gem is out of date. It works with Github, so you can watch it at Pullreq timing.It's free for now.

Also, I recommend a gem that only checks the rubocop with the modified rubocop-git


2022-09-29 22:18

If you use guard, you can pick up execution errors in real time.Of course, syntax is also.
I will post an article that I have used as a reference online.

Use the Guardgem to detect file changes and perform any task automatically


2022-09-29 22:18

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.