betterlint 1.20.0 → 1.21.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: a8373ada8389173714d5f6086fd98f64e056340b8ddbd6c3b7e9cb78a3143b1f
4
- data.tar.gz: bf710724c7163b0ef355cecfaad17bcf6af70c58fa50cdb81fd7d691d1e6e269
3
+ metadata.gz: 25f8e840f59447c480bca9bb7c6ec070d1a6ef4cc5d784448bbaae92bc81e0ee
4
+ data.tar.gz: 1aeef2d6f6c42e0967605a5dca2f69a43b58d7a4b705338956b392979c8fefe0
5
5
  SHA512:
6
- metadata.gz: 991c3a041583443b9e53e0c3baa7ace7354b76a5a07e322d85e82f73bea4a01b7252f203ccbbac1e6947675eb20940777cc4f6df72132ba40f64aab265fbbbf3
7
- data.tar.gz: c52af40049be9780cbd719df55e3747902f5c51d7e0136340140aaecc1bab53b8a17f5ecc9f84843dc43e066a9a7df90b02ce751d46c8784d2b0f77baba6e47f
6
+ metadata.gz: 4ed29d409e9038101e030a72bb736be26fa2687e8e2028be8b0fa25cddf49a768582c8fb04c546ebad0dcc4585a12705b9e0a94fa87fd81c7f381fd25f199fea
7
+ data.tar.gz: 622fab9cfcf2b8aeb6bc6e3ccc0c13cb62ed473d282a498798a814e1227dbfb3893f71e089359de11af7a6c8ba92b2ae4ea25f3abd0cda162b20abe8d9fdb8c6
data/config/default.yml CHANGED
@@ -124,6 +124,13 @@ Betterment/UseGlobalStrictLoading/ForAssociations:
124
124
  FactoryBot/AssociationStyle:
125
125
  Enabled: false
126
126
 
127
+ Betterment/NotUsingRswag:
128
+ Enabled: false
129
+ SafeAutoCorrect: false
130
+ Description: Detect API specs missing OpenAPI documentation using rswag
131
+ Include:
132
+ - spec/requests/**/*_spec.rb
133
+
127
134
  FactoryBot/ConsistentParenthesesStyle:
128
135
  Enabled: false
129
136
 
@@ -0,0 +1,59 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RuboCop
4
+ module Cop
5
+ module Betterment
6
+ class NotUsingRswag < Base
7
+ MSG = 'Request specs must use rswag to test and document their API endpoints. See: https://github.com/rswag/rswag'
8
+
9
+ def on_block(node)
10
+ # Only run from root Rspec.describe block
11
+ return unless rspec_describe?(node)
12
+
13
+ # If the block descendants contain rswag structure, it's valid
14
+ return if contains_rswag_structure?(node)
15
+
16
+ # Otherwise, add offense
17
+ add_offense(node)
18
+ end
19
+
20
+ private
21
+
22
+ def contains_rswag_structure?(node)
23
+ has_path_block?(node) &&
24
+ has_http_method_block?(node) &&
25
+ has_response_block?(node)
26
+ end
27
+
28
+ # @!method rspec_describe?(node)
29
+ def_node_matcher :rspec_describe?, <<~PATTERN
30
+ (block
31
+ (send
32
+ (const nil? :RSpec) :describe ...)
33
+ ...)
34
+ PATTERN
35
+
36
+ # @!method has_path_block?(node)
37
+ def_node_matcher :has_path_block?, <<~PATTERN
38
+ `(block
39
+ (send nil? :path (str _))
40
+ ...)
41
+ PATTERN
42
+
43
+ # @!method has_http_method_block?(node)
44
+ def_node_matcher :has_http_method_block?, <<~PATTERN
45
+ `(block
46
+ (send nil? {:get :post :put :patch :delete} (str _))
47
+ ...)
48
+ PATTERN
49
+
50
+ # @!method has_response_block?(node)
51
+ def_node_matcher :has_response_block?, <<~PATTERN
52
+ `(block
53
+ (send nil? :response (str _) (str _))
54
+ ...)
55
+ PATTERN
56
+ end
57
+ end
58
+ end
59
+ end
@@ -14,6 +14,7 @@ require 'rubocop/cop/betterment/internals_protection'
14
14
  require 'rubocop/cop/betterment/memoization_with_arguments'
15
15
  require 'rubocop/cop/betterment/non_standard_actions'
16
16
  require 'rubocop/cop/betterment/non_standard_controller'
17
+ require 'rubocop/cop/betterment/not_using_rswag'
17
18
  require 'rubocop/cop/betterment/redirect_status'
18
19
  require 'rubocop/cop/betterment/render_status'
19
20
  require 'rubocop/cop/betterment/server_error_assertion'
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: betterlint
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.20.0
4
+ version: 1.21.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Development
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-05-28 00:00:00.000000000 Z
10
+ date: 2025-06-05 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: rubocop
@@ -117,6 +117,7 @@ files:
117
117
  - lib/rubocop/cop/betterment/memoization_with_arguments.rb
118
118
  - lib/rubocop/cop/betterment/non_standard_actions.rb
119
119
  - lib/rubocop/cop/betterment/non_standard_controller.rb
120
+ - lib/rubocop/cop/betterment/not_using_rswag.rb
120
121
  - lib/rubocop/cop/betterment/redirect_status.rb
121
122
  - lib/rubocop/cop/betterment/render_status.rb
122
123
  - lib/rubocop/cop/betterment/server_error_assertion.rb
@@ -136,10 +137,10 @@ licenses:
136
137
  - MIT
137
138
  metadata:
138
139
  homepage_uri: https://github.com/Betterment/betterlint
139
- source_code_uri: https://github.com/Betterment/betterlint/tree/v1.20.0
140
- changelog_uri: https://github.com/Betterment/betterlint/blob/v1.20.0/CHANGELOG.md
140
+ source_code_uri: https://github.com/Betterment/betterlint/tree/v1.21.0
141
+ changelog_uri: https://github.com/Betterment/betterlint/blob/v1.21.0/CHANGELOG.md
141
142
  bug_tracker_uri: https://github.com/Betterment/betterlint/issues
142
- documentation_uri: https://www.rubydoc.info/gems/betterlint/1.20.0
143
+ documentation_uri: https://www.rubydoc.info/gems/betterlint/1.21.0
143
144
  rubygems_mfa_required: 'true'
144
145
  rdoc_options: []
145
146
  require_paths: