gl_rubocop 0.2.5 → 0.2.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/default.yml +4 -0
- data/lib/gl_rubocop/gl_cops/rails_cache.rb +24 -0
- data/lib/gl_rubocop/gl_cops/unique_identifier.rb +4 -6
- data/lib/gl_rubocop/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cc932e911296ebd58c3e59febe32b734287f3ac302762c807c7f2cf58cc1c3ea
|
4
|
+
data.tar.gz: 9e9a20252ffcf744d7c8faf367f53f355e07dfcd9d8cb20f29a7d28401c5fd42
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c1f6f481ca4275167ba6c630eaf558a83bd29cac26f6a777c8354dd0dff798c792f86eaded520dab8df616294cb6c0941477a2343abc4a13bdfa548bb021e7b7
|
7
|
+
data.tar.gz: 3ef8ba758032a3623ebfe92fbc3cef16b4736b78e0875051ef1f158131f78bbf5b1cb8933ea12c78d4beb103c86d525e3f4ddd607e19d03cc69ea3bc331290d9
|
data/default.yml
CHANGED
@@ -7,6 +7,7 @@ require:
|
|
7
7
|
- ./lib/gl_rubocop/gl_cops/interactor_inherits_from_interactor_base.rb
|
8
8
|
- ./lib/gl_rubocop/gl_cops/callback_method_names.rb
|
9
9
|
- ./lib/gl_rubocop/gl_cops/prevent_erb_files.rb
|
10
|
+
- ./lib/gl_rubocop/gl_cops/rails_cache.rb
|
10
11
|
- ./lib/gl_rubocop/gl_cops/sidekiq_inherits_from_sidekiq_job.rb
|
11
12
|
- ./lib/gl_rubocop/gl_cops/unique_identifier.rb
|
12
13
|
|
@@ -37,6 +38,9 @@ GLCops/CallbackMethodNames:
|
|
37
38
|
GLCops/PreventErbFiles:
|
38
39
|
Enabled: true
|
39
40
|
|
41
|
+
GLCops/RailsCache:
|
42
|
+
Enabled: true
|
43
|
+
|
40
44
|
GLCops/SidekiqInheritsFromSidekiqJob:
|
41
45
|
Include:
|
42
46
|
- 'app/**/*_worker.rb'
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module GLRubocop
|
2
|
+
module GLCops
|
3
|
+
class RailsCache < RuboCop::Cop::Base
|
4
|
+
# This cop ensures that Rails.cache is not directly used.
|
5
|
+
# This is to prevent generation of unique key ids (SIG Code Quality Discussion 2024-12-16):
|
6
|
+
# https://www.notion.so/givelively/2024-12-16-152eb3d1736e805abe85de1fd96f3599?pvs=4#15eeb3d1736e80ecb82defd5d6b1f0e5
|
7
|
+
|
8
|
+
MSG = 'Rails.cache should not be used directly'.freeze
|
9
|
+
|
10
|
+
def_node_matcher :using_rails_cache?, <<~PATTERN
|
11
|
+
(send#{' '}
|
12
|
+
(send (const nil? :Rails) :cache)
|
13
|
+
{:fetch :read :write :delete :exist? :clear}
|
14
|
+
...)
|
15
|
+
PATTERN
|
16
|
+
|
17
|
+
def on_send(node)
|
18
|
+
return unless using_rails_cache?(node)
|
19
|
+
|
20
|
+
add_offense(node)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -4,12 +4,10 @@ module GLRubocop
|
|
4
4
|
# This cop ensures that view components include a data-test-id attribute.
|
5
5
|
#
|
6
6
|
# Good:
|
7
|
-
# {data-test-id:
|
7
|
+
# {data-test-id: "unique-id"}
|
8
8
|
# {data-test-id: @unique_id }
|
9
|
-
# {'data-test-id':
|
9
|
+
# {'data-test-id': "unique-id"}
|
10
10
|
# {"data-test-id": "unique-id"}
|
11
|
-
# {data: {test-id: 'unique-id'}}
|
12
|
-
# {data: {'test-id': 'unique-id'}}
|
13
11
|
#
|
14
12
|
# Bad:
|
15
13
|
# {data: {testId: "unique-id"}}
|
@@ -17,7 +15,7 @@ module GLRubocop
|
|
17
15
|
|
18
16
|
MSG = 'View components must include a data-test-id attribute'.freeze
|
19
17
|
EMPTY_MSG = 'data-test-id attribute must not be empty'.freeze
|
20
|
-
UNIQUE_IDENTIFIER = 'test-id'.freeze
|
18
|
+
UNIQUE_IDENTIFIER = 'data-test-id'.freeze
|
21
19
|
|
22
20
|
def on_send(node)
|
23
21
|
return unless file_exists? && valid_method_name?(node)
|
@@ -44,7 +42,7 @@ module GLRubocop
|
|
44
42
|
|
45
43
|
def regex_for_indentifier_and_value
|
46
44
|
key = Regexp.quote(UNIQUE_IDENTIFIER)
|
47
|
-
/(
|
45
|
+
/(?:#{key}|["']#{key}["']):\s*(["']([^"']*)["']|@\w+)/
|
48
46
|
end
|
49
47
|
|
50
48
|
def test_id_value
|
data/lib/gl_rubocop/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gl_rubocop
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Give Lively
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-01-
|
11
|
+
date: 2025-01-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubocop
|
@@ -123,6 +123,7 @@ files:
|
|
123
123
|
- lib/gl_rubocop/gl_cops/callback_method_names.rb
|
124
124
|
- lib/gl_rubocop/gl_cops/interactor_inherits_from_interactor_base.rb
|
125
125
|
- lib/gl_rubocop/gl_cops/prevent_erb_files.rb
|
126
|
+
- lib/gl_rubocop/gl_cops/rails_cache.rb
|
126
127
|
- lib/gl_rubocop/gl_cops/sidekiq_inherits_from_sidekiq_job.rb
|
127
128
|
- lib/gl_rubocop/gl_cops/unique_identifier.rb
|
128
129
|
- lib/gl_rubocop/version.rb
|