rubocop-fluentd 0.1.0 → 0.1.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: d2f08b0f70066010f0a03161c19f17b8167f5a83189c81c4352314b202b06d0e
4
- data.tar.gz: 148332ce3ad1d4713096690b9e70ad346947905ec5de3e4386c55d921e816824
3
+ metadata.gz: 56610f49bc89a80c7cfc74091dbf9e0e5af8a2c7de39698bcf0b9464357d4682
4
+ data.tar.gz: b6fa1274a3afda983e6e5f3c7552476f664521a2e163343b0299178e46ab487d
5
5
  SHA512:
6
- metadata.gz: 6ff125adaa98eb0cb9427314816e222a48e513fe8285e15298fb839883902fa0349ea90be1dc055e35369d3b6b02a2c9df3d8459383ec20bfc470be2ace8a857
7
- data.tar.gz: 77f4e315f0584cd8cb62e00d0b53709a806a6c9323e500c2e3ad23f7c4d363beb4a1f1d3bffa655f27f30362893ebaf86c07af2da01557259afd00494f253321
6
+ metadata.gz: 9f938ec1fec15a0c9d0f7aac29857a76853831f6b6bc19b1c2bf73846fbe6ade79ca003797b34a0d9538831f1cf2764d235036dd4d33e562dbfcc63a76b40240
7
+ data.tar.gz: f1131bc32c16d6ccaa783b8d40641735bcd7ce7ec3462a2e111212a4783afe02624e0ebfcb599b907d8a9ade2bfe4cf2a9d4ea9ed5d82b29f226d26853c5afeb
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## 0.1.1 - 2025-07-09
4
+
5
+ * Add Lint/FluentdPluginConfigParamDefaultTime
6
+
3
7
  ## 0.1.0 - 2025-07-07
4
8
 
5
9
  * Initial release
data/README.md CHANGED
@@ -23,6 +23,8 @@ Configure `.rubocop.yml` like this:
23
23
  ```yaml
24
24
  Lint/FluentdPluginLogScope:
25
25
  Enabled: true
26
+ Lint/FluentdPluginConfigParamDefaultTime:
27
+ Enabled: true
26
28
  Performance/FluentdPluginLogStringInterpolation:
27
29
  Enabled: true
28
30
  ```
data/config/default.yml CHANGED
@@ -1,5 +1,10 @@
1
1
  # Write it!
2
2
 
3
+ Lint/FluentdPluginConfigParamDefaultTime:
4
+ Description: 'Warn the default value of :time for config_param is string'
5
+ Enabled: true
6
+ VersionAdded: '0.1.1'
7
+
3
8
  Lint/FluentdPluginLogLevel:
4
9
  Description: 'Warn global scope `$log` was used in Fluentd plugin. The scope of plugin log level was supported since Fluentd 0.10.43'
5
10
  Enabled: true
@@ -1,3 +1,4 @@
1
1
  # frozen_string_literal: true
2
+ require_relative 'lint/plugin_config_param_time'
2
3
  require_relative 'lint/plugin_log_scope'
3
4
  require_relative 'performance/plugin_log_string_interpolation'
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RuboCop
4
+ module Cop
5
+ module Lint
6
+ #
7
+ # @example FluentdPluginConfigParamDefaultTime (default)
8
+ #
9
+ # # bad
10
+ # config_param :interval, :time, :default => '1h'
11
+ #
12
+ # # good
13
+ # config_param :interval, :time, :default => 3600
14
+ #
15
+ # See https://github.com/fluent/fluent-plugin-opensearch/pull/159
16
+ #
17
+ class FluentdPluginConfigParamDefaultTime < Base
18
+ include IgnoredNode
19
+
20
+ RESTRICT_ON_SEND = %i[config_param].freeze
21
+
22
+ # @!method config_param_default_time?(node)
23
+ def_node_matcher :config_param_default_string_time?, <<~PATTERN
24
+ (send nil? :config_param (sym _) (sym :time) (hash (pair (sym :default) (str _))))
25
+ PATTERN
26
+
27
+ def on_send(node)
28
+ return unless config_param_default_string_time?(node)
29
+
30
+ symbol = node.children[2]
31
+ parameter = symbol.value
32
+ message = "The value of :#{parameter} must be `integer` or `float` for default time value."
33
+ add_offense(node, message: message)
34
+ ignore_node(node)
35
+ end
36
+ alias on_csend on_send
37
+ end
38
+ end
39
+ end
40
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module RuboCop
4
4
  module Fluentd
5
- VERSION = "0.1.0"
5
+ VERSION = "0.1.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.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kentaro Hayashi
@@ -53,6 +53,7 @@ files:
53
53
  - config/default.yml
54
54
  - lib/rubocop-fluentd.rb
55
55
  - lib/rubocop/cop/fluentd_cops.rb
56
+ - lib/rubocop/cop/lint/plugin_config_param_time.rb
56
57
  - lib/rubocop/cop/lint/plugin_log_scope.rb
57
58
  - lib/rubocop/cop/performance/plugin_log_string_interpolation.rb
58
59
  - lib/rubocop/fluentd.rb