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

Run Rubocop in GH Actions not CodeClimate #98

Merged
merged 8 commits into from
Jan 2, 2024
Merged
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
3 changes: 1 addition & 2 deletions .codeclimate.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
---
engines:
rubocop:
enabled: true
channel: rubocop-0-49
enabled: false
ratings:
paths:
- "**.rb"
20 changes: 20 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,23 @@ jobs:
run: sudo systemctl start mysql.service
- run: bin/setup
- run: bundle exec rake
lint:
strategy:
fail-fast: false
matrix:
ruby:
- 2.7
rails:
- 6.1.0
env:
PERCONA_DB_USER: root
PERCONA_DB_PASSWORD: root
RAILS_VERSION: "~> ${{ matrix.rails }}"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true
- run: bundle exec rubocop --parallel
4 changes: 4 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
---
inherit_from:
- .rubocop_todo.yml

AllCops:
TargetRubyVersion: 2.4

Expand Down Expand Up @@ -39,6 +42,7 @@ Style/BracesAroundHashParameters:
Exclude:
- 'spec/fixtures/migrate/**.rb'
- 'spec/integration/**.rb'
- 'spec/lhm/adapter/**.rb'

Style/CommandLiteral:
Exclude:
Expand Down
111 changes: 111 additions & 0 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2024-01-02 13:03:20 -0300 using RuboCop version 0.49.1.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again.

# Offense count: 3
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: leading, trailing
Layout/DotPosition:
Exclude:
- 'spec/integration/indexes_spec.rb'

# Offense count: 4
# Cop supports --auto-correct.
# Configuration parameters: SupportedStyles, IndentationWidth.
# SupportedStyles: special_inside_parentheses, consistent, align_brackets
Layout/IndentArray:
EnforcedStyle: consistent

# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: Width, IgnoredPatterns.
Layout/IndentationWidth:
Exclude:
- 'spec/integration/indexes_spec.rb'

# Offense count: 2
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles, EnforcedStyleForEmptyBraces, SupportedStylesForEmptyBraces.
# SupportedStyles: space, no_space, compact
# SupportedStylesForEmptyBraces: space, no_space
Layout/SpaceInsideHashLiteralBraces:
Exclude:
- 'spec/active_record/connection_adapters/percona_adapter_spec.rb'

# Offense count: 2
# Cop supports --auto-correct.
# Configuration parameters: AllowUnusedKeywordArguments, IgnoreEmptyMethods.
Lint/UnusedMethodArgument:
Exclude:
- 'lib/active_record/connection_adapters/for_alter.rb'
- 'spec/spec_helper.rb'

# Offense count: 1
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
# URISchemes: http, https
Metrics/LineLength:
Max: 123

# Offense count: 1
# Cop supports --auto-correct.
Security/YAMLLoad:
Exclude:
- 'configuration.rb'

# Offense count: 12
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: braces, no_braces, context_dependent
Style/BracesAroundHashParameters:
Exclude:
- 'spec/fixtures/migrate/**.rb'
- 'spec/integration/**.rb'
- 'spec/lhm/adapter/add_unique_index_spec.rb'
- 'spec/lhm/adapter/remove_index_spec.rb'

# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: compact, expanded
Style/EmptyMethod:
Exclude:
- 'spec/fixtures/migrate/0029_disable_departure.rb'

# Offense count: 12
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles, ConsistentQuotesInMultiline.
# SupportedStyles: single_quotes, double_quotes
Style/StringLiterals:
Exclude:
- 'spec/active_record/connection_adapters/percona_adapter_spec.rb'
- 'spec/fixtures/migrate/0030_data_migration_with_upsert_all.rb'
- 'spec/integration/data_migrations_spec.rb'
- 'spec/integration/foreign_keys_spec.rb'
- 'spec/lhm/column_with_sql_spec.rb'

# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyleForMultiline, SupportedStylesForMultiline.
# SupportedStylesForMultiline: comma, consistent_comma, no_comma
Style/TrailingCommaInArguments:
Exclude:
- 'spec/departure/runner_spec.rb'

# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyleForMultiline, SupportedStylesForMultiline.
# SupportedStylesForMultiline: comma, consistent_comma, no_comma
Style/TrailingCommaInLiteral:
Exclude:
- 'spec/integration/data_migrations_spec.rb'

# Offense count: 1
# Cop supports --auto-correct.
Style/UnneededInterpolation:
Exclude:
- 'spec/active_record/connection_adapters/percona_adapter_spec.rb'
4 changes: 2 additions & 2 deletions lib/active_record/connection_adapters/percona_adapter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def adapter
end

class SchemaCreation < ActiveRecord::ConnectionAdapters::MySQL::SchemaCreation
def visit_DropForeignKey(name) # rubocop:disable Naming/MethodName
def visit_DropForeignKey(name) # rubocop:disable Style/MethodName
fk_name =
if name =~ /^__(.+)/
Regexp.last_match(1)
Expand Down Expand Up @@ -188,7 +188,7 @@ def full_version

# This is a method defined in Rails 6.0, and we have no control over the
# naming of this method.
def get_full_version # rubocop:disable Naming/AccessorMethodName
def get_full_version # rubocop:disable Style/AccessorMethodName
mysql_adapter.raw_connection.server_info[:version]
end

Expand Down
2 changes: 1 addition & 1 deletion spec/integration/indexes_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class Comment < ActiveRecord::Base; end

it 'executes the percona command' do
if ActiveRecord::Base.connection.send(:supports_rename_index?)
expect_percona_command('RENAME INDEX `index_comments_on_some_id_field` TO `new_index_comments_on_some_id_field`')
expect_percona_command('RENAME INDEX `index_comments_on_some_id_field` TO `new_index_comments_on_some_id_field`') # rubocop:disable Metrics/LineLength
else
expect_percona_command('ADD INDEX `new_index_comments_on_some_id_field` (`some_id_field`)')
expect_percona_command('DROP INDEX `index_comments_on_some_id_field`')
Expand Down