Skip to content

Instantly share code, notes, and snippets.

@bruno-
Created May 9, 2015 20:19
Show Gist options
  • Save bruno-/4cb455708b0f04852777 to your computer and use it in GitHub Desktop.
Save bruno-/4cb455708b0f04852777 to your computer and use it in GitHub Desktop.

Rubocop

Installation & usage

$ gem install rubocop

  • usage $ rubocop #=> bunch of errors (1000's maybe)

Initial workflow setup

Strategy:

  • permit everything
  • fix incrementally

Permit everything

$ rubocop --auto-gen-config

  • creates '.rubocop_todo.yml' (the permit everything file)

  • now add rubocop to CI

Fix incrementally

  • comment out rule from '.rubocop_todo.yml'
  • fix it => commit

Tweaking rubocop

Other lessons

  • slow with large files, very slow with very large files $ rubocop gets stuck

  • see where rubocop gets stuck with

      $ rubocop -f fuubar
    
  • rubocop useful reports other than line length and single/double quotes:

    • do not start setter methods with set_method, use method=
    • Hash#has_key? is deprectead, use Hash#key?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment