Skip to content

Commit c644027

Browse files
authored
Merge pull request #1532 from appsignal/bump-rubocop
Upgrade RuboCop to 1.87
2 parents 41ac2c1 + caf0f61 commit c644027

24 files changed

Lines changed: 199 additions & 115 deletions

.rubocop.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,12 @@ Style/SymbolArray:
6767
Style/RedundantConstantBase:
6868
Enabled: false
6969

70+
# Keep the detection but never autocorrect: removing the `\` after a `%()`
71+
# literal silently breaks adjacent-string concatenation, turning the joined
72+
# string into dead code. Let it flag for a human instead of rewriting.
73+
Style/RedundantLineContinuation:
74+
AutoCorrect: false
75+
7076
Lint/ConstantDefinitionInBlock:
7177
Exclude:
7278
- "spec/**/*.rb"

.rubocop_todo.yml

Lines changed: 38 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# This configuration was generated by
22
# `rubocop --auto-gen-config`
3-
# on 2024-06-27 09:42:06 UTC using RuboCop version 1.64.1.
3+
# on 2026-06-26 10:42:55 UTC using RuboCop version 1.87.0.
44
# The point is for the user to remove these configuration records
55
# one by one as the offenses are removed from the code base.
66
# Note that changes in the inspected code, or installation of new
@@ -18,32 +18,54 @@ Lint/StructNewOverride:
1818
Exclude:
1919
- 'spec/lib/appsignal/probes/sidekiq_spec.rb'
2020

21-
# Offense count: 63
21+
# Offense count: 78
2222
# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes.
2323
Metrics/AbcSize:
24-
Max: 44
24+
Max: 43
2525

26-
# Offense count: 6
26+
# Offense count: 4
2727
# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
2828
# AllowedMethods: refine
2929
Metrics/BlockLength:
3030
Max: 31
3131

32-
# Offense count: 21
32+
# Offense count: 25
3333
# Configuration parameters: AllowedMethods, AllowedPatterns.
3434
Metrics/CyclomaticComplexity:
3535
Max: 11
3636

37-
# Offense count: 139
37+
# Offense count: 176
3838
# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
3939
Metrics/MethodLength:
40-
Max: 56
40+
Max: 54
4141

42-
# Offense count: 18
42+
# Offense count: 20
4343
# Configuration parameters: AllowedMethods, AllowedPatterns.
4444
Metrics/PerceivedComplexity:
4545
Max: 13
4646

47+
# Offense count: 5
48+
# Configuration parameters: Mode, AllowedMethods, AllowedPatterns, AllowBangMethods, WaywardPredicates.
49+
# AllowedMethods: call
50+
# WaywardPredicates: infinite?, nonzero?
51+
Naming/PredicateMethod:
52+
Exclude:
53+
- 'ext/base.rb'
54+
- 'lib/appsignal/demo.rb'
55+
- 'spec/lib/appsignal/integrations/delayed_job_plugin_spec.rb'
56+
- 'spec/support/testing.rb'
57+
58+
# Offense count: 1
59+
# Configuration parameters: NamePrefix, ForbiddenPrefixes, AllowedMethods, MethodDefinitionMacros, UseSorbetSigs.
60+
# NamePrefix: is_, has_, have_, does_
61+
# ForbiddenPrefixes: is_, has_, have_, does_
62+
# AllowedMethods: is_a?
63+
# MethodDefinitionMacros: define_method, define_singleton_method
64+
Naming/PredicatePrefix:
65+
Exclude:
66+
- 'spec/**/*'
67+
- 'ext/extconf.rb'
68+
4769
# Offense count: 2
4870
Security/Open:
4971
Exclude:
@@ -56,7 +78,7 @@ Security/YAMLLoad:
5678
- 'lib/appsignal/config.rb'
5779
- 'lib/appsignal/integrations/sidekiq.rb'
5880

59-
# Offense count: 7
81+
# Offense count: 22
6082
# This cop supports safe autocorrection (--autocorrect).
6183
# Configuration parameters: EnforcedStyle.
6284
# SupportedStyles: prefer_alias, prefer_alias_method
@@ -70,15 +92,17 @@ Style/ClassVars:
7092
Exclude:
7193
- 'spec/lib/appsignal/event_formatter_spec.rb'
7294

73-
# Offense count: 1
74-
Style/OpenStructUse:
75-
Exclude:
76-
- 'lib/appsignal/cli/install.rb'
77-
7895
# Offense count: 2
7996
# Configuration parameters: AllowedMethods.
8097
# AllowedMethods: respond_to_missing?
8198
Style/OptionalBooleanParameter:
8299
Exclude:
83100
- 'lib/appsignal/integrations/delayed_job_plugin.rb'
84101
- 'lib/appsignal/utils/query_params_sanitizer.rb'
102+
103+
# Offense count: 1
104+
# This cop supports unsafe autocorrection (--autocorrect-all).
105+
# Configuration parameters: AllowedMethods, AllowedPatterns.
106+
Style/ReturnNilInPredicateMethodDefinition:
107+
Exclude:
108+
- 'spec/support/testing.rb'

appsignal.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ Gem::Specification.new do |gem| # rubocop:disable Metrics/BlockLength
6363
gem.add_development_dependency "pry"
6464
gem.add_development_dependency "rake", ">= 12"
6565
gem.add_development_dependency "rspec", "~> 3.8"
66-
gem.add_development_dependency "rubocop", "1.64.1"
66+
gem.add_development_dependency "rubocop", "~> 1.87.0"
6767
gem.add_development_dependency("sord") unless RUBY_PLATFORM == "java"
6868
gem.add_development_dependency "timecop"
6969
gem.add_development_dependency "webmock"

ext/base.rb

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,15 +100,11 @@ def installation_succeeded?
100100
end
101101

102102
def check_architecture
103-
if APPSIGNAL_AGENT_CONFIG["triples"].key?(TARGET_TRIPLE)
104-
true
105-
else
106-
abort_installation(
103+
APPSIGNAL_AGENT_CONFIG["triples"].key?(TARGET_TRIPLE) || abort_installation(
107104
"AppSignal currently does not support your system architecture (#{TARGET_TRIPLE})." \
108105
"Please let us know at support@appsignal.com, we aim to support everything " \
109106
"our customers run."
110107
)
111-
end
112108
end
113109

114110
def download_archive(type)

ext/extconf.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def link_libraries
7777
end
7878
end
7979

80-
def have_required_function(library, func) # rubocop:disable Naming/PredicateName
80+
def have_required_function(library, func)
8181
if have_func(func)
8282
report["build"]["dependencies"][library] = "linked"
8383
return

lib/appsignal/check_in/event.rb

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ module Appsignal
44
module CheckIn
55
# @!visibility private
66
class Event
7+
CRON_KINDS = %w[start finish].freeze
8+
private_constant :CRON_KINDS
9+
710
class << self
811
def new(check_in_type:, identifier:, digest: nil, kind: nil)
912
{
@@ -67,7 +70,7 @@ def describe(events)
6770
end
6871
end
6972

70-
def deduplicate_cron!(events) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity
73+
def deduplicate_cron!(events) # rubocop:disable Metrics/AbcSize
7174
# Remove redundant cron check-in events from the given list of events.
7275
# This is done by removing redundant *pairs* of events -- that is,
7376
# for each identifier, only send one complete pair of start and
@@ -111,9 +114,7 @@ def deduplicate_cron!(events) # rubocop:disable Metrics/AbcSize,Metrics/Cyclomat
111114
# Do not remove events that are not cron check-in events or that
112115
# have an unknown kind.
113116
return false unless
114-
event[:check_in_type] == "cron" && (
115-
event[:kind] == "start" ||
116-
event[:kind] == "finish")
117+
event[:check_in_type] == "cron" && CRON_KINDS.include?(event[:kind])
117118

118119
# Remove any event that is part of a complete digest pair, except
119120
# for the one digest that should be kept.

lib/appsignal/cli/helpers.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
module Appsignal
66
class CLI
77
module Helpers
8-
private
9-
108
COLOR_CODES = {
119
:red => 31,
1210
:green => 32,
@@ -16,6 +14,8 @@ module Helpers
1614
:default => 0
1715
}.freeze
1816

17+
private
18+
1919
def coloring=(value)
2020
@coloring = value
2121
end

lib/appsignal/extension/jruby.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -547,6 +547,7 @@ def close
547547

548548
class Data
549549
include StringHelpers
550+
550551
attr_reader :pointer
551552

552553
def initialize(pointer)

lib/appsignal/rack/hanami_middleware.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ def initialize(app, options = {})
1414

1515
HANAMI_ACTION_INSTANCE = "hanami.action_instance"
1616
ROUTER_PARAMS = "router.params"
17+
private_constant :HANAMI_ACTION_INSTANCE, :ROUTER_PARAMS
1718

1819
def add_transaction_metadata_after(transaction, request)
1920
action_name = fetch_hanami_action(request.env)

lib/appsignal/sample_data.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ def empty?
6868
private
6969

7070
UNSET_VALUE = nil
71+
private_constant :UNSET_VALUE
7172

7273
# Method called by `dup` and `clone` to create a duplicate instance.
7374
# Make sure the `@blocks` variable is also properly duplicated.

0 commit comments

Comments
 (0)