salsify_rubocop 0.91.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b7075a3184d398f5ed45dc726da7a289323eb1839dd7ecb78fe614b242b6798f
4
- data.tar.gz: 70c2dfb69a48fa75e58a218e8cea848fc477dfbfd22fc50adefbac86589132f3
3
+ metadata.gz: ec6518eab32e91fe9d55cddeeebe45b6c894646f416489b35d124c68ca9d45b6
4
+ data.tar.gz: 29aae33cb64d4c8505bcc2d5bdc99bc316d82bdb6ecb0963f06993d3f856ef38
5
5
  SHA512:
6
- metadata.gz: ddcd5e8975a9d35a5b5efe66e5e90d1ca4645aebca2d6b70e8084c6dda8fac05b36c27f557aebdc45fabe6458215a6bab4c06dc4acd8935a02017dc22a2131cb
7
- data.tar.gz: 33e382909c34f89e5ba8f14ea1a03bb443df82fad6d2e80905d1faf7ef8950692a85e768dfa2a8bcc8bc7ef7ceac21e500c00675939ff481a5ed31dc8751f158
6
+ metadata.gz: aa3992654fbaa71f4cfbdab64203590153483e9a5a57718f72f64022ba65d7cea95bcb71665cfa229dd4f6283d883a20551e27139ce3fabaaaf1d19599ba69e3
7
+ data.tar.gz: 95aa6ec7078f655bae79f0b6a53bd0037888d2fcf20465dbad819e4ed9c9749a840dadc2b54af78857da67ffb0a390ca8b8d36f670abfdac285e227bfa45de24
@@ -0,0 +1,71 @@
1
+ version: 2.1
2
+ jobs:
3
+ lint:
4
+ docker:
5
+ - image: salsify/ruby_ci:2.6.6
6
+ working_directory: ~/salsify_rubocop
7
+ steps:
8
+ - checkout
9
+ - restore_cache:
10
+ keys:
11
+ - v1-gems-ruby-2.6.6-{{ checksum "salsify_rubocop.gemspec" }}-{{ checksum "Gemfile" }}
12
+ - v1-gems-ruby-2.6.6-
13
+ - run:
14
+ name: Install Gems
15
+ command: |
16
+ if ! bundle check --path=vendor/bundle; then
17
+ bundle install --path=vendor/bundle --jobs=4 --retry=3
18
+ bundle clean
19
+ fi
20
+ - save_cache:
21
+ key: v1-gems-ruby-2.6.6-{{ checksum "salsify_rubocop.gemspec" }}-{{ checksum "Gemfile" }}
22
+ paths:
23
+ - "vendor/bundle"
24
+ - "gemfiles/vendor/bundle"
25
+ - run:
26
+ name: Run Rubocop
27
+ command: bundle exec rubocop --config .rubocop.yml
28
+ test:
29
+ parameters:
30
+ ruby_version:
31
+ type: string
32
+ docker:
33
+ - image: salsify/ruby_ci:<< parameters.ruby_version >>
34
+ environment:
35
+ CIRCLE_TEST_REPORTS: "test-results"
36
+ working_directory: ~/salsify_rubocop
37
+ steps:
38
+ - checkout
39
+ - restore_cache:
40
+ keys:
41
+ - v1-gems-ruby-<< parameters.ruby_version >>-{{ checksum "salsify_rubocop.gemspec" }}-{{ checksum "Gemfile" }}
42
+ - v1-gems-ruby-<< parameters.ruby_version >>-
43
+ - run:
44
+ name: Install Gems
45
+ command: |
46
+ if ! bundle check --path=vendor/bundle; then
47
+ bundle install --path=vendor/bundle --jobs=4 --retry=3
48
+ bundle clean
49
+ fi
50
+ - save_cache:
51
+ key: v1-gems-ruby-<< parameters.ruby_version >>-{{ checksum "salsify_rubocop.gemspec" }}-{{ checksum "Gemfile" }}
52
+ paths:
53
+ - "vendor/bundle"
54
+ - "gemfiles/vendor/bundle"
55
+ - run:
56
+ name: Run Tests
57
+ command: |
58
+ bundle exec rspec --format RspecJunitFormatter --out $CIRCLE_TEST_REPORTS/rspec/junit.xml --format progress spec
59
+ - store_test_results:
60
+ path: "test-results"
61
+ workflows:
62
+ build:
63
+ jobs:
64
+ - lint
65
+ - test:
66
+ matrix:
67
+ parameters:
68
+ ruby_version:
69
+ - "2.6.6"
70
+ - "2.7.2"
71
+ - "3.0.0"
data/.rubocop.yml CHANGED
@@ -2,7 +2,7 @@ inherit_from:
2
2
  - conf/rubocop.yml
3
3
 
4
4
  AllCops:
5
- TargetRubyVersion: 2.4
5
+ TargetRubyVersion: 2.6
6
6
 
7
7
  Layout/LineLength:
8
8
  Exclude:
data/CHANGELOG.md CHANGED
@@ -1,7 +1,26 @@
1
1
  # salsify_rubocop
2
2
 
3
- ## 0.91.0
3
+ ## 1.1.0
4
+ - Re-enable version specifier checks for the `Bundler/GemComment` cop, for limiting version specifiers only.
5
+ - Upgrade to `rubocop` v1.13.0
6
+ - Drop support for Ruby 2.5 now that's in EOL
7
+
8
+ ## 1.0.2
9
+ - Disable version specifier checks for the `Bundler/GemComment` cop until https://github.com/rubocop/rubocop/pull/9358
10
+ is merged.
11
+
12
+ ## 1.0.1
13
+ - Configure file exclusions for `Rails/RakeEnvironment` and `Gemspec/RequiredRubyVersion`
4
14
 
15
+ ## 1.0.0
16
+ - Upgrade to `rubocop` v1.0.0
17
+ - Upgrade to `rubocop-rspec` v2.0.0
18
+
19
+ ## 0.93.1
20
+ - Upgrade to `rubocop` v0.93.1
21
+ - Add configuration for pending 1.0 cops
22
+
23
+ ## 0.91.0
5
24
  - Upgrade to `rubocop` v0.91.0
6
25
 
7
26
  ## 0.85.0
data/README.md CHANGED
@@ -93,6 +93,30 @@ This gem also includes a dependency on `rubocop-rspec` that will be updated to
93
93
  the latest compatible version each time that the MAJOR.MINOR version of `rubocop`
94
94
  is updated.
95
95
 
96
+ ## Change Process
97
+
98
+ This configuration is meant to represent the general opinion of Salsify's Ruby community around best practices for
99
+ writing readable Ruby code. As a result, changes to this configuration should go through a discussion phase in the
100
+ #rubocop-changes Slack channel to ensure the broader Salsify Ruby community is on board with the change. Non-Salsify
101
+ developers should file an issue via GitHub with proposed changes.
102
+
103
+ When enabling a cop we try to keep the following points in mind to avoid overburdening consumers:
104
+
105
+ * Does the cop support safe auto-correction? If not, do we expect a large number of offenses needing manual remediation?
106
+ * Does the cop help avoid bugs or is it merely stylistic?
107
+ * For stylistic cops, does the enforced style reflect that of Salsify developers?
108
+
109
+ ### Updating RuboCop
110
+
111
+ Updating to a new minor version of `rubocop` may add new "pending" cops which are not enabled until the next major
112
+ version (see: [RuboCop Versioning](https://docs.rubocop.org/rubocop/versioning.html)). However, we may wish to eagerly
113
+ enable or explicitly disable newly introduced cops. Any such decisions around "pending" cops should go through the
114
+ change process described above.
115
+
116
+ When updating to a new major version or updating other dependencies that don't follow the same versioning pattern, we
117
+ should check if there are any newly enabled cops included in the update. Any new cops should go through a review process
118
+ in #rubocop-changes to ensure we truly want to enable the cop.
119
+
96
120
  ## Development
97
121
 
98
122
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment. Run `bundle exec salsify_rubocop` to use the gem in this directory, ignoring other installed copies of this gem.
data/conf/rubocop.yml CHANGED
@@ -37,3 +37,6 @@ RSpec/NestedGroups:
37
37
 
38
38
  RSpec/ContextWording:
39
39
  Enabled: false
40
+
41
+ RSpec/MultipleMemoizedHelpers:
42
+ Enabled: false
@@ -15,6 +15,10 @@ Rails/TimeZone:
15
15
  Exclude:
16
16
  - 'spec/**/*'
17
17
 
18
+ Rails/RakeEnvironment:
19
+ Exclude:
20
+ - lib/tasks/auto_annotate_models.rake
21
+
18
22
  Rails/UniqBeforePluck:
19
23
  EnforcedStyle: aggressive
20
24
 
@@ -1,4 +1,9 @@
1
+ require:
2
+ - rubocop-performance
3
+ - rubocop-rails
4
+
1
5
  AllCops:
6
+ NewCops: disable
2
7
  DisplayCopNames: true
3
8
  Exclude:
4
9
  - 'bin/**/*'
@@ -12,12 +17,16 @@ AllCops:
12
17
  Bundler/GemComment:
13
18
  Enabled: true
14
19
  OnlyFor:
15
- - 'version_specifiers'
20
+ - 'restrictive_version_specificiers'
16
21
  - 'source'
17
22
  - 'git'
18
23
  - 'github'
19
24
  - 'gist'
20
25
 
26
+ Gemspec/RequiredRubyVersion:
27
+ Exclude:
28
+ - schemas_gem/*_schemas.gemspec
29
+
21
30
  # This cop has poor handling for the common case of a lambda arg in a DSL
22
31
  Lint/AmbiguousBlockAssociation:
23
32
  Enabled: false
@@ -196,3 +205,33 @@ Style/WordArray:
196
205
 
197
206
  Style/SymbolArray:
198
207
  EnforcedStyle: brackets
208
+
209
+ Lint/HashCompareByIdentity:
210
+ Enabled: false
211
+
212
+ Lint/IdentityComparison:
213
+ Enabled: false
214
+
215
+ Lint/MixedRegexpCaptureTypes:
216
+ Enabled: false
217
+
218
+ Lint/TopLevelReturnWithArgument:
219
+ Enabled: false
220
+
221
+ Style/CombinableLoops:
222
+ Enabled: false
223
+
224
+ Style/HashAsLastArrayItem:
225
+ Enabled: false
226
+
227
+ Style/HashEachMethods:
228
+ Enabled: false
229
+
230
+ Style/OptionalBooleanParameter:
231
+ Enabled: false
232
+
233
+ Style/RedundantSelfAssignment:
234
+ Enabled: false
235
+
236
+ Style/SingleArgumentDig:
237
+ 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,36 +28,37 @@ 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
58
+ return unless wrong_quotes?(doc_node)
59
+
60
+ add_offense(doc_node, message: style == :single_quotes ? SINGLE_QUOTE_MSG : DOUBLE_QUOTE_MSG) do |corrector|
61
+ StringLiteralCorrector.correct(corrector, doc_node, style)
60
62
  end
61
63
  end
62
64
 
@@ -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
@@ -11,7 +11,8 @@ module RuboCop
11
11
  # Used together with Salsify/RspecDocString it allows one quote style to
12
12
  # be used for doc strings (`describe "foobar"`) and another style to be
13
13
  # used for all other strings in specs.
14
- class RspecStringLiterals < Cop
14
+ class RspecStringLiterals < RuboCop::Cop::RSpec::Base
15
+ extend RuboCop::Cop::AutoCorrector
15
16
  include ConfigurableEnforcedStyle
16
17
  include StringLiteralsHelp
17
18
 
@@ -22,8 +23,8 @@ module RuboCop
22
23
  DOUBLE_QUOTE_MSG = 'Prefer double-quoted strings unless you need ' \
23
24
  'single quotes to avoid extra backslashes for escaping.'
24
25
 
25
- def autocorrect(node)
26
- StringLiteralCorrector.correct(node, style)
26
+ def autocorrect(corrector, node)
27
+ StringLiteralCorrector.correct(corrector, node, style)
27
28
  end
28
29
 
29
30
  private
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SalsifyRubocop
4
- VERSION = '0.91.0'
4
+ VERSION = '1.1.0'
5
5
  end
@@ -30,14 +30,15 @@ Gem::Specification.new do |spec|
30
30
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
31
31
  spec.require_paths = ['lib']
32
32
 
33
- spec.required_ruby_version = '>= 2.4'
33
+ spec.required_ruby_version = '>= 2.6'
34
34
 
35
35
  spec.add_development_dependency 'bundler', '~> 2.0'
36
- spec.add_development_dependency 'rake', '~> 10.0'
36
+ spec.add_development_dependency 'rake', '~> 13.0'
37
37
  spec.add_development_dependency 'rspec', '~> 3.0'
38
+ spec.add_development_dependency 'rspec_junit_formatter'
38
39
 
39
- spec.add_runtime_dependency 'rubocop', '~> 0.91.0'
40
+ spec.add_runtime_dependency 'rubocop', '~> 1.13.0'
40
41
  spec.add_runtime_dependency 'rubocop-performance', '~> 1.5.0'
41
42
  spec.add_runtime_dependency 'rubocop-rails', '~> 2.4.0'
42
- spec.add_runtime_dependency 'rubocop-rspec', '~> 1.37.0'
43
+ spec.add_runtime_dependency 'rubocop-rspec', '~> 2.0.0'
43
44
  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.1.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: 2021-08-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '10.0'
33
+ version: '13.0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '10.0'
40
+ version: '13.0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -52,20 +52,34 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec_junit_formatter
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: rubocop
57
71
  requirement: !ruby/object:Gem::Requirement
58
72
  requirements:
59
73
  - - "~>"
60
74
  - !ruby/object:Gem::Version
61
- version: 0.91.0
75
+ version: 1.13.0
62
76
  type: :runtime
63
77
  prerelease: false
64
78
  version_requirements: !ruby/object:Gem::Requirement
65
79
  requirements:
66
80
  - - "~>"
67
81
  - !ruby/object:Gem::Version
68
- version: 0.91.0
82
+ version: 1.13.0
69
83
  - !ruby/object:Gem::Dependency
70
84
  name: rubocop-performance
71
85
  requirement: !ruby/object:Gem::Requirement
@@ -100,14 +114,14 @@ dependencies:
100
114
  requirements:
101
115
  - - "~>"
102
116
  - !ruby/object:Gem::Version
103
- version: 1.37.0
117
+ version: 2.0.0
104
118
  type: :runtime
105
119
  prerelease: false
106
120
  version_requirements: !ruby/object:Gem::Requirement
107
121
  requirements:
108
122
  - - "~>"
109
123
  - !ruby/object:Gem::Version
110
- version: 1.37.0
124
+ version: 2.0.0
111
125
  description: Shared shared RuboCop configuration
112
126
  email:
113
127
  - engineering@salsify.com
@@ -115,10 +129,10 @@ executables: []
115
129
  extensions: []
116
130
  extra_rdoc_files: []
117
131
  files:
132
+ - ".circleci/config.yml"
118
133
  - ".gitignore"
119
134
  - ".rspec"
120
135
  - ".rubocop.yml"
121
- - ".travis.yml"
122
136
  - CHANGELOG.md
123
137
  - Gemfile
124
138
  - LICENSE.txt
@@ -138,7 +152,6 @@ files:
138
152
  - lib/rubocop/cop/salsify/rspec_dot_not_self_dot.rb
139
153
  - lib/rubocop/cop/salsify/rspec_string_literals.rb
140
154
  - lib/rubocop/cop/salsify/style_dig.rb
141
- - lib/rubocop/rspec/language/each_selector.rb
142
155
  - lib/salsify_rubocop.rb
143
156
  - lib/salsify_rubocop/version.rb
144
157
  - salsify_rubocop.gemspec
@@ -155,14 +168,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
155
168
  requirements:
156
169
  - - ">="
157
170
  - !ruby/object:Gem::Version
158
- version: '2.4'
171
+ version: '2.6'
159
172
  required_rubygems_version: !ruby/object:Gem::Requirement
160
173
  requirements:
161
174
  - - ">="
162
175
  - !ruby/object:Gem::Version
163
176
  version: '0'
164
177
  requirements: []
165
- rubygems_version: 3.1.2
178
+ rubygems_version: 3.1.4
166
179
  signing_key:
167
180
  specification_version: 4
168
181
  summary: Shared shared RuboCop configuration
data/.travis.yml DELETED
@@ -1,12 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - 2.7.0
4
- - 2.6.0
5
- - 2.5.3
6
- - 2.4.5
7
- before_install:
8
- - gem update --system
9
- - gem install bundler
10
- script:
11
- - bundle exec rubocop
12
- - bundle exec rspec
@@ -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