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 +4 -4
- data/CHANGELOG.md +10 -0
- data/conf/rubocop.yml +3 -0
- data/conf/rubocop_without_rspec.yml +31 -0
- data/lib/rubocop/cop/salsify/rspec_doc_string.rb +24 -22
- data/lib/rubocop/cop/salsify/rspec_dot_not_self_dot.rb +9 -10
- data/lib/salsify_rubocop/version.rb +1 -1
- data/salsify_rubocop.gemspec +2 -2
- metadata +7 -8
- data/lib/rubocop/rspec/language/each_selector.rb +0 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2056598e677c6cf0b213308613d5ab676b7eee1e97dd93534321a75ba341e2b9
|
4
|
+
data.tar.gz: f0053c47716a510ef4ef57c5e90465e2309a0573ab5944d92b23a42cd154ab2c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fe21f0ff75e19ef071efe283cce27a01cde095fe4918d3ef7eb10bddff6d9ca476b8b4a4263b92f871c55ec7434283b9a6812400e546012c8c3d11cb0d280b73
|
7
|
+
data.tar.gz: 339fc5ad332c3602d2d73106f76c6d26fc9103c398b6bee9059971b1ac97dcbbe930b7ce731d21cda5794d9fdd53f04454d6c203ba8ffe6e7dc6b67695971062
|
data/CHANGELOG.md
CHANGED
data/conf/rubocop.yml
CHANGED
@@ -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 =
|
35
|
-
|
36
|
-
|
37
|
-
|
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,
|
41
|
-
return unless
|
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
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
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 _ #
|
27
|
+
(send _ #ExampleGroups.all $_ ...)
|
27
28
|
PATTERN
|
28
29
|
|
29
30
|
def on_send(node)
|
30
31
|
example_group_match(node) do |doc|
|
31
|
-
|
32
|
-
end
|
33
|
-
end
|
32
|
+
next unless SELF_DOT_REGEXP.match?(doc.source)
|
34
33
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
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
|
data/salsify_rubocop.gemspec
CHANGED
@@ -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.
|
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', '~>
|
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.
|
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-
|
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.
|
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.
|
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:
|
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:
|
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.
|
164
|
+
rubygems_version: 3.0.8
|
166
165
|
signing_key:
|
167
166
|
specification_version: 4
|
168
167
|
summary: Shared shared RuboCop configuration
|