Skip to content

Commit 289de53

Browse files
authored
Merge pull request #1533 from appsignal/rubocop-cleanup
Remove the RuboCop todo file and prune lint disables
2 parents d7fd56a + b53c211 commit 289de53

39 files changed

Lines changed: 131 additions & 197 deletions

.rubocop.yml

Lines changed: 37 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
inherit_from: .rubocop_todo.yml
2-
31
AllCops:
42
TargetRubyVersion: 2.7
53
NewCops: enable
@@ -73,6 +71,14 @@ Style/RedundantConstantBase:
7371
Style/RedundantLineContinuation:
7472
AutoCorrect: false
7573

74+
# We rescue Exception only in deliberate, reviewed places: integrations that
75+
# record the error and re-raise it, and a spec helper that retries on RSpec
76+
# expectation failures (ExpectationNotMetError subclasses Exception). The cop
77+
# can't tell these from a careless rescue, so we disable it rather than scatter
78+
# inline disables.
79+
Lint/RescueException:
80+
Enabled: false
81+
7682
Lint/ConstantDefinitionInBlock:
7783
Exclude:
7884
- "spec/**/*.rb"
@@ -116,26 +122,48 @@ Naming/FileName:
116122
Exclude:
117123
- "ext/Rakefile"
118124

125+
# Our API mirrors the agent's set_*/get_* method names, a convention used
126+
# throughout the gem and the extension. We follow it deliberately, so disable
127+
# the cop instead of scattering excludes and inline disables for it.
119128
Naming/AccessorMethodName:
120-
Exclude:
121-
- "lib/appsignal/helpers/instrumentation.rb"
122-
- "lib/appsignal/transaction.rb"
129+
Enabled: false
130+
131+
# Several command methods return a boolean status (abort_installation,
132+
# Demo.transmit). The cop wants them renamed with a `?`, which would wrongly
133+
# read them as queries, so we don't run it.
134+
Naming/PredicateMethod:
135+
Enabled: false
123136

124137
Naming/RescuedExceptionsVariableName:
125138
Enabled: false
126139

127140
Naming/VariableNumber:
128141
Enabled: false
129142

130-
Metrics/ModuleLength:
143+
# Complexity and length metrics were never enforced here: their thresholds
144+
# floated for years through `rubocop --auto-gen-config` and the remaining hits
145+
# were silenced inline. They flag a style we deliberately accept, so instead of
146+
# tracking an ever-changing Max we don't run them.
147+
Metrics/AbcSize:
148+
Enabled: false
149+
150+
Metrics/BlockLength:
131151
Enabled: false
132152

133153
Metrics/ClassLength:
134154
Enabled: false
135155

136-
Metrics/BlockLength:
137-
Exclude:
138-
- "Rakefile"
156+
Metrics/CyclomaticComplexity:
157+
Enabled: false
158+
159+
Metrics/MethodLength:
160+
Enabled: false
161+
162+
Metrics/ModuleLength:
163+
Enabled: false
164+
165+
Metrics/PerceivedComplexity:
166+
Enabled: false
139167

140168
Gemspec/DevelopmentDependencies:
141169
Enabled: false

.rubocop_todo.yml

Lines changed: 0 additions & 108 deletions
This file was deleted.

appsignal.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ IGNORED_PATHS = [
2121
".rubocop_todo.yml"
2222
].freeze
2323

24-
Gem::Specification.new do |gem| # rubocop:disable Metrics/BlockLength
24+
Gem::Specification.new do |gem|
2525
gem.authors = [
2626
"Robert Beekman",
2727
"Thijs Cadier",

ext/base.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,9 @@ def download_archive(type)
136136
:proxy => proxy }
137137
]
138138
if URI.respond_to?(:open) # rubocop:disable Style/GuardClause
139-
return URI.open(*args)
139+
return URI.open(*args) # rubocop:disable Security/Open
140140
else
141-
return open(*args)
141+
return open(*args) # rubocop:disable Security/Open
142142
end
143143
rescue => error
144144
backtrace = error.backtrace.join("\n")

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)
80+
def have_required_function(library, func) # rubocop:disable Naming/PredicatePrefix
8181
if have_func(func)
8282
report["build"]["dependencies"][library] = "linked"
8383
return

lib/appsignal.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ def testing?
105105
#
106106
# @return [void]
107107
# @since 0.7.0
108-
def start # rubocop:disable Metrics/AbcSize
108+
def start
109109
if ENV.fetch("_APPSIGNAL_DIAGNOSE", false)
110110
internal_logger.info("Skipping start in diagnose context")
111111
return
@@ -169,7 +169,7 @@ def start # rubocop:disable Metrics/AbcSize
169169
# @param block [Proc] Optional block to configure the config object.
170170
# @return [void]
171171
# @!visibility private
172-
def _load_config!(env_param = nil, &block) # rubocop:disable Metrics/PerceivedComplexity, Metrics/CyclomaticComplexity
172+
def _load_config!(env_param = nil, &block)
173173
# Ensure it's not an empty string if it's a value
174174
proper_env_param = env_param&.to_s&.strip
175175
# Unset it if it's an empty string

lib/appsignal/check_in/event.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def describe(events)
7070
end
7171
end
7272

73-
def deduplicate_cron!(events) # rubocop:disable Metrics/AbcSize
73+
def deduplicate_cron!(events)
7474
# Remove redundant cron check-in events from the given list of events.
7575
# This is done by removing redundant *pairs* of events -- that is,
7676
# for each identifier, only send one complete pair of start and

lib/appsignal/cli/diagnose.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ def fetch_installation_report
350350
path = File.expand_path("../../../ext/install.report", __dir__)
351351
raw_report = File.read(path)
352352
JSON.parse(raw_report)
353-
rescue StandardError, JSON::ParserError => e # rubocop:disable Lint/ShadowedException
353+
rescue StandardError => e
354354
{
355355
"parsing_error" => {
356356
"error" => "#{e.class}: #{e}",

lib/appsignal/cli/install.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class Install
1212
EXCLUDED_ENVIRONMENTS = ["test"].freeze
1313

1414
class << self
15-
def run(push_api_key, options) # rubocop:disable Metrics/AbcSize
15+
def run(push_api_key, options)
1616
self.coloring = options.delete(:color) { true }
1717
$stdout.sync = true
1818

@@ -228,7 +228,7 @@ def install_for_unknown_framework(config)
228228
done_notice
229229
end
230230

231-
def configure(config, environments, name_overwritten) # rubocop:disable Metrics/AbcSize
231+
def configure(config, environments, name_overwritten)
232232
install_for_capistrano
233233

234234
ENV["APPSIGNAL_APP_ENV"] = "development"
@@ -241,7 +241,7 @@ def configure(config, environments, name_overwritten) # rubocop:disable Metrics/
241241
puts " See our docs for information on the different configuration methods: "
242242
puts " https://docs.appsignal.com/ruby/configuration.html"
243243
puts
244-
loop do # rubocop:disable Metrics/BlockLength
244+
loop do
245245
print " Choose (1-3): "
246246
case ask_for_input
247247
when "1"

lib/appsignal/config.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ def active?
432432
end
433433

434434
# @!visibility private
435-
def write_to_environment # rubocop:disable Metrics/AbcSize
435+
def write_to_environment
436436
ENV["_APPSIGNAL_ACTIVE"] = active?.to_s
437437
ENV["_APPSIGNAL_AGENT_PATH"] = File.expand_path("../../ext", __dir__).to_s
438438
ENV["_APPSIGNAL_APP_NAME"] = config_hash[:name]
@@ -591,7 +591,9 @@ def load_from_disk
591591
return unless yml_config_file?
592592

593593
read_options = YAML::VERSION >= "4.0.0" ? { :aliases => true } : {}
594+
# rubocop:disable Security/YAMLLoad
594595
configurations = YAML.load(ERB.new(File.read(yml_config_file)).result, **read_options)
596+
# rubocop:enable Security/YAMLLoad
595597
config_for_this_env = configurations[env]
596598
if config_for_this_env
597599
config_for_this_env.transform_keys(&:to_sym)

0 commit comments

Comments
 (0)