light-services 3.2.0 → 3.2.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: eaf377a62c2b05d82860527f64df11bb2239745d2e3b6ab1bc060cddc153effc
4
- data.tar.gz: 86eb6a64e0744e6fe2f80b1b4fc06e9d38a740911f88c2b076da9e9a2aab082b
3
+ metadata.gz: c2d31f74eaaa7add84302e90f4d2748c5c099f34ea44e1be0d8eb6faa286ec37
4
+ data.tar.gz: 7bb83450e6be42ab27938df758644820476138684712f7d015694b4d1f675d92
5
5
  SHA512:
6
- metadata.gz: b11918fed0617837cd922a9c7c2181a855844d359bce30aa7f523a828e77e3605522cff64440cf200f90732cb17bbee901305a01920bde54a3cb4777b748a760
7
- data.tar.gz: aa78896f8cf22b7e2cf17853700bbe347d0dd364409ee4033064d7c4c5fa57d9377620e5ab6b29473cf15c2894e29b189aa8634e7d71ffda9ad2ca6fa6fce792
6
+ metadata.gz: e2cf4be4b70f330c77d53b104b4f4c36686a6a1aaeba1cee0478d25941c06c5ff7e31d9bc0d4998710dd8a4b811e06f39794d54b9102663480d5d32adfbca45a
7
+ data.tar.gz: 56134a214344e9a3c7448b4cca8becdb05d03df864962faa5c1f9412cf65ce774a5245ac1a5eda2127e86bdc5b41d01a5ab2893109b401d8259f3dc704420220
data/CHANGELOG.md CHANGED
@@ -1,6 +1,12 @@
1
1
  # Changelog
2
2
 
3
- ## 3.2.0 (2025-12-14)
3
+ ## 3.2.1 (2025-12-15)
4
+
5
+ ### Added
6
+
7
+ - Add RuboCop cop `ReservedName`
8
+
9
+ ## 3.2.0 (2025-12-15)
4
10
 
5
11
  ### Added
6
12
 
@@ -12,7 +18,7 @@
12
18
 
13
19
  - Service runs steps with `always: true` after `fail_immediately!` was called
14
20
 
15
- ## 3.1.2 (2025-12-13)
21
+ ## 3.1.2 (2025-12-14)
16
22
 
17
23
  ### Added
18
24
 
@@ -22,7 +28,7 @@
22
28
 
23
29
  - Split `config.require_type` into `config.require_arg_type` and `config.require_output_type`
24
30
 
25
- ## 3.1.1 (2025-12-13)
31
+ ## 3.1.1 (2025-12-14)
26
32
 
27
33
  ### Added
28
34
 
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- light-services (3.2.0)
4
+ light-services (3.2.1)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -0,0 +1,56 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "../../../../../light/services/constants"
4
+
5
+ module RuboCop
6
+ module Cop
7
+ module LightServices
8
+ # Ensures that `arg`, `step`, and `output` declarations do not use reserved names
9
+ # that would conflict with Light::Services methods.
10
+ #
11
+ # @example
12
+ # # bad
13
+ # arg :errors, type: Array
14
+ # arg :outputs, type: Hash
15
+ # step :call
16
+ # output :success?, type: [TrueClass, FalseClass]
17
+ #
18
+ # # good
19
+ # arg :validation_errors, type: Array
20
+ # arg :result_outputs, type: Hash
21
+ # step :execute
22
+ # output :succeeded, type: [TrueClass, FalseClass]
23
+ #
24
+ class ReservedName < Base
25
+ include RuboCop::Cop::RangeHelp
26
+
27
+ MSG = "`%<name>s` is a reserved name and cannot be used as %<field_type>s. " \
28
+ "It conflicts with Light::Services methods."
29
+
30
+ SEVERITY = :error
31
+
32
+ RESTRICT_ON_SEND = [:arg, :step, :output].freeze
33
+
34
+ FIELD_TYPE_NAMES = {
35
+ arg: "an argument",
36
+ step: "a step",
37
+ output: "an output",
38
+ }.freeze
39
+
40
+ # @!method dsl_call?(node)
41
+ def_node_matcher :dsl_call?, <<~PATTERN
42
+ (send nil? ${:arg :step :output} (sym $_) ...)
43
+ PATTERN
44
+
45
+ def on_send(node)
46
+ dsl_call?(node) do |method_name, name|
47
+ return unless Light::Services::ReservedNames::ALL.include?(name)
48
+
49
+ field_type = FIELD_TYPE_NAMES[method_name]
50
+ add_offense(node, message: format(MSG, name: name, field_type: field_type), severity: SEVERITY)
51
+ end
52
+ end
53
+ end
54
+ end
55
+ end
56
+ end
@@ -10,4 +10,5 @@ require_relative "rubocop/cop/light_services/missing_private_keyword"
10
10
  require_relative "rubocop/cop/light_services/no_direct_instantiation"
11
11
  require_relative "rubocop/cop/light_services/output_type_required"
12
12
  require_relative "rubocop/cop/light_services/prefer_fail_method"
13
+ require_relative "rubocop/cop/light_services/reserved_name"
13
14
  require_relative "rubocop/cop/light_services/step_method_exists"
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Light
4
4
  module Services
5
- VERSION = "3.2.0"
5
+ VERSION = "3.2.1"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: light-services
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.0
4
+ version: 3.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Kodkod
@@ -99,6 +99,7 @@ files:
99
99
  - lib/light/services/rubocop/cop/light_services/no_direct_instantiation.rb
100
100
  - lib/light/services/rubocop/cop/light_services/output_type_required.rb
101
101
  - lib/light/services/rubocop/cop/light_services/prefer_fail_method.rb
102
+ - lib/light/services/rubocop/cop/light_services/reserved_name.rb
102
103
  - lib/light/services/rubocop/cop/light_services/step_method_exists.rb
103
104
  - lib/light/services/settings/field.rb
104
105
  - lib/light/services/settings/step.rb