and code formatter (from official documentation). • a useful tool to make a team’s coding standard explicit and automatically executable. • an AST-based tool with complex internals, while most customization can be done by simply editing YAML files.
team’s coding rule/ standard with YAML files. • Coding rules are enforceable/executable by various ways such as CI, which makes your code more maintainable. • Autocorrect feature with editor plugins enables us to edit code faster.
has a rule of offense and sometimes knows how to fix a problem (autocorrect). • “Autocorrect” is a feature of RuboCop modifying code with a rule automatically if possible (eg. fixing indentation). • “Config file” is a file named “.rubocop.yml”, which configures RuboCop’s behavior. • “Todo file” is a YAML file similar to normal config file but generated by RuboCop command.
style guide at Ruby Style Guide (https://github.com/ rubocop-hq/ruby-style-guide) • This guide is not “approved by” authorities nor admitted by the whole Ruby community. • There are more guides, such as Cookpad’s one (https://github.com/cookpad/styleguide/blob/ master/ruby.en.md)
4k era, not vt100 era (however, some people argue character length makes sense). • Double negation is a famous Ruby idiom but RuboCop warns you by default. • Percent literal delimiters default is []… IMHO most of us prefer (), right?
15… isn’t it too strict? • Symbol/String Array cops are mostly useful but sometimes we’d like to use bracket style. • Should spaces inside braces be required? What about spaces inside parentheses?
you introduce RuboCop to an ongoing project) • Disable all cops for auto generated files like bin, schema.rb, etc.. • Use auto-gen-config feature to generate todo file for fixing problems later unless your project is brand new.
when you modify “.rubocop.yml” file to get consensus from your team. • Don’t be hasty. Don’t copy them from other teams or companies unless they share most of the rules. It’s a matter of culture.
a certain Cop. • One way is to disable each Cop in config file • Another way is to add a special comment to where you want to disable, such as “rubocop:disable Style/WordArray”.
plugin for Ruby, RuboCop or syntax checker, you might be able to run RuboCop on the fly, while you edit code. • Autocorrect works on the fly as well. • If your editor does not have a plugin, I recommend changing an editor (use Vim if you have no preference )
to suit your team. Don’t believe the default rules. • Don’t try to fix all problems at once if your project is mature/ongoing. Agree on coding standards of your team first, and write config for RuboCop following it.