Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/statsd/instrument/datagram.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def eql?(other)
(?:\|\#(?<tags>(?:[^\|,]+(?:,[^\|,]+)*)))?
\n? # In some implementations, the datagram may include a trailing newline.
\z
}x
}x.freeze

def parsed_datagram
@parsed ||= if (match_info = PARSER.match(@source))
Expand Down
4 changes: 2 additions & 2 deletions lib/statsd/instrument/dogstatsd_datagram.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def parsed_datagram
(?:\|m:(?<message>[^\|]+))?
\n? # In some implementations, the datagram may include a trailing newline.
\z
}x
}x.freeze

# |k:my-key|p:low|s:source|t:success|
EVENT_PARSER = %r{
Expand All @@ -84,7 +84,7 @@ def parsed_datagram
(?:\|\#(?<tags>(?:[^\|,]+(?:,[^\|,]+)*)))?
\n? # In some implementations, the datagram may include a trailing newline.
\z
}x
}x.freeze

PARSER = Regexp.union(StatsD::Instrument::Datagram::PARSER, SERVICE_CHECK_PARSER, EVENT_PARSER)
end
Expand Down
6 changes: 3 additions & 3 deletions lib/statsd/instrument/rubocop.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
module RuboCop
module Cop
module StatsD
METRIC_METHODS = [:increment, :gauge, :measure, :set, :histogram, :distribution, :key_value]
METRIC_METHODS = [:increment, :gauge, :measure, :set, :histogram, :distribution, :key_value].freeze

METAPROGRAMMING_METHODS = [
:statsd_measure,
:statsd_distribution,
:statsd_count_success,
:statsd_count_if,
:statsd_count,
]
].freeze

SINGLETON_CONFIGURATION_METHODS = [
:backend,
Expand All @@ -22,7 +22,7 @@ module StatsD
:"default_tags=",
:default_sample_rate,
:"default_sample_rate=",
]
].freeze

private

Expand Down
2 changes: 1 addition & 1 deletion lib/statsd/instrument/rubocop/metric_return_value.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class MetricReturnValue < Base

MSG = "Do not use the return value of StatsD metric methods"

INVALID_PARENTS = [:lvasgn, :array, :pair, :send, :return, :yield]
INVALID_PARENTS = [:lvasgn, :array, :pair, :send, :return, :yield].freeze

def on_send(node)
if metric_method?(node) && node.arguments.last&.type != :block_pass
Expand Down
3 changes: 3 additions & 0 deletions test/rubocop/singleton_configuration_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ def test_offense_statsd_backend

def test_offense_statsd_prefix
assert_offense('StatsD.prefix = "foo"')
# The interpolation is intentionally literal source passed to the cop under test.
# rubocop:disable Lint/InterpolationCheck
assert_offense('"#{StatsD.prefix}.foo"')
# rubocop:enable Lint/InterpolationCheck
end

def test_offense_statsd_default_tags
Expand Down
Loading