rubocop-flexport 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8b441520e98f7b859443aefbd06f3d9794600b702d8b70ad37f1a5a072898947
4
- data.tar.gz: 0c3767638f4c7303b0ff941cdbf16a589b757628404ae9b9f3a2b5505a9c8f37
3
+ metadata.gz: f0ad53cef118c00bda51659b577dd8a099fb46127d71d90df345a0eb2199aa06
4
+ data.tar.gz: e94a72b0ed1f9e9ca886b25ca2fa68538edf9b08874398f9fd4e7fe5e2c50f27
5
5
  SHA512:
6
- metadata.gz: '08541d28bbedcf79eb1e570b97de445b965eed4c6ed266a4d6333bed6904f6e07ae63e2286a05607660cb7771829bddb830785a4565af1222eb4cb9f46f4d321'
7
- data.tar.gz: a4ca03afba08fc095a8e6f152abe7ee8527b1eb80cd55f34a7d5c95bd4f86a46b34cb389d5d4af9cd1fc21fa13d30ca8624d79aa8f0c0f870c2a3e93247f4e2d
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 from within Rails Engine.'
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
@@ -2,6 +2,6 @@
2
2
 
3
3
  module RuboCop
4
4
  module Flexport
5
- VERSION = '0.3.0'
5
+ VERSION = '0.4.0'
6
6
  end
7
7
  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.3.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-05 00:00:00.000000000 Z
11
+ date: 2019-12-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport