inherit_from: .rubocop_todo.yml AllCops: DisplayCopNames: true DisplayStyleGuide: true TargetRubyVersion: 2.3 Exclude: - 'how_is.gemspec' - 'bin/*' - '**/*~' - 'spec/capture_warnings.rb' - 'lib/how_is/cli.rb' # FIXME: Make HowIs::CLI.parse not a disaster. # Exceptions should inherit from StandardError. # (RuboCop default is to inherit from RuntimeError.) Lint/InheritException: EnforcedStyle: standard_error Metrics/BlockLength: Exclude: - 'spec/**/*_spec.rb' # The guiding principle of classes is SRP, SRP can't be accurately measured by LoC #Metrics/ClassLength: # Max: 1500 # Still try for 80, but we'll allow 110 because there's a not-insignificant # number of cases where we have long lines. # # It may be worth revisiting this in the future and refactoring those lines. Metrics/LineLength: Max: 120 AllowHeredoc: true # Too short methods lead to extraction of single-use methods, which can make # the code easier to read (by naming things), but can also clutter the class Metrics/MethodLength: Max: 20 Style/Alias: EnforcedStyle: prefer_alias_method # Most readable form. Layout/AlignHash: EnforcedHashRocketStyle: table EnforcedColonStyle: table # Disable because it wound up conflicting with a lot of things like: # foo('bar', # baz: 'asdf', # beep: 'boop') # # I suspect these'll disappear when overarching architectural issues are # addressed. Enabled: false Layout/AlignParameters: # See Style/AlignedHash. Enabled: false # This codebase may be English, but some English words contain diacritics. Style/AsciiComments: Enabled: false # Despite the fact that some English words contain diacritics, we want all # method names to be writable by people who don't have an easy way to type # words with diacritics. Style/AsciiIdentifiers: Enabled: true # { ... } for multi-line blocks is okay, follow Weirichs rule instead: # https://web.archive.org/web/20140221124509/http://onestepback.org/index.cgi/Tech/Ruby/BraceVsDoEnd.rdoc Style/BlockDelimiters: Enabled: false # There's more nuance around this than RuboCop seems capable of. Style/BracesAroundHashParameters: Enabled: false # Don't force use of Time or Date; DateTime is okay. Style/DateTime: Enabled: false # Unicode is good, mkay? Style/Encoding: Enabled: true # Force Unix line endings. Layout/EndOfLine: Enabled: true EnforcedStyle: lf # A lot of the approaches I use for making things readable makes this angry. # E.g., formatting multiple consecutive assignments so that the equal signs # and values line up. # # foobar = 'blah' # baz = 'asdf' # beep = 'boop' Layout/ExtraSpacing: Enabled: false # # bad # # format('%s', greeting: 'Hello') # format('%s', 'Hello') # # # good # # format('%{greeting}', greeting: 'Hello') Style/FormatStringToken: EnforcedStyle: template # Freeze string literals to future-proof the code. # TODO: Enable this always. (Disabled due to not knowing what will happen.) Style/FrozenStringLiteralComment: Enabled: true #EnforcedStyle: always # Mixing hash styles just looks silly. # http://www.rubydoc.info/gems/rubocop/RuboCop/Cop/Style/HashSyntax Style/HashSyntax: EnforcedStyle: no_mixed_keys Layout/IndentHash: Enabled: true EnforcedStyle: consistent Layout/IndentArray: Enabled: true EnforcedStyle: consistent # I deplore assignments in conditions and never want them in any codebase # I have direct control over. Style/ParenthesesAroundCondition: AllowSafeAssignment: false Lint/AssignmentInCondition: AllowSafeAssignment: false # Use [] for `%`-literal delimiters (e.g. for %q[]) that RuboCop doesn't define # anything for. (E.g., %q[].) # # The reason I prefer [] instead of () is that most of the time I use # `%`-literals is inside of function calls, and using () makes it blend in too # much. Style/PercentLiteralDelimiters: Enabled: true PreferredDelimiters: default: "[]" '%w': '[]' '%W': '[]' # `has_key?` and `has_value?` are clearer than `key?` and `value?`. Style/PreferredHashMethods: Enabled: true EnforcedStyle: verbose # do / end blocks should be used for side effects, # methods that run a block for side effects and have # a useful return value are rare, assign the return # value to a local variable for those cases. Style/MethodCalledOnDoEndBlock: Enabled: true # Indenting the chained dots beneath each other is not supported by this cop, # see https://github.com/bbatsov/rubocop/issues/1633 Layout/MultilineOperationIndentation: Enabled: false # {'foo' => 'bar'} not { 'foo' => 'bar' } Layout/SpaceInsideHashLiteralBraces: Enabled: true EnforcedStyle: no_space # Use double quotes everywhere by default. Style/StringLiterals: EnforcedStyle: double_quotes # TODO: Maybe make it so you have to do [:foo, :bar] not %i[foo bar]? Style/SymbolArray: Enabled: false # Require parentheses around complex ternary conditions. Style/TernaryParentheses: Enabled: true EnforcedStyle: require_parentheses_when_complex # Require a comma after the last item in an array or hash if each item is on # its own line. Style/TrailingCommaInLiteral: EnforcedStyleForMultiline: comma