Stay Out Of Trouble
"Excuse me, I have to go. Somewhere there is a bug happening." - Robocop (1987) (kinda)
Reporter: "Robo, excuse me, Robo, any special message for all the kids watching at home?"
RoboCop: "Stay out of trouble."
- Robocop (1987) (for real)
I recently attended the December Ruby Zagreb Meetup. In addition to learning about the excellent gem webmachine I also learned about Rubocop, as presented by Željko Filipin and as outlined in his blog post on the topic.
Rubocop scans your code and shows you when new code is not conforming to agreed upon style, if you aren't using good/secure practices, or if your code is too complex. In addition it can:
- Allow configuration of it's various tests (called "cops")
- Automatically fix certain problems when you run
rubocop -a
- Act as a gatekeeper in continuous integration
We've just implemented Rubocop in both the neo4j and neo4j-core gems and it's fixed and standardized a lot of our code. It addition we've configured Travis CI to run Rubocop for every build and fail the build if any violations are found. This way we can focus on higher level problems when reviewing pull requests (which appeals to us both as Ruby-ists and Neo4j-ists)
As per Željko's suggestions in his post we created .rubocop_todo.yml
files in addition to our .rubocop.yml
files. These are lists of cops which we haven't yet enabled / set back to defaults, either because:
- Refactoring is to complex to deal with right now
- We're not sure if we want to implement the cop
Inside the .rubocop.yml
file are all of the rules that we've configured different from the defaults or rules that we've decided not to implement. You can see the config for neo4j
here
If you use ruby, and especially if you maintain an open source project, give Rubocop a try!
Tagged with style, quality, ruby