Skip to content

Commit

Permalink
Merge pull request #108 from flavorjones/flavorjones-rails-rubocop-st…
Browse files Browse the repository at this point in the history
…andards

update project to rails rubocop standards
  • Loading branch information
eileencodes authored Jul 6, 2023
2 parents 8795bc6 + 43d6205 commit 90c2418
Show file tree
Hide file tree
Showing 22 changed files with 830 additions and 411 deletions.
15 changes: 13 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,20 @@ on:
pull_request:

jobs:
rubocop:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: ruby/setup-ruby@v1
with:
ruby-version: 3.2
bundler-cache: true
- run: bundle exec rubocop

test:
needs: ["rubocop"]
name: "activesupport ${{ matrix.activesupport }} / ruby ${{ matrix.ruby }}"
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
Expand Down Expand Up @@ -52,7 +63,7 @@ jobs:
env:
BUNDLE_GEMFILE: gemfiles/active_support_${{ matrix.activesupport }}.gemfile
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
Expand Down
330 changes: 330 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,330 @@
require:
- rubocop-minitest
- rubocop-packaging
- rubocop-performance
- rubocop-rails

AllCops:
TargetRubyVersion: 2.5

# RuboCop has a bunch of cops enabled by default. This setting tells RuboCop
# to ignore them, so only the ones explicitly set in this file are enabled.
DisabledByDefault: true
SuggestExtensions: false

Performance:
Exclude:
- 'test/**/*'

# Prefer assert_not over assert !
Rails/AssertNot:
Include:
- 'test/**/*'

# Prefer assert_not_x over refute_x
Rails/RefuteMethods:
Include:
- 'test/**/*'

Rails/IndexBy:
Enabled: true

Rails/IndexWith:
Enabled: true

# Prefer &&/|| over and/or.
Style/AndOr:
Enabled: true

# Align `when` with `case`.
Layout/CaseIndentation:
Enabled: true

Layout/ClosingHeredocIndentation:
Enabled: true

Layout/ClosingParenthesisIndentation:
Enabled: true

# Align comments with method definitions.
Layout/CommentIndentation:
Enabled: true

Layout/ElseAlignment:
Enabled: true

# Align `end` with the matching keyword or starting expression except for
# assignments, where it should be aligned with the LHS.
Layout/EndAlignment:
Enabled: true
EnforcedStyleAlignWith: variable
AutoCorrect: true

Layout/EndOfLine:
Enabled: true

Layout/EmptyLineAfterMagicComment:
Enabled: true

Layout/EmptyLinesAroundAccessModifier:
Enabled: true
EnforcedStyle: only_before

Layout/EmptyLinesAroundBlockBody:
Enabled: true

# In a regular class definition, no empty lines around the body.
Layout/EmptyLinesAroundClassBody:
Enabled: true

# In a regular method definition, no empty lines around the body.
Layout/EmptyLinesAroundMethodBody:
Enabled: true

# In a regular module definition, no empty lines around the body.
Layout/EmptyLinesAroundModuleBody:
Enabled: true

# Use Ruby >= 1.9 syntax for hashes. Prefer { a: :b } over { :a => :b }.
Style/HashSyntax:
Enabled: true

# Method definitions after `private` or `protected` isolated calls need one
# extra level of indentation.
Layout/IndentationConsistency:
Enabled: true
EnforcedStyle: indented_internal_methods

# Two spaces, no tabs (for indentation).
Layout/IndentationWidth:
Enabled: true

Layout/LeadingCommentSpace:
Enabled: true

Layout/SpaceAfterColon:
Enabled: true

Layout/SpaceAfterComma:
Enabled: true

Layout/SpaceAfterSemicolon:
Enabled: true

Layout/SpaceAroundEqualsInParameterDefault:
Enabled: true

Layout/SpaceAroundKeyword:
Enabled: true

Layout/SpaceAroundOperators:
Enabled: true

Layout/SpaceBeforeComma:
Enabled: true

Layout/SpaceBeforeComment:
Enabled: true

Layout/SpaceBeforeFirstArg:
Enabled: true

Style/DefWithParentheses:
Enabled: true

# Defining a method with parameters needs parentheses.
Style/MethodDefParentheses:
Enabled: true

Style/ExplicitBlockArgument:
Enabled: true

Style/FrozenStringLiteralComment:
Enabled: true
EnforcedStyle: always

Style/MapToHash:
Enabled: true

Style/RedundantFreeze:
Enabled: true

# Use `foo {}` not `foo{}`.
Layout/SpaceBeforeBlockBraces:
Enabled: true

# Use `foo { bar }` not `foo {bar}`.
Layout/SpaceInsideBlockBraces:
Enabled: true
EnforcedStyleForEmptyBraces: space

# Use `{ a: 1 }` not `{a:1}`.
Layout/SpaceInsideHashLiteralBraces:
Enabled: true

Layout/SpaceInsideParens:
Enabled: true

# Check quotes usage according to lint rule below.
Style/StringLiterals:
Enabled: true
EnforcedStyle: double_quotes

# Detect hard tabs, no hard tabs.
Layout/IndentationStyle:
Enabled: true

# Empty lines should not have any spaces.
Layout/TrailingEmptyLines:
Enabled: true

# No trailing whitespace.
Layout/TrailingWhitespace:
Enabled: true

# Use quotes for string literals when they are enough.
Style/RedundantPercentQ:
Enabled: true

Lint/AmbiguousOperator:
Enabled: true

Lint/AmbiguousRegexpLiteral:
Enabled: true

Lint/DuplicateRequire:
Enabled: true

Lint/DuplicateMagicComment:
Enabled: true

Lint/DuplicateMethods:
Enabled: true

Lint/ErbNewArguments:
Enabled: true

Lint/EnsureReturn:
Enabled: true

# Use my_method(my_arg) not my_method( my_arg ) or my_method my_arg.
Lint/RequireParentheses:
Enabled: true

Lint/RedundantStringCoercion:
Enabled: true

Lint/UriEscapeUnescape:
Enabled: true

Lint/UselessAssignment:
Enabled: true

Lint/DeprecatedClassMethods:
Enabled: true

Style/EvalWithLocation:
Enabled: true

Style/ParenthesesAroundCondition:
Enabled: true

Style/HashTransformKeys:
Enabled: true

Style/HashTransformValues:
Enabled: true

Style/RedundantBegin:
Enabled: true

Style/RedundantReturn:
Enabled: true
AllowMultipleReturnValues: true

Style/RedundantRegexpEscape:
Enabled: true

Style/Semicolon:
Enabled: true
AllowAsExpressionSeparator: true

# Prefer Foo.method over Foo::method
Style/ColonMethodCall:
Enabled: true

Style/TrivialAccessors:
Enabled: true

# Prefer a = b || c over a = b ? b : c
Style/RedundantCondition:
Enabled: true

Performance/BindCall:
Enabled: true

Performance/FlatMap:
Enabled: true

Performance/MapCompact:
Enabled: true

Performance/SelectMap:
Enabled: true

Performance/RedundantMerge:
Enabled: true

Performance/StartWith:
Enabled: true

Performance/EndWith:
Enabled: true

Performance/RegexpMatch:
Enabled: true

Performance/ReverseEach:
Enabled: true

Performance/StringReplacement:
Enabled: true

Performance/UnfreezeString:
Enabled: true

Performance/DeletePrefix:
Enabled: true

Performance/DeleteSuffix:
Enabled: true

Performance/OpenStruct:
Enabled: true

Performance/InefficientHashSearch:
Enabled: true

Performance/ConstantRegexp:
Enabled: true

Performance/RedundantStringChars:
Enabled: true

Performance/StringInclude:
Enabled: true

Minitest/AssertRaisesWithRegexpArgument:
Enabled: true

Minitest/AssertWithExpectedArgument:
Enabled: true

Minitest/SkipEnsure:
Enabled: true

Minitest/UnreachableAssertion:
Enabled: true

Minitest/NoAssertions:
Enabled: true
12 changes: 11 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
source 'https://rubygems.org'
# frozen_string_literal: true

source "https://rubygems.org"

# Specify your gem's dependencies in rails-dom-testing.gemspec
gemspec

group :rubocop do
gem "rubocop", require: false
gem "rubocop-minitest", require: false
gem "rubocop-packaging", require: false
gem "rubocop-performance", require: false
gem "rubocop-rails", require: false
end
Loading

0 comments on commit 90c2418

Please sign in to comment.