rubocop-munra 0.2.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.
Files changed (53) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +42 -0
  3. data/README.md +11 -1
  4. data/config/default.yml +101 -1
  5. data/lib/rubocop/cop/munra/00_model_scope_names.rb +42 -0
  6. data/lib/rubocop/cop/munra/00_model_spec_section_checks.rb +71 -0
  7. data/lib/rubocop/cop/munra/00_rspec_helpers.rb +26 -3
  8. data/lib/rubocop/cop/munra/00_transaction_block_mixin.rb +7 -6
  9. data/lib/rubocop/cop/munra/address_fields_order.rb +66 -0
  10. data/lib/rubocop/cop/munra/address_state_select.rb +3 -3
  11. data/lib/rubocop/cop/munra/admin_policy.rb +55 -8
  12. data/lib/rubocop/cop/munra/brazilian_state_inclusion.rb +67 -0
  13. data/lib/rubocop/cop/munra/builtin_validation_options.rb +24 -6
  14. data/lib/rubocop/cop/munra/digits_only_attributes.rb +103 -0
  15. data/lib/rubocop/cop/munra/email_format.rb +21 -26
  16. data/lib/rubocop/cop/munra/flash_success_locale_name.rb +30 -25
  17. data/lib/rubocop/cop/munra/flash_success_name.rb +2 -2
  18. data/lib/rubocop/cop/munra/full_error_messages.rb +3 -6
  19. data/lib/rubocop/cop/munra/let_layout.rb +9 -2
  20. data/lib/rubocop/cop/munra/literal_expectation.rb +68 -0
  21. data/lib/rubocop/cop/munra/model_spec_structure.rb +156 -0
  22. data/lib/rubocop/cop/munra/named_subject_layout.rb +4 -6
  23. data/lib/rubocop/cop/munra/no_current_date_in_system_spec.rb +37 -0
  24. data/lib/rubocop/cop/munra/no_human_attribute_name.rb +1 -1
  25. data/lib/rubocop/cop/munra/no_inline_validation.rb +1 -1
  26. data/lib/rubocop/cop/munra/no_leading_dot.rb +1 -1
  27. data/lib/rubocop/cop/munra/no_mixed_example_siblings.rb +57 -0
  28. data/lib/rubocop/cop/munra/no_shared_examples.rb +9 -4
  29. data/lib/rubocop/cop/munra/one_example_per_context.rb +54 -0
  30. data/lib/rubocop/cop/munra/policy_blank_deny.rb +133 -0
  31. data/lib/rubocop/cop/munra/service_object.rb +14 -6
  32. data/lib/rubocop/cop/munra/validations_before_callbacks.rb +80 -0
  33. data/lib/rubocop/munra/plugin.rb +1 -1
  34. data/lib/rubocop/munra/version.rb +1 -3
  35. metadata +14 -19
  36. data/.github/workflows/ci.yml +0 -29
  37. data/.github/workflows/docs.yml +0 -90
  38. data/.ruby-version +0 -1
  39. data/AGENTS.md +0 -101
  40. data/CODE_OF_CONDUCT.md +0 -10
  41. data/Rakefile +0 -42
  42. data/antora-playbook.yml +0 -22
  43. data/docs/antora.yml +0 -5
  44. data/docs/modules/ROOT/nav.adoc +0 -5
  45. data/docs/modules/ROOT/pages/cops.adoc +0 -2
  46. data/docs/modules/ROOT/pages/cops_munra.adoc +0 -1026
  47. data/docs/modules/ROOT/pages/index.adoc +0 -11
  48. data/docs/modules/ROOT/pages/installation.adoc +0 -50
  49. data/docs/modules/ROOT/pages/usage.adoc +0 -98
  50. data/docs/usage.md +0 -29
  51. data/package-lock.json +0 -1930
  52. data/package.json +0 -12
  53. data/sig/rubocop/munra.rbs +0 -6
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Disallow `Date.current` and `Date.today` in system specs.
4
+ #
5
+ # Prefer fixed dates so system specs stay deterministic.
6
+ #
7
+ # @example
8
+ # # bad
9
+ # fill_in 'Date', with: Date.current
10
+ #
11
+ # # bad
12
+ # fill_in 'Date', with: Date.today
13
+ #
14
+ # # good
15
+ # fill_in 'Date', with: Date.new(2024, 1, 15)
16
+ class RuboCop::Cop::Munra::NoCurrentDateInSystemSpec < RuboCop::Cop::Base
17
+ MSG = 'Use fixed dates in system specs instead of `Date.current` / `Date.today`.'
18
+
19
+ RESTRICT_ON_SEND = [:current, :today].freeze
20
+
21
+ def on_send(node)
22
+ return unless system_spec_file?
23
+ return unless date_receiver?(node, :Date)
24
+
25
+ add_offense(node)
26
+ end
27
+
28
+ private
29
+
30
+ def system_spec_file?
31
+ processed_source.file_path.to_s.match?(%r{(?:^|/)spec/system/})
32
+ end
33
+
34
+ def date_receiver?(node, name)
35
+ node.receiver&.const_type? && node.receiver.short_name == name
36
+ end
37
+ end
@@ -14,7 +14,7 @@
14
14
  class RuboCop::Cop::Munra::NoHumanAttributeName < RuboCop::Cop::Base
15
15
  MSG = 'Use `I18n.t(\'activerecord.attributes...\')` instead of `human_attribute_name`.'
16
16
 
17
- RESTRICT_ON_SEND = %i[human_attribute_name].freeze
17
+ RESTRICT_ON_SEND = [:human_attribute_name].freeze
18
18
 
19
19
  def on_send(node)
20
20
  return if defining_human_attribute_name?(node)
@@ -11,7 +11,7 @@
11
11
  class RuboCop::Cop::Munra::NoInlineValidation < RuboCop::Cop::Base
12
12
  MSG = 'Use a validator class with `validates_with` instead of `validate`.'
13
13
 
14
- RESTRICT_ON_SEND = %i[validate].freeze
14
+ RESTRICT_ON_SEND = [:validate].freeze
15
15
 
16
16
  def on_send(node)
17
17
  return unless node.receiver.nil?
@@ -33,7 +33,7 @@ class RuboCop::Cop::Munra::NoLeadingDot < RuboCop::Cop::Base
33
33
 
34
34
  add_offense(dot) do |corrector|
35
35
  corrector.remove(dot)
36
- corrector.insert_after(receiver, '.')
36
+ corrector.insert_after(receiver, dot.source)
37
37
  end
38
38
  end
39
39
  end
@@ -0,0 +1,57 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Do not mix an `it` / `specify` / `example` with a sibling `context` or
4
+ # `describe`. Wrap the bare example in its own grouping block.
5
+ #
6
+ # @example
7
+ # # bad
8
+ # RSpec.describe FooJob do
9
+ # context 'when success' do
10
+ # it 'performs the job' do
11
+ # end
12
+ #
13
+ # context 'when broadcasting feedback' do
14
+ # it 'broadcasts a toast' do
15
+ # end
16
+ # end
17
+ # end
18
+ # end
19
+ #
20
+ # # good
21
+ # RSpec.describe FooJob do
22
+ # context 'when success' do
23
+ # context 'when performing the job' do
24
+ # it 'performs the job' do
25
+ # end
26
+ # end
27
+ #
28
+ # context 'when broadcasting feedback' do
29
+ # it 'broadcasts a toast' do
30
+ # end
31
+ # end
32
+ # end
33
+ # end
34
+ #
35
+ # # good
36
+ # RSpec.describe FooJob do
37
+ # context 'when success' do
38
+ # it 'performs the job' do
39
+ # end
40
+ # end
41
+ # end
42
+ class RuboCop::Cop::Munra::NoMixedExampleSiblings < RuboCop::Cop::Base
43
+ include RuboCop::Cop::Munra::RSpecHelpers
44
+
45
+ MSG = 'Do not place `it` / `specify` as a sibling of `context` / `describe`. Wrap the example in a `context`.'
46
+
47
+ def on_block(node)
48
+ return unless example_group?(node)
49
+
50
+ children = block_statement_children(node)
51
+ examples = children.select { |child| example?(child) }
52
+ nested_groups = children.select { |child| example_group?(child) }
53
+ return if examples.empty? || nested_groups.empty?
54
+
55
+ examples.each { |example| add_offense(example) }
56
+ end
57
+ end
@@ -36,9 +36,14 @@ class RuboCop::Cop::Munra::NoSharedExamples < RuboCop::Cop::Base
36
36
  def forbidden_methods
37
37
  Array(
38
38
  cop_config.fetch(
39
- 'ForbiddenMethods', %w[
40
- shared_examples shared_examples_for shared_context
41
- it_behaves_like it_should_behave_like include_examples include_context
39
+ 'ForbiddenMethods', [
40
+ 'shared_examples',
41
+ 'shared_examples_for',
42
+ 'shared_context',
43
+ 'it_behaves_like',
44
+ 'it_should_behave_like',
45
+ 'include_examples',
46
+ 'include_context'
42
47
  ]
43
48
  )
44
49
  ).map(&:to_sym)
@@ -49,6 +54,6 @@ class RuboCop::Cop::Munra::NoSharedExamples < RuboCop::Cop::Base
49
54
  return true if receiver.nil?
50
55
  return true if receiver.const_type? && receiver.short_name == :RSpec
51
56
 
52
- receiver.send_type? && %i[describe context].include?(receiver.method_name)
57
+ receiver.send_type? && [:describe, :context].include?(receiver.method_name)
53
58
  end
54
59
  end
@@ -0,0 +1,54 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Allow only one `it` / `specify` per `describe` / `context`.
4
+ #
5
+ # Wrap additional examples in their own grouping blocks.
6
+ #
7
+ # @example
8
+ # # bad
9
+ # RSpec.describe Foo do
10
+ # context 'when foo' do
11
+ # it 'does one thing' do
12
+ # end
13
+ #
14
+ # it 'does another thing' do
15
+ # end
16
+ # end
17
+ # end
18
+ #
19
+ # # good
20
+ # RSpec.describe Foo do
21
+ # context 'when foo' do
22
+ # context 'when doing one thing' do
23
+ # it 'does one thing' do
24
+ # end
25
+ # end
26
+ #
27
+ # context 'when doing another thing' do
28
+ # it 'does another thing' do
29
+ # end
30
+ # end
31
+ # end
32
+ # end
33
+ #
34
+ # # good
35
+ # RSpec.describe Foo do
36
+ # context 'when foo' do
37
+ # it 'does one thing' do
38
+ # end
39
+ # end
40
+ # end
41
+ class RuboCop::Cop::Munra::OneExamplePerContext < RuboCop::Cop::Base
42
+ include RuboCop::Cop::Munra::RSpecHelpers
43
+
44
+ MSG = 'Only one `it` / `specify` is allowed per `describe` / `context`.'
45
+
46
+ def on_block(node)
47
+ return unless example_group?(node)
48
+
49
+ examples = block_statement_children(node).select { |child| example?(child) }
50
+ return if examples.size <= 1
51
+
52
+ examples.drop(1).each { |example| add_offense(example) }
53
+ end
54
+ end
@@ -0,0 +1,133 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Flags `return true` when a configured blank attribute guard is present — blank must deny.
4
+ #
5
+ # Covers modifier form (`return true if ...`) and block form where `return true` sits
6
+ # in the `if` / `unless` body, including when the body is wrapped in `begin`.
7
+ #
8
+ # @example
9
+ # # bad
10
+ # return true if record.account_id.blank?
11
+ #
12
+ # # bad
13
+ # return true unless record.employee_id.present?
14
+ #
15
+ # # bad
16
+ # if record.account_id.blank?
17
+ # return true
18
+ # end
19
+ #
20
+ # # good
21
+ # return false if record.account_id.blank?
22
+ #
23
+ # # good
24
+ # return true if same_account?
25
+ class RuboCop::Cop::Munra::PolicyBlankDeny < RuboCop::Cop::Base
26
+ MSG = 'Do not `return true` when %<attributes>s is blank; blank must deny access.'
27
+
28
+ def on_return(node)
29
+ return unless returns_true?(node)
30
+ return unless blank_id_guard?(node)
31
+
32
+ add_offense(node, message: offense_message)
33
+ end
34
+
35
+ private
36
+
37
+ def blank_attributes
38
+ cop_config.fetch('BlankAttributes', ['account_id', 'employee_id']).map(&:to_sym)
39
+ end
40
+
41
+ def offense_message
42
+ formatted = blank_attributes.map { |attr| "`#{attr}`" }.join(' or ')
43
+ format(MSG, attributes: formatted)
44
+ end
45
+
46
+ def returns_true?(node)
47
+ child = node.children.first
48
+ child&.true_type?
49
+ end
50
+
51
+ def blank_id_guard?(node)
52
+ if_node = guard_if_for(node)
53
+ return false unless if_node
54
+
55
+ condition = if_node.condition
56
+ return false unless condition
57
+
58
+ blank_id_condition?(condition, negate: if_node.unless?)
59
+ end
60
+
61
+ # Finds the `if` / `unless` whose then-branch contains this return.
62
+ #
63
+ # @param node [RuboCop::AST::Node] a `return` node
64
+ # @return [RuboCop::AST::Node, nil]
65
+ def guard_if_for(node)
66
+ parent = node.parent
67
+ return parent if if_guard?(parent) && parent.if_branch.equal?(node)
68
+ return unless begin_body?(parent)
69
+
70
+ if_node = parent.parent
71
+ return unless if_guard?(if_node)
72
+ return unless if_node.if_branch.equal?(parent)
73
+
74
+ if_node
75
+ end
76
+
77
+ def if_guard?(node)
78
+ return false unless node&.if_type?
79
+
80
+ node.if? || node.unless?
81
+ end
82
+
83
+ def begin_body?(node)
84
+ return false unless node
85
+
86
+ node.begin_type? || node.kwbegin_type?
87
+ end
88
+
89
+ def blank_id_condition?(node, negate: false)
90
+ case node.type
91
+ when :begin, :and, :or
92
+ node.children.any? { |child| blank_id_condition?(child, negate: negate) }
93
+ when :send, :csend
94
+ blank_id_send?(node, negate: negate)
95
+ else
96
+ false
97
+ end
98
+ end
99
+
100
+ def blank_id_send?(node, negate:)
101
+ return id_blank_predicate?(node) unless negate
102
+ return id_blank_predicate?(node.receiver) if node.method_name == :! && node.receiver
103
+
104
+ id_present_predicate?(node)
105
+ end
106
+
107
+ def id_blank_predicate?(node)
108
+ return false unless call_node?(node)
109
+ return false unless [:blank?, :nil?].include?(node.method_name)
110
+
111
+ blank_attribute_receiver?(node.receiver)
112
+ end
113
+
114
+ def id_present_predicate?(node)
115
+ return false unless call_node?(node)
116
+ return false unless node.method_name == :present?
117
+
118
+ blank_attribute_receiver?(node.receiver)
119
+ end
120
+
121
+ def call_node?(node)
122
+ node&.send_type? || node&.csend_type?
123
+ end
124
+
125
+ def blank_attribute_receiver?(receiver)
126
+ return false unless receiver
127
+
128
+ attributes = blank_attributes
129
+ return true if receiver.send_type? && attributes.include?(receiver.method_name)
130
+
131
+ receiver.csend_type? && attributes.include?(receiver.method_name)
132
+ end
133
+ end
@@ -38,12 +38,11 @@ class RuboCop::Cop::Munra::ServiceObject < RuboCop::Cop::Base
38
38
  MSG_SELF_CALL = 'Do not redefine `self.call`; use `%<superclass>s.call`.'
39
39
  MSG_CALL_PUBLIC = '`call` must be declared below `private`.'
40
40
 
41
- RESTRICT_ON_SEND = [:private].freeze
42
-
43
41
  def on_class(node)
44
42
  suffix = expected_suffix
45
43
  class_name = node.identifier.short_name
46
44
  return unless class_name.to_s.end_with?(suffix)
45
+ return if base_service_class?(node)
47
46
 
48
47
  check_superclass(node)
49
48
  check_self_call(node)
@@ -124,6 +123,7 @@ class RuboCop::Cop::Munra::ServiceObject < RuboCop::Cop::Base
124
123
  visibility = update_visibility(child, visibility)
125
124
  return true if child == call_def && visibility == :private
126
125
  end
126
+
127
127
  false
128
128
  end
129
129
 
@@ -133,13 +133,21 @@ class RuboCop::Cop::Munra::ServiceObject < RuboCop::Cop::Base
133
133
  end
134
134
 
135
135
  def private_call_symbol?(child)
136
- child.send_type? && child.method_name == :private &&
137
- child.arguments.any? { |arg| arg.sym_type? && arg.value == :call }
136
+ child.send_type? && child.method_name == :private && child.arguments.any? { |arg| arg.sym_type? && arg.value == :call }
137
+ end
138
+
139
+ def base_service_class?(node)
140
+ node.identifier.source == expected_superclass
138
141
  end
139
142
 
140
143
  def update_visibility(child, visibility)
141
- return :private if child.send_type? && child.method_name == :private && child.arguments.empty?
144
+ return visibility unless child.send_type? && child.arguments.empty?
142
145
 
143
- visibility
146
+ case child.method_name
147
+ when :private then :private
148
+ when :protected then :protected
149
+ when :public then :public
150
+ else visibility
151
+ end
144
152
  end
145
153
  end
@@ -0,0 +1,80 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Require `validates` / `validates_with` before ActiveRecord callbacks.
4
+ #
5
+ # @example
6
+ # # bad
7
+ # class Foo < ApplicationRecord
8
+ # before_validation :strip_name
9
+ # validates :name, presence: true
10
+ # end
11
+ #
12
+ # # good
13
+ # class Foo < ApplicationRecord
14
+ # validates :name, presence: true
15
+ # before_validation :strip_name
16
+ # end
17
+ class RuboCop::Cop::Munra::ValidationsBeforeCallbacks < RuboCop::Cop::Base
18
+ include RuboCop::Cop::Munra::ClassBodyHelper
19
+
20
+ MSG = 'Declare `validates` / `validates_with` before ActiveRecord callbacks.'
21
+
22
+ CALLBACK_MACROS = [
23
+ :before_validation,
24
+ :around_validation,
25
+ :after_validation,
26
+ :before_save,
27
+ :around_save,
28
+ :after_save,
29
+ :before_create,
30
+ :around_create,
31
+ :after_create,
32
+ :before_update,
33
+ :around_update,
34
+ :after_update,
35
+ :before_destroy,
36
+ :around_destroy,
37
+ :after_destroy,
38
+ :after_commit,
39
+ :before_commit,
40
+ :after_create_commit,
41
+ :after_update_commit,
42
+ :after_destroy_commit,
43
+ :after_save_commit,
44
+ :after_rollback,
45
+ :after_find,
46
+ :after_initialize,
47
+ :after_touch
48
+ ].freeze
49
+
50
+ def on_class(node)
51
+ seen_callback = false
52
+ class_body_statements(node).each do |child|
53
+ if callback_declaration?(child)
54
+ seen_callback = true
55
+ elsif validation_declaration?(child) && seen_callback
56
+ add_offense(child)
57
+ end
58
+ end
59
+ end
60
+
61
+ private
62
+
63
+ def validation_declaration?(node)
64
+ return false unless node.send_type?
65
+
66
+ [:validates, :validates_with].include?(node.method_name)
67
+ end
68
+
69
+ def callback_declaration?(node)
70
+ return callback_block?(node) if node.block_type?
71
+ return false unless node.send_type?
72
+
73
+ CALLBACK_MACROS.include?(node.method_name)
74
+ end
75
+
76
+ def callback_block?(node)
77
+ send = node.send_node
78
+ send && CALLBACK_MACROS.include?(send.method_name)
79
+ end
80
+ end
@@ -14,7 +14,7 @@ class RuboCop::Munra::Plugin < LintRoller::Plugin
14
14
  def about
15
15
  LintRoller::About.new(
16
16
  name: 'rubocop-munra',
17
- version: RuboCop::Munra::STRING,
17
+ version: RuboCop::Munra::VERSION,
18
18
  description: 'RuboCop cops for Rails application conventions.'
19
19
  )
20
20
  end
@@ -7,8 +7,6 @@ module RuboCop
7
7
  # Compact style (`module RuboCop::Munra`) needs that constant to exist already.
8
8
  module Munra
9
9
  # Gem version. Keep in sync with the changelog.
10
- VERSION = '0.2.0'
11
- # String form required by LintRoller::About.
12
- STRING = VERSION
10
+ VERSION = '1.0.0'
13
11
  end
14
12
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubocop-munra
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ramonsantos
@@ -51,54 +51,48 @@ executables: []
51
51
  extensions: []
52
52
  extra_rdoc_files: []
53
53
  files:
54
- - ".github/workflows/ci.yml"
55
- - ".github/workflows/docs.yml"
56
- - ".ruby-version"
57
- - AGENTS.md
58
54
  - CHANGELOG.md
59
- - CODE_OF_CONDUCT.md
60
55
  - LICENSE.txt
61
56
  - README.md
62
- - Rakefile
63
- - antora-playbook.yml
64
57
  - config/default.yml
65
- - docs/antora.yml
66
- - docs/modules/ROOT/nav.adoc
67
- - docs/modules/ROOT/pages/cops.adoc
68
- - docs/modules/ROOT/pages/cops_munra.adoc
69
- - docs/modules/ROOT/pages/index.adoc
70
- - docs/modules/ROOT/pages/installation.adoc
71
- - docs/modules/ROOT/pages/usage.adoc
72
- - docs/usage.md
73
58
  - lib/rubocop-munra.rb
74
59
  - lib/rubocop/cop/munra.rb
75
60
  - lib/rubocop/cop/munra/00_body_statements.rb
76
61
  - lib/rubocop/cop/munra/00_class_body_helper.rb
62
+ - lib/rubocop/cop/munra/00_model_scope_names.rb
63
+ - lib/rubocop/cop/munra/00_model_spec_section_checks.rb
77
64
  - lib/rubocop/cop/munra/00_rspec_helpers.rb
78
65
  - lib/rubocop/cop/munra/00_transaction_block_mixin.rb
66
+ - lib/rubocop/cop/munra/address_fields_order.rb
79
67
  - lib/rubocop/cop/munra/address_state_select.rb
80
68
  - lib/rubocop/cop/munra/admin_policy.rb
69
+ - lib/rubocop/cop/munra/brazilian_state_inclusion.rb
81
70
  - lib/rubocop/cop/munra/builtin_validation_options.rb
82
71
  - lib/rubocop/cop/munra/custom_validator.rb
72
+ - lib/rubocop/cop/munra/digits_only_attributes.rb
83
73
  - lib/rubocop/cop/munra/email_format.rb
84
74
  - lib/rubocop/cop/munra/flash_success_locale_name.rb
85
75
  - lib/rubocop/cop/munra/flash_success_name.rb
86
76
  - lib/rubocop/cop/munra/full_error_messages.rb
87
77
  - lib/rubocop/cop/munra/let_layout.rb
78
+ - lib/rubocop/cop/munra/literal_expectation.rb
79
+ - lib/rubocop/cop/munra/model_spec_structure.rb
88
80
  - lib/rubocop/cop/munra/named_subject_layout.rb
81
+ - lib/rubocop/cop/munra/no_current_date_in_system_spec.rb
89
82
  - lib/rubocop/cop/munra/no_human_attribute_name.rb
90
83
  - lib/rubocop/cop/munra/no_inline_validation.rb
91
84
  - lib/rubocop/cop/munra/no_leading_dot.rb
85
+ - lib/rubocop/cop/munra/no_mixed_example_siblings.rb
92
86
  - lib/rubocop/cop/munra/no_shared_examples.rb
93
87
  - lib/rubocop/cop/munra/no_spec_method.rb
94
88
  - lib/rubocop/cop/munra/no_transaction_exit.rb
89
+ - lib/rubocop/cop/munra/one_example_per_context.rb
90
+ - lib/rubocop/cop/munra/policy_blank_deny.rb
95
91
  - lib/rubocop/cop/munra/service_object.rb
96
92
  - lib/rubocop/cop/munra/success_error_siblings.rb
93
+ - lib/rubocop/cop/munra/validations_before_callbacks.rb
97
94
  - lib/rubocop/munra/plugin.rb
98
95
  - lib/rubocop/munra/version.rb
99
- - package-lock.json
100
- - package.json
101
- - sig/rubocop/munra.rbs
102
96
  homepage: https://ramonsantos.github.io/rubocop-munra/
103
97
  licenses:
104
98
  - MIT
@@ -108,6 +102,7 @@ metadata:
108
102
  source_code_uri: https://github.com/ramonsantos/rubocop-munra
109
103
  bug_tracker_uri: https://github.com/ramonsantos/rubocop-munra/issues
110
104
  changelog_uri: https://github.com/ramonsantos/rubocop-munra/blob/main/CHANGELOG.md
105
+ allowed_push_host: https://rubygems.org
111
106
  default_lint_roller_plugin: RuboCop::Munra::Plugin
112
107
  rubygems_mfa_required: 'true'
113
108
  post_install_message:
@@ -1,29 +0,0 @@
1
- name: CI
2
-
3
- on:
4
- push:
5
- branches: [main]
6
- pull_request:
7
-
8
- concurrency:
9
- group: ci-${{ github.workflow }}-${{ github.ref }}
10
- cancel-in-progress: true
11
-
12
- jobs:
13
- test:
14
- runs-on: ubuntu-latest
15
- steps:
16
- - name: Checkout
17
- uses: actions/checkout@v4
18
-
19
- - name: Set up Ruby
20
- uses: ruby/setup-ruby@v1
21
- with:
22
- ruby-version: '3.2'
23
- bundler-cache: true
24
-
25
- - name: RuboCop
26
- run: bundle exec rubocop
27
-
28
- - name: Tests
29
- run: bundle exec rake test
@@ -1,90 +0,0 @@
1
- name: Publish docs to GitHub Pages
2
-
3
- on:
4
- push:
5
- branches: [main]
6
- paths:
7
- - 'config/default.yml'
8
- - 'docs/**'
9
- - 'lib/rubocop/cop/munra/**'
10
- - 'lib/rubocop/munra/**'
11
- - 'Rakefile'
12
- - 'antora-playbook.yml'
13
- - 'package.json'
14
- - 'package-lock.json'
15
- - '.github/workflows/docs.yml'
16
- pull_request:
17
- paths:
18
- - 'config/default.yml'
19
- - 'docs/**'
20
- - 'lib/rubocop/cop/munra/**'
21
- - 'lib/rubocop/munra/**'
22
- - 'Rakefile'
23
- - 'antora-playbook.yml'
24
- - 'package.json'
25
- - 'package-lock.json'
26
- - '.github/workflows/docs.yml'
27
- workflow_dispatch:
28
-
29
- concurrency:
30
- group: github-pages-${{ github.ref }}
31
- cancel-in-progress: false
32
-
33
- permissions:
34
- contents: read
35
- pages: write
36
- id-token: write
37
-
38
- jobs:
39
- build:
40
- runs-on: ubuntu-latest
41
- steps:
42
- - name: Checkout
43
- uses: actions/checkout@v4
44
-
45
- - name: Set up Ruby
46
- uses: ruby/setup-ruby@v1
47
- with:
48
- # Latest 3.2.x on the runner image; exact 3.2.0 is not built for newer Ubuntu.
49
- ruby-version: '3.2'
50
- bundler-cache: true
51
-
52
- - name: Generate cop documentation
53
- run: bundle exec rake generate_cops_documentation
54
-
55
- - name: Assert generated docs are committed
56
- run: git diff --exit-code -- docs/modules/ROOT/pages/cops.adoc docs/modules/ROOT/pages/cops_munra.adoc
57
-
58
- - name: Set up Node.js
59
- uses: actions/setup-node@v4
60
- with:
61
- node-version: '20'
62
- cache: npm
63
-
64
- - name: Install Antora
65
- run: npm ci
66
-
67
- - name: Build Antora site
68
- run: npx antora antora-playbook.yml
69
-
70
- - name: Configure Pages
71
- if: github.event_name != 'pull_request'
72
- uses: actions/configure-pages@v5
73
-
74
- - name: Upload Pages artifact
75
- if: github.event_name != 'pull_request'
76
- uses: actions/upload-pages-artifact@v4
77
- with:
78
- path: build/site
79
-
80
- deploy:
81
- if: github.event_name != 'pull_request'
82
- needs: build
83
- runs-on: ubuntu-latest
84
- environment:
85
- name: github-pages
86
- url: ${{ steps.deployment.outputs.page_url }}
87
- steps:
88
- - name: Deploy to GitHub Pages
89
- id: deployment
90
- uses: actions/deploy-pages@v4
data/.ruby-version DELETED
@@ -1 +0,0 @@
1
- 3.2.0