rubocop-gusto 11.2.0 → 11.3.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 +4 -4
- data/CHANGELOG.md +7 -0
- data/config/gusto_cops.yml +3 -0
- data/lib/rubocop/cop/gusto/feature_flag_constants.rb +35 -0
- data/lib/rubocop/gusto/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 63e4d5c0598bcf51b28b73659d6ef7d2441d350b425f8d34ac4b02dc7eaaf41c
|
|
4
|
+
data.tar.gz: 0ac1b025edbc7f1add82364538074752bd47c2272d8b5fd59fc3aa90db9b052c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 827456db6259cd5414df4d864b65b360cf67f1ba6f8d047d4e4d5bc3374fe42f9220d7012bbf8b1f84fcbac1b5b6d675ea9bc42a77a26ef59f86a0179b92800d
|
|
7
|
+
data.tar.gz: 7543bc23e8c2aaf3747bbfe9e661fb0c83c1a62d23dad639dc95bbc60a7ecd913dce2bc3c8057f35183b8a9367105ee2b6e64821513f50d6365aa74e1935b776
|
data/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,13 @@
|
|
|
3
3
|
- Remove redundant `Rails: Enabled: true` from `config/rails.yml` (already set by rubocop-rails' own defaults)
|
|
4
4
|
- Enable `Rails/DefaultScope` cop (disabled by default in rubocop-rails)
|
|
5
5
|
|
|
6
|
+
## [11.3.0](https://github.com/Gusto/rubocop-gusto/compare/v11.2.0...v11.3.0) (2026-06-29)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* add Gusto/FeatureFlagConstants cop (RR-890) ([#144](https://github.com/Gusto/rubocop-gusto/issues/144)) ([9058e0e](https://github.com/Gusto/rubocop-gusto/commit/9058e0e3055445a6be1818f2c142013239773bb5))
|
|
12
|
+
|
|
6
13
|
## [11.2.0](https://github.com/Gusto/rubocop-gusto/compare/v11.1.1...v11.2.0) (2026-06-26)
|
|
7
14
|
|
|
8
15
|
|
data/config/gusto_cops.yml
CHANGED
|
@@ -43,6 +43,9 @@ Gusto/FactoryClassesOrModules:
|
|
|
43
43
|
Include:
|
|
44
44
|
- 'spec/**/factories/*.rb'
|
|
45
45
|
|
|
46
|
+
Gusto/FeatureFlagConstants:
|
|
47
|
+
Description: 'FeatureFlag keys should be constants, not strings.'
|
|
48
|
+
|
|
46
49
|
Gusto/MinByMaxBy:
|
|
47
50
|
Description: 'Checks for the use of `min` or `max` with a proc. Corrects to `min_by` or `max_by`.'
|
|
48
51
|
Safe: false
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module RuboCop
|
|
4
|
+
module Cop
|
|
5
|
+
module Gusto
|
|
6
|
+
# Enforces that `FeatureFlag.active?` is called with a constant rather than a
|
|
7
|
+
# string literal. Defining flag keys as constants keeps them in one place,
|
|
8
|
+
# makes typos a load-time error instead of a silent always-off flag, and lets
|
|
9
|
+
# tools find every reference to a flag.
|
|
10
|
+
#
|
|
11
|
+
# `FeatureFlag` is a constant, so it is never nil and safe navigation
|
|
12
|
+
# (`FeatureFlag&.active?`) is never used; the cop only handles `on_send`.
|
|
13
|
+
#
|
|
14
|
+
# @example
|
|
15
|
+
# # bad
|
|
16
|
+
# FeatureFlag.active?("some_feature_flag")
|
|
17
|
+
#
|
|
18
|
+
# # good
|
|
19
|
+
# FeatureFlag.active?(SomeModule::SOME_FEATURE_FLAG)
|
|
20
|
+
class FeatureFlagConstants < Base
|
|
21
|
+
MSG = "FeatureFlag keys should be constants, not strings"
|
|
22
|
+
RESTRICT_ON_SEND = %i(active?).freeze
|
|
23
|
+
|
|
24
|
+
# @!method feature_flag_with_string?(node)
|
|
25
|
+
def_node_matcher :feature_flag_with_string?, <<~PATTERN
|
|
26
|
+
(send (const nil? :FeatureFlag) :active? (str _) ...)
|
|
27
|
+
PATTERN
|
|
28
|
+
|
|
29
|
+
def on_send(node)
|
|
30
|
+
add_offense(node) if feature_flag_with_string?(node)
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
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: 11.
|
|
4
|
+
version: 11.3.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Gusto Engineering
|
|
@@ -160,6 +160,7 @@ files:
|
|
|
160
160
|
- lib/rubocop/cop/gusto/discouraged_gem.rb
|
|
161
161
|
- lib/rubocop/cop/gusto/execute_migration.rb
|
|
162
162
|
- lib/rubocop/cop/gusto/factory_classes_or_modules.rb
|
|
163
|
+
- lib/rubocop/cop/gusto/feature_flag_constants.rb
|
|
163
164
|
- lib/rubocop/cop/gusto/min_by_max_by.rb
|
|
164
165
|
- lib/rubocop/cop/gusto/no_metaprogramming.rb
|
|
165
166
|
- lib/rubocop/cop/gusto/no_rescue_error_message_checking.rb
|