rubocop-thread_safety 0.3.0 → 0.4.0

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: 88d48cd3238f82a82b8fb0a8a29543e111ff34f5
4
- data.tar.gz: 2a150df94ee24d94dc9173fa13837bcd82044590
2
+ SHA256:
3
+ metadata.gz: 33c8f2c01aa5f51c5ae09093a3ebb895a764330600ef32c05995836891cc1bd2
4
+ data.tar.gz: 5d4bc3124aff9203407cb61b000564084962e0ad18d72fff954d0994eb944276
5
5
  SHA512:
6
- metadata.gz: 13c4f7b7cb97c02a1cd0e7cb33bb87453ee3b3e5e9bb826c936f2f266c7536ce3ce4234e6c6dd50bc742089604efbe8c7fcc77a21cb9bcda712fb78533e24fb3
7
- data.tar.gz: bdb1ec4b1c42ec44f29c272a0cfaf27226d2b961822eeb64eb2462be22d537b9fb8329dd6045ec7619414a4da7bc012cdd81afdb3f398e58f7a78359d5ac601e
6
+ metadata.gz: 130074abe1ba664fad05877bf2f215ed6965a8da36a92ba8865d05305c1f3661d9f2acfe67836620446c43bee81b3819111c764f37cbe2506474de3b0597de87
7
+ data.tar.gz: ed769cdad040ba59dba88a68af2cadbf04e3eaedd1c389261050cd0917ec4a629b775798c20d3e893650796deea250dc01c80c05a32d5c2c19151fd9d88667d0
@@ -1,14 +1,14 @@
1
1
  AllCops:
2
2
  DisplayCopNames: true
3
- Include:
4
- - Gemfile
5
- - Rakefile
3
+
4
+ Metrics/BlockLength:
6
5
  Exclude:
7
- - vendor/**/*
6
+ - "spec/**/*"
8
7
 
9
- Style/FileName:
8
+ Naming/FileName:
10
9
  Exclude:
11
10
  - lib/rubocop-thread_safety.rb
11
+ - rubocop-thread_safety.gemspec
12
12
 
13
13
  # Enable more cops that are disabled by default:
14
14
 
@@ -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,7 @@ 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
36
 
37
37
  ## Development
38
38
 
@@ -44,3 +44,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
44
44
 
45
45
  Bug reports and pull requests are welcome on GitHub at https://github.com/covermymeds/rubocop-thread_safety.
46
46
 
47
+ ## Copyright
48
+
49
+ Copyright (c) 2016-2020 CoverMyMeds.
50
+ 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
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'rubocop'
2
4
 
3
5
  require 'rubocop/thread_safety/version'
@@ -1,4 +1,3 @@
1
- # encoding: utf-8
2
1
  # frozen_string_literal: true
3
2
 
4
3
  module RuboCop
@@ -14,23 +13,24 @@ 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
30
29
 
31
30
  def on_send(node)
32
31
  return unless mattr?(node) || singleton_attr?(node)
33
- add_offense(node, :expression, format(MSG, node.source))
32
+
33
+ add_offense(node, message: MSG)
34
34
  end
35
35
 
36
36
  private
@@ -1,4 +1,3 @@
1
- # encoding: utf-8
2
1
  # frozen_string_literal: true
3
2
 
4
3
  module RuboCop
@@ -15,13 +14,13 @@ module RuboCop
15
14
  # end
16
15
  # end
17
16
  class InstanceVariableInClassMethod < Cop
18
- MSG = 'Avoid instance variables in class methods.'.freeze
17
+ MSG = 'Avoid instance variables in class methods.'
19
18
 
20
19
  def on_ivar(node)
21
20
  return unless class_method_definition?(node)
22
21
  return if synchronized?(node)
23
22
 
24
- add_offense(node, :name, MSG)
23
+ add_offense(node, location: :name, message: MSG)
25
24
  end
26
25
  alias on_ivasgn on_ivar
27
26
 
@@ -44,23 +43,26 @@ module RuboCop
44
43
  ancestor.type == :def
45
44
  end
46
45
 
47
- defn && defn.ancestors.any? do |ancestor|
46
+ defn&.ancestors&.any? do |ancestor|
48
47
  ancestor.type == :sclass
49
48
  end
50
49
  end
51
50
 
52
51
  def singleton_method_definition?(node)
53
52
  node.ancestors.any? do |ancestor|
54
- next unless ancestor.children.first.is_a? Node
53
+ next unless ancestor.children.first.is_a? AST::SendNode
54
+
55
55
  ancestor.children.first.command? :define_singleton_method
56
56
  end
57
57
  end
58
58
 
59
59
  def synchronized?(node)
60
- p = node.parent
61
- return false unless p.block_type?
62
- s = p.children.first
63
- s.send_type? && s.children.last == :synchronize
60
+ node.ancestors.find do |ancestor|
61
+ next unless ancestor.block_type?
62
+
63
+ s = ancestor.children.first
64
+ s.send_type? && s.children.last == :synchronize
65
+ end
64
66
  end
65
67
  end
66
68
  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
@@ -1,5 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module RuboCop
2
4
  module ThreadSafety
3
- VERSION = '0.3.0'.freeze
5
+ VERSION = '0.4.0'
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.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: 2016-10-01 00:00:00.000000000 Z
11
+ date: 2020-06-22 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,6 +114,7 @@ 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
@@ -105,7 +126,8 @@ files:
105
126
  - lib/rubocop/thread_safety/version.rb
106
127
  - rubocop-thread_safety.gemspec
107
128
  homepage: https://github.com/covermymeds/rubocop-thread_safety
108
- licenses: []
129
+ licenses:
130
+ - MIT
109
131
  metadata: {}
110
132
  post_install_message:
111
133
  rdoc_options: []
@@ -122,10 +144,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
122
144
  - !ruby/object:Gem::Version
123
145
  version: '0'
124
146
  requirements: []
125
- rubyforge_project:
126
- rubygems_version: 2.4.8
147
+ rubygems_version: 3.0.3
127
148
  signing_key:
128
149
  specification_version: 4
129
150
  summary: Thread-safety checks via static analysis
130
151
  test_files: []
131
- has_rdoc: