shoes/shoes4 — pull request #859 by PragTob (2014-08-18 14:10:31+00:00)
Title: introduce rubocop?!

This idea came to my mind while talking over style in #854 as @jasonrclark mentioned the [ruby style guide](https://github.com/bbatsov/ruby-style-guide). There is [rubocop](https://github.com/bbatsov/rubocop) automatically checking all those style guidelines.

Personally I don't personally agree with all those style guidelines (e.g. I like to have no spaces around `{`, `}` in one line blocks as that looks compact), a lot of the style guides are good.

This is meant for discussion about if we want to add it as a dependency and use it to check our style.

If we disagree with specific checks, we can turn them off.

Right now our result is quite high:

```ruby
tobi@speedy:~/github/shoes4$ rubocop lib/ -f o

181 Style/Documentation
168 Style/SpaceInsideParens
153 Metrics/LineLength
136 Style/StringLiterals
124 Style/SpaceInsideBlockBraces
110 Style/SpaceAroundOperators
102 Lint/UnusedMethodArgument
65 Style/CaseIndentation
57 Style/SpaceBeforeBlockBraces
56 Style/EmptyLinesAroundBody
54 Metrics/MethodLength
54 Style/HashSyntax
53 Style/MethodDefParentheses
50 Style/SpaceInsideHashLiteralBraces
39 Style/SpaceAroundEqualsInParameterDefault
35 Style/AndOr
32 Style/EmptyLinesAroundAccessModifier
26 Style/RedundantSelf
23 Style/TrailingWhitespace
22 Style/LeadingCommentSpace
21 Lint/AmbiguousOperator
21 Metrics/ParameterLists
19 Style/PerlBackrefs
19 Style/TrivialAccessors
18 Style/TrailingBlankLines
17 Style/DotPosition
17 Style/EmptyLines
16 Style/GuardClause
14 Style/SignalException
13 Metrics/CyclomaticComplexity
12 Lint/UnusedBlockArgument
12 Lint/UselessAssignment
12 Style/Semicolon
12 Style/WhenThen
11 Metrics/ClassLength
11 Style/AlignParameters
10 Style/MethodCallParentheses
9 Metrics/BlockNesting
9 Metrics/PerceivedComplexity
9 Style/AccessorMethodName
9 Style/PercentLiteralDelimiters
8 Style/IfUnlessModifier
8 Style/MethodName
8 Style/SpaceAfterComma
8 Style/TrailingComma
7 Style/Not
6 Style/Blocks
6 Style/EndOfLine
6 Style/IndentHash
6 Style/PredicateName
5 Style/AlignArray
5 Style/CharacterLiteral
5 Style/FormatString
5 Style/LineEndConcatenation
5 Style/Proc
5 Style/SingleSpaceBeforeFirstArg
4 Style/ClassAndModuleChildren
4 Style/GlobalVars
4 Style/NilComparison
4 Style/RedundantReturn
4 Style/RegexpLiteral
4 Style/SpaceBeforeSemicolon
4 Style/SpaceInsideBrackets
3 Lint/ShadowingOuterLocalVariable
3 Lint/StringConversionInInterpolation
3 Style/CollectionMethods
3 Style/ColonMethodCall
3 Style/CommentAnnotation
3 Style/DeprecatedHashMethods
3 Style/EvenOdd
3 Style/IndentationWidth
3 Style/ParenthesesAroundCondition
3 Style/SpaceAfterColon
3 Style/UnlessElse
2 Lint/DeprecatedClassMethods
2 Lint/Eval
2 Lint/RequireParentheses
2 Lint/UselessAccessModifier
2 Style/AccessModifierIndentation
2 Style/BracesAroundHashParameters
2 Style/CommentIndentation
2 Style/EmptyLineBetweenDefs
2 Style/IndentationConsistency
2 Style/NegatedIf
2 Style/NestedTernaryOperator
2 Style/SelfAssignment
2 Style/SpaceAfterSemicolon
1 Lint/BlockAlignment
1 Lint/ConditionPosition
1 Lint/HandleExceptions
1 Lint/RescueException
1 Lint/UnderscorePrefixedVariableName
1 Style/AsciiComments
1 Style/BarePercentLiterals
1 Style/BlockEndNewline
1 Style/ClassCheck
1 Style/ConstantName
1 Style/EmptyLiteral
1 Style/MultilineBlockChain
1 Style/MultilineBlockLayout
1 Style/NegatedWhile
1 Style/NonNilCheck
1 Style/OneLineConditional
1 Style/OpMethod
1 Style/RedundantBegin
1 Style/SingleLineBlockParams
1 Style/SpaceBeforeComment
1 Style/VariableInterpolation
1 Style/WhileUntilDo
1 Style/WhileUntilModifier
1 Style/WordArray
--
2035 Total
```

You can see the result of running `rubocop lib/` in [this gist](https://gist.github.com/PragTob/b3376f460d5077e288b7)

A lot of the checks really to help, e.g. sometimes we have spaces inside method definition argument parentheses. Or unused method arguments (it has some linting ability as well).

I didn't dig through all of them yet, but it seems reasonable. For instance, I'm no big fan of comments but a top level module comment per file might be nice for newcomers in a newcomer friendly project like ours.

What do you think?