diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml new file mode 100644 index 00000000..43f97de9 --- /dev/null +++ b/.github/workflows/CI.yml @@ -0,0 +1,20 @@ +name: CI + +on: + push: + branches: + - master + - github_actions + pull_request: + +jobs: + RuboCop: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: ruby/setup-ruby@v1 + with: + ruby-version: ruby + bundler-cache: true + - run: | + bundle exec rubocop --color --format github --format clang diff --git a/.rubocop.yml b/.rubocop.yml index 28d2dcd7..abe92cba 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,7 +1,9 @@ +inherit_from: .rubocop_todo.yml + AllCops: DisplayCopNames: true DisplayStyleGuide: true - TargetRubyVersion: 2.2 + TargetRubyVersion: 2.7 Exclude: - 'vendor/**/*' @@ -20,7 +22,7 @@ Metrics/CyclomaticComplexity: Metrics/MethodLength: Enabled: false -Metrics/LineLength: +Layout/LineLength: Enabled: false Metrics/PerceivedComplexity: diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml new file mode 100644 index 00000000..59df78e6 --- /dev/null +++ b/.rubocop_todo.yml @@ -0,0 +1,106 @@ +# This configuration was generated by +# `rubocop --auto-gen-config` +# on 2022-03-14 22:30:45 UTC using RuboCop version 1.26.0. +# 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: 1 +# Configuration parameters: Include. +# Include: **/*.gemspec +Gemspec/RequiredRubyVersion: + Exclude: + - 'odbc_adapter.gemspec' + +# Offense count: 6 +# This cop supports safe auto-correction (--auto-correct). +Layout/EmptyLineAfterGuardClause: + Exclude: + - 'lib/odbc_adapter/adapters/postgresql_odbc_adapter.rb' + - 'lib/odbc_adapter/column_metadata.rb' + - 'lib/odbc_adapter/quoting.rb' + - 'lib/odbc_adapter/registry.rb' + - 'lib/odbc_adapter/schema_statements.rb' + +# Offense count: 16 +# This cop supports safe auto-correction (--auto-correct). +# Configuration parameters: AllowMultipleStyles, EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle. +# SupportedHashRocketStyles: key, separator, table +# SupportedColonStyles: key, separator, table +# SupportedLastArgumentHashStyles: always_inspect, always_ignore, ignore_implicit, ignore_explicit +Layout/HashAlignment: + Exclude: + - 'lib/odbc_adapter/column_metadata.rb' + - 'lib/odbc_adapter/registry.rb' + - 'lib/odbc_adapter/schema_statements.rb' + +# Offense count: 1 +# This cop supports safe auto-correction (--auto-correct). +# Configuration parameters: AllowInHeredoc. +Layout/TrailingWhitespace: + Exclude: + - 'lib/odbc_adapter/adapters/null_odbc_adapter.rb' + +# Offense count: 1 +Lint/MissingSuper: + Exclude: + - 'test/registry_test.rb' + +# Offense count: 2 +# Configuration parameters: Max, CountKeywordArgs. +Metrics/ParameterLists: + MaxOptionalParameters: 4 + +# Offense count: 35 +# This cop supports safe auto-correction (--auto-correct). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: always, always_true, never +Style/FrozenStringLiteralComment: + Enabled: false + +# Offense count: 5 +# This cop supports safe auto-correction (--auto-correct). +Style/IfUnlessModifier: + Exclude: + - 'lib/odbc_adapter/adapters/mysql_odbc_adapter.rb' + - 'lib/odbc_adapter/quoting.rb' + - 'lib/odbc_adapter/schema_statements.rb' + +# Offense count: 1 +# This cop supports safe auto-correction (--auto-correct). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: literals, strict +Style/MutableConstant: + Exclude: + - 'lib/active_record/connection_adapters/odbc_adapter.rb' + +# Offense count: 1 +# Configuration parameters: AllowedMethods. +# AllowedMethods: respond_to_missing? +Style/OptionalBooleanParameter: + Exclude: + - 'lib/odbc_adapter/column.rb' + +# Offense count: 1 +# This cop supports safe auto-correction (--auto-correct). +Style/RedundantRegexpEscape: + Exclude: + - 'lib/odbc_adapter/quoting.rb' + +# Offense count: 4 +# This cop supports safe auto-correction (--auto-correct). +# Configuration parameters: ConvertCodeThatCanStartToReturnNil, AllowedMethods. +# AllowedMethods: present?, blank?, presence, try, try! +Style/SafeNavigation: + Exclude: + - 'lib/odbc_adapter/column_metadata.rb' + - 'lib/odbc_adapter/schema_statements.rb' + +# Offense count: 2 +# This cop supports safe auto-correction (--auto-correct). +# Configuration parameters: AllowModifier. +Style/SoleNestedConditional: + Exclude: + - 'lib/odbc_adapter/adapters/mysql_odbc_adapter.rb' + - 'lib/odbc_adapter/quoting.rb' diff --git a/Rakefile b/Rakefile index b9dcde93..b63b5498 100644 --- a/Rakefile +++ b/Rakefile @@ -1,6 +1,6 @@ require 'bundler/gem_tasks' -task default: %i[rubocop test] +task default: %i[test] desc 'Run rubocop' task :rubocop do diff --git a/odbc_adapter.gemspec b/odbc_adapter.gemspec index f3a8ed01..c787e6c6 100644 --- a/odbc_adapter.gemspec +++ b/odbc_adapter.gemspec @@ -26,6 +26,6 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'minitest', '~> 5.10' spec.add_development_dependency 'pry', '~> 0.11' spec.add_development_dependency 'rake', '~> 12.0' - spec.add_development_dependency 'rubocop', '<= 0.58' + spec.add_development_dependency 'rubocop', '~> 1.26.0' spec.add_development_dependency 'simplecov', '~> 0.14' end