rubocop-gusto 10.0.1 → 10.1.1

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.
Files changed (35) hide show
  1. checksums.yaml +4 -4
  2. data/config/rails.yml +3 -0
  3. data/exe/gusto-rubocop +2 -2
  4. data/exe/rubocop-gusto +2 -2
  5. data/lib/rubocop/cop/gusto/bootsnap_load_file.rb +2 -2
  6. data/lib/rubocop/cop/gusto/datadog_constant.rb +2 -2
  7. data/lib/rubocop/cop/gusto/execute_migration.rb +1 -1
  8. data/lib/rubocop/cop/gusto/factory_classes_or_modules.rb +1 -1
  9. data/lib/rubocop/cop/gusto/min_by_max_by.rb +1 -1
  10. data/lib/rubocop/cop/gusto/no_metaprogramming.rb +7 -7
  11. data/lib/rubocop/cop/gusto/no_rescue_error_message_checking.rb +1 -1
  12. data/lib/rubocop/cop/gusto/no_send.rb +1 -1
  13. data/lib/rubocop/cop/gusto/object_in.rb +1 -1
  14. data/lib/rubocop/cop/gusto/paperclip_or_attachable.rb +1 -1
  15. data/lib/rubocop/cop/gusto/perform_class_method.rb +2 -2
  16. data/lib/rubocop/cop/gusto/polymorphic_type_validation.rb +1 -1
  17. data/lib/rubocop/cop/gusto/prefer_process_last_status.rb +2 -2
  18. data/lib/rubocop/cop/gusto/rabl_extends.rb +2 -2
  19. data/lib/rubocop/cop/gusto/rails_env.rb +2 -2
  20. data/lib/rubocop/cop/gusto/rake_constants.rb +1 -1
  21. data/lib/rubocop/cop/gusto/regexp_bypass.rb +4 -4
  22. data/lib/rubocop/cop/gusto/sidekiq_params.rb +1 -1
  23. data/lib/rubocop/cop/gusto/toplevel_constants.rb +1 -1
  24. data/lib/rubocop/cop/gusto/use_paint_not_colorize.rb +7 -7
  25. data/lib/rubocop/cop/gusto/vcr_recordings.rb +3 -3
  26. data/lib/rubocop/cop/internal_affairs/assignment_first.rb +1 -1
  27. data/lib/rubocop/cop/internal_affairs/require_restrict_on_send.rb +1 -1
  28. data/lib/rubocop/gusto/cli.rb +7 -7
  29. data/lib/rubocop/gusto/config_yml.rb +6 -6
  30. data/lib/rubocop/gusto/init.rb +13 -13
  31. data/lib/rubocop/gusto/plugin.rb +5 -5
  32. data/lib/rubocop/gusto/version.rb +1 -1
  33. data/lib/rubocop/gusto.rb +1 -1
  34. data/lib/rubocop-gusto.rb +6 -6
  35. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6d5f9caaca5dbe1a2cdd70a064d7bf6f5a29a029ae5bc5efe9071613785a698c
4
- data.tar.gz: 1b355982894e5ef91090dfb8e2d0fe4d301690d55d47c485f0951c2d38f1a77e
3
+ metadata.gz: 8a06f9920ea80223223c9353783cfc0a8824f232cc3e18c323195811a28eb28a
4
+ data.tar.gz: 2943d0fd74fc5f31be0f0527e136ee034514d4215357c33e5c64207e377855e1
5
5
  SHA512:
6
- metadata.gz: 48e622d548efed1455bccd269a0c3e459d9149e4e782058f0540505e7a528bb7e1c6ce3d5cbede01f2be62b587ef11cfd2a32ba914f2806f36a4fa57117d4f3a
7
- data.tar.gz: c11542ccc1d6029a8b15cc1ef89de87adcbb8fb2ed7eb0492efc4ce90454f959877b73daaddcdaf443417ebab40a78f60343024ca7f323fa4f1380e6b82c2c55
6
+ metadata.gz: 7dffff3eae0680c7ced3dfd4fc42eb98b37431a86aebcce90c0492a3c05f9c7f13a38c3634037aa3da96647d9857e8553af6ca155ba3707bbcf0a7e9d3fa2e42
7
+ data.tar.gz: ebc7a8072aa0e99bf33f1596aa4502573c99006d28ba179f15fa5c32394d6dc27f94bebc322942c586157e6549a7b2c25b907fd3f4092f4f9f604c58bbd1579a
data/config/rails.yml CHANGED
@@ -82,6 +82,9 @@ Rails/HttpPositionalArguments:
82
82
  - packs/**/spec/{controllers,fixture_generators}/**/*
83
83
  - spec/{controllers,fixture_generators}/**/*
84
84
 
85
+ Rails/IgnoredColumnsAssignment:
86
+ Enabled: true
87
+
85
88
  Rails/InverseOf:
86
89
  Include:
87
90
  - '**/app/models/**/*'
data/exe/gusto-rubocop CHANGED
@@ -5,8 +5,8 @@
5
5
  # This file is here to conform to our gusto-* convention.
6
6
  # rubocop gems have their own naming convention so we're doing both.
7
7
 
8
- $LOAD_PATH.unshift(File.expand_path('../lib', __dir__))
8
+ $LOAD_PATH.unshift(File.expand_path("../lib", __dir__))
9
9
 
10
- require 'rubocop/gusto/cli'
10
+ require "rubocop/gusto/cli"
11
11
 
12
12
  RuboCop::Gusto::Cli.start(ARGV)
data/exe/rubocop-gusto CHANGED
@@ -2,8 +2,8 @@
2
2
  # frozen_string_literal: true
3
3
  # typed: strict
4
4
 
5
- $LOAD_PATH.unshift(File.expand_path('../lib', __dir__))
5
+ $LOAD_PATH.unshift(File.expand_path("../lib", __dir__))
6
6
 
7
- require 'rubocop/gusto/cli'
7
+ require "rubocop/gusto/cli"
8
8
 
9
9
  RuboCop::Gusto::Cli.start(ARGV)
@@ -9,10 +9,10 @@ module RuboCop
9
9
  RESTRICT_ON_SEND = %i(load).freeze
10
10
 
11
11
  # @!method yaml_or_json_load(node)
12
- def_node_matcher :yaml_or_json_load, '(send $(const nil? PROHIBITED_CONSTANTS) :load ...)'
12
+ def_node_matcher :yaml_or_json_load, "(send $(const nil? PROHIBITED_CONSTANTS) :load ...)"
13
13
 
14
14
  # @!method file_read(node)
15
- def_node_matcher :file_read, '(send (const nil? :File) :read $_)'
15
+ def_node_matcher :file_read, "(send (const nil? :File) :read $_)"
16
16
 
17
17
  # @!method load_inside_file_open(node)
18
18
  def_node_matcher :load_inside_file_open, <<~PATTERN
@@ -4,8 +4,8 @@ module RuboCop
4
4
  module Cop
5
5
  module Gusto
6
6
  class DatadogConstant < Base
7
- MSG = 'Do not call Datadog directly, use an appropriate wrapper library.'
8
- NAMESPACE = 'Datadog'
7
+ MSG = "Do not call Datadog directly, use an appropriate wrapper library."
8
+ NAMESPACE = "Datadog"
9
9
 
10
10
  def on_const(node)
11
11
  add_offense(node) if node.const_name == NAMESPACE
@@ -4,7 +4,7 @@ module RuboCop
4
4
  module Cop
5
5
  module Gusto
6
6
  class ExecuteMigration < Base
7
- MSG = 'Do not use `execute` to run raw SQL in a migration. Run the query from a backfill rake task or pass the SQL options to the `add_column`/`change_column` method.'
7
+ MSG = "Do not use `execute` to run raw SQL in a migration. Run the query from a backfill rake task or pass the SQL options to the `add_column`/`change_column` method."
8
8
  RESTRICT_ON_SEND = [:execute].freeze
9
9
 
10
10
  def on_send(node)
@@ -4,7 +4,7 @@ module RuboCop
4
4
  module Cop
5
5
  module Gusto
6
6
  class FactoryClassesOrModules < Base
7
- MSG = 'Do not define modules or classes in factory directories - they break reloading'
7
+ MSG = "Do not define modules or classes in factory directories - they break reloading"
8
8
 
9
9
  def on_class(node)
10
10
  add_offense(node)
@@ -26,7 +26,7 @@ module RuboCop
26
26
  class MinByMaxBy < Base
27
27
  extend AutoCorrector
28
28
 
29
- MSG = 'Use `%{method}_by` instead of `%{method}` with a proc like `&:my_method_proc`. `%{method}` expects Comparable elements.'
29
+ MSG = "Use `%{method}_by` instead of `%{method}` with a proc like `&:my_method_proc`. `%{method}` expects Comparable elements."
30
30
  RESTRICT_ON_SEND = %i(min max).freeze
31
31
 
32
32
  def on_send(node)
@@ -94,35 +94,35 @@ module RuboCop
94
94
 
95
95
  def on_defs(node)
96
96
  included_definition?(node) do
97
- add_offense(node, message: 'self.included modifies the behavior of classes at runtime. Please avoid using if possible.')
97
+ add_offense(node, message: "self.included modifies the behavior of classes at runtime. Please avoid using if possible.")
98
98
  end
99
99
 
100
100
  inherited_definition?(node) do
101
- add_offense(node, message: 'self.inherited modifies the behavior of classes at runtime. Please avoid using if possible.')
101
+ add_offense(node, message: "self.inherited modifies the behavior of classes at runtime. Please avoid using if possible.")
102
102
  end
103
103
  end
104
104
 
105
105
  def on_def(node)
106
106
  using_method_missing?(node) do
107
- add_offense(node, message: 'Please do not use method_missing. Instead, explicitly define the methods you expect to receive.')
107
+ add_offense(node, message: "Please do not use method_missing. Instead, explicitly define the methods you expect to receive.")
108
108
  end
109
109
  end
110
110
 
111
111
  def on_send(node)
112
112
  using_define_method?(node) do
113
- add_offense(node, message: 'Please do not define methods dynamically, instead define them using `def` and explicitly. This helps readability for both humans and machines.')
113
+ add_offense(node, message: "Please do not define methods dynamically, instead define them using `def` and explicitly. This helps readability for both humans and machines.")
114
114
  end
115
115
 
116
116
  using_define_singleton_method_on_klass_instance?(node) do
117
- add_offense(node, message: 'Please do not use define_singleton_method. Instead, define the method explicitly using `def self.my_method; end`')
117
+ add_offense(node, message: "Please do not use define_singleton_method. Instead, define the method explicitly using `def self.my_method; end`")
118
118
  end
119
119
 
120
120
  using_instance_eval?(node) do
121
- add_offense(node, message: 'Please do not use instance_eval to augment behavior onto an instance. Instead, define the method you want to use in the class definition.')
121
+ add_offense(node, message: "Please do not use instance_eval to augment behavior onto an instance. Instead, define the method you want to use in the class definition.")
122
122
  end
123
123
 
124
124
  using_class_eval?(node) do
125
- add_offense(node, message: 'Please do not use class_eval to augment behavior onto a class. Instead, define the method you want to use in the class definition.')
125
+ add_offense(node, message: "Please do not use class_eval to augment behavior onto a class. Instead, define the method you want to use in the class definition.")
126
126
  end
127
127
  end
128
128
  end
@@ -37,7 +37,7 @@ module RuboCop
37
37
  # end
38
38
  #
39
39
  class NoRescueErrorMessageChecking < Base
40
- MSG = 'Avoid checking error message while handling exceptions. This is brittle and can break easily.'
40
+ MSG = "Avoid checking error message while handling exceptions. This is brittle and can break easily."
41
41
  METHODS_TO_CHECK = %i(match? include? ==).to_set.freeze
42
42
 
43
43
  def on_rescue(node)
@@ -14,7 +14,7 @@ module RuboCop
14
14
  # There's no better alternative, don't call private methods.
15
15
  #
16
16
  class NoSend < Base
17
- MSG = 'Do not call a private method via `__send__`.'
17
+ MSG = "Do not call a private method via `__send__`."
18
18
  RESTRICT_ON_SEND = %i(__send__).freeze
19
19
 
20
20
  # @!method invoke_private_method_send?(node)
@@ -16,7 +16,7 @@ module RuboCop
16
16
  # ('a'..'z').cover?('yellow') # => true
17
17
  #
18
18
  class ObjectIn < Base
19
- MSG = 'Use `Range#cover?` instead of `Object#in?`.'
19
+ MSG = "Use `Range#cover?` instead of `Object#in?`."
20
20
  RESTRICT_ON_SEND = [:in?].freeze
21
21
 
22
22
  # @!method object_in(node)
@@ -5,7 +5,7 @@ module RuboCop
5
5
  module Cop
6
6
  module Gusto
7
7
  class PaperclipOrAttachable < Base
8
- MSG = 'No more new paperclip or Attachable are allowed. New attachments should use ActiveStorage instead'
8
+ MSG = "No more new paperclip or Attachable are allowed. New attachments should use ActiveStorage instead"
9
9
  RESTRICT_ON_SEND = %i(has_attached_file has_pdf_attachment has_attachment).freeze
10
10
 
11
11
  def on_send(node)
@@ -26,9 +26,9 @@ module RuboCop
26
26
  # end
27
27
  #
28
28
  class PerformClassMethod < Base
29
- MSG = 'Class-level `perform` method is being defined. Did you mean to use an instance method?'
29
+ MSG = "Class-level `perform` method is being defined. Did you mean to use an instance method?"
30
30
  WORKER_FALLBACK = %w(Sidekiq::Worker).freeze
31
- WORKER_MODULES = 'WorkerModules'
31
+ WORKER_MODULES = "WorkerModules"
32
32
 
33
33
  def on_def(node)
34
34
  return unless node.method?(:perform)
@@ -28,7 +28,7 @@ module RuboCop
28
28
  polymorphic_methods_for :subscription_detail, VALID_TYPES
29
29
  MESSAGE
30
30
 
31
- ALLOW_BLANK_MSG = 'Polymorphic type validations cannot use allow_blank: true'
31
+ ALLOW_BLANK_MSG = "Polymorphic type validations cannot use allow_blank: true"
32
32
 
33
33
  # @!method polymorphic_relation?(node)
34
34
  def_node_matcher :polymorphic_relation?, <<~PATTERN
@@ -17,7 +17,7 @@ module RuboCop
17
17
  class PreferProcessLastStatus < Base
18
18
  extend AutoCorrector
19
19
 
20
- MSG = 'Prefer using `Process.last_status` instead of the global variables: `$?` and `$CHILD_STATUS`.'
20
+ MSG = "Prefer using `Process.last_status` instead of the global variables: `$?` and `$CHILD_STATUS`."
21
21
  OFFENDERS = Set[:$?, :$CHILD_STATUS].freeze
22
22
 
23
23
  def on_gvar(node)
@@ -27,7 +27,7 @@ module RuboCop
27
27
  end
28
28
 
29
29
  def autocorrect(corrector, node)
30
- corrector.replace(node, 'Process.last_status')
30
+ corrector.replace(node, "Process.last_status")
31
31
  end
32
32
  end
33
33
  end
@@ -19,8 +19,8 @@ module RuboCop
19
19
  # child(:baz) { attributes :qux }
20
20
  #
21
21
  class RablExtends < Base
22
- MSG = 'Avoid using Rabl extends as it has poor caching performance. Inline your JSON instead.'
23
- RABL_EXTENSION = '.rabl'
22
+ MSG = "Avoid using Rabl extends as it has poor caching performance. Inline your JSON instead."
23
+ RABL_EXTENSION = ".rabl"
24
24
  RESTRICT_ON_SEND = %i(extends).freeze
25
25
 
26
26
  # @!method rabl_extends?(node)
@@ -51,8 +51,8 @@ module RuboCop
51
51
  local?
52
52
  )
53
53
  ).freeze
54
- MSG = 'Use Feature Flags or config instead of `Rails.env`.'
55
- PROHIBITED_CLASS = 'Rails'
54
+ MSG = "Use Feature Flags or config instead of `Rails.env`."
55
+ PROHIBITED_CLASS = "Rails"
56
56
  RESTRICT_ON_SEND = %i(env).freeze
57
57
 
58
58
  def on_send(node)
@@ -28,7 +28,7 @@ module RuboCop
28
28
  # end
29
29
  #
30
30
  class RakeConstants < Base
31
- MSG = 'Do not define a constant in rake file, because they are sometimes `load`ed, instead of `require`d which can lead to warnings about redefining constants'
31
+ MSG = "Do not define a constant in rake file, because they are sometimes `load`ed, instead of `require`d which can lead to warnings about redefining constants"
32
32
 
33
33
  # @!method task_or_namespace?(node)
34
34
  def_node_matcher :task_or_namespace?, <<-PATTERN
@@ -39,16 +39,16 @@ module RuboCop
39
39
  extend AutoCorrector
40
40
 
41
41
  MSG = 'Regular expressions matching a single line should use \A instead of ^ and \z instead of $'
42
- PROHIBITED_ANCHOR = '^'
43
- PROHIBITED_END_ANCHOR = '$'
42
+ PROHIBITED_ANCHOR = "^"
43
+ PROHIBITED_END_ANCHOR = "$"
44
44
 
45
45
  def on_regexp(node)
46
- return if node.children.find(&:regopt_type?)&.source&.include?('m')
46
+ return if node.children.find(&:regopt_type?)&.source&.include?("m")
47
47
 
48
48
  first_child = node.children.first
49
49
  return unless first_child && !first_child.regopt_type?
50
50
 
51
- captureless_source = first_child.source.delete('()') # Remove parentheses to check actual content
51
+ captureless_source = first_child.source.delete("()") # Remove parentheses to check actual content
52
52
  return unless captureless_source.start_with?(PROHIBITED_ANCHOR) || captureless_source.end_with?(PROHIBITED_END_ANCHOR)
53
53
 
54
54
  add_offense(first_child) do |corrector|
@@ -4,7 +4,7 @@ module RuboCop
4
4
  module Cop
5
5
  module Gusto
6
6
  class SidekiqParams < Base
7
- MSG = 'Sidekiq perform methods cannot take keyword arguments'
7
+ MSG = "Sidekiq perform methods cannot take keyword arguments"
8
8
  PROHIBITED_ARG_TYPES = Set.new(%i(kwoptarg kwarg)).freeze
9
9
 
10
10
  def on_def(node)
@@ -39,7 +39,7 @@ module RuboCop
39
39
  # FOO = 'bar' # config/initializers/foo.rb
40
40
  #
41
41
  class ToplevelConstants < Base
42
- MSG = 'Top-level constants should be defined in an initializer. See https://github.com/Gusto/rubocop-gusto/blob/main/lib/rubocop/cop/gusto/toplevel_constants.rb'
42
+ MSG = "Top-level constants should be defined in an initializer. See https://github.com/Gusto/rubocop-gusto/blob/main/lib/rubocop/cop/gusto/toplevel_constants.rb"
43
43
 
44
44
  def on_casgn(node)
45
45
  # Allow nested constants
@@ -92,8 +92,8 @@ module RuboCop
92
92
  )
93
93
  ).freeze
94
94
 
95
- MSG = 'Use Paint instead of colorize for terminal colors.'
96
- PROHIBITED_CLASS = 'String'
95
+ MSG = "Use Paint instead of colorize for terminal colors."
96
+ PROHIBITED_CLASS = "String"
97
97
  RESTRICT_ON_SEND = COLOR_METHODS
98
98
 
99
99
  def on_send(node)
@@ -170,16 +170,16 @@ module RuboCop
170
170
  elsif method_name == :uncolorize
171
171
  # If uncolorize is called, convert to Paint.unpaint
172
172
  return "Paint.unpaint(#{original_string.source})"
173
- elsif method_name.start_with?('on_')
173
+ elsif method_name.start_with?("on_")
174
174
  # Background color
175
- color_name = method_name.to_s.delete_prefix('on_')
175
+ color_name = method_name.to_s.delete_prefix("on_")
176
176
  background = ":#{color_name}"
177
177
  elsif STYLE_MODIFIERS.include?(method_name)
178
178
  # Style modifier
179
179
  styles << ":#{method_name}"
180
- elsif method_name.start_with?('light_')
180
+ elsif method_name.start_with?("light_")
181
181
  # Light/bright foreground color
182
- color = method_name.to_s.delete_prefix('light_')
182
+ color = method_name.to_s.delete_prefix("light_")
183
183
  foreground = ":bright, :#{color}"
184
184
  else
185
185
  # Regular foreground color
@@ -221,7 +221,7 @@ module RuboCop
221
221
 
222
222
  # Add nil as a placeholder for foreground if we only have a background
223
223
  if background && !foreground
224
- params << 'nil'
224
+ params << "nil"
225
225
  elsif foreground
226
226
  params << foreground
227
227
  end
@@ -17,7 +17,7 @@ module RuboCop
17
17
  class VcrRecordings < Base
18
18
  extend AutoCorrector
19
19
 
20
- MSG = 'VCR should be set to not record in tests. Please use vcr: {record: :none}.'
20
+ MSG = "VCR should be set to not record in tests. Please use vcr: {record: :none}."
21
21
 
22
22
  # @!method vcr_recording?(node)
23
23
  def_node_matcher :vcr_recording?, <<~PATTERN
@@ -29,7 +29,7 @@ module RuboCop
29
29
  return unless recording_enabled?(node.key.children.first, node.value.children.first)
30
30
 
31
31
  add_offense(node) do |corrector|
32
- replacement = node.source.sub(/: :\w*/, ': :none')
32
+ replacement = node.source.sub(/: :\w*/, ": :none")
33
33
  corrector.replace(node, replacement)
34
34
  end
35
35
  end
@@ -37,7 +37,7 @@ module RuboCop
37
37
  private
38
38
 
39
39
  def vcr_setting?(node)
40
- node.parent.parent.source.include?('vcr')
40
+ node.parent.parent.source.include?("vcr")
41
41
  end
42
42
 
43
43
  def recording_enabled?(option, value)
@@ -38,7 +38,7 @@ module RuboCop
38
38
  after_class
39
39
  after_module
40
40
  ).to_set.freeze
41
- MSG = 'Avoid placing an assignment as the first action in `%{hook}`.'
41
+ MSG = "Avoid placing an assignment as the first action in `%{hook}`."
42
42
 
43
43
  def on_def(node)
44
44
  return unless HOOKS.include?(node.method_name)
@@ -24,7 +24,7 @@ module RuboCop
24
24
  # NOTE: This works for us because we do not write cops that investigate every send node.
25
25
  # Upstream Rubocop chose not to implement this as there are many cops in Core that investigate every node.
26
26
  class RequireRestrictOnSend < Base
27
- MSG = 'Missing `RESTRICT_ON_SEND` declaration when using `on_send` or `after_send`.'
27
+ MSG = "Missing `RESTRICT_ON_SEND` declaration when using `on_send` or `after_send`."
28
28
 
29
29
  # @!method defined_send_callback?(node)
30
30
  def_node_search :defined_send_callback?, <<~PATTERN
@@ -1,17 +1,17 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'thor'
4
- require 'rubocop/gusto/config_yml'
5
- require 'rubocop/gusto/init'
3
+ require "thor"
4
+ require "rubocop/gusto/config_yml"
5
+ require "rubocop/gusto/init"
6
6
 
7
7
  module RuboCop
8
8
  module Gusto
9
9
  class Cli < Thor
10
- register(Init, 'init', 'init', 'Initialize rubocop-gusto and update .rubocop.yml')
10
+ register(Init, "init", "init", "Initialize rubocop-gusto and update .rubocop.yml")
11
11
 
12
- desc 'sort [RUBOCOP_YML_PATH]', 'Sort the cops in a .rubocop.yml file (default: .rubocop.yml)'
13
- method_option :output, type: :string, default: nil, desc: 'The path to the output file'
14
- def sort(rubocop_yml_path = '.rubocop.yml')
12
+ desc "sort [RUBOCOP_YML_PATH]", "Sort the cops in a .rubocop.yml file (default: .rubocop.yml)"
13
+ method_option :output, type: :string, default: nil, desc: "The path to the output file"
14
+ def sort(rubocop_yml_path = ".rubocop.yml")
15
15
  say "Sorting #{rubocop_yml_path}..."
16
16
  output_path = options[:output] || rubocop_yml_path
17
17
  ConfigYml.load_file(rubocop_yml_path).sort!.write(output_path)
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'pathname'
3
+ require "pathname"
4
4
 
5
5
  module RuboCop
6
6
  module Gusto
@@ -16,7 +16,7 @@ module RuboCop
16
16
  INDENT_REGEX = /\A( |- )/
17
17
 
18
18
  # @param [String] file_path the path to the .rubocop.yml file
19
- def self.load_file(file_path = '.rubocop.yml')
19
+ def self.load_file(file_path = ".rubocop.yml")
20
20
  new(File.readlines(file_path))
21
21
  rescue Errno::ENOENT
22
22
  new([])
@@ -33,7 +33,7 @@ module RuboCop
33
33
 
34
34
  # Find if there's already an inherit_gem section and add the gem to it if needed
35
35
  def add_inherit_gem(gem_name, *config_paths)
36
- update_section_data('inherit_gem') do |data|
36
+ update_section_data("inherit_gem") do |data|
37
37
  data ||= {}
38
38
  data[gem_name.to_s] = config_paths.flatten
39
39
  data
@@ -42,7 +42,7 @@ module RuboCop
42
42
 
43
43
  # Add a plugin to the plugins section or create it if it doesn't exist
44
44
  def add_plugin(plugins)
45
- update_section_data('plugins') do |data|
45
+ update_section_data("plugins") do |data|
46
46
  data ||= []
47
47
  data.concat(plugins).uniq
48
48
  end
@@ -80,7 +80,7 @@ module RuboCop
80
80
  end
81
81
 
82
82
  # Sort the cops by their key name, putting comments at the top
83
- cops.sort_by! { |cop| chunk_name(cop) || 'AAAAA/Comment?' }
83
+ cops.sort_by! { |cop| chunk_name(cop) || "AAAAA/Comment?" }
84
84
 
85
85
  self
86
86
  end
@@ -110,7 +110,7 @@ module RuboCop
110
110
  # Try to find a line that exactly matches KEY_REGEX
111
111
  # Use rstrip, not strip, to preserve indentation
112
112
  name_line = chunk.find { |line| line.rstrip.match?(KEY_REGEX) }
113
- name_line&.rstrip&.delete_suffix(':')
113
+ name_line&.rstrip&.delete_suffix(":")
114
114
  end
115
115
 
116
116
  # Splits the lines into blocks whenever we drop from indented to unindented
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'pathname'
4
- require 'yaml'
5
- require 'rubocop/gusto/config_yml'
3
+ require "pathname"
4
+ require "yaml"
5
+ require "rubocop/gusto/config_yml"
6
6
 
7
7
  module RuboCop
8
8
  module Gusto
@@ -11,48 +11,48 @@ module RuboCop
11
11
 
12
12
  PLUGINS = %w(rubocop-gusto rubocop-rspec rubocop-performance rubocop-rake rubocop-rails).freeze
13
13
 
14
- class_option :rubocop_yml, type: :string, default: '.rubocop.yml'
14
+ class_option :rubocop_yml, type: :string, default: ".rubocop.yml"
15
15
 
16
16
  def self.source_root
17
- File.expand_path('templates', __dir__)
17
+ File.expand_path("templates", __dir__)
18
18
  end
19
19
 
20
20
  def add_dependencies
21
21
  if rails?
22
22
  # we don't want rubocop-rails to be a dependency of the gem so that we can use this in non-rails gems
23
- run 'bundle show rubocop-rails >/dev/null || bundle add rubocop-rails --group development', capture: true
23
+ run "bundle show rubocop-rails >/dev/null || bundle add rubocop-rails --group development", capture: true
24
24
  end
25
25
 
26
- run 'bundle binstub rubocop', capture: true
26
+ run "bundle binstub rubocop", capture: true
27
27
  end
28
28
 
29
29
  def copy_config_files
30
30
  config = ConfigYml.load_file(options[:rubocop_yml])
31
31
 
32
32
  if config.empty?
33
- template 'rubocop.yml', options[:rubocop_yml]
33
+ template "rubocop.yml", options[:rubocop_yml]
34
34
  config = ConfigYml.load_file(options[:rubocop_yml])
35
35
  end
36
36
 
37
37
  if rails?
38
- config.add_inherit_gem('rubocop-gusto', 'config/default.yml', 'config/rails.yml')
38
+ config.add_inherit_gem("rubocop-gusto", "config/default.yml", "config/rails.yml")
39
39
  config.add_plugin(PLUGINS)
40
40
  else
41
- config.add_inherit_gem('rubocop-gusto', 'config/default.yml')
41
+ config.add_inherit_gem("rubocop-gusto", "config/default.yml")
42
42
  config.add_plugin(PLUGINS - %w(rubocop-rails))
43
43
  end
44
44
 
45
45
  config.sort!
46
46
  config.write(options[:rubocop_yml])
47
- say_status 'update', options[:rubocop_yml]
47
+ say_status "update", options[:rubocop_yml]
48
48
 
49
- create_file('.rubocop_todo.yml', skip: true)
49
+ create_file(".rubocop_todo.yml", skip: true)
50
50
  end
51
51
 
52
52
  private
53
53
 
54
54
  def rails?
55
- File.exist?('config/application.rb')
55
+ File.exist?("config/application.rb")
56
56
  end
57
57
  end
58
58
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'lint_roller'
3
+ require "lint_roller"
4
4
 
5
5
  module RuboCop
6
6
  module Gusto
@@ -8,9 +8,9 @@ module RuboCop
8
8
  class Plugin < LintRoller::Plugin
9
9
  def about
10
10
  LintRoller::About.new(
11
- name: 'rubocop-gusto',
11
+ name: "rubocop-gusto",
12
12
  version: RuboCop::Gusto::VERSION,
13
- homepage: 'https://github.com/Gusto/rubocop-gusto',
13
+ homepage: "https://github.com/Gusto/rubocop-gusto",
14
14
  description: "A collection of Gusto's standard RuboCop cops and rules."
15
15
  )
16
16
  end
@@ -20,9 +20,9 @@ module RuboCop
20
20
  end
21
21
 
22
22
  def rules(_context)
23
- project_root = Pathname.new(__dir__).join('../../..')
23
+ project_root = Pathname.new(__dir__).join("../../..")
24
24
 
25
- LintRoller::Rules.new(type: :path, config_format: :rubocop, value: project_root.join('config', 'default.yml'))
25
+ LintRoller::Rules.new(type: :path, config_format: :rubocop, value: project_root.join("config", "default.yml"))
26
26
  end
27
27
  end
28
28
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module RuboCop
4
4
  module Gusto
5
- VERSION = '10.0.1'
5
+ VERSION = "10.1.1"
6
6
  end
7
7
  end
data/lib/rubocop/gusto.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative 'gusto/version'
3
+ require_relative "gusto/version"
4
4
 
5
5
  module RuboCop
6
6
  # RuboCop Gusto project namespace.
data/lib/rubocop-gusto.rb CHANGED
@@ -1,13 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'rubocop'
4
- require 'rubocop-rspec'
3
+ require "rubocop"
4
+ require "rubocop-rspec"
5
5
 
6
- require_relative 'rubocop/gusto'
7
- require_relative 'rubocop/gusto/version'
8
- require_relative 'rubocop/gusto/plugin'
6
+ require_relative "rubocop/gusto"
7
+ require_relative "rubocop/gusto/version"
8
+ require_relative "rubocop/gusto/plugin"
9
9
 
10
10
  # Require all cops
11
- Dir.glob(File.join(File.dirname(__FILE__), 'rubocop/cop/**/*.rb')).each do |file|
11
+ Dir.glob(File.join(File.dirname(__FILE__), "rubocop/cop/**/*.rb")).each do |file|
12
12
  require file
13
13
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubocop-gusto
3
3
  version: !ruby/object:Gem::Version
4
- version: 10.0.1
4
+ version: 10.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gusto Engineering
@@ -172,7 +172,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
172
172
  - !ruby/object:Gem::Version
173
173
  version: '0'
174
174
  requirements: []
175
- rubygems_version: 3.6.9
175
+ rubygems_version: 3.7.1
176
176
  specification_version: 4
177
177
  summary: A gem for sharing gusto rubocop rules
178
178
  test_files: []