Skip to content

Commit

Permalink
Update RuboCop config to reference my main config
Browse files Browse the repository at this point in the history
Also added a .gitignore file, to ignore the config file that RuboCop caches.
  • Loading branch information
booch committed Jan 20, 2021
1 parent 1bb6658 commit ad2ad2c
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 171 deletions.
18 changes: 18 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Temp directory
/tmp/

# Bundler config and bundled gems
/.bundle/
/vendor/bundle

# Typical files generated by test frameworks
/spec/reports/
/spec/examples.txt
/test/tmp/
/test/version_tmp/

# Byebug command history
/.byebug_history

# Caching of remote RuboCop config files pulled in from `inherit_from` directive
/.rubocop-https?--*
178 changes: 7 additions & 171 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,15 @@ require:
- rubocop-rspec
- rubocop-performance

# Provide more details in output.
AllCops:
TargetRubyVersion: 2.7
DisplayCopNames: true
DisplayStyleGuide: true
ExtraDetails: true
inherit_from:
- https://raw.githubusercontent.com/booch/config_files/master/ruby/rubocop.yml

# Allow longer lines.
Metrics/LineLength:
Max: 160

# Don't require documentation for everything.
Style/Documentation:
Enabled: false

# Require `private` on the same line as each private method. We find this easier to read and move code.
Style/AccessModifierDeclarations:
EnforcedStyle: inline

# Use `{}` for blocks that return a value; otherwise use `do` and `end`.
# We make a few exceptions, mostly for RSpec.
# We make a few exceptions, mostly for RSpec. And for grammar and transform rules.
Style/BlockDelimiters:
EnforcedStyle: semantic
FunctionalMethods:
Expand All @@ -36,170 +24,18 @@ Style/BlockDelimiters:
- let!
- subject

# Don't require `freeze` on every immutable constant.
Style/MutableConstant:
Enabled: false

# I don't want to add `# frozen_string_literal: true` to every file in Ruby 2.3+.
Style/FrozenStringLiteralComment:
Enabled: false

# Don't use backticks -- they're too hard to distinguish.
Style/CommandLiteral:
EnforcedStyle: percent_x

# Don't require underscores for long numeric literals (but warn about them).
Style/NumericLiterals:
Severity: warning

# Require blank lines inside class/module definitions.
Layout/EmptyLinesAroundClassBody:
EnforcedStyle: empty_lines
Layout/EmptyLinesAroundModuleBody:
EnforcedStyle: empty_lines

# Allow (but don't require) extra empty lines.
Layout/EmptyLines:
Enabled: false

# Don't require empty methods to have the `def` and `end` on a single line.
Style/EmptyMethod:
Enabled: false

# Use `[]` for `%w`, to remind us that we're creating an Array.
# Use `[]` for `%x`, because it looks kind of like an input box.
# Use `{}` for `%q`, because it's set off a bit nicer than `()`.
# Use `{}` for `%r`, because regular expressions might have unbalanced `()` or `<>`.
Style/PercentLiteralDelimiters:
PreferredDelimiters:
'%w': '[]'
'%W': '[]'
'%x': '[]'
'%': '{}'
'%q': '{}'
'%Q': '{}'
'%r': '{}'

# Allow explicit `self`, as it adds clarity on occasion.
Style/RedundantSelf:
Enabled: false

# Use `%r` for regular expressions that span more than 1 line.
Style/RegexpLiteral:
EnforcedStyle: mixed

# Use Jim Weirich's suggestion of using `fail`, except when re-raising an exception.
Style/SignalException:
EnforcedStyle: semantic

# Default to double quotes, as they require less incidental changes.
Style/StringLiterals:
EnforcedStyle: double_quotes

# Allow either type of quotes within the Ruby code inside interpolations.
Style/StringLiteralsInInterpolation:
Enabled: false

# Allow (but don't require) a space before a block brace.
Layout/SpaceBeforeBlockBraces:
Enabled: false

# Don't allow a space directly inside a Hash literal.
Layout/SpaceInsideHashLiteralBraces:
EnforcedStyle: no_space

# Require a space directly inside a block delineated with braces.
# This is the default, but I wanted to call it out in contrast to Hash literals.
Layout/SpaceInsideBlockBraces:
EnforcedStyle: space
EnforcedStyleForEmptyBraces: no_space
SpaceBeforeBlockParameters: true

# When using multi-line Arrays and Hashes, ensure the first element is also on its own line.
Layout/FirstArrayElementLineBreak:
Enabled: true
Layout/FirstHashElementLineBreak:
Enabled: true

# Allow (but don't require) trailing comma in Array and Hash literals.
Style/TrailingCommaInArrayLiteral:
Enabled: false
Style/TrailingCommaInHashLiteral:
Enabled: false

# Don't complain about the block comments generated by RSpec.
Style/BlockComments:
Exclude:
- 'spec/spec_helper.rb'

# Allow `send`. (It might be better to prefer `__send__` or `public_send`, but I'm not 100% convinced.)
Style/Send:
Enabled: false

# Don't complain that `has_many` doesn't end with a question mark.
Naming/PredicateName:
AllowedMethods:
- has_many

# Allow `has_key?` and `has_value?` on Hash, as they read better than `key?` and `value?`.
Style/PreferredHashMethods:
Enabled: false

# Ensure there's a newline at the end of the file, but not a blank line.
Style/TrailingEmptyLines:
EnforcedStyle: final_newline

# Allow assigning to the same variable in multiple branches of an `if` or `case`.
Style/ConditionalAssignment:
Enabled: false

# Allow long blocks in specs and tests.
Metrics/BlockLength:
Exclude:
- spec/**/*
- test/**/*

# Don't require use of Ruby 2.3+ safe navigation operator.
Style/SafeNavigation:
Enabled: false

# Allow `!!` to force a boolean result.
Style/DoubleNegation:
Enabled: false

# Allow non-ASCII identifiers.
Naming/AsciiIdentifiers:
Enabled: false

# I prefer to order my gems in order of "importance".
Bundler/OrderedGems:
Enabled: false

# Don't require an empty line after a guard clause. TODO: Perhaps reconsider this decision.
Layout/EmptyLineAfterGuardClause:
Enabled: false

# I often prefer to put each accessor on its own line.
Style/AccessorGrouping:
Enabled: false

# I don't see any good reason to call `super` when the superclass has no explicit `initialize`.
# TODO: Add a config to the cop to allow (only) this case to pass. See https://github.com/rubocop-hq/rubocop/issues/8506
Lint/MissingSuper:
Enabled: false



## Exceptions.
# Some of our classes are going to be long.
Metrics/ClassLength:
Max: 250

# Sometimes we need to pass a block down recursively, so allow expressing that.
Performance/RedundantBlockCall:
Enabled: false

# Some of our classes are going to be long.
Metrics/ClassLength:
Max: 250

# Not sure why `∧` and `∨` are problematic, even after allowing non-ASCII identifiers.
# Also allow `builtin_ClassName` methods.
Naming/MethodName:
Expand All @@ -213,7 +49,7 @@ Layout/AccessModifierIndentation:
Exclude:
- src/stone/top.rb

# Allow `expr = expr + x` in this file, to parallel `expr = x + expr` that's right next to it.
# Allow `expr = expr + x` in this particular file, to parallel `expr = x + expr` that's right next to it.
Style/SelfAssignment:
Exclude:
- src/stone/ast/binary_operation.rb
Expand Down

0 comments on commit ad2ad2c

Please sign in to comment.