salsify_rubocop 0.63.0 → 1.0.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: 9e3126722e0cfd738a292ca81b06494f3f1a7d11231984ef9d2275893568dd20
4
- data.tar.gz: 35af08baf302fc3e077e4cac91dc134ecebc8b202909fab50122773d26c0de15
3
+ metadata.gz: 2056598e677c6cf0b213308613d5ab676b7eee1e97dd93534321a75ba341e2b9
4
+ data.tar.gz: f0053c47716a510ef4ef57c5e90465e2309a0573ab5944d92b23a42cd154ab2c
5
5
  SHA512:
6
- metadata.gz: 4eb7b3432ff1a7c49194bf4c0c4f8310b749bbdcff8790aa9a77110c7498264c6cb0938d74e81f998caaf13fcaf5008b300cc7e6f2aaabb77da243ee7863e253
7
- data.tar.gz: ce93adfb8de00444f300018a0404d0abc0ae138388895c76865ac55e9ebcad3ce1a5dadba8421dbb91984d9153ad43b48886f358ee7f76121b0a7b95b104b26b
6
+ metadata.gz: fe21f0ff75e19ef071efe283cce27a01cde095fe4918d3ef7eb10bddff6d9ca476b8b4a4263b92f871c55ec7434283b9a6812400e546012c8c3d11cb0d280b73
7
+ data.tar.gz: 339fc5ad332c3602d2d73106f76c6d26fc9103c398b6bee9059971b1ac97dcbbe930b7ce731d21cda5794d9fdd53f04454d6c203ba8ffe6e7dc6b67695971062
@@ -2,8 +2,8 @@ inherit_from:
2
2
  - conf/rubocop.yml
3
3
 
4
4
  AllCops:
5
- TargetRubyVersion: 2.3
5
+ TargetRubyVersion: 2.4
6
6
 
7
- Metrics/LineLength:
7
+ Layout/LineLength:
8
8
  Exclude:
9
9
  - '*.gemspec'
@@ -1,9 +1,9 @@
1
1
  language: ruby
2
2
  rvm:
3
+ - 2.7.0
3
4
  - 2.6.0
4
5
  - 2.5.3
5
6
  - 2.4.5
6
- - 2.3.8
7
7
  before_install:
8
8
  - gem update --system
9
9
  - gem install bundler
@@ -1,5 +1,35 @@
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
+
13
+ ## 0.91.0
14
+
15
+ - Upgrade to `rubocop` v0.91.0
16
+
17
+ ## 0.85.0
18
+ - Upgrade to `rubocop` v0.85.0
19
+ - Enable enforcement of Gem comments when specifying versions or sources
20
+ - Drop support for Ruby 2.3, as rubocop v0.81+ doesn't support it anymore
21
+ - Add `FrozenStringLiteralComment` and `LineLength` (max 120) rules.
22
+
23
+ ## v0.78.1
24
+ - Fix "`Style/SymbolArray` is concealed by line 190" warning
25
+
26
+ ## v0.78.0
27
+ - Upgrade to `rubocop` v0.78.0
28
+ - Upgrade to `rubocop_rspec` v1.37.0
29
+ - Add `rubocop-rails `v2.4.0`
30
+ - Add `rubocop-performance `v1.5.0`
31
+ - Update names/namespaces of rules that changed between 0.62 and 0.78
32
+
3
33
  ## v0.62.0
4
34
  - Upgrade to `rubocop` v0.62.0
5
35
  - Upgrade to `rubocop_rspec` v1.31.0
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 salsify_rubocop.gemspec
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
 
@@ -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/**/*'
@@ -9,6 +10,15 @@ AllCops:
9
10
  - 'tmp/**/*'
10
11
  - 'vendor/**/*'
11
12
 
13
+ Bundler/GemComment:
14
+ Enabled: true
15
+ OnlyFor:
16
+ - 'version_specifiers'
17
+ - 'source'
18
+ - 'git'
19
+ - 'github'
20
+ - 'gist'
21
+
12
22
  # This cop has poor handling for the common case of a lambda arg in a DSL
13
23
  Lint/AmbiguousBlockAssociation:
14
24
  Enabled: false
@@ -22,7 +32,7 @@ Performance/RedundantMerge:
22
32
  Style/Alias:
23
33
  EnforcedStyle: prefer_alias_method
24
34
 
25
- Layout/AlignHash:
35
+ Layout/HashAlignment:
26
36
  Enabled: false
27
37
 
28
38
  Style/Documentation:
@@ -67,13 +77,13 @@ Naming/FileName:
67
77
  - 'Appraisals'
68
78
 
69
79
  Style/FrozenStringLiteralComment:
70
- Enabled: false
80
+ Enabled: true
71
81
 
72
82
  Style/GuardClause:
73
83
  Enabled: false
74
84
 
75
85
  # does not make sense to enable this without AlignHash
76
- Layout/IndentHash:
86
+ Layout/FirstHashElementIndentation:
77
87
  Enabled: false
78
88
 
79
89
  Style/Lambda:
@@ -134,10 +144,6 @@ Style/StringLiterals:
134
144
  Exclude:
135
145
  - 'spec/**/*'
136
146
 
137
- # We don't require %i() for an array of symbols.
138
- Style/SymbolArray:
139
- Enabled: false
140
-
141
147
  Naming/VariableNumber:
142
148
  Enabled: false
143
149
 
@@ -156,10 +162,12 @@ Metrics/ClassLength:
156
162
  Metrics/CyclomaticComplexity:
157
163
  Enabled: false
158
164
 
159
- # Disabling line length enforcement since annotate generates
160
- # some pretty long lines
161
- Metrics/LineLength:
162
- Enabled: false
165
+ Layout/LineLength:
166
+ Enabled: true
167
+ Max: 120
168
+ IgnoreCopDirectives: true
169
+ IgnoredPatterns:
170
+ - ^#
163
171
 
164
172
  Metrics/MethodLength:
165
173
  Enabled: false
@@ -189,3 +197,33 @@ Style/WordArray:
189
197
 
190
198
  Style/SymbolArray:
191
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
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module RuboCop
2
4
  module Cop
3
5
  module Salsify
@@ -19,9 +21,9 @@ module RuboCop
19
21
 
20
22
  minimum_target_rails_version 5.0
21
23
 
22
- MSG = 'Mailers should subclass `ApplicationMailer`.'.freeze
23
- SUPERCLASS = 'ApplicationMailer'.freeze
24
- BASE_PATTERN = '(const (const nil? :ActionMailer) :Base)'.freeze
24
+ MSG = 'Mailers should subclass `ApplicationMailer`.'
25
+ SUPERCLASS = 'ApplicationMailer'
26
+ BASE_PATTERN = '(const (const nil? :ActionMailer) :Base)'
25
27
 
26
28
  include RuboCop::Cop::EnforceSuperclass
27
29
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module RuboCop
2
4
  module Cop
3
5
  module Salsify
@@ -19,9 +21,9 @@ module RuboCop
19
21
 
20
22
  minimum_target_rails_version 5.0
21
23
 
22
- MSG = 'Serializers should subclass `ApplicationSerializer`.'.freeze
23
- SUPERCLASS = 'ApplicationSerializer'.freeze
24
- BASE_PATTERN = '(const (const nil? :ActiveModel) :Serializer)'.freeze
24
+ MSG = 'Serializers should subclass `ApplicationSerializer`.'
25
+ SUPERCLASS = 'ApplicationSerializer'
26
+ BASE_PATTERN = '(const (const nil? :ActiveModel) :Serializer)'
25
27
 
26
28
  include RuboCop::Cop::EnforceSuperclass
27
29
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module RuboCop
2
4
  module Cop
3
5
  module Salsify
@@ -11,7 +13,7 @@ module RuboCop
11
13
  # # bad
12
14
  # User.unscoped
13
15
  class RailsUnscoped < Cop
14
- MSG = 'Explicitly remove scopes instead of using `unscoped`.'.freeze
16
+ MSG = 'Explicitly remove scopes instead of using `unscoped`.'
15
17
 
16
18
  def_node_matcher :unscoped?, <<-PATTERN
17
19
  (send _ :unscoped)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module RuboCop
2
4
  module Cop
3
5
  module Salsify
@@ -17,45 +19,47 @@ module RuboCop
17
19
  # it 'does something' do
18
20
  # ...
19
21
  # end
20
- class RspecDocString < Cop
22
+ class RspecDocString < RuboCop::Cop::RSpec::Base
23
+ extend RuboCop::Cop::AutoCorrector
21
24
  include ConfigurableEnforcedStyle
22
25
 
23
26
  SINGLE_QUOTE_MSG =
24
- 'Example Group/Example doc strings must be single-quoted.'.freeze
27
+ 'Example Group/Example doc strings must be single-quoted.'
25
28
  DOUBLE_QUOTE_MSG =
26
- 'Example Group/Example doc strings must be double-quoted.'.freeze
29
+ 'Example Group/Example doc strings must be double-quoted.'
30
+
27
31
 
28
- SHARED_EXAMPLES = RuboCop::RSpec::Language::SelectorSet.new(
29
- [:include_examples, :it_behaves_like, :it_should_behave_like, :include_context]
30
- ).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)
31
37
 
32
- DOCUMENTED_METHODS = (RuboCop::RSpec::Language::ExampleGroups::ALL +
33
- RuboCop::RSpec::Language::Examples::ALL +
34
- RuboCop::RSpec::Language::SharedGroups::ALL +
35
- SHARED_EXAMPLES).freeze
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
36
47
 
37
48
  def on_send(node)
38
- _receiver, method_name, *args = *node
39
- return unless DOCUMENTED_METHODS.include?(method_name) &&
40
- !args.empty? && args.first.str_type?
49
+ _receiver, _method_name, *args = *node
50
+ return unless documented_method?(node) && args.first&.str_type?
41
51
 
42
52
  check_quotes(args.first)
43
53
  end
44
54
 
45
- def autocorrect(node)
46
- StringLiteralCorrector.correct(node, style)
47
- end
48
-
49
55
  private
50
56
 
51
57
  def check_quotes(doc_node)
52
- if wrong_quotes?(doc_node)
53
- if style == :single_quotes
54
- add_offense(doc_node, message: SINGLE_QUOTE_MSG)
55
- else
56
- add_offense(doc_node, message: DOUBLE_QUOTE_MSG)
57
- end
58
- 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))
59
63
  end
60
64
 
61
65
  def wrong_quotes?(node)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module RuboCop
2
4
  module Cop
3
5
  module Salsify
@@ -15,26 +17,25 @@ module RuboCop
15
17
  # describe "self.does_stuff" do
16
18
  # ...
17
19
  # end
18
- class RspecDotNotSelfDot < Cop
20
+ class RspecDotNotSelfDot < RuboCop::Cop::RSpec::Base
21
+ extend RuboCop::Cop::AutoCorrector
19
22
 
20
23
  SELF_DOT_REGEXP = /["']self\./.freeze
21
- MSG = 'Use ".<class method>" instead of "self.<class method>" for example group description.'.freeze
24
+ MSG = 'Use ".<class method>" instead of "self.<class method>" for example group description.'
22
25
 
23
26
  def_node_matcher :example_group_match, <<-PATTERN
24
- (send _ #{RuboCop::RSpec::Language::ExampleGroups::ALL.node_pattern_union} $_ ...)
27
+ (send _ #ExampleGroups.all $_ ...)
25
28
  PATTERN
26
29
 
27
30
  def on_send(node)
28
31
  example_group_match(node) do |doc|
29
- add_offense(doc) if SELF_DOT_REGEXP =~ doc.source
30
- end
31
- end
32
+ next unless SELF_DOT_REGEXP.match?(doc.source)
32
33
 
33
- def autocorrect(node)
34
- lambda do |corrector|
35
- corrector.remove(Parser::Source::Range.new(node.source_range.source_buffer,
36
- node.source_range.begin_pos + 1,
37
- 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
38
39
  end
39
40
  end
40
41
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module RuboCop
2
4
  module Cop
3
5
  module Salsify
@@ -16,9 +18,9 @@ module RuboCop
16
18
  DOCUMENTED_METHODS = RuboCop::Cop::Salsify::RspecDocString::DOCUMENTED_METHODS
17
19
 
18
20
  SINGLE_QUOTE_MSG = 'Prefer single-quoted strings unless you need ' \
19
- 'interpolation or special symbols.'.freeze
21
+ 'interpolation or special symbols.'
20
22
  DOUBLE_QUOTE_MSG = 'Prefer double-quoted strings unless you need ' \
21
- 'single quotes to avoid extra backslashes for escaping.'.freeze
23
+ 'single quotes to avoid extra backslashes for escaping.'
22
24
 
23
25
  def autocorrect(node)
24
26
  StringLiteralCorrector.correct(node, style)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # This may be added in the near future to rubocop, see https://github.com/bbatsov/rubocop/issues/5332
2
4
 
3
5
  module RuboCop
@@ -21,7 +23,7 @@ module RuboCop
21
23
 
22
24
  minimum_target_ruby_version 2.3
23
25
 
24
- MSG = 'Use `dig` for nested access.'.freeze
26
+ MSG = 'Use `dig` for nested access.'
25
27
 
26
28
  def_node_matcher :nested_access_match, <<-PATTERN
27
29
  (send (send (send _receiver !:[]) :[] !{irange erange}) :[] !{irange erange})
@@ -1,4 +1,8 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'salsify_rubocop/version'
4
+ require 'rubocop-performance'
5
+ require 'rubocop-rails'
2
6
  require 'rubocop-rspec'
3
7
 
4
8
  # Because RuboCop doesn't yet support plugins, we have to monkey patch in a
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module SalsifyRubocop
2
- VERSION = '0.63.0'.freeze
4
+ VERSION = '1.0.0'
3
5
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  lib = File.expand_path('lib', __dir__)
2
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
5
  require 'salsify_rubocop/version'
@@ -28,10 +30,14 @@ Gem::Specification.new do |spec|
28
30
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
29
31
  spec.require_paths = ['lib']
30
32
 
33
+ spec.required_ruby_version = '>= 2.4'
34
+
31
35
  spec.add_development_dependency 'bundler', '~> 2.0'
32
36
  spec.add_development_dependency 'rake', '~> 10.0'
33
37
  spec.add_development_dependency 'rspec', '~> 3.0'
34
38
 
35
- spec.add_runtime_dependency 'rubocop', '~> 0.62.0'
36
- spec.add_runtime_dependency 'rubocop-rspec', '~> 1.31.0'
39
+ spec.add_runtime_dependency 'rubocop', '~> 1.0.0'
40
+ spec.add_runtime_dependency 'rubocop-performance', '~> 1.5.0'
41
+ spec.add_runtime_dependency 'rubocop-rails', '~> 2.4.0'
42
+ spec.add_runtime_dependency 'rubocop-rspec', '~> 2.0.0'
37
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.63.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Salsify, Inc
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-04-17 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,28 +58,56 @@ dependencies:
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 0.62.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.62.0
68
+ version: 1.0.0
69
+ - !ruby/object:Gem::Dependency
70
+ name: rubocop-performance
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 1.5.0
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 1.5.0
83
+ - !ruby/object:Gem::Dependency
84
+ name: rubocop-rails
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: 2.4.0
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: 2.4.0
69
97
  - !ruby/object:Gem::Dependency
70
98
  name: rubocop-rspec
71
99
  requirement: !ruby/object:Gem::Requirement
72
100
  requirements:
73
101
  - - "~>"
74
102
  - !ruby/object:Gem::Version
75
- version: 1.31.0
103
+ version: 2.0.0
76
104
  type: :runtime
77
105
  prerelease: false
78
106
  version_requirements: !ruby/object:Gem::Requirement
79
107
  requirements:
80
108
  - - "~>"
81
109
  - !ruby/object:Gem::Version
82
- version: 1.31.0
110
+ version: 2.0.0
83
111
  description: Shared shared RuboCop configuration
84
112
  email:
85
113
  - engineering@salsify.com
@@ -110,7 +138,6 @@ files:
110
138
  - lib/rubocop/cop/salsify/rspec_dot_not_self_dot.rb
111
139
  - lib/rubocop/cop/salsify/rspec_string_literals.rb
112
140
  - lib/rubocop/cop/salsify/style_dig.rb
113
- - lib/rubocop/rspec/language/each_selector.rb
114
141
  - lib/salsify_rubocop.rb
115
142
  - lib/salsify_rubocop/version.rb
116
143
  - salsify_rubocop.gemspec
@@ -119,7 +146,7 @@ licenses:
119
146
  - MIT
120
147
  metadata:
121
148
  allowed_push_host: https://rubygems.org
122
- post_install_message:
149
+ post_install_message:
123
150
  rdoc_options: []
124
151
  require_paths:
125
152
  - lib
@@ -127,16 +154,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
127
154
  requirements:
128
155
  - - ">="
129
156
  - !ruby/object:Gem::Version
130
- version: '0'
157
+ version: '2.4'
131
158
  required_rubygems_version: !ruby/object:Gem::Requirement
132
159
  requirements:
133
160
  - - ">="
134
161
  - !ruby/object:Gem::Version
135
162
  version: '0'
136
163
  requirements: []
137
- rubyforge_project:
138
- rubygems_version: 2.7.9
139
- signing_key:
164
+ rubygems_version: 3.0.8
165
+ signing_key:
140
166
  specification_version: 4
141
167
  summary: Shared shared RuboCop configuration
142
168
  test_files: []
@@ -1,13 +0,0 @@
1
- # Monkey-patch SelectorSet to allow enumeration of selectors.
2
-
3
- module RuboCop
4
- module RSpec
5
- module Language
6
- class SelectorSet
7
- def each(&blk)
8
- selectors.each(&blk)
9
- end
10
- end
11
- end
12
- end
13
- end