Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge in changes from latest master in original file #1

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions rubocop-airbnb/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,28 @@
# 4.0.0
* Add support for Ruby 3.0
* Run CI against Ruby 2.7
* Drop support for Ruby 2.3
* Update rubocop to 0.93.1
* Update rubocop-performance to 1.10.2
* Update rubocop-rails to 2.9.1
* Update rubocop-rspec to 1.44.1
* Disable Style/BracesAroundHashParameters
* Set `DisabledByDefault: true` to disable any new rubocop cops that have not yet been evaluated for this style guide

# 3.0.2
* Moves `require`s for `rubocop-performance` and `rubocop-rails` to library code for better transitivity.

# 3.0.1
* Update supported ruby versions in gemspec

# 3.0.0
* Update to rubocop 0.76
* Enable Rails/IgnoredSkipActionFilterOption
* Enable Rails/ReflectionClassName
* Disable and delete Airbnb/ClassName
* Enable Layout/IndentFirstParameter
* Drop support for Ruby 2.2

# 2.0.0
* Upgrade to rubocop-rspec 1.30.0, use ~> to allow for PATCH version flexibility
* Upgrade to rubocop 0.58.0, use ~> to allow for PATCH version flexibility
Expand Down
5 changes: 5 additions & 0 deletions rubocop-airbnb/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ Just put this in your `Gemfile` it depends on the appropriate version of rubocop
gem 'rubocop-airbnb'
```

Note: If you want to run with Ruby 2.2 you will need to set your version to 2
```
gem 'rubocop-airbnb', '~> 2'
```

## Usage

You need to tell RuboCop to load the Airbnb extension. There are three
Expand Down
25 changes: 17 additions & 8 deletions rubocop-airbnb/config/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,23 @@ AllCops:
- 'vendor/**/*'
- Vagrantfile
- Guardfile
RSpec:
Patterns:
- _spec.rb
- "(?:^|/)spec/"
RSpec/FactoryBot:
Patterns:
- spec/factories/**/*.rb
- features/support/factories/**/*.rb
# RSpec:
# Patterns:
# - _spec.rb
# - "(?:^|/)spec/"
# RSpec/FactoryBot:
# Patterns:
# - spec/factories/**/*.rb
# - features/support/factories/**/*.rb

# While Rubocop has released a bunch of new cops, not all of these cops have been evaluated as
# part of this styleguide. To prevent new, unevaluated cops from imposing on this styleguide, we
# are marking these new cops as disabled. Note that as a consumer of this styleguide, you can
# always override any choices here by setting `Enabled: true` on any cops that you would like to
# have be enabled, even if we have explicitly disabled them (or if they are new and we have yet
# to evaluate them). For more on this configuration parameter, see
# https://github.com/rubocop/rubocop/blob/1e55b1aa5e4c5eaeccad5d61f08b7930ed6bc341/config/default.yml#L89-L101
DisabledByDefault: true

inherit_from:
- './rubocop-airbnb.yml'
Expand Down
5 changes: 0 additions & 5 deletions rubocop-airbnb/config/rubocop-airbnb.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@
# They are custom built for use inside Airbnb and address issues that we have experienced in
# testing and production.

Airbnb/ClassName:
Description: Use :class_name => "Model" instead of :class_name => Model.name
to avoid a long cascade of autoloading.
Enabled: true

Airbnb/ClassOrModuleDeclaredInWrongFile:
Description: Declare a class or module in the file that matches its namespace and name.
Enabled: true
Expand Down
3 changes: 3 additions & 0 deletions rubocop-airbnb/config/rubocop-gemspec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@ Gemspec/RequiredRubyVersion:
Enabled: false
Include:
- '**/*.gemspec'

Gemspec/RubyVersionGlobalsUsage:
Enabled: true
34 changes: 20 additions & 14 deletions rubocop-airbnb/config/rubocop-layout.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ Layout/AccessModifierIndentation:
- indent

# Supports --auto-correct
Layout/AlignArray:
Layout/ArrayAlignment:
Description: Align the elements of an array literal if they span more than one line.
StyleGuide: https://github.com/rubocop-hq/ruby-style-guide#align-multiline-arrays
Enabled: true

# Supports --auto-correct
Layout/AlignHash:
Layout/HashAlignment:
Description: Align the elements of a hash literal if they span more than one line.
Enabled: true
EnforcedHashRocketStyle: key
Expand All @@ -30,7 +30,7 @@ Layout/AlignHash:
- ignore_explicit

# Supports --auto-correct
Layout/AlignParameters:
Layout/ParameterAlignment:
Description: Align the parameters of a method call if they span more than one line.
StyleGuide: https://github.com/rubocop-hq/ruby-style-guide#no-double-indent
Enabled: true
Expand Down Expand Up @@ -227,7 +227,7 @@ Layout/FirstMethodParameterLineBreak:
Enabled: false

# Supports --auto-correct
Layout/IndentFirstArgument:
Layout/FirstArgumentIndentation:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like we lost the custom renames of these rules. oth, i don't know why we wanted to customize this by renaming rules anyway. Seems like a low ROI and high maintenance cost to me. Would recommend we ditch our customizations, but probably want to check w/ John. Also, they changed the format so the old kindsys renames would be inconsistent anyway.

afaict, there are 3 renames in the kindsys customizations (note that the source rule names have changed):
Layout/FirstParameterIndentation -> Layout/IndentFirstArgument
Layout/IndentArray -> Layout/IndentFirstArrayElement
Layout/IndentHash -> Layout/IndentFirstHashElement

Description: Checks the indentation of the first parameter in a method call.
Enabled: true
EnforcedStyle: consistent
Expand All @@ -238,28 +238,27 @@ Layout/IndentFirstArgument:
- special_for_inner_method_call_in_parentheses

# Supports --auto-correct
Layout/IndentFirstArrayElement:
Layout/FirstArrayElementIndentation:
Description: Checks the indentation of the first element in an array literal.
Enabled: true
EnforcedStyle: consistent

# Supports --auto-correct
Layout/IndentAssignment:
Layout/AssignmentIndentation:
Description: Checks the indentation of the first line of the right-hand-side of a
multi-line assignment.
Enabled: true
IndentationWidth:

# Supports --auto-correct
Layout/IndentFirstHashElement:
Layout/FirstHashElementIndentation:
Description: Checks the indentation of the first key in a hash literal.
Enabled: true
EnforcedStyle: consistent
SupportedStyles:
- special_inside_parentheses
- consistent

Layout/IndentHeredoc:
Layout/HeredocIndentation:
Enabled: false

# Supports --auto-correct
Expand All @@ -269,7 +268,7 @@ Layout/IndentationConsistency:
EnforcedStyle: normal
SupportedStyles:
- normal
- rails
- indented_internal_methods

# Supports --auto-correct
Layout/IndentationWidth:
Expand All @@ -283,7 +282,7 @@ Layout/InitialIndentation:
Description: Checks the indentation of the first non-blank non-comment line in a file.
Enabled: true

Layout/LeadingBlankLines:
Layout/LeadingEmptyLines:
Enabled: true

# Supports --auto-correct
Expand Down Expand Up @@ -344,7 +343,6 @@ Layout/MultilineMethodCallIndentation:
SupportedStyles:
- aligned
- indented
IndentationWidth:

Layout/MultilineMethodDefinitionBraceLayout:
Description: >-
Expand Down Expand Up @@ -533,13 +531,13 @@ Layout/SpaceInsideStringInterpolation:
- no_space

# Supports --auto-correct
Layout/Tab:
Layout/IndentationStyle:
Description: No hard tabs.
StyleGuide: https://github.com/rubocop-hq/ruby-style-guide#spaces-indentation
Enabled: true

# Supports --auto-correct
Layout/TrailingBlankLines:
Layout/TrailingEmptyLines:
Description: Checks trailing blank lines and final newline.
StyleGuide: https://github.com/rubocop-hq/ruby-style-guide#newline-eof
Enabled: true
Expand All @@ -553,3 +551,11 @@ Layout/TrailingWhitespace:
Description: Avoid trailing whitespace.
StyleGuide: https://github.com/rubocop-hq/ruby-style-guide#no-trailing-whitespace
Enabled: true

Layout/FirstParameterIndentation:
Enabled: true

# Supports --auto-correct
Layout/LineLength:
Max: 100
AllowURI: true
33 changes: 16 additions & 17 deletions rubocop-airbnb/config/rubocop-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ Lint/DuplicateMethods:
Description: Check for duplicate methods calls.
Enabled: true

Lint/DuplicatedKey:
Lint/DuplicateHashKey:
Description: Check for duplicate keys in hash literals.
Enabled: true

Expand All @@ -68,10 +68,6 @@ Lint/EmptyInterpolation:
Lint/EmptyWhen:
Enabled: false

Lint/EndInMethod:
Description: END blocks should not be placed inside method definitions.
Enabled: false

Lint/EnsureReturn:
Description: Do not use return in an ensure block.
StyleGuide: https://github.com/rubocop-hq/ruby-style-guide#no-return-ensure
Expand All @@ -80,20 +76,20 @@ Lint/EnsureReturn:
Lint/ErbNewArguments:
Enabled: false

Lint/FloatOutOfRange:
Description: Catches floating-point literals too large or small for Ruby to represent.
Enabled: false

Lint/FlipFlop:
Description: Checks for flip flops
StyleGuide: https://github.com/rubocop-hq/ruby-style-guide#no-flip-flops
Enabled: false

Lint/FloatOutOfRange:
Description: Catches floating-point literals too large or small for Ruby to represent.
Enabled: false

Lint/FormatParameterMismatch:
Description: The number of parameters to format/sprint must match the fields.
Enabled: true

Lint/HandleExceptions:
Lint/SuppressedException:
Description: Don't suppress exception.
StyleGuide: https://github.com/rubocop-hq/ruby-style-guide#dont-hide-exceptions
Enabled: false
Expand Down Expand Up @@ -144,7 +140,10 @@ Lint/MissingCopEnableDirective:
Description: 'Checks for a `# rubocop:enable` after `# rubocop:disable`'
Enabled: true

Lint/MultipleCompare:
Lint/MissingSuper:
Enabled: false

Lint/MultipleComparison:
Enabled: false

Lint/NestedMethodDefinition:
Expand Down Expand Up @@ -230,7 +229,7 @@ Lint/ShadowingOuterLocalVariable:
Enabled: true

# Supports --auto-correct
Lint/StringConversionInInterpolation:
Lint/RedundantStringCoercion:
Description: Checks for Object#to_s usage in string interpolation.
StyleGuide: https://github.com/rubocop-hq/ruby-style-guide#no-to-s
Enabled: true
Expand All @@ -242,20 +241,20 @@ Lint/UnderscorePrefixedVariableName:
Lint/UnifiedInteger:
Enabled: false

Lint/UnneededCopDisableDirective:
Lint/RedundantCopDisableDirective:
Description: >-
Checks for rubocop:disable comments that can be removed.
Note: this cop is not disabled when disabling all cops. It must be explicitly disabled.
Enabled: true

Lint/UnneededCopEnableDirective:
Lint/RedundantCopEnableDirective:
Description: Checks for rubocop:enable comments that can be removed.
Enabled: true

Lint/UnneededRequireStatement:
Lint/RedundantRequireStatement:
Enabled: false

Lint/UnneededSplatExpansion:
Lint/RedundantSplatExpansion:
Enabled: false

Lint/UnreachableCode:
Expand Down Expand Up @@ -289,7 +288,7 @@ Lint/UselessAssignment:
StyleGuide: https://github.com/rubocop-hq/ruby-style-guide#underscore-unused-vars
Enabled: true

Lint/UselessComparison:
Lint/BinaryOperatorWithIdenticalOperands:
Description: Checks for comparison of something with itself.
Enabled: true

Expand Down
4 changes: 0 additions & 4 deletions rubocop-airbnb/config/rubocop-metrics.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@ Metrics/CyclomaticComplexity:
Enabled: false
Max: 6

Metrics/LineLength:
Max: 100
AllowURI: true

Metrics/MethodLength:
Enabled: false

Expand Down
9 changes: 6 additions & 3 deletions rubocop-airbnb/config/rubocop-naming.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,18 +55,18 @@ Naming/PredicateName:
- is_
- has_
- have_
NamePrefixBlacklist:
ForbiddenPrefixes:
- is_
- has_
- have_

Naming/UncommunicativeBlockParamName:
Naming/BlockParameterName:
Description: >-
Checks for block parameter names that contain capital letters,
end in numbers, or do not meet a minimal length.
Enabled: false

Naming/UncommunicativeMethodParamName:
Naming/MethodParameterName:
Description: >-
Checks for method parameter names that contain capital letters,
end in numbers, or do not meet a minimal length.
Expand All @@ -83,3 +83,6 @@ Naming/VariableName:

Naming/VariableNumber:
Enabled: false

Naming/RescuedExceptionsVariableName:
Enabled: false
5 changes: 0 additions & 5 deletions rubocop-airbnb/config/rubocop-performance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,6 @@ Performance/FlatMap:
Performance/InefficientHashSearch:
Enabled: false

# # Supports --auto-correct
# Performance/LstripRstrip:
# Description: Use `strip` instead of `lstrip.rstrip`.
# Enabled: false

# Supports --auto-correct
Performance/RangeInclude:
Description: Use `Range#cover?` instead of `Range#include?`.
Expand Down
16 changes: 16 additions & 0 deletions rubocop-airbnb/config/rubocop-rails.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ Rails/Exit:
exits during unit testing or running in production.
Enabled: false

Rails/FilePath:
Enabled: false

# Supports --auto-correct
Rails/FindBy:
Description: Prefer find_by over where.first.
Expand Down Expand Up @@ -167,6 +170,9 @@ Rails/RequestReferer:
Rails/ReversibleMigration:
Enabled: false

Rails/SafeNavigation:
Enabled: false

Rails/SaveBang:
Enabled: false

Expand Down Expand Up @@ -200,3 +206,13 @@ Rails/Validation:
Enabled: false
Include:
- app/models/**/*.rb

Rails/IgnoredSkipActionFilterOption:
Enabled: true

Rails/ReflectionClassName:
Enabled: true

Rails/RakeEnvironment:
Description: Ensures that rake tasks depend on :environment
Enabled: false
Loading