rubocop-thread_safety 0.3.4 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.rubocop.yml +0 -5
- data/.travis.yml +3 -2
- data/Gemfile +2 -0
- data/LICENSE.txt +1 -1
- data/README.md +1 -1
- data/Rakefile +2 -0
- data/bin/console +2 -0
- data/lib/rubocop-thread_safety.rb +2 -0
- data/lib/rubocop/cop/thread_safety/class_and_module_attributes.rb +2 -1
- data/lib/rubocop/cop/thread_safety/instance_variable_in_class_method.rb +4 -2
- data/lib/rubocop/cop/thread_safety/new_thread.rb +2 -1
- data/lib/rubocop/thread_safety/version.rb +3 -1
- data/rubocop-thread_safety.gemspec +6 -3
- metadata +27 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 33c8f2c01aa5f51c5ae09093a3ebb895a764330600ef32c05995836891cc1bd2
|
4
|
+
data.tar.gz: 5d4bc3124aff9203407cb61b000564084962e0ad18d72fff954d0994eb944276
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 130074abe1ba664fad05877bf2f215ed6965a8da36a92ba8865d05305c1f3661d9f2acfe67836620446c43bee81b3819111c764f37cbe2506474de3b0597de87
|
7
|
+
data.tar.gz: ed769cdad040ba59dba88a68af2cadbf04e3eaedd1c389261050cd0917ec4a629b775798c20d3e893650796deea250dc01c80c05a32d5c2c19151fd9d88667d0
|
data/.rubocop.yml
CHANGED
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
data/LICENSE.txt
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
Copyright 2016-
|
1
|
+
Copyright 2016-2020 CoverMyMeds
|
2
2
|
|
3
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
4
|
|
data/README.md
CHANGED
data/Rakefile
CHANGED
data/bin/console
CHANGED
@@ -13,7 +13,7 @@ module RuboCop
|
|
13
13
|
# cattr_accessor :current_user
|
14
14
|
# end
|
15
15
|
class ClassAndModuleAttributes < Cop
|
16
|
-
MSG = 'Avoid mutating class and module attributes.'
|
16
|
+
MSG = 'Avoid mutating class and module attributes.'
|
17
17
|
|
18
18
|
def_node_matcher :mattr?, <<-MATCHER
|
19
19
|
(send nil?
|
@@ -29,6 +29,7 @@ module RuboCop
|
|
29
29
|
|
30
30
|
def on_send(node)
|
31
31
|
return unless mattr?(node) || singleton_attr?(node)
|
32
|
+
|
32
33
|
add_offense(node, message: MSG)
|
33
34
|
end
|
34
35
|
|
@@ -14,7 +14,7 @@ module RuboCop
|
|
14
14
|
# end
|
15
15
|
# end
|
16
16
|
class InstanceVariableInClassMethod < Cop
|
17
|
-
MSG = 'Avoid instance variables in class methods.'
|
17
|
+
MSG = 'Avoid instance variables in class methods.'
|
18
18
|
|
19
19
|
def on_ivar(node)
|
20
20
|
return unless class_method_definition?(node)
|
@@ -43,7 +43,7 @@ module RuboCop
|
|
43
43
|
ancestor.type == :def
|
44
44
|
end
|
45
45
|
|
46
|
-
defn
|
46
|
+
defn&.ancestors&.any? do |ancestor|
|
47
47
|
ancestor.type == :sclass
|
48
48
|
end
|
49
49
|
end
|
@@ -51,6 +51,7 @@ module RuboCop
|
|
51
51
|
def singleton_method_definition?(node)
|
52
52
|
node.ancestors.any? do |ancestor|
|
53
53
|
next unless ancestor.children.first.is_a? AST::SendNode
|
54
|
+
|
54
55
|
ancestor.children.first.command? :define_singleton_method
|
55
56
|
end
|
56
57
|
end
|
@@ -58,6 +59,7 @@ module RuboCop
|
|
58
59
|
def synchronized?(node)
|
59
60
|
node.ancestors.find do |ancestor|
|
60
61
|
next unless ancestor.block_type?
|
62
|
+
|
61
63
|
s = ancestor.children.first
|
62
64
|
s.send_type? && s.children.last == :synchronize
|
63
65
|
end
|
@@ -11,7 +11,7 @@ module RuboCop
|
|
11
11
|
# # bad
|
12
12
|
# Thread.new { do_work }
|
13
13
|
class NewThread < Cop
|
14
|
-
MSG = 'Avoid starting new threads.'
|
14
|
+
MSG = 'Avoid starting new threads.'
|
15
15
|
|
16
16
|
def_node_matcher :new_thread?, <<-MATCHER
|
17
17
|
(send (const nil? :Thread) :new)
|
@@ -19,6 +19,7 @@ module RuboCop
|
|
19
19
|
|
20
20
|
def on_send(node)
|
21
21
|
return unless new_thread?(node)
|
22
|
+
|
22
23
|
add_offense(node, message: MSG)
|
23
24
|
end
|
24
25
|
end
|
@@ -1,4 +1,6 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
lib = File.expand_path('lib', __dir__)
|
2
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
5
|
require 'rubocop/thread_safety/version'
|
4
6
|
|
@@ -26,8 +28,9 @@ Gem::Specification.new do |spec|
|
|
26
28
|
|
27
29
|
spec.add_runtime_dependency 'rubocop', '>= 0.51.0'
|
28
30
|
|
29
|
-
spec.add_development_dependency 'bundler', '
|
31
|
+
spec.add_development_dependency 'bundler', '>= 1.10', '< 3'
|
32
|
+
spec.add_development_dependency 'powerpack', '~> 0.1'
|
30
33
|
spec.add_development_dependency 'pry' unless ENV['CI']
|
31
|
-
spec.add_development_dependency 'rake', '
|
34
|
+
spec.add_development_dependency 'rake', '>= 10.0'
|
32
35
|
spec.add_development_dependency 'rspec', '~> 3.0'
|
33
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.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Gee
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-06-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubocop
|
@@ -28,16 +28,36 @@ dependencies:
|
|
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'
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: powerpack
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - "~>"
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0.1'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - "~>"
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '0.1'
|
41
61
|
- !ruby/object:Gem::Dependency
|
42
62
|
name: pry
|
43
63
|
requirement: !ruby/object:Gem::Requirement
|
@@ -56,14 +76,14 @@ dependencies:
|
|
56
76
|
name: rake
|
57
77
|
requirement: !ruby/object:Gem::Requirement
|
58
78
|
requirements:
|
59
|
-
- - "
|
79
|
+
- - ">="
|
60
80
|
- !ruby/object:Gem::Version
|
61
81
|
version: '10.0'
|
62
82
|
type: :development
|
63
83
|
prerelease: false
|
64
84
|
version_requirements: !ruby/object:Gem::Requirement
|
65
85
|
requirements:
|
66
|
-
- - "
|
86
|
+
- - ">="
|
67
87
|
- !ruby/object:Gem::Version
|
68
88
|
version: '10.0'
|
69
89
|
- !ruby/object:Gem::Dependency
|
@@ -124,8 +144,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
124
144
|
- !ruby/object:Gem::Version
|
125
145
|
version: '0'
|
126
146
|
requirements: []
|
127
|
-
|
128
|
-
rubygems_version: 2.6.8
|
147
|
+
rubygems_version: 3.0.3
|
129
148
|
signing_key:
|
130
149
|
specification_version: 4
|
131
150
|
summary: Thread-safety checks via static analysis
|