From 666ebe40f0b59fe124556f9f1506bc8f2818d85c Mon Sep 17 00:00:00 2001 From: omgitsbillryan Date: Wed, 13 Nov 2019 13:46:53 -0500 Subject: [PATCH 1/6] thread saftey rubocop plugin --- .rubocop.yml | 1 + Gemfile | 2 ++ Gemfile.lock | 3 +++ 3 files changed, 6 insertions(+) diff --git a/.rubocop.yml b/.rubocop.yml index 68766d6a028..84322c1e6c7 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,6 +1,7 @@ require: - rubocop-rails - rubocop-rspec + - rubocop-thread_safety AllCops: TargetRailsVersion: 5.2 diff --git a/Gemfile b/Gemfile index e6e00b37686..cd9d75189ee 100644 --- a/Gemfile +++ b/Gemfile @@ -4,6 +4,8 @@ source 'https://rubygems.org' ruby '2.4.5' +gem 'rubocop-thread_safety' + # Modules gem 'appeals_api', path: 'modules/appeals_api' gem 'claims_api', path: 'modules/claims_api' diff --git a/Gemfile.lock b/Gemfile.lock index fe0c51eeb3a..eae5ddd00bb 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -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) @@ -823,6 +825,7 @@ DEPENDENCIES rubocop-junit-formatter rubocop-rails rubocop-rspec + rubocop-thread_safety ruby-saml rubyzip (>= 1.3.0) savon From 0862d13f32c57b4a32336c126cdfd83354d0542e Mon Sep 17 00:00:00 2001 From: omgitsbillryan Date: Fri, 29 Nov 2019 12:03:52 -0500 Subject: [PATCH 2/6] use --auto-gen-config rubocop flag --- .rubocop.yml | 2 ++ .rubocop_todo.yml | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 .rubocop_todo.yml diff --git a/.rubocop.yml b/.rubocop.yml index 84322c1e6c7..9a61e9b6a0d 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,3 +1,5 @@ +inherit_from: .rubocop_todo.yml + require: - rubocop-rails - rubocop-rspec diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml new file mode 100644 index 00000000000..52937dc707d --- /dev/null +++ b/.rubocop_todo.yml @@ -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' From 374d5f2c124e1605e51dd90744844ced35bd79ba Mon Sep 17 00:00:00 2001 From: omgitsbillryan Date: Fri, 29 Nov 2019 12:05:19 -0500 Subject: [PATCH 3/6] move gem to :test :development group --- Gemfile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Gemfile b/Gemfile index 2c135eb59a1..40d2ec21da6 100644 --- a/Gemfile +++ b/Gemfile @@ -4,8 +4,6 @@ source 'https://rubygems.org' ruby '2.4.5' -gem 'rubocop-thread_safety' - # Modules gem 'appeals_api', path: 'modules/appeals_api' gem 'claims_api', path: 'modules/claims_api' @@ -158,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' From 36912d7e6bd4018a128e73b435877996effe243c Mon Sep 17 00:00:00 2001 From: omgitsbillryan Date: Mon, 2 Dec 2019 21:56:27 -0500 Subject: [PATCH 4/6] move thread checks to rake task --- .rubocop.yml | 1 - rakelib/lint.rake | 15 +++++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 9a61e9b6a0d..9404077ae47 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -3,7 +3,6 @@ inherit_from: .rubocop_todo.yml require: - rubocop-rails - rubocop-rspec - - rubocop-thread_safety AllCops: TargetRailsVersion: 5.2 diff --git a/rakelib/lint.rake b/rakelib/lint.rake index 8e79303c65d..a600826edf6 100644 --- a/rakelib/lint.rake +++ b/rakelib/lint.rake @@ -7,15 +7,18 @@ 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' + 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...' + byebug rubocop_result = ShellCommand.run("rubocop #{opts} --color") puts "\n" From a89de786a88c3b1fbe37abb73c25949760e6f70f Mon Sep 17 00:00:00 2001 From: omgitsbillryan Date: Mon, 2 Dec 2019 21:59:29 -0500 Subject: [PATCH 5/6] woops, remove byebug --- rakelib/lint.rake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rakelib/lint.rake b/rakelib/lint.rake index a600826edf6..5556bee9bde 100644 --- a/rakelib/lint.rake +++ b/rakelib/lint.rake @@ -18,7 +18,7 @@ task :lint do end puts 'running rubocop...' - byebug + rubocop_result = ShellCommand.run("rubocop #{opts} --color") puts "\n" From 9bdd81abee6300670d1cdbf4707b578a3d22d243 Mon Sep 17 00:00:00 2001 From: omgitsbillryan Date: Mon, 2 Dec 2019 22:04:57 -0500 Subject: [PATCH 6/6] fix lint issue --- rakelib/lint.rake | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/rakelib/lint.rake b/rakelib/lint.rake index 5556bee9bde..ace4e16773d 100644 --- a/rakelib/lint.rake +++ b/rakelib/lint.rake @@ -15,10 +15,9 @@ task :lint do --format clang" else '--display-cop-names --auto-correct' - end + end puts 'running rubocop...' - rubocop_result = ShellCommand.run("rubocop #{opts} --color") puts "\n"