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 +4 -4
- data/config/default.yml +1 -0
- data/lib/betterlint/version.rb +1 -1
- data/lib/rubocop/cop/betterment/non_namespaced_class.rb +18 -2
- metadata +5 -5
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 070e58e2493975205fb3f5f52f1c6082109835db4388e67d7876bfd471861e59
|
|
4
|
+
data.tar.gz: 73a4c6ddd11054bd6b2c3add1e3963f62b6849241b2eb4be2a41a1bec41cc2f7
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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: []
|
data/lib/betterlint/version.rb
CHANGED
|
@@ -4,19 +4,35 @@ module RuboCop
|
|
|
4
4
|
module Cop
|
|
5
5
|
module Betterment
|
|
6
6
|
class NonNamespacedClass < Base
|
|
7
|
-
|
|
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
|
-
|
|
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.
|
|
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-
|
|
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.
|
|
207
|
-
changelog_uri: https://github.com/Betterment/betterlint/blob/v1.
|
|
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.
|
|
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:
|