rubocop-fluentd 0.2.0 → 0.2.1

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: 36fbca65669f2ece9eebbf4b11704127822b9fe495cdd613eaabb1bd54a0ed34
4
- data.tar.gz: 26785e17f1b748804fec642f24746cbdd880542eb2e73e6c1f0fa7fe68d69831
3
+ metadata.gz: cf200b231db6c6f68db7f54526977ad2e6b7e29a335e2a51612ec241f0dd33d9
4
+ data.tar.gz: 62d5abe1ac0b6a2e2ef55563e2a0dee22c57ec5bcf11152d9af68cdb5f9ad47c
5
5
  SHA512:
6
- metadata.gz: 3e7dea98385b42b570a66f60358813f02bd1dad063c001aedd7bf53fd782c47e2a5be199dcec79c9c79fb2dc8383fcb69e695d4746c22c99ad64e18825a4cab0
7
- data.tar.gz: 5cc4b01eff6ec31f8f1a623c1331956b65f72aa17ae2fc4d6d311f2e2971af35da027f0fe27edafa1cda9339d0cd1809ace43afc6435854e80dc90728436b028
6
+ metadata.gz: 904369abf32fd8b3ee741e51d7397e71a8dd5d33979dd25e7d6cb715ec8bae3f7843b85b850bca7b74a1ed1ad351efbcdfe5173174a5e700f4eb05bfe66efd51
7
+ data.tar.gz: 43494d019a086657e42e483d32c07f17b46353081e2894f69ef38bf3a121f4bb79934c21f75a3d5719e16e14c113ef3f2e0a82d6bd261e6579d5040752bf6d29
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## 0.2.1 - 2025-07-15
4
+
5
+ * Transfer ownership to https://github.com/fluent-plugins-nursery/rubocop-fluentd
6
+ * Warn string interpolation which might contains too long message.
7
+
3
8
  ## 0.2.0 - 2025-07-10
4
9
 
5
10
  * Support autocorrect for the following custom cop
data/README.md CHANGED
@@ -37,7 +37,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
37
37
 
38
38
  ## Contributing
39
39
 
40
- Bug reports and pull requests are welcome on GitHub at https://github.com/kenhys/rubocop-fluentd.
40
+ Bug reports and pull requests are welcome on GitHub at https://github.com/fluent-plugins-nursery/rubocop-fluentd.
41
41
 
42
42
  ## License
43
43
 
@@ -52,14 +52,32 @@ module RuboCop
52
52
  (block (send gvar $_) _ $(...))
53
53
  PATTERN
54
54
 
55
+ # @!method local_log_method?(node)
56
+ def_node_matcher :local_log_method?, <<~PATTERN
57
+ (send (send nil? :log) $_ $(...))
58
+ PATTERN
59
+
55
60
  def on_send(node)
56
61
  return if part_of_ignored_node?(node)
57
- expression = global_reciever_method?(node)
58
- return unless expression
59
-
60
- # $log.method(...)
61
- if send_global_log_node?(node)
62
- add_offense(node) do |corrector|
62
+ global_expression = global_reciever_method?(node)
63
+ local_expression = local_log_method?(node)
64
+ return unless global_expression or local_expression
65
+ if global_expression and send_global_log_node?(node)
66
+ expression = global_expression
67
+ # $log.method(...)
68
+ message = 'Use plugin scope `log` instead of global scope `$log`.'
69
+ add_offense(node, message: MSG) do |corrector|
70
+ method = expression.first
71
+ literal = expression.last
72
+ source_code = "log.#{method} { #{literal.source} }"
73
+ # $log.xxx => log.xxx
74
+ corrector.replace(node, source_code)
75
+ end
76
+ elsif local_expression and send_local_log_node?(node)
77
+ # log.method "#{expansion}"
78
+ expression = local_expression
79
+ message = "Use block not to evaluate too long message"
80
+ add_offense(node, message: message) do |corrector|
63
81
  method = expression.first
64
82
  literal = expression.last
65
83
  source_code = "log.#{method} { #{literal.source} }"
@@ -103,6 +121,11 @@ module RuboCop
103
121
  def global_log_reciever?(node)
104
122
  node.name == :$log
105
123
  end
124
+
125
+ def send_local_log_node?(node)
126
+ node.class == RuboCop::AST::SendNode and
127
+ node.children.last.class == RuboCop::AST::DstrNode
128
+ end
106
129
  end
107
130
  end
108
131
  end
@@ -10,7 +10,7 @@ module RuboCop
10
10
  LintRoller::About.new(
11
11
  name: 'rubocop-fluentd',
12
12
  version: VERSION,
13
- homepage: "https://github.com/kenhys/rubocop-fluentd",
13
+ homepage: "https://github.com/fluent-plugins-nursery/rubocop-fluentd",
14
14
  description: "Custom Cop for Fluentd plugins"
15
15
  )
16
16
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module RuboCop
4
4
  module Fluentd
5
- VERSION = "0.2.0"
5
+ VERSION = "0.2.1"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubocop-fluentd
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kentaro Hayashi
@@ -74,14 +74,14 @@ files:
74
74
  - lib/rubocop/fluentd/plugin.rb
75
75
  - lib/rubocop/fluentd/version.rb
76
76
  - sig/rubocop/fluentd.rbs
77
- homepage: https://github.com/kenhys/rubocop-fluentd
77
+ homepage: https://github.com/fluent-plugins-nursery/rubocop-fluentd
78
78
  licenses:
79
79
  - Apache-2.0
80
80
  metadata:
81
81
  allowed_push_host: https://rubygems.org
82
- homepage_uri: https://github.com/kenhys/rubocop-fluentd
83
- source_code_uri: https://github.com/kenhys/rubocop-fluentd
84
- changelog_uri: https://github.com/kenhys/rubocop-fluentd/blob/main/CHANGELOG.md
82
+ homepage_uri: https://github.com/fluent-plugins-nursery/rubocop-fluentd
83
+ source_code_uri: https://github.com/fluent-plugins-nursery/rubocop-fluentd
84
+ changelog_uri: https://github.com/fluent-plugins-nursery/rubocop-fluentd/blob/main/CHANGELOG.md
85
85
  rubygems_mfa_required: 'true'
86
86
  default_lint_roller_plugin: RuboCop::Fluentd::Plugin
87
87
  rdoc_options: []