rubocop-thread_safety 0.3.1 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: c5f5c22a96a3391f7f115be07f1188663a7a69ef
4
- data.tar.gz: 6452d077eacf1cb4ace91f7bbe4f885ad598dd5d
2
+ SHA256:
3
+ metadata.gz: d2f9c0ded508d65e482cd339fc6bafe4a843f19982884ea8c03aa0f6ceb1f4cd
4
+ data.tar.gz: bcfb88db93ee4c0bacdb1df6e60e72bdd044209ecd1c9c27fc8b8e8597f5eff9
5
5
  SHA512:
6
- metadata.gz: 96bf2dc90d94df8578ce8ab9bfa132f99dc373a1dd79350712a892ed20578d55bc2cc382d55c88105efa60f10f3eb7a84d3735b25d8a6fb33d3a2342a3d918c1
7
- data.tar.gz: eee8aa84da1d89cb330838909c774e1434f07277b8ec2b7e4c092efca9ffc7901ecb06bea670b6da888bd99f841d7b36ed65effe8c4ec0d1cad375019a95ebc3
6
+ metadata.gz: 81a037e33675b2aa5cf77bad8732b43e4b09bcbb0fc1127fe64eda0481516a20068e70f3afd32d4a69673729c8ce68422374b81ad7788a9de6bbe0ab9d4ae4bd
7
+ data.tar.gz: e6c0c3e2626e371eaf47b7fc144eb7659661d98184c47e2002d49a3f276e744f6ebc67c932fa361ff4379e536322d775579303b51e0dcf806907e9e712e61532
@@ -1,14 +1,20 @@
1
1
  AllCops:
2
2
  DisplayCopNames: true
3
- Include:
4
- - Gemfile
5
- - Rakefile
3
+
4
+ Metrics/BlockLength:
6
5
  Exclude:
7
- - vendor/**/*
6
+ - "spec/**/*"
7
+
8
+ Metrics/ClassLength:
9
+ Enabled: false
10
+
11
+ Metrics/MethodLength:
12
+ Max: 14
8
13
 
9
- Style/FileName:
14
+ Naming/FileName:
10
15
  Exclude:
11
16
  - lib/rubocop-thread_safety.rb
17
+ - rubocop-thread_safety.gemspec
12
18
 
13
19
  # Enable more cops that are disabled by default:
14
20
 
@@ -2,18 +2,14 @@ sudo: false
2
2
  cache: bundler
3
3
  language: ruby
4
4
  rvm:
5
- - 2.0.0
6
- - 2.1
7
- - 2.2
5
+ - jruby-9.1.14.0
8
6
  - 2.3.0
9
- - ruby-head
10
- - jruby-9.0.1.0
11
- - rbx-3
7
+ - 2.4
8
+ - 2.5
9
+ - 2.6
10
+ - 2.7
12
11
 
13
12
  matrix:
14
- allow_failures:
15
- - rvm: ruby-head
16
- - rvm: rbx-3
17
13
  fast_finish: true
18
14
 
19
15
  before_install: gem install --remote bundler
data/Gemfile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source 'https://rubygems.org'
2
4
 
3
5
  # Specify your gem's dependencies in rubocop-thread_safety.gemspec
@@ -0,0 +1,7 @@
1
+ Copyright 2016-2020 CoverMyMeds
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md CHANGED
@@ -32,7 +32,11 @@ Install the gem:
32
32
 
33
33
  Scan the application for just thread-safety issues:
34
34
 
35
- $ rubocop -r rubocop-thread_safety --only Threadsafety,Style/GlobalVars,Style/ClassVars,Style/MutableConstant
35
+ $ rubocop -r rubocop-thread_safety --only ThreadSafety,Style/GlobalVars,Style/ClassVars,Style/MutableConstant
36
+
37
+ ### Configuration
38
+
39
+ There are some added [configuration options](https://github.com/covermymeds/rubocop-thread_safety/blob/master/config/default.yml) that can be tweaked to modify the behaviour of these thread-safety cops.
36
40
 
37
41
  ## Development
38
42
 
@@ -44,3 +48,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
44
48
 
45
49
  Bug reports and pull requests are welcome on GitHub at https://github.com/covermymeds/rubocop-thread_safety.
46
50
 
51
+ ## Copyright
52
+
53
+ Copyright (c) 2016-2020 CoverMyMeds.
54
+ See [LICENSE.txt](LICENSE.txt) for further details.
data/Rakefile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'bundler/gem_tasks'
2
4
  require 'rspec/core/rake_task'
3
5
 
@@ -1,5 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
+ # frozen_string_literal: true
4
+
3
5
  require 'bundler/setup'
4
6
  require 'rubocop-thread_safety'
5
7
 
@@ -0,0 +1,30 @@
1
+ # Additional configuration for thread_safety cops
2
+ #
3
+ # Without adding these to your rubocop config, these values will be the default.
4
+
5
+ ThreadSafety/ClassAndModuleAttributes:
6
+ Description: 'Avoid mutating class and module attributes.'
7
+ Enabled: true
8
+
9
+ ThreadSafety/InstanceVariableInClassMethod:
10
+ Description: 'Avoid using instance variables in class methods.'
11
+ Enabled: true
12
+
13
+ ThreadSafety/MutableClassInstanceVariable:
14
+ Description: 'Do not assign mutable objects to class instance variables.'
15
+ Enabled: true
16
+ EnforcedStyle: literals
17
+ SupportedStyles:
18
+ # literals: freeze literals assigned to constants
19
+ # strict: freeze all constants
20
+ # Strict mode is considered an experimental feature. It has not been updated
21
+ # with an exhaustive list of all methods that will produce frozen objects so
22
+ # there is a decent chance of getting some false positives. Luckily, there is
23
+ # no harm in freezing an already frozen object.
24
+ - literals
25
+ - strict
26
+
27
+ ThreadSafety/NewThread:
28
+ Description: >-
29
+ Avoid starting new threads.
30
+ Let a framework like Sidekiq handle the threads.
@@ -1,7 +1,14 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'rubocop'
2
4
 
5
+ require 'rubocop/thread_safety'
3
6
  require 'rubocop/thread_safety/version'
7
+ require 'rubocop/thread_safety/inject'
8
+
9
+ RuboCop::ThreadSafety::Inject.defaults!
4
10
 
5
11
  require 'rubocop/cop/thread_safety/instance_variable_in_class_method'
6
12
  require 'rubocop/cop/thread_safety/class_and_module_attributes'
13
+ require 'rubocop/cop/thread_safety/mutable_class_instance_variable'
7
14
  require 'rubocop/cop/thread_safety/new_thread'
@@ -1,4 +1,3 @@
1
- # encoding: utf-8
2
1
  # frozen_string_literal: true
3
2
 
4
3
  module RuboCop
@@ -14,29 +13,44 @@ module RuboCop
14
13
  # cattr_accessor :current_user
15
14
  # end
16
15
  class ClassAndModuleAttributes < Cop
17
- MSG = 'Avoid mutating class and module attributes.'.freeze
16
+ MSG = 'Avoid mutating class and module attributes.'
18
17
 
19
- def_node_matcher :mattr?, <<-END
20
- (send nil
18
+ def_node_matcher :mattr?, <<-MATCHER
19
+ (send nil?
21
20
  {:mattr_writer :mattr_accessor :cattr_writer :cattr_accessor}
22
21
  ...)
23
- END
22
+ MATCHER
24
23
 
25
- def_node_matcher :attr?, <<-END
26
- (send nil
24
+ def_node_matcher :attr?, <<-MATCHER
25
+ (send nil?
27
26
  {:attr :attr_accessor :attr_writer}
28
27
  ...)
29
- END
28
+ MATCHER
29
+
30
+ def_node_matcher :attr_internal?, <<-MATCHER
31
+ (send nil?
32
+ {:attr_internal :attr_internal_accessor :attr_internal_writer}
33
+ ...)
34
+ MATCHER
35
+
36
+ def_node_matcher :class_attr?, <<-MATCHER
37
+ (send nil?
38
+ :class_attribute
39
+ ...)
40
+ MATCHER
30
41
 
31
42
  def on_send(node)
32
- return unless mattr?(node) || singleton_attr?(node)
33
- add_offense(node, :expression, format(MSG, node.source))
43
+ return unless mattr?(node) || class_attr?(node) ||
44
+ singleton_attr?(node)
45
+
46
+ add_offense(node, message: MSG)
34
47
  end
35
48
 
36
49
  private
37
50
 
38
51
  def singleton_attr?(node)
39
- attr?(node) && node.ancestors.map(&:type).include?(:sclass)
52
+ (attr?(node) || attr_internal?(node)) &&
53
+ node.ancestors.map(&:type).include?(:sclass)
40
54
  end
41
55
  end
42
56
  end
@@ -1,4 +1,3 @@
1
- # encoding: utf-8
2
1
  # frozen_string_literal: true
3
2
 
4
3
  module RuboCop
@@ -14,17 +13,49 @@ module RuboCop
14
13
  # Notifier.new(@info).deliver
15
14
  # end
16
15
  # end
16
+ #
17
+ # class Model
18
+ # class << self
19
+ # def table_name(name)
20
+ # @table_name = name
21
+ # end
22
+ # end
23
+ # end
24
+ #
25
+ # class Host
26
+ # %i[uri port].each do |key|
27
+ # define_singleton_method("#{key}=") do |value|
28
+ # instance_variable_set("@#{key}", value)
29
+ # end
30
+ # end
31
+ # end
17
32
  class InstanceVariableInClassMethod < Cop
18
- MSG = 'Avoid instance variables in class methods.'.freeze
33
+ MSG = 'Avoid instance variables in class methods.'
34
+
35
+ def_node_matcher :instance_variable_set_call?, <<-MATCHER
36
+ (send nil? :instance_variable_set (...) (...))
37
+ MATCHER
38
+
39
+ def_node_matcher :instance_variable_get_call?, <<-MATCHER
40
+ (send nil? :instance_variable_get (...))
41
+ MATCHER
19
42
 
20
43
  def on_ivar(node)
21
44
  return unless class_method_definition?(node)
22
45
  return if synchronized?(node)
23
46
 
24
- add_offense(node, :name, MSG)
47
+ add_offense(node, location: :name, message: MSG)
25
48
  end
26
49
  alias on_ivasgn on_ivar
27
50
 
51
+ def on_send(node)
52
+ return unless instance_variable_call?(node)
53
+ return unless class_method_definition?(node)
54
+ return if synchronized?(node)
55
+
56
+ add_offense(node, message: MSG)
57
+ end
58
+
28
59
  private
29
60
 
30
61
  def class_method_definition?(node)
@@ -44,14 +75,15 @@ module RuboCop
44
75
  ancestor.type == :def
45
76
  end
46
77
 
47
- defn && defn.ancestors.any? do |ancestor|
78
+ defn&.ancestors&.any? do |ancestor|
48
79
  ancestor.type == :sclass
49
80
  end
50
81
  end
51
82
 
52
83
  def singleton_method_definition?(node)
53
84
  node.ancestors.any? do |ancestor|
54
- next unless ancestor.children.first.is_a? Node
85
+ next unless ancestor.children.first.is_a? AST::SendNode
86
+
55
87
  ancestor.children.first.command? :define_singleton_method
56
88
  end
57
89
  end
@@ -59,10 +91,15 @@ module RuboCop
59
91
  def synchronized?(node)
60
92
  node.ancestors.find do |ancestor|
61
93
  next unless ancestor.block_type?
94
+
62
95
  s = ancestor.children.first
63
96
  s.send_type? && s.children.last == :synchronize
64
97
  end
65
98
  end
99
+
100
+ def instance_variable_call?(node)
101
+ instance_variable_set_call?(node) || instance_variable_get_call?(node)
102
+ end
66
103
  end
67
104
  end
68
105
  end
@@ -0,0 +1,227 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RuboCop
4
+ module Cop
5
+ module ThreadSafety
6
+ # This cop checks whether some class instance variable isn't a
7
+ # mutable literal (e.g. array or hash).
8
+ #
9
+ # It is based on Style/MutableConstant from RuboCop.
10
+ # See https://github.com/rubocop-hq/rubocop/blob/master/lib/rubocop/cop/style/mutable_constant.rb
11
+ #
12
+ # Class instance variables are a risk to threaded code as they are shared
13
+ # between threads. A mutable object such as an array or hash may be
14
+ # updated via an attr_reader so would not be detected by the
15
+ # ThreadSafety/ClassAndModuleAttributes cop.
16
+ #
17
+ # Strict mode can be used to freeze all class instance variables, rather
18
+ # than just literals.
19
+ # Strict mode is considered an experimental feature. It has not been
20
+ # updated with an exhaustive list of all methods that will produce frozen
21
+ # objects so there is a decent chance of getting some false positives.
22
+ # Luckily, there is no harm in freezing an already frozen object.
23
+ #
24
+ # @example EnforcedStyle: literals (default)
25
+ # # bad
26
+ # class Model
27
+ # @list = [1, 2, 3]
28
+ # end
29
+ #
30
+ # # good
31
+ # class Model
32
+ # @list = [1, 2, 3].freeze
33
+ # end
34
+ #
35
+ # # good
36
+ # class Model
37
+ # @var = <<-TESTING.freeze
38
+ # This is a heredoc
39
+ # TESTING
40
+ # end
41
+ #
42
+ # # good
43
+ # class Model
44
+ # @var = Something.new
45
+ # end
46
+ #
47
+ # @example EnforcedStyle: strict
48
+ # # bad
49
+ # class Model
50
+ # @var = Something.new
51
+ # end
52
+ #
53
+ # # bad
54
+ # class Model
55
+ # @var = Struct.new do
56
+ # def foo
57
+ # puts 1
58
+ # end
59
+ # end
60
+ # end
61
+ #
62
+ # # good
63
+ # class Model
64
+ # @var = Something.new.freeze
65
+ # end
66
+ #
67
+ # # good
68
+ # class Model
69
+ # @var = Struct.new do
70
+ # def foo
71
+ # puts 1
72
+ # end
73
+ # end.freeze
74
+ # end
75
+ class MutableClassInstanceVariable < Cop
76
+ include FrozenStringLiteral
77
+ include ConfigurableEnforcedStyle
78
+
79
+ MSG = 'Freeze mutable objects assigned to class instance variables.'
80
+
81
+ def on_ivasgn(node)
82
+ return unless in_class?(node)
83
+
84
+ _, value = *node
85
+ on_assignment(value)
86
+ end
87
+
88
+ def on_or_asgn(node)
89
+ lhs, value = *node
90
+ return unless lhs&.ivasgn_type?
91
+ return unless in_class?(node)
92
+
93
+ on_assignment(value)
94
+ end
95
+
96
+ def on_masgn(node)
97
+ return unless in_class?(node)
98
+
99
+ mlhs, values = *node
100
+ return unless values.array_type?
101
+
102
+ mlhs.to_a.zip(values.to_a).each do |lhs, value|
103
+ next unless lhs.ivasgn_type?
104
+
105
+ on_assignment(value)
106
+ end
107
+ end
108
+
109
+ def autocorrect(node)
110
+ expr = node.source_range
111
+
112
+ lambda do |corrector|
113
+ splat_value = splat_value(node)
114
+ if splat_value
115
+ correct_splat_expansion(corrector, expr, splat_value)
116
+ elsif node.array_type? && !node.bracketed?
117
+ corrector.insert_before(expr, '[')
118
+ corrector.insert_after(expr, ']')
119
+ elsif requires_parentheses?(node)
120
+ corrector.insert_before(expr, '(')
121
+ corrector.insert_after(expr, ')')
122
+ end
123
+
124
+ corrector.insert_after(expr, '.freeze')
125
+ end
126
+ end
127
+
128
+ private
129
+
130
+ def on_assignment(value)
131
+ if style == :strict
132
+ strict_check(value)
133
+ else
134
+ check(value)
135
+ end
136
+ end
137
+
138
+ def strict_check(value)
139
+ return if immutable_literal?(value)
140
+ return if operation_produces_immutable_object?(value)
141
+ return if frozen_string_literal?(value)
142
+
143
+ add_offense(value)
144
+ end
145
+
146
+ def check(value)
147
+ return unless mutable_literal?(value) ||
148
+ range_enclosed_in_parentheses?(value)
149
+ return if frozen_string_literal?(value)
150
+
151
+ add_offense(value)
152
+ end
153
+
154
+ def in_class?(node)
155
+ container = node.ancestors.find do |ancestor|
156
+ container?(ancestor)
157
+ end
158
+ return false if container.nil?
159
+
160
+ %i[class module].include?(container.type)
161
+ end
162
+
163
+ def container?(node)
164
+ return true if define_singleton_method?(node)
165
+
166
+ %i[def defs class module].include?(node.type)
167
+ end
168
+
169
+ def mutable_literal?(node)
170
+ node&.mutable_literal?
171
+ end
172
+
173
+ def immutable_literal?(node)
174
+ node.nil? || node.immutable_literal?
175
+ end
176
+
177
+ def frozen_string_literal?(node)
178
+ FROZEN_STRING_LITERAL_TYPES.include?(node.type) &&
179
+ frozen_string_literals_enabled?
180
+ end
181
+
182
+ def requires_parentheses?(node)
183
+ node.range_type? ||
184
+ (node.send_type? && node.loc.dot.nil?)
185
+ end
186
+
187
+ def correct_splat_expansion(corrector, expr, splat_value)
188
+ if range_enclosed_in_parentheses?(splat_value)
189
+ corrector.replace(expr, "#{splat_value.source}.to_a")
190
+ else
191
+ corrector.replace(expr, "(#{splat_value.source}).to_a")
192
+ end
193
+ end
194
+
195
+ def_node_matcher :define_singleton_method?, <<-PATTERN
196
+ (block (send nil? :define_singleton_method ...) ...)
197
+ PATTERN
198
+
199
+ def_node_matcher :splat_value, <<-PATTERN
200
+ (array (splat $_))
201
+ PATTERN
202
+
203
+ # NOTE: Some of these patterns may not actually return an immutable
204
+ # object but we will consider them immutable for this cop.
205
+ def_node_matcher :operation_produces_immutable_object?, <<-PATTERN
206
+ {
207
+ (const _ _)
208
+ (send (const nil? :Struct) :new ...)
209
+ (block (send (const nil? :Struct) :new ...) ...)
210
+ (send _ :freeze)
211
+ (send {float int} {:+ :- :* :** :/ :% :<<} _)
212
+ (send _ {:+ :- :* :** :/ :%} {float int})
213
+ (send _ {:== :=== :!= :<= :>= :< :>} _)
214
+ (send (const nil? :ENV) :[] _)
215
+ (or (send (const nil? :ENV) :[] _) _)
216
+ (send _ {:count :length :size} ...)
217
+ (block (send _ {:count :length :size} ...) ...)
218
+ }
219
+ PATTERN
220
+
221
+ def_node_matcher :range_enclosed_in_parentheses?, <<-PATTERN
222
+ (begin ({irange erange} _ _))
223
+ PATTERN
224
+ end
225
+ end
226
+ end
227
+ end
@@ -1,4 +1,3 @@
1
- # encoding: utf-8
2
1
  # frozen_string_literal: true
3
2
 
4
3
  module RuboCop
@@ -12,15 +11,16 @@ module RuboCop
12
11
  # # bad
13
12
  # Thread.new { do_work }
14
13
  class NewThread < Cop
15
- MSG = 'Avoid starting new threads.'.freeze
14
+ MSG = 'Avoid starting new threads.'
16
15
 
17
- def_node_matcher :new_thread?, <<-END
18
- (send (const nil :Thread) :new)
19
- END
16
+ def_node_matcher :new_thread?, <<-MATCHER
17
+ (send (const nil? :Thread) :new)
18
+ MATCHER
20
19
 
21
20
  def on_send(node)
22
21
  return unless new_thread?(node)
23
- add_offense(node, :expression, format(MSG, node.source))
22
+
23
+ add_offense(node, message: MSG)
24
24
  end
25
25
  end
26
26
  end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RuboCop
4
+ # RuboCop::ThreadSafety detects some potential thread safety issues.
5
+ module ThreadSafety
6
+ PROJECT_ROOT = Pathname.new(File.expand_path('../../', __dir__))
7
+ CONFIG_DEFAULT = PROJECT_ROOT.join('config', 'default.yml').freeze
8
+ CONFIG = YAML.safe_load(CONFIG_DEFAULT.read).freeze
9
+
10
+ private_constant(:CONFIG_DEFAULT, :PROJECT_ROOT)
11
+ end
12
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ # The original code is from https://github.com/rubocop-hq/rubocop-rspec/blob/master/lib/rubocop/rspec/inject.rb
4
+ # See https://github.com/rubocop-hq/rubocop-rspec/blob/master/MIT_LICENSE.md
5
+ module RuboCop
6
+ module ThreadSafety
7
+ # Because RuboCop doesn't yet support plugins, we have to monkey patch in a
8
+ # bit of our configuration.
9
+ module Inject
10
+ def self.defaults!
11
+ path = CONFIG_DEFAULT.to_s
12
+ hash = ConfigLoader.__send__(:load_yaml_configuration, path)
13
+ config = Config.new(hash, path).tap(&:make_excludes_absolute)
14
+ puts "configuration from \#{path}" if ConfigLoader.debug?
15
+ config = ConfigLoader.merge_with_default(config, path)
16
+ ConfigLoader.instance_variable_set(:@default_configuration, config)
17
+ end
18
+ end
19
+ end
20
+ end
@@ -1,5 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module RuboCop
2
4
  module ThreadSafety
3
- VERSION = '0.3.1'.freeze
5
+ VERSION = '0.4.1'
4
6
  end
5
7
  end
@@ -1,5 +1,6 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
1
+ # frozen_string_literal: true
2
+
3
+ lib = File.expand_path('lib', __dir__)
3
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
5
  require 'rubocop/thread_safety/version'
5
6
 
@@ -10,21 +11,26 @@ Gem::Specification.new do |spec|
10
11
  spec.email = ['michaelpgee@gmail.com']
11
12
 
12
13
  spec.summary = 'Thread-safety checks via static analysis'
13
- spec.description = <<-end_description
14
+ spec.description = <<-DESCRIPTION
14
15
  Thread-safety checks via static analysis.
15
16
  A plugin for the RuboCop code style enforcing & linting tool.
16
- end_description
17
- spec.homepage = 'https://github.com/covermymeds/rubocop-thread_safety'
17
+ DESCRIPTION
18
+ spec.homepage = 'https://github.com/covermymeds/rubocop-thread_safety'
19
+ spec.licenses = ['MIT']
20
+
21
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
22
+ f.match(%r{^(test|spec|features)/})
23
+ end
18
24
 
19
- spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
20
25
  spec.bindir = 'exe'
21
26
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
27
  spec.require_paths = ['lib']
23
28
 
24
- spec.add_runtime_dependency 'rubocop', '>= 0.41.1'
29
+ spec.add_runtime_dependency 'rubocop', '>= 0.51.0'
25
30
 
26
- spec.add_development_dependency 'bundler', '~> 1.10'
27
- spec.add_development_dependency 'rake', '~> 10.0'
28
- spec.add_development_dependency 'rspec', '~> 3.0'
31
+ spec.add_development_dependency 'bundler', '>= 1.10', '< 3'
32
+ spec.add_development_dependency 'powerpack', '~> 0.1'
29
33
  spec.add_development_dependency 'pry' unless ENV['CI']
34
+ spec.add_development_dependency 'rake', '>= 10.0'
35
+ spec.add_development_dependency 'rspec', '~> 3.0'
30
36
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubocop-thread_safety
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Gee
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-10-01 00:00:00.000000000 Z
11
+ date: 2020-06-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubocop
@@ -16,70 +16,90 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 0.41.1
19
+ version: 0.51.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: 0.41.1
26
+ version: 0.51.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '1.10'
34
+ - - "<"
35
+ - !ruby/object:Gem::Version
36
+ version: '3'
34
37
  type: :development
35
38
  prerelease: false
36
39
  version_requirements: !ruby/object:Gem::Requirement
37
40
  requirements:
38
- - - "~>"
41
+ - - ">="
39
42
  - !ruby/object:Gem::Version
40
43
  version: '1.10'
44
+ - - "<"
45
+ - !ruby/object:Gem::Version
46
+ version: '3'
41
47
  - !ruby/object:Gem::Dependency
42
- name: rake
48
+ name: powerpack
43
49
  requirement: !ruby/object:Gem::Requirement
44
50
  requirements:
45
51
  - - "~>"
46
52
  - !ruby/object:Gem::Version
47
- version: '10.0'
53
+ version: '0.1'
48
54
  type: :development
49
55
  prerelease: false
50
56
  version_requirements: !ruby/object:Gem::Requirement
51
57
  requirements:
52
58
  - - "~>"
53
59
  - !ruby/object:Gem::Version
54
- version: '10.0'
60
+ version: '0.1'
55
61
  - !ruby/object:Gem::Dependency
56
- name: rspec
62
+ name: pry
57
63
  requirement: !ruby/object:Gem::Requirement
58
64
  requirements:
59
- - - "~>"
65
+ - - ">="
60
66
  - !ruby/object:Gem::Version
61
- version: '3.0'
67
+ version: '0'
62
68
  type: :development
63
69
  prerelease: false
64
70
  version_requirements: !ruby/object:Gem::Requirement
65
71
  requirements:
66
- - - "~>"
72
+ - - ">="
67
73
  - !ruby/object:Gem::Version
68
- version: '3.0'
74
+ version: '0'
69
75
  - !ruby/object:Gem::Dependency
70
- name: pry
76
+ name: rake
71
77
  requirement: !ruby/object:Gem::Requirement
72
78
  requirements:
73
79
  - - ">="
74
80
  - !ruby/object:Gem::Version
75
- version: '0'
81
+ version: '10.0'
76
82
  type: :development
77
83
  prerelease: false
78
84
  version_requirements: !ruby/object:Gem::Requirement
79
85
  requirements:
80
86
  - - ">="
81
87
  - !ruby/object:Gem::Version
82
- version: '0'
88
+ version: '10.0'
89
+ - !ruby/object:Gem::Dependency
90
+ name: rspec
91
+ requirement: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - "~>"
94
+ - !ruby/object:Gem::Version
95
+ version: '3.0'
96
+ type: :development
97
+ prerelease: false
98
+ version_requirements: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - "~>"
101
+ - !ruby/object:Gem::Version
102
+ version: '3.0'
83
103
  description: |2
84
104
  Thread-safety checks via static analysis.
85
105
  A plugin for the RuboCop code style enforcing & linting tool.
@@ -94,18 +114,24 @@ files:
94
114
  - ".rubocop.yml"
95
115
  - ".travis.yml"
96
116
  - Gemfile
117
+ - LICENSE.txt
97
118
  - README.md
98
119
  - Rakefile
99
120
  - bin/console
100
121
  - bin/setup
122
+ - config/default.yml
101
123
  - lib/rubocop-thread_safety.rb
102
124
  - lib/rubocop/cop/thread_safety/class_and_module_attributes.rb
103
125
  - lib/rubocop/cop/thread_safety/instance_variable_in_class_method.rb
126
+ - lib/rubocop/cop/thread_safety/mutable_class_instance_variable.rb
104
127
  - lib/rubocop/cop/thread_safety/new_thread.rb
128
+ - lib/rubocop/thread_safety.rb
129
+ - lib/rubocop/thread_safety/inject.rb
105
130
  - lib/rubocop/thread_safety/version.rb
106
131
  - rubocop-thread_safety.gemspec
107
132
  homepage: https://github.com/covermymeds/rubocop-thread_safety
108
- licenses: []
133
+ licenses:
134
+ - MIT
109
135
  metadata: {}
110
136
  post_install_message:
111
137
  rdoc_options: []
@@ -122,10 +148,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
122
148
  - !ruby/object:Gem::Version
123
149
  version: '0'
124
150
  requirements: []
125
- rubyforge_project:
126
- rubygems_version: 2.4.8
151
+ rubygems_version: 3.0.3
127
152
  signing_key:
128
153
  specification_version: 4
129
154
  summary: Thread-safety checks via static analysis
130
155
  test_files: []
131
- has_rdoc: