betterlint 1.27.0 → 1.28.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: 6bd1ad5be3babcc02d2b5c8f481e9106bf90d575849e9f309d44b137298b1ab0
4
- data.tar.gz: d999b55f53b8528b169110f2257b1b0cb0127629b50ecdfcc5a59250cb9f79c3
3
+ metadata.gz: 070e58e2493975205fb3f5f52f1c6082109835db4388e67d7876bfd471861e59
4
+ data.tar.gz: 73a4c6ddd11054bd6b2c3add1e3963f62b6849241b2eb4be2a41a1bec41cc2f7
5
5
  SHA512:
6
- metadata.gz: af695c343d0618c7d0ac9bc937a67e99fdc5732e6d507bf8efb6a11d1d4981c437dd3118881bd09e504a3427de8e44a852cc7790502767022671de9c2fa88bfa
7
- data.tar.gz: 56309c5e67dbdd2c4c6a83eb51cf466b2195f5f3deb6ad9b16409e4595b032c2c7aa3140b731a00b325ee5bbcfe14a694ec96b2c3c0d99c53c124059fb680c18
6
+ metadata.gz: c212dd812b46431b40bea0876f5aeefe5d4f657ef59bb0355342a4e22d19e167cbe950ca7edd237ad581e17cc2400f7c08cabc84ce677b16731f56957ba517d6
7
+ data.tar.gz: 486bdb3b54a34ee2363cf482e113a928840bda36ca94a9407e2b269748fa534a24d75e407df839d5b86561dedb50c9a1648558b507ae49acf6152b77866cfb8a
data/config/default.yml CHANGED
@@ -66,6 +66,7 @@ Betterment/NonNamespacedClass:
66
66
  Description: Detects classes that are not namespaced under a module or constant
67
67
  StyleGuide: '#bettermentnonamespacedclass'
68
68
  Enabled: false
69
+ AllowedClasses: []
69
70
 
70
71
  Betterment/NonStandardActions:
71
72
  AdditionalAllowedActions: []
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Betterlint
4
- VERSION = '1.27.0'
4
+ VERSION = '1.28.0'
5
5
  end
@@ -4,19 +4,35 @@ module RuboCop
4
4
  module Cop
5
5
  module Betterment
6
6
  class NonNamespacedClass < Base
7
- MSG = <<~TEXT.gsub(/\s+/, " ").strip
7
+ attr_accessor :allowed_classes
8
+
9
+ MSG = <<~TEXT
8
10
  Do not add new classes that are not namespaced underneath another constant.
9
11
  Classes should be defined within a module namespace (e.g., `module MyNamespace; class Foo; end; end`)
10
12
  or use the `::` syntax (e.g., `class MyNamespace::Foo`).
13
+
14
+ See here for more information on this cop:
15
+ https://github.com/Betterment/betterlint/blob/main/README.md#bettermentnonamespacedclass
11
16
  TEXT
12
17
 
18
+ def initialize(config = nil, options = nil)
19
+ super
20
+ @allowed_classes = cop_config.fetch("AllowedClasses", []).map(&:to_sym)
21
+ end
22
+
13
23
  def on_class(node)
14
24
  class_name_node = node.children[0]
15
25
 
16
26
  # Skip if the class name is nil (anonymous class)
17
27
  return unless class_name_node
18
28
 
19
- if class_name_node.const_type? && !namespaced?(class_name_node) && !inside_namespace?(node)
29
+ class_name = class_name_node.short_name
30
+
31
+ if class_name_node.const_type? &&
32
+ !namespaced?(class_name_node) &&
33
+ !inside_namespace?(node) &&
34
+ !allowed_classes.include?(class_name)
35
+
20
36
  add_offense(node)
21
37
  end
22
38
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: betterlint
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.27.0
4
+ version: 1.28.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Development
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-01-27 00:00:00.000000000 Z
11
+ date: 2026-01-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: lint_roller
@@ -203,10 +203,10 @@ licenses:
203
203
  - MIT
204
204
  metadata:
205
205
  homepage_uri: https://github.com/Betterment/betterlint
206
- source_code_uri: https://github.com/Betterment/betterlint/tree/v1.27.0
207
- changelog_uri: https://github.com/Betterment/betterlint/blob/v1.27.0/CHANGELOG.md
206
+ source_code_uri: https://github.com/Betterment/betterlint/tree/v1.28.0
207
+ changelog_uri: https://github.com/Betterment/betterlint/blob/v1.28.0/CHANGELOG.md
208
208
  bug_tracker_uri: https://github.com/Betterment/betterlint/issues
209
- documentation_uri: https://www.rubydoc.info/gems/betterlint/1.27.0
209
+ documentation_uri: https://www.rubydoc.info/gems/betterlint/1.28.0
210
210
  rubygems_mfa_required: 'true'
211
211
  default_lint_roller_plugin: Betterlint::Plugin
212
212
  post_install_message: