Skip to content

Commit

Permalink
rubocop: enable Style/RescueModifier
Browse files Browse the repository at this point in the history
  • Loading branch information
jreidinger committed Dec 28, 2023
1 parent 9aafcd2 commit 9ba3cae
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
6 changes: 0 additions & 6 deletions .rubocop.yml
Expand Up @@ -161,9 +161,3 @@ Style/NonNilCheck:
- 'src/include/security/dialogs.rb'
- 'src/include/security/routines.rb'
- 'src/modules/Security.rb'

# Offense count: 2
# Cop supports --auto-correct.
Style/RescueModifier:
Exclude:
- 'src/modules/Security.rb'
13 changes: 11 additions & 2 deletions src/modules/Security.rb
Expand Up @@ -98,7 +98,12 @@ def init_settings
# Services to check
srv_file = Directory.find_data_file("security/services.yml")
srv_lists = if srv_file
YAML.load_file(srv_file) rescue {}
begin
YAML.load_file(srv_file)
rescue StandardError => e
log.warn "Failed to load #{srv_file}. Error: #{e.inspect}"
{}
end
else
{}
end
Expand Down Expand Up @@ -609,7 +614,11 @@ def write_kernel_settings
# NOTE: the call to #sort is only needed to satisfy the old testsuite
@sysctl.sort.each do |key, default_value|
val = @Settings.fetch(key, default_value)
int_val = Integer(val) rescue nil
int_val = begin
Integer(val)
rescue StandardError
nil
end
if int_val.nil? && ![TrueClass, FalseClass].include?(val.class)
log.error "value #{val} for #{key} has wrong type, not writing"
elsif val != read_sysctl_value(key)
Expand Down

0 comments on commit 9ba3cae

Please sign in to comment.