salsify_rubocop 0.91.0 → 1.0.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
2
  SHA256:
3
- metadata.gz: b7075a3184d398f5ed45dc726da7a289323eb1839dd7ecb78fe614b242b6798f
4
- data.tar.gz: 70c2dfb69a48fa75e58a218e8cea848fc477dfbfd22fc50adefbac86589132f3
3
+ metadata.gz: 2056598e677c6cf0b213308613d5ab676b7eee1e97dd93534321a75ba341e2b9
4
+ data.tar.gz: f0053c47716a510ef4ef57c5e90465e2309a0573ab5944d92b23a42cd154ab2c
5
5
  SHA512:
6
- metadata.gz: ddcd5e8975a9d35a5b5efe66e5e90d1ca4645aebca2d6b70e8084c6dda8fac05b36c27f557aebdc45fabe6458215a6bab4c06dc4acd8935a02017dc22a2131cb
7
- data.tar.gz: 33e382909c34f89e5ba8f14ea1a03bb443df82fad6d2e80905d1faf7ef8950692a85e768dfa2a8bcc8bc7ef7ceac21e500c00675939ff481a5ed31dc8751f158
6
+ metadata.gz: fe21f0ff75e19ef071efe283cce27a01cde095fe4918d3ef7eb10bddff6d9ca476b8b4a4263b92f871c55ec7434283b9a6812400e546012c8c3d11cb0d280b73
7
+ data.tar.gz: 339fc5ad332c3602d2d73106f76c6d26fc9103c398b6bee9059971b1ac97dcbbe930b7ce731d21cda5794d9fdd53f04454d6c203ba8ffe6e7dc6b67695971062
@@ -1,5 +1,15 @@
1
1
  # salsify_rubocop
2
2
 
3
+ ## 1.0.0
4
+
5
+ - Upgrade to `rubocop` v1.0.0
6
+ - Upgrade to `rubocop-rspec` v2.0.0
7
+
8
+ ## 0.93.1
9
+
10
+ - Upgrade to `rubocop` v0.93.1
11
+ - Add configuration for pending 1.0 cops
12
+
3
13
  ## 0.91.0
4
14
 
5
15
  - Upgrade to `rubocop` v0.91.0
@@ -37,3 +37,6 @@ RSpec/NestedGroups:
37
37
 
38
38
  RSpec/ContextWording:
39
39
  Enabled: false
40
+
41
+ RSpec/MultipleMemoizedHelpers:
42
+ Enabled: false
@@ -1,4 +1,5 @@
1
1
  AllCops:
2
+ NewCops: disable
2
3
  DisplayCopNames: true
3
4
  Exclude:
4
5
  - 'bin/**/*'
@@ -196,3 +197,33 @@ Style/WordArray:
196
197
 
197
198
  Style/SymbolArray:
198
199
  EnforcedStyle: brackets
200
+
201
+ Lint/HashCompareByIdentity:
202
+ Enabled: false
203
+
204
+ Lint/IdentityComparison:
205
+ Enabled: false
206
+
207
+ Lint/MixedRegexpCaptureTypes:
208
+ Enabled: false
209
+
210
+ Lint/TopLevelReturnWithArgument:
211
+ Enabled: false
212
+
213
+ Style/CombinableLoops:
214
+ Enabled: false
215
+
216
+ Style/HashAsLastArrayItem:
217
+ Enabled: false
218
+
219
+ Style/HashEachMethods:
220
+ Enabled: false
221
+
222
+ Style/OptionalBooleanParameter:
223
+ Enabled: false
224
+
225
+ Style/RedundantSelfAssignment:
226
+ Enabled: false
227
+
228
+ Style/SingleArgumentDig:
229
+ Enabled: false
@@ -19,7 +19,8 @@ module RuboCop
19
19
  # it 'does something' do
20
20
  # ...
21
21
  # end
22
- class RspecDocString < Cop
22
+ class RspecDocString < RuboCop::Cop::RSpec::Base
23
+ extend RuboCop::Cop::AutoCorrector
23
24
  include ConfigurableEnforcedStyle
24
25
 
25
26
  SINGLE_QUOTE_MSG =
@@ -27,37 +28,38 @@ module RuboCop
27
28
  DOUBLE_QUOTE_MSG =
28
29
  'Example Group/Example doc strings must be double-quoted.'
29
30
 
30
- SHARED_EXAMPLES = RuboCop::RSpec::Language::SelectorSet.new(
31
- [:include_examples, :it_behaves_like, :it_should_behave_like, :include_context]
32
- ).freeze
33
31
 
34
- DOCUMENTED_METHODS = (RuboCop::RSpec::Language::ExampleGroups::ALL +
35
- RuboCop::RSpec::Language::Examples::ALL +
36
- RuboCop::RSpec::Language::SharedGroups::ALL +
37
- SHARED_EXAMPLES).freeze
32
+ DOCUMENTED_METHODS = RuboCop::ConfigLoader.default_configuration.for_department('RSpec')
33
+ .fetch('Language')
34
+ .values_at('ExampleGroups', 'Examples', 'SharedGroups', 'Includes')
35
+ .flat_map { |element| element.values.flatten }
36
+ .map(&:to_sym)
37
+
38
+ def_node_matcher :documented_method?,
39
+ send_pattern(<<~PATTERN)
40
+ {
41
+ #ExampleGroups.all
42
+ #Examples.all
43
+ #SharedGroups.all
44
+ #Includes.all
45
+ }
46
+ PATTERN
38
47
 
39
48
  def on_send(node)
40
- _receiver, method_name, *args = *node
41
- return unless DOCUMENTED_METHODS.include?(method_name) &&
42
- !args.empty? && args.first.str_type?
49
+ _receiver, _method_name, *args = *node
50
+ return unless documented_method?(node) && args.first&.str_type?
43
51
 
44
52
  check_quotes(args.first)
45
53
  end
46
54
 
47
- def autocorrect(node)
48
- StringLiteralCorrector.correct(node, style)
49
- end
50
-
51
55
  private
52
56
 
53
57
  def check_quotes(doc_node)
54
- if wrong_quotes?(doc_node)
55
- if style == :single_quotes
56
- add_offense(doc_node, message: SINGLE_QUOTE_MSG)
57
- else
58
- add_offense(doc_node, message: DOUBLE_QUOTE_MSG)
59
- end
60
- end
58
+ return unless wrong_quotes?(doc_node)
59
+
60
+ add_offense(doc_node,
61
+ message: style == :single_quotes ? SINGLE_QUOTE_MSG : DOUBLE_QUOTE_MSG,
62
+ &StringLiteralCorrector.correct(doc_node, style))
61
63
  end
62
64
 
63
65
  def wrong_quotes?(node)
@@ -17,26 +17,25 @@ module RuboCop
17
17
  # describe "self.does_stuff" do
18
18
  # ...
19
19
  # end
20
- class RspecDotNotSelfDot < Cop
20
+ class RspecDotNotSelfDot < RuboCop::Cop::RSpec::Base
21
+ extend RuboCop::Cop::AutoCorrector
21
22
 
22
23
  SELF_DOT_REGEXP = /["']self\./.freeze
23
24
  MSG = 'Use ".<class method>" instead of "self.<class method>" for example group description.'
24
25
 
25
26
  def_node_matcher :example_group_match, <<-PATTERN
26
- (send _ #{RuboCop::RSpec::Language::ExampleGroups::ALL.node_pattern_union} $_ ...)
27
+ (send _ #ExampleGroups.all $_ ...)
27
28
  PATTERN
28
29
 
29
30
  def on_send(node)
30
31
  example_group_match(node) do |doc|
31
- add_offense(doc) if SELF_DOT_REGEXP.match?(doc.source)
32
- end
33
- end
32
+ next unless SELF_DOT_REGEXP.match?(doc.source)
34
33
 
35
- def autocorrect(node)
36
- lambda do |corrector|
37
- corrector.remove(Parser::Source::Range.new(node.source_range.source_buffer,
38
- node.source_range.begin_pos + 1,
39
- node.source_range.begin_pos + 5))
34
+ add_offense(doc) do |corrector|
35
+ corrector.remove(Parser::Source::Range.new(doc.source_range.source_buffer,
36
+ doc.source_range.begin_pos + 1,
37
+ doc.source_range.begin_pos + 5))
38
+ end
40
39
  end
41
40
  end
42
41
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SalsifyRubocop
4
- VERSION = '0.91.0'
4
+ VERSION = '1.0.0'
5
5
  end
@@ -36,8 +36,8 @@ Gem::Specification.new do |spec|
36
36
  spec.add_development_dependency 'rake', '~> 10.0'
37
37
  spec.add_development_dependency 'rspec', '~> 3.0'
38
38
 
39
- spec.add_runtime_dependency 'rubocop', '~> 0.91.0'
39
+ spec.add_runtime_dependency 'rubocop', '~> 1.0.0'
40
40
  spec.add_runtime_dependency 'rubocop-performance', '~> 1.5.0'
41
41
  spec.add_runtime_dependency 'rubocop-rails', '~> 2.4.0'
42
- spec.add_runtime_dependency 'rubocop-rspec', '~> 1.37.0'
42
+ spec.add_runtime_dependency 'rubocop-rspec', '~> 2.0.0'
43
43
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: salsify_rubocop
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.91.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Salsify, Inc
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-09-21 00:00:00.000000000 Z
11
+ date: 2020-11-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -58,14 +58,14 @@ dependencies:
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 0.91.0
61
+ version: 1.0.0
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: 0.91.0
68
+ version: 1.0.0
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rubocop-performance
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -100,14 +100,14 @@ dependencies:
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: 1.37.0
103
+ version: 2.0.0
104
104
  type: :runtime
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: 1.37.0
110
+ version: 2.0.0
111
111
  description: Shared shared RuboCop configuration
112
112
  email:
113
113
  - engineering@salsify.com
@@ -138,7 +138,6 @@ files:
138
138
  - lib/rubocop/cop/salsify/rspec_dot_not_self_dot.rb
139
139
  - lib/rubocop/cop/salsify/rspec_string_literals.rb
140
140
  - lib/rubocop/cop/salsify/style_dig.rb
141
- - lib/rubocop/rspec/language/each_selector.rb
142
141
  - lib/salsify_rubocop.rb
143
142
  - lib/salsify_rubocop/version.rb
144
143
  - salsify_rubocop.gemspec
@@ -162,7 +161,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
162
161
  - !ruby/object:Gem::Version
163
162
  version: '0'
164
163
  requirements: []
165
- rubygems_version: 3.1.2
164
+ rubygems_version: 3.0.8
166
165
  signing_key:
167
166
  specification_version: 4
168
167
  summary: Shared shared RuboCop configuration
@@ -1,15 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # Monkey-patch SelectorSet to allow enumeration of selectors.
4
-
5
- module RuboCop
6
- module RSpec
7
- module Language
8
- class SelectorSet
9
- def each(&blk)
10
- selectors.each(&blk)
11
- end
12
- end
13
- end
14
- end
15
- end