rubocop-flexport 0.3.0 → 0.4.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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f0ad53cef118c00bda51659b577dd8a099fb46127d71d90df345a0eb2199aa06
|
4
|
+
data.tar.gz: e94a72b0ed1f9e9ca886b25ca2fa68538edf9b08874398f9fd4e7fe5e2c50f27
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 73d6743b8da7bd0f7a325950dc312ab96c5a8eb2fd643b5fd1df8e419900996d14cddb3745ddbe204712c00d0e1dd2956ba477b95d08473ac9f977a84faf485d
|
7
|
+
data.tar.gz: d7c790e2a061b3ff32f7a447569d465903e28eb8c955a73841d60c2ae240d8212fef34d4ce496a3a098ca09aa2d1fbd777cb817c76173eef1b49fa1759ecaef9
|
@@ -46,7 +46,8 @@ module RuboCop
|
|
46
46
|
# end
|
47
47
|
#
|
48
48
|
class GlobalModelAccessFromEngine < Cop
|
49
|
-
MSG = 'Direct access of global model
|
49
|
+
MSG = 'Direct access of global model `%<model>s` ' \
|
50
|
+
'from within Rails Engine.'
|
50
51
|
|
51
52
|
def_node_matcher :rails_association_hash_args, <<-PATTERN
|
52
53
|
(send _ {:belongs_to :has_one :has_many} sym $hash)
|
@@ -58,7 +59,7 @@ module RuboCop
|
|
58
59
|
# The cop allows access to e.g. MyGlobalModel::MY_CONST.
|
59
60
|
return if child_of_const?(node)
|
60
61
|
|
61
|
-
add_offense(node)
|
62
|
+
add_offense(node, message: message(node.source))
|
62
63
|
end
|
63
64
|
|
64
65
|
def on_send(node)
|
@@ -69,7 +70,7 @@ module RuboCop
|
|
69
70
|
class_name = class_name_node&.value
|
70
71
|
next unless global_model?(class_name)
|
71
72
|
|
72
|
-
add_offense(class_name_node)
|
73
|
+
add_offense(class_name_node, message: message(class_name))
|
73
74
|
end
|
74
75
|
end
|
75
76
|
|
@@ -82,6 +83,10 @@ module RuboCop
|
|
82
83
|
|
83
84
|
private
|
84
85
|
|
86
|
+
def message(model)
|
87
|
+
format(MSG, model: model)
|
88
|
+
end
|
89
|
+
|
85
90
|
def global_model_names
|
86
91
|
@global_model_names ||= calculate_global_models
|
87
92
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubocop-flexport
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Flexport Engineering
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-12-
|
11
|
+
date: 2019-12-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|