|
| 1 | +--- |
| 2 | +####################### |
| 3 | +# Rubocop Config file # |
| 4 | +####################### |
| 5 | + |
| 6 | +################################################################################ |
| 7 | +############################## Rails Rules ##################################### |
| 8 | +################################################################################ |
| 9 | + |
| 10 | +# Set the linter to enable rails rules |
| 11 | +Rails: |
| 12 | + Enabled: true |
| 13 | + |
| 14 | +################################################################################ |
| 15 | +############################# Security Rules ################################### |
| 16 | +################################################################################ |
| 17 | + |
| 18 | +# Security rules |
| 19 | +Security/Open: |
| 20 | + Enabled: false |
| 21 | +################################################################################ |
| 22 | +############################# Metrics Rules #################################### |
| 23 | +################################################################################ |
| 24 | + |
| 25 | +# Commonly used screens these days easily fit more than 80 characters. |
| 26 | +Metrics/LineLength: |
| 27 | + Max: 120 |
| 28 | + |
| 29 | +# Too short methods lead to extraction of single-use methods, which can make |
| 30 | +# the code easier to read (by naming things), but can also clutter the class |
| 31 | +Metrics/MethodLength: |
| 32 | + Max: 30 |
| 33 | + |
| 34 | +# The guiding principle of classes is SRP, |
| 35 | +# SRP can't be accurately measured by LoC |
| 36 | +Metrics/ClassLength: |
| 37 | + Max: 1500 |
| 38 | + |
| 39 | +# Turn off the Assignment Branch Condition size for the case of these scripts |
| 40 | +Metrics/AbcSize: |
| 41 | + Enabled: false |
| 42 | + |
| 43 | +# Set the complexity of the metrics |
| 44 | +Metrics/PerceivedComplexity: |
| 45 | + Max: 10 |
| 46 | + |
| 47 | +# Set the complexity of the cyle |
| 48 | +Metrics/CyclomaticComplexity: |
| 49 | + Max: 10 |
| 50 | + |
| 51 | +################################################################################ |
| 52 | +########################## Layout Rules ######################################## |
| 53 | +################################################################################ |
| 54 | + |
| 55 | +# No space makes the method definition shorter and differentiates |
| 56 | +# from a regular assignment. |
| 57 | +Layout/SpaceAroundEqualsInParameterDefault: |
| 58 | + EnforcedStyle: no_space |
| 59 | + |
| 60 | +# Most readable form. |
| 61 | +Layout/AlignHash: |
| 62 | + EnforcedHashRocketStyle: table |
| 63 | + EnforcedColonStyle: table |
| 64 | + |
| 65 | +# Indenting the chained dots beneath each other is not supported by this cop, |
| 66 | +# see https://github.com/bbatsov/rubocop/issues/1633 |
| 67 | +Layout/MultilineOperationIndentation: |
| 68 | + Enabled: false |
| 69 | + |
| 70 | +Layout/SpaceInsideBlockBraces: |
| 71 | + # The space here provides no real gain in readability while consuming |
| 72 | + # horizontal space that could be used for a better parameter name. |
| 73 | + # Also {| differentiates better from a hash than { | does. |
| 74 | + SpaceBeforeBlockParameters: false |
| 75 | + |
| 76 | +# No trailing space differentiates better from the block: |
| 77 | +# foo} means hash, foo } means block. |
| 78 | +Layout/SpaceInsideHashLiteralBraces: |
| 79 | + EnforcedStyle: no_space |
| 80 | + |
| 81 | +################################################################################ |
| 82 | +########################### Style Rules ######################################## |
| 83 | +################################################################################ |
| 84 | + |
| 85 | +# Single quotes being faster is hardly measurable and only affects parse time. |
| 86 | +# Enforcing double quotes reduces the times where you need to change them |
| 87 | +# when introducing an interpolation. Use single quotes only if their semantics |
| 88 | +# are needed. |
| 89 | +Style/StringLiterals: |
| 90 | + EnforcedStyle: double_quotes |
| 91 | + |
| 92 | +# We do not need to support Ruby 1.9, so this is good to use. |
| 93 | +Style/SymbolArray: |
| 94 | + Enabled: true |
| 95 | + |
| 96 | +# Mixing the styles looks just silly. |
| 97 | +Style/HashSyntax: |
| 98 | + EnforcedStyle: ruby19_no_mixed_keys |
| 99 | + |
| 100 | +# has_key? and has_value? are far more readable than key? and value? |
| 101 | +Style/PreferredHashMethods: |
| 102 | + Enabled: false |
| 103 | + |
| 104 | +# String#% is by far the least verbose and only object oriented variant. |
| 105 | +Style/FormatString: |
| 106 | + EnforcedStyle: percent |
| 107 | + |
| 108 | +Style/CollectionMethods: |
| 109 | + Enabled: true |
| 110 | + PreferredMethods: |
| 111 | + # inject seems more common in the community. |
| 112 | + reduce: "inject" |
| 113 | + |
| 114 | +# Either allow this style or don't. Marking it as safe with parenthesis |
| 115 | +# is silly. Let's try to live without them for now. |
| 116 | +Style/ParenthesesAroundCondition: |
| 117 | + AllowSafeAssignment: false |
| 118 | + |
| 119 | +# A specialized exception class will take one or more arguments |
| 120 | +# and construct the message from it. So both variants make sense. |
| 121 | +Style/RaiseArgs: |
| 122 | + Enabled: false |
| 123 | + |
| 124 | +# Fail is an alias of raise. Avoid aliases, |
| 125 | +# it's more cognitive load for no gain. The argument that fail |
| 126 | +# should be used to abort the program is wrong too, |
| 127 | +# there's Kernel#abort for that. |
| 128 | +Style/SignalException: |
| 129 | + EnforcedStyle: only_raise |
| 130 | + |
| 131 | +# { ... } for multi-line blocks is okay, follow Weirichs rule instead: |
| 132 | +# https://web.archive.org/web/20140221124509/http://onestepback.org/index.cgi/Tech/Ruby/BraceVsDoEnd.rdoc |
| 133 | +Style/BlockDelimiters: |
| 134 | + Enabled: false |
| 135 | + |
| 136 | +# do / end blocks should be used for side effects, |
| 137 | +# methods that run a block for side effects and have |
| 138 | +# a useful return value are rare, assign the return |
| 139 | +# value to a local variable for those cases. |
| 140 | +Style/MethodCalledOnDoEndBlock: |
| 141 | + Enabled: true |
| 142 | + |
| 143 | +# Enforcing the names of variables? To single letter ones? Just no. |
| 144 | +Style/SingleLineBlockParams: |
| 145 | + Enabled: false |
| 146 | + |
| 147 | +# Check with yard instead. |
| 148 | +Style/Documentation: |
| 149 | + Enabled: false |
| 150 | + |
| 151 | +# Style preference |
| 152 | +Style/MethodDefParentheses: |
| 153 | + Enabled: false |
| 154 | + |
| 155 | +################################################################################ |
| 156 | +########################### Linter Rules ####################################### |
| 157 | +################################################################################ |
| 158 | + |
| 159 | +# There are valid cases, for example debugging Cucumber steps, |
| 160 | +# also they'll fail CI anyway |
| 161 | +Lint/Debugger: |
| 162 | + Enabled: false |
| 163 | + |
| 164 | +# Shadowing outer local variables with block parameters is often useful |
| 165 | +# to not reinvent a new name for the same thing, it highlights the relation |
| 166 | +# between the outer variable and the parameter. The cases where it's actually |
| 167 | +# confusing are rare, and usually bad for other reasons already, for example |
| 168 | +# because the method is too long. |
| 169 | +Lint/ShadowingOuterLocalVariable: |
| 170 | + Enabled: false |
| 171 | + |
| 172 | +# Suppressing exceptions can be perfectly fine, and be it to avoid to |
| 173 | +# explicitly type nil into the rescue since that's what you want to return, |
| 174 | +# or suppressing LoadError for optional dependencies |
| 175 | +Lint/HandleExceptions: |
| 176 | + Enabled: false |
| 177 | + |
| 178 | +Lint/AssignmentInCondition: |
| 179 | + AllowSafeAssignment: false |
| 180 | + |
| 181 | +################################################################################ |
| 182 | +############################ Naming Rules ###################################### |
| 183 | +################################################################################ |
| 184 | + |
| 185 | +# This is just silly. Calling the argument `other` in all cases makes no sense. |
| 186 | +Naming/BinaryOperatorParameterName: |
| 187 | + Enabled: false |
| 188 | + |
| 189 | +################################################################################ |
0 commit comments