rubocop-standard 1.12.0 → 1.14.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: 21aca3bd04a2838d939d1f924aa804cfc4c033d196ce067e4609890f5c6d25e6
4
- data.tar.gz: 72109de6b63a02852b57fec08261b2fabe0a6864de597be46ea60d46294f5857
3
+ metadata.gz: c0c408c8483f108e7f01e3aeabc27edfd600de157f1f1a2420cf28c3296496c8
4
+ data.tar.gz: ca41d2d7a619d1008351ffc30a287d6142529babcb170a259d7acc298d24c712
5
5
  SHA512:
6
- metadata.gz: 8bf78a47274edc9fa253eafe42a658664b33bc009a338cba2fdd79cd73f03ff1c925cf38fb94f95bc77390a6354f8f61de9842d9c8c6d24cfe6eabdcb7fc02b5
7
- data.tar.gz: e986542ca7e3b6f0e7facab994e06453e6d748fe7276d7ae79ed07d8ea01c2fb2f8f1986bf666faf5e0e02d97b21b259dcc1182523ab1ea485ee8c78770d3f3f
6
+ metadata.gz: 617cab056ab07550c3657a2f37298a9dbd92fc40fdfdd170065c876e0332adeca1e40de8067dcf421bbb30e5d5efb3218b2bfd9a60752add06dedd9cb821939a
7
+ data.tar.gz: 86e4d63d7df020c2d870372013c434b0c5daca8ba0a8c239155ce9c61a2550766a055507bee405d8fdef9c2dff5588b6b6adf01a655252965562785d40a290f4
@@ -1,4 +1,5 @@
1
1
  require: rubocop/cop/standard
2
+ require: rubocop-performance
2
3
 
3
4
  AllCops:
4
5
  DisabledByDefault: true
@@ -229,9 +230,6 @@ Performance/EndWith:
229
230
  Performance/FlatMap:
230
231
  Enabled: true
231
232
 
232
- Performance/LstripRstrip:
233
- Enabled: true
234
-
235
233
  Performance/RangeInclude:
236
234
  Enabled: false
237
235
 
@@ -242,15 +240,9 @@ Performance/RedundantMerge:
242
240
  Enabled: true
243
241
  MaxKeyValuePairs: 1
244
242
 
245
- Performance/RedundantSortBy:
246
- Enabled: true
247
-
248
243
  Performance/ReverseEach:
249
244
  Enabled: true
250
245
 
251
- Performance/Sample:
252
- Enabled: true
253
-
254
246
  Performance/Size:
255
247
  Enabled: true
256
248
 
@@ -318,9 +310,18 @@ Style/Not:
318
310
  Style/OneLineConditional:
319
311
  Enabled: true
320
312
 
313
+ Style/RedundantSortBy:
314
+ Enabled: true
315
+
316
+ Style/Sample:
317
+ Enabled: true
318
+
321
319
  Style/StabbyLambdaParentheses:
322
320
  Enabled: true
323
321
 
324
322
  Style/StringLiterals:
325
323
  Enabled: true
326
- EnforcedStyle: double_quotes
324
+ EnforcedStyle: single_quotes
325
+
326
+ Style/Strip:
327
+ Enabled: true
@@ -1,12 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "rubocop/cop/standard/rails_application_record"
4
- require "rubocop/cop/standard/rails_controller_render_action_symbol"
5
- require "rubocop/cop/standard/rails_controller_render_literal"
6
- require "rubocop/cop/standard/rails_controller_render_paths_exist"
7
- require "rubocop/cop/standard/rails_controller_render_shorthand"
8
- require "rubocop/cop/standard/rails_render_inline"
9
- require "rubocop/cop/standard/rails_render_object_collection"
10
- require "rubocop/cop/standard/rails_view_render_literal"
11
- require "rubocop/cop/standard/rails_view_render_paths_exist"
12
- require "rubocop/cop/standard/rails_view_render_shorthand"
3
+ require 'rubocop/cop/standard/rails_application_record'
4
+ require 'rubocop/cop/standard/rails_controller_render_action_symbol'
5
+ require 'rubocop/cop/standard/rails_controller_render_literal'
6
+ require 'rubocop/cop/standard/rails_controller_render_paths_exist'
7
+ require 'rubocop/cop/standard/rails_controller_render_shorthand'
8
+ require 'rubocop/cop/standard/rails_render_inline'
9
+ require 'rubocop/cop/standard/rails_render_object_collection'
10
+ require 'rubocop/cop/standard/rails_view_render_literal'
11
+ require 'rubocop/cop/standard/rails_view_render_paths_exist'
12
+ require 'rubocop/cop/standard/rails_view_render_shorthand'
@@ -1,12 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "rubocop"
3
+ require 'rubocop'
4
4
 
5
5
  module RuboCop
6
6
  module Cop
7
7
  module Standard
8
8
  class RailsApplicationRecord < Cop
9
- MSG = "Models should subclass from ApplicationRecord"
9
+ MSG = 'Models should subclass from ApplicationRecord'
10
10
 
11
11
  def_node_matcher :active_record_base_const?, <<-PATTERN
12
12
  (const (const nil? :ActiveRecord) :Base)
@@ -1,12 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "rubocop"
3
+ require 'rubocop'
4
4
 
5
5
  module RuboCop
6
6
  module Cop
7
7
  module Standard
8
8
  class RailsControllerRenderActionSymbol < Cop
9
- MSG = "Prefer `render` with string instead of symbol"
9
+ MSG = 'Prefer `render` with string instead of symbol'
10
10
 
11
11
  def_node_matcher :render_sym?, <<-PATTERN
12
12
  (send nil? :render $(sym _))
@@ -1,12 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "rubocop"
3
+ require 'rubocop'
4
4
 
5
5
  module RuboCop
6
6
  module Cop
7
7
  module Standard
8
8
  class RailsControllerRenderLiteral < Cop
9
- MSG = "render must be used with a string literal"
9
+ MSG = 'render must be used with a string literal'
10
10
 
11
11
  def_node_matcher :literal?, <<-PATTERN
12
12
  ({str sym true false nil?} ...)
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "rubocop"
3
+ require 'rubocop'
4
4
 
5
5
  module RuboCop
6
6
  module Cop
@@ -23,12 +23,12 @@ module RuboCop
23
23
  PATTERN
24
24
 
25
25
  def on_send(node)
26
- return unless cop_config["ViewPath"]
26
+ return unless cop_config['ViewPath']
27
27
 
28
28
  if args = render_str?(node)
29
29
  node, path = args
30
30
  unless resolve_template(path.to_s)
31
- add_offense(node, location: :expression, message: "Template could not be found")
31
+ add_offense(node, location: :expression, message: 'Template could not be found')
32
32
  end
33
33
  elsif pairs = render_options?(node)
34
34
  if pair = pairs.detect { |p| render_key?(p) }
@@ -37,11 +37,11 @@ module RuboCop
37
37
  case key
38
38
  when :action, :template
39
39
  unless resolve_template(path.to_s)
40
- add_offense(node, location: :expression, message: "Template could not be found")
40
+ add_offense(node, location: :expression, message: 'Template could not be found')
41
41
  end
42
42
  when :partial
43
43
  unless resolve_partial(path.to_s)
44
- add_offense(node, location: :expression, message: "Partial template could not be found")
44
+ add_offense(node, location: :expression, message: 'Partial template could not be found')
45
45
  end
46
46
  end
47
47
  end
@@ -49,8 +49,8 @@ module RuboCop
49
49
  end
50
50
 
51
51
  def resolve_template(path)
52
- cop_config["ViewPath"].each do |view_path|
53
- if m = Dir[File.join(config.path_relative_to_config(view_path), path) + "*"].first
52
+ cop_config['ViewPath'].each do |view_path|
53
+ if m = Dir[File.join(config.path_relative_to_config(view_path), path) + '*'].first
54
54
  return m
55
55
  end
56
56
  end
@@ -1,12 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "rubocop"
3
+ require 'rubocop'
4
4
 
5
5
  module RuboCop
6
6
  module Cop
7
7
  module Standard
8
8
  class RailsControllerRenderShorthand < Cop
9
- MSG = "Prefer `render` template shorthand"
9
+ MSG = 'Prefer `render` template shorthand'
10
10
 
11
11
  def_node_matcher :render_with_options?, <<-PATTERN
12
12
  (send nil? :render (hash $...))
@@ -32,10 +32,10 @@ module RuboCop
32
32
  if option_pairs = render_with_options?(node)
33
33
  option_pairs.each do |pair|
34
34
  if value_node = action_key?(pair)
35
- comma = option_pairs.length > 1 ? ", " : ""
35
+ comma = option_pairs.length > 1 ? ', ' : ''
36
36
  corrected_source = node.source
37
- .sub(/#{pair.source}(,\s*)?/, "")
38
- .sub("render ", "render \"#{str(value_node)}\"#{comma}")
37
+ .sub(/#{pair.source}(,\s*)?/, '')
38
+ .sub('render ', "render \"#{str(value_node)}\"#{comma}")
39
39
 
40
40
  @autocorrect[node] = lambda do |corrector|
41
41
  corrector.replace(node.source_range, corrected_source)
@@ -1,12 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "rubocop"
3
+ require 'rubocop'
4
4
 
5
5
  module RuboCop
6
6
  module Cop
7
7
  module Standard
8
8
  class RailsRenderInline < Cop
9
- MSG = "Avoid `render inline:`"
9
+ MSG = 'Avoid `render inline:`'
10
10
 
11
11
  def_node_matcher :render_with_options?, <<-PATTERN
12
12
  (send nil? :render (hash $...))
@@ -1,12 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "rubocop"
3
+ require 'rubocop'
4
4
 
5
5
  module RuboCop
6
6
  module Cop
7
7
  module Standard
8
8
  class RailsRenderObjectCollection < Cop
9
- MSG = "Avoid `render object:`"
9
+ MSG = 'Avoid `render object:`'
10
10
 
11
11
  def_node_matcher :render_with_options?, <<-PATTERN
12
12
  (send nil? :render (hash $...) ...)
@@ -36,7 +36,7 @@ module RuboCop
36
36
  end
37
37
  add_offense(node, location: :expression, message: "Avoid `render object:`#{suggestion}")
38
38
  when :collection, :spacer_template
39
- add_offense(node, location: :expression, message: "Avoid `render collection:`")
39
+ add_offense(node, location: :expression, message: 'Avoid `render collection:`')
40
40
  end
41
41
  end
42
42
  end
@@ -1,12 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "rubocop"
3
+ require 'rubocop'
4
4
 
5
5
  module RuboCop
6
6
  module Cop
7
7
  module Standard
8
8
  class RailsViewRenderLiteral < Cop
9
- MSG = "render must be used with a string literal"
9
+ MSG = 'render must be used with a string literal'
10
10
 
11
11
  def_node_matcher :literal?, <<-PATTERN
12
12
  ({str sym true false nil?} ...)
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "rubocop"
3
+ require 'rubocop'
4
4
 
5
5
  module RuboCop
6
6
  module Cop
@@ -23,19 +23,19 @@ module RuboCop
23
23
  PATTERN
24
24
 
25
25
  def on_send(node)
26
- return unless cop_config["ViewPath"]
26
+ return unless cop_config['ViewPath']
27
27
 
28
28
  if args = render_str?(node)
29
29
  node, path = args
30
30
  unless resolve_partial(path.to_s)
31
- add_offense(node, location: :expression, message: "Partial template could not be found")
31
+ add_offense(node, location: :expression, message: 'Partial template could not be found')
32
32
  end
33
33
  elsif pairs = render_options?(node)
34
34
  if pair = pairs.detect { |p| partial_key?(p) }
35
35
  node, path = partial_key?(pair)
36
36
 
37
37
  unless resolve_partial(path.to_s)
38
- add_offense(node, location: :expression, message: "Partial template could not be found")
38
+ add_offense(node, location: :expression, message: 'Partial template could not be found')
39
39
  end
40
40
  end
41
41
  end
@@ -46,8 +46,8 @@ module RuboCop
46
46
  parts << "_#{parts.pop}"
47
47
  path = parts.join(File::SEPARATOR)
48
48
 
49
- cop_config["ViewPath"].each do |view_path|
50
- if m = Dir[File.join(config.path_relative_to_config(view_path), path) + "*"].first
49
+ cop_config['ViewPath'].each do |view_path|
50
+ if m = Dir[File.join(config.path_relative_to_config(view_path), path) + '*'].first
51
51
  return m
52
52
  end
53
53
  end
@@ -1,12 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "rubocop"
3
+ require 'rubocop'
4
4
 
5
5
  module RuboCop
6
6
  module Cop
7
7
  module Standard
8
8
  class RailsViewRenderShorthand < Cop
9
- MSG = "Prefer `render` partial shorthand"
9
+ MSG = 'Prefer `render` partial shorthand'
10
10
 
11
11
  def_node_matcher :render_with_options?, <<-PATTERN
12
12
  (send nil? :render (hash $...))
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubocop-standard
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.12.0
4
+ version: 1.14.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Garen Torikian
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-04-03 00:00:00.000000000 Z
11
+ date: 2019-04-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubocop
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0.63'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rubocop-performance
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 1.1.0
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 1.1.0
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: actionview
29
43
  requirement: !ruby/object:Gem::Requirement