Skip to content

Commit

Permalink
Thread safety rubocop plugin (#3543)
Browse files Browse the repository at this point in the history
* thread saftey rubocop plugin

* use --auto-gen-config rubocop flag

* move gem to :test :development group

* move thread checks to rake task

* woops, remove byebug

* fix lint issue
  • Loading branch information
omgitsbillryan authored Dec 3, 2019
1 parent 9431856 commit 6ee87b6
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 7 deletions.
2 changes: 2 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
inherit_from: .rubocop_todo.yml

require:
- rubocop-rails
- rubocop-rspec
Expand Down
39 changes: 39 additions & 0 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2019-11-29 12:01:22 -0500 using RuboCop version 0.74.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: 7
ThreadSafety/ClassAndModuleAttributes:
Exclude:
- 'app/models/base_facility.rb'
- 'lib/common/models/redis_store.rb'
- 'lib/facilities/nca_facility.rb'
- 'lib/facilities/vba_facility.rb'
- 'lib/facilities/vc_facility.rb'
- 'lib/facilities/vha_facility.rb'
- 'lib/saml/health_status.rb'

# Offense count: 36
ThreadSafety/InstanceVariableInClassMethod:
Exclude:
- 'app/models/base_facility.rb'
- 'app/models/form_profile.rb'
- 'lib/common/client/base.rb'
- 'lib/common/models/base.rb'
- 'lib/common/models/collection.rb'
- 'lib/common/models/concerns/active_record_cache_aside.rb'
- 'lib/common/models/redis_store.rb'
- 'lib/oidc/key_service.rb'
- 'lib/saml/settings_service.rb'
- 'lib/vet360/contact_information/person_response.rb'
- 'lib/vet360/contact_information/transaction_response.rb'
- 'lib/vic/url_helper.rb'

# Offense count: 1
ThreadSafety/NewThread:
Exclude:
- 'spec/lib/common/client/middleware/request/remove_cookies_spec.rb'
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ group :development, :test do
gem 'rubocop', require: false
gem 'rubocop-rails'
gem 'rubocop-rspec'
gem 'rubocop-thread_safety'
gem 'sidekiq', '~> 4.2'
gem 'timecop'
gem 'webmock'
Expand Down
3 changes: 3 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -596,6 +596,8 @@ GEM
rubocop (>= 0.72.0)
rubocop-rspec (1.35.0)
rubocop (>= 0.60.0)
rubocop-thread_safety (0.3.4)
rubocop (>= 0.51.0)
ruby-progressbar (1.10.1)
ruby-rc4 (0.1.5)
ruby-saml (1.7.0)
Expand Down Expand Up @@ -823,6 +825,7 @@ DEPENDENCIES
rubocop-junit-formatter
rubocop-rails
rubocop-rspec
rubocop-thread_safety
ruby-saml
rubyzip (>= 1.3.0)
savon
Expand Down
16 changes: 9 additions & 7 deletions rakelib/lint.rake
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@ desc 'shortcut to run all linting tools, at the same time.'
task :lint do
require 'rainbow'

opts = if ENV['CI']
"-r rubocop/formatter/junit_formatter.rb \
--format RuboCop::Formatter::JUnitFormatter --out log/rubocop.xml \
--format clang"
else
'--display-cop-names --auto-correct'
end
opts = '-r rubocop-thread_safety '

opts += if ENV['CI']
"-r rubocop/formatter/junit_formatter.rb \
--format RuboCop::Formatter::JUnitFormatter --out log/rubocop.xml \
--format clang"
else
'--display-cop-names --auto-correct'
end

puts 'running rubocop...'
rubocop_result = ShellCommand.run("rubocop #{opts} --color")
Expand Down

0 comments on commit 6ee87b6

Please sign in to comment.