Skip to content

Commit

Permalink
Merge pull request #148 from collectiveidea/khanify-rubocop
Browse files Browse the repository at this point in the history
Update rubocop and fixing the test suite
  • Loading branch information
albus522 committed Feb 5, 2018
2 parents 45cebed + 100f422 commit a98dbac
Show file tree
Hide file tree
Showing 38 changed files with 323 additions and 296 deletions.
121 changes: 92 additions & 29 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,91 +1,154 @@
# Load the rubocop-rspec gem
require: rubocop-rspec

Rails:
Enabled: true
AllCops:
RunRailsCops: true
Exclude:
- lib/**/templates/*
- vendor/**/*

#################
# [i] Overrides #
#################

CollectionMethods:
Style/CollectionMethods:
Enabled: true
# Mapping from undesired method to desired_method
# e.g. to use `detect` over `find`:
#
# CollectionMethods:
# PreferredMethods:
# find: detect
PreferredMethods:
collect: 'map'
collect!: 'map!'
reduce: 'inject'
find_all: 'select'
find: 'detect'
each_with_index: 'each.with_index'

# Multi-line method chaining should be done with leading dots.
DotPosition:
EnforcedStyle: trailing
Style/EmptyMethod:
EnforcedStyle: expanded

# Align ends correctly.
EndAlignment:
AlignWith: variable

IfUnlessModifier:
MaxLineLength: 75
EnforcedStyleAlignWith: variable

LineLength:
Max: 200
Max: 120

SignalException:
EnforcedStyle: only_raise

SpaceInsideBlockBraces:
SpaceBeforeBlockParameters: false
SpaceBeforeBlockParameters: true

SpaceInsideHashLiteralBraces:
EnforcedStyle: no_space
EnforcedStyle: space

BracesAroundHashParameters:
EnforcedStyle: context_dependent

StringLiterals:
EnforcedStyle: double_quotes

#################
# Disabled cops #
#################
AbcSize:
Metrics/ClassLength:
Enabled: false

Metrics/CyclomaticComplexity:
Enabled: false

Metrics/MethodLength:
Enabled: false

ClassAndModuleChildren:
Style/ClassAndModuleChildren:
Enabled: false

ClassLength:
Style/Documentation:
Enabled: false

CyclomaticComplexity:
Style/EachWithObject:
Enabled: false

Documentation:
Style/FormatString:
Enabled: false

EachWithObject:
Style/Lambda:
Enabled: false

FormatString:
Style/NegatedIf:
Enabled: false

Lambda:
Style/PercentLiteralDelimiters:
PreferredDelimiters:
"%w": "[]"
"%W": "[]"
"%i": "[]"
"%I": "[]"

Style/Semicolon:
Enabled: false

MethodLength:
Style/SingleLineBlockParams:
Enabled: false

NegatedIf:
Style/TrailingCommaInLiteral:
Enabled: false

Style/WordArray:
Enabled: false

# HABTM still has a place.
# https://collectiveidea.com/blog/archives/2014/08/11/has_and_belongs_to_many-isnt-dead/
Rails/HasAndBelongsToMany:
Enabled: false

# enforces using the class name in a describe block (e.g. `describe TestedClass do`)
RSpec/DescribeClass:
Enabled: false

# enforces using the described_class variablea (`described_class` instead of MyClass)
RSpec/DescribedClass:
Enabled: false

# RSpec examples are ok if they're long.
# Explicitness is better than cleverness in tests.
RSpec/ExampleLength:
Enabled: false

# enforces using either `expect` or `allow` for stubs. Since they do differnet things,
# we should let the developer decide which to use
RSpec/MessageExpectation:
Enabled: false

# enforces having only one `expect` per test
RSpec/MultipleExpectations:
Enabled: false

# enforces rules about how many nested `describe` blocks are allowed
RSpec/NestedGroups:
Enabled: false

# enforces rules about using `it` or `describe` block methods instead of `feature` or `scenario`
Capybara/FeatureMethods:
Enabled: false

###################
# Local overrides #
###################

Rails/ApplicationRecord:
Enabled: false

Semicolon:
Rails/SkipsModelValidations:
Enabled: false

SingleLineBlockParams:
Security/YAMLLoad:
Enabled: false

TrailingComma:
Style/FormatStringToken:
Enabled: false

WordArray:
Style/NumericPredicate:
Enabled: false
60 changes: 38 additions & 22 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ branches:
- master
before_script:
- mysql -e 'create database delayed_job_test;'
- mysql --version
- psql -c 'create database delayed_job_test;' -U postgres
script: bundle exec rspec
script: bundle exec $COMMAND
env:
global:
- JRUBY_OPTS="$JRUBY_OPTS -Xcli.debug=true --debug"
- COMMAND=rspec
gemfile: # Supported
- gemfiles/mysql2/4-2.gemfile
- gemfiles/mysql2/5-0.gemfile
Expand All @@ -20,9 +22,9 @@ gemfile: # Supported
- gemfiles/sqlite3/5-0.gemfile
- gemfiles/sqlite3/5-1.gemfile
rvm: # Supported
- 2.2.7
- 2.3.4
- 2.4.1
- 2.2.9
- 2.3.6
- 2.4.3
- jruby-9.1.8.0

jdk: oraclejdk8
Expand All @@ -45,15 +47,29 @@ matrix:

include:
#
# Rubocop
#
- rvm: 2.5.0
gemfile: Gemfile
env:
- COMMAND=rubocop
#
# The future
#
# MRI 2.5.0
- rvm: 2.5.0
gemfile: gemfiles/mysql2/5-1.gemfile
- rvm: 2.5.0
gemfile: gemfiles/postgresql/5-1.gemfile
- rvm: 2.5.0
gemfile: gemfiles/sqlite3/5-1.gemfile
# Active Record head
- gemfile: gemfiles/mysql2/master.gemfile
rvm: 2.4.1
rvm: 2.4.3
- gemfile: gemfiles/postgresql/master.gemfile
rvm: 2.4.1
rvm: 2.4.3
- gemfile: gemfiles/sqlite3/master.gemfile
rvm: 2.4.1
rvm: 2.4.3
# MRI Ruby head
- rvm: ruby-head
gemfile: gemfiles/mysql2/5-1.gemfile
Expand All @@ -73,35 +89,35 @@ matrix:
#
# EOL Active Record
- gemfile: gemfiles/mysql2/3-0.gemfile
rvm: 2.2.7
rvm: 2.2.9
- gemfile: gemfiles/mysql2/3-1.gemfile
rvm: 2.2.7
rvm: 2.2.9
- gemfile: gemfiles/mysql2/3-2.gemfile
rvm: 2.2.7
rvm: 2.2.9
- gemfile: gemfiles/mysql2/4-0.gemfile
rvm: 2.3.4
rvm: 2.3.6
- gemfile: gemfiles/mysql2/4-1.gemfile
rvm: 2.3.4
rvm: 2.3.6
- gemfile: gemfiles/postgresql/3-0.gemfile
rvm: 2.2.7
rvm: 2.2.9
- gemfile: gemfiles/postgresql/3-1.gemfile
rvm: 2.2.7
rvm: 2.2.9
- gemfile: gemfiles/postgresql/3-2.gemfile
rvm: 2.2.7
rvm: 2.2.9
- gemfile: gemfiles/postgresql/4-0.gemfile
rvm: 2.3.4
rvm: 2.3.6
- gemfile: gemfiles/postgresql/4-1.gemfile
rvm: 2.3.4
rvm: 2.3.6
- gemfile: gemfiles/sqlite3/3-0.gemfile
rvm: 2.2.7
rvm: 2.2.9
- gemfile: gemfiles/sqlite3/3-1.gemfile
rvm: 2.2.7
rvm: 2.2.9
- gemfile: gemfiles/sqlite3/3-2.gemfile
rvm: 2.2.7
rvm: 2.2.9
- gemfile: gemfiles/sqlite3/4-0.gemfile
rvm: 2.3.4
rvm: 2.3.6
- gemfile: gemfiles/sqlite3/4-1.gemfile
rvm: 2.3.4
rvm: 2.3.6
#
# The parallel dimension
#
Expand Down
15 changes: 7 additions & 8 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,21 @@ gem "rake"

group :test do
platforms :jruby do
gem 'activerecord-jdbcmysql-adapter', git: 'https://github.com/jruby/activerecord-jdbc-adapter', branch: 'rails-5'

gem 'activerecord-jdbcpostgresql-adapter', git: 'https://github.com/jruby/activerecord-jdbc-adapter', branch: 'rails-5'

gem 'activerecord-jdbcsqlite3-adapter', git: 'https://github.com/jruby/activerecord-jdbc-adapter', branch: 'rails-5'
gem "activerecord-jdbcmysql-adapter"
gem "activerecord-jdbcpostgresql-adapter"
gem "activerecord-jdbcsqlite3-adapter"
end

platforms :ruby, :mswin, :mingw do
gem 'mysql2', '~> 0.4.5'
gem "pg"
gem "mysql2", "~> 0.4.5"
gem "pg", "~> 0.18"
gem "sqlite3"
end

gem "coveralls", require: false
gem "rspec", ">= 3"
gem "rubocop", ">= 0.23"
gem "rubocop"
gem "rubocop-rspec"
gem "simplecov", require: false
end

Expand Down
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Bundler::GemHelper.install_tasks

require "rspec/core/rake_task"

ADAPTERS = %w(mysql2 postgresql sqlite3)
ADAPTERS = %w[mysql2 postgresql sqlite3].freeze

ADAPTERS.each do |adapter|
desc "Run RSpec code examples for #{adapter} adapter"
Expand Down
2 changes: 1 addition & 1 deletion delayed_job_active_record.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Gem::Specification.new do |spec|
spec.authors = ["Brian Ryckbost", "Matt Griffin", "Erik Michaels-Ober"]
spec.description = "ActiveRecord backend for Delayed::Job, originally authored by Tobias Lütke"
spec.email = ["[email protected]", "[email protected]", "[email protected]"]
spec.files = %w(CONTRIBUTING.md LICENSE.md README.md delayed_job_active_record.gemspec) + Dir["lib/**/*.rb"]
spec.files = %w[CONTRIBUTING.md LICENSE.md README.md delayed_job_active_record.gemspec] + Dir["lib/**/*.rb"]
spec.homepage = "https://github.com/collectiveidea/delayed_job_active_record"
spec.licenses = ["MIT"]
spec.name = "delayed_job_active_record"
Expand Down
8 changes: 1 addition & 7 deletions gemfiles/mysql2/3-0.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,7 @@ source 'https://rubygems.org'
gem 'rake'

group :test do
platforms :jruby do
gem 'activerecord-jdbcmysql-adapter'
end

platforms :ruby, :mswin, :mingw do
gem 'activerecord-mysql2-adapter'
end
gem 'activerecord-mysql2-adapter'

gem 'coveralls', :require => false
gem 'rspec', '>= 2.11'
Expand Down
18 changes: 5 additions & 13 deletions gemfiles/mysql2/3-1.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,13 @@ source 'https://rubygems.org'

gem 'rake'

group :test do
platforms :jruby do
gem 'activerecord-jdbcmysql-adapter'
end
gem 'mysql2', '~> 0.3.10'

platforms :ruby, :mswin, :mingw do
gem 'mysql2', '~> 0.3.10'
gem 'activerecord-mysql2-adapter'
end
gem 'coveralls', :require => false
gem 'rspec', '>= 2.11'
gem 'simplecov', :require => false

gem 'coveralls', :require => false
gem 'rspec', '>= 2.11'
gem 'simplecov', :require => false
gem 'activerecord', "~> 3.1.0"

gem 'activerecord', "~> 3.1.0"
end

gemspec :path => "../../"
Loading

0 comments on commit a98dbac

Please sign in to comment.