Skip to content

Commit a1f7ed6

Browse files
committed
rubocop fixes
1 parent 60344d7 commit a1f7ed6

File tree

87 files changed

+1097
-1029
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

87 files changed

+1097
-1029
lines changed

.github/linters/.ruby-lint.yml

Lines changed: 86 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,106 @@
1-
---
21
#######################
32
# Rubocop Config file #
43
#######################
4+
55
Metrics/MethodLength:
66
Max: 25
7+
Exclude:
8+
- alarm_actions.rb
9+
- alarm_basics.rb
10+
- create_alarm.rb
11+
- metrics_basics.rb
12+
- show_alarms.rb
13+
- scenario_users.rb
14+
- auth_session_token_request_test.rb
15+
716
Metrics/BlockLength:
817
Max: 75
18+
Exclude:
19+
- spec/send_events_ec2_spec.rb
20+
- encryption_v2/spec/test_s3_get_cskms_decrypt_item.rb
21+
922
Metrics/AbcSize:
1023
Max: 20
24+
Exclude:
25+
- metrics_basics.rb
26+
- show_alarms.rb
27+
- list_users.rb
28+
- manage_users.rb
29+
- scenario_users.rb
30+
- auth_session_token_request_test.rb
31+
- encryption_v2/spec/test_s3_get_cskms_decrypt_item.rb
32+
33+
Metrics/ParameterLists:
34+
Max: 5
35+
Exclude:
36+
- alarm_actions.rb
37+
- alarm_basics.rb
38+
- create_alarm.rb
39+
- metrics_basics.rb
40+
41+
Metrics/CyclomaticComplexity:
42+
Max: 7
43+
Exclude:
44+
- show_alarms.rb
45+
46+
Metrics/PerceivedComplexity:
47+
Max: 8
48+
Exclude:
49+
- show_alarms.rb
50+
- auth_session_token_request_test.rb
51+
52+
Metrics/ClassLength:
53+
Max: 100
54+
Exclude:
55+
- manage_roles.rb
56+
- manage_users.rb
57+
- scenario_users.rb
58+
1159
Style/FrozenStringLiteralComment:
1260
Enabled: false
61+
1362
Layout/EndOfLine:
1463
Enabled: false
64+
1565
Layout/LineLength:
66+
Max: 120
1667
Exclude:
1768
- ruby/example_code/kms/decrypt_data.rb
69+
- spec/list_admins_spec.rb
70+
- encryption_v2/s3_add_cskms_encrypt_item.rb
71+
- encryption_v2/spec/test_s3_add_cskms_encrypt_item.rb
72+
- encryption_v2/spec/test_s3_get_cskms_decrypt_item.rb
73+
1874
Naming/FileName:
1975
Enabled: false
76+
2077
Style/HashSyntax:
2178
EnforcedShorthandSyntax: either
79+
80+
Naming/PredicateName:
81+
Enabled: false
82+
Exclude:
83+
- list_admins.rb
84+
85+
Naming/AccessorMethodName:
86+
Enabled: false
87+
Exclude:
88+
- list_users.rb
89+
- manage_users.rb
90+
- bucket_cors.rb
91+
- bucket_policy.rb
92+
- bucket_put_encryption.rb
93+
- encryption_v2/s3_add_csaes_encrypt_item.rb
94+
- object_get_encryption.rb
95+
- s3.rb
96+
97+
Naming/MethodParameterName:
98+
Min: 3
99+
Exclude:
100+
- manage_roles.rb
101+
- s3.rb
102+
103+
Naming/VariableNumber:
104+
Enabled: false
105+
Exclude:
106+
- encryption_v2/s3_add_csaes_encrypt_item.rb

ruby/example_code/cloudwatch/alarm_actions.rb

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# 2. Disable all actions for an alarm.
77

88
# snippet-start:[cloudwatch.Ruby.createAnAlarm]
9-
require "aws-sdk-cloudwatch"
9+
require 'aws-sdk-cloudwatch'
1010

1111
# Creates or updates an alarm in Amazon CloudWatch.
1212

@@ -84,11 +84,12 @@ def alarm_created_or_updated?(
8484
threshold: threshold,
8585
comparison_operator: comparison_operator
8686
)
87-
return true
87+
true
8888
rescue StandardError => e
8989
puts "Error creating alarm: #{e.message}"
90-
return false
90+
false
9191
end
92+
9293
# snippet-end:[cloudwatch.Ruby.createAnAlarm]
9394
# snippet-start:[cloudwatch.Ruby.disableAnAlarm]
9495
# Disables an alarm in Amazon CloudWatch.
@@ -108,39 +109,39 @@ def alarm_created_or_updated?(
108109
# )
109110
def alarm_actions_disabled?(cloudwatch_client, alarm_name)
110111
cloudwatch_client.disable_alarm_actions(alarm_names: [alarm_name])
111-
return true
112+
true
112113
rescue StandardError => e
113114
puts "Error disabling alarm actions: #{e.message}"
114-
return false
115+
false
115116
end
116117

117118
# Example usage:
118119
def run_me
119-
alarm_name = "ObjectsInBucket"
120-
alarm_description = "Objects exist in this bucket for more than 1 day."
121-
metric_name = "NumberOfObjects"
120+
alarm_name = 'ObjectsInBucket'
121+
alarm_description = 'Objects exist in this bucket for more than 1 day.'
122+
metric_name = 'NumberOfObjects'
122123
# Notify this Amazon Simple Notification Service (Amazon SNS) topic when
123124
# the alarm transitions to the ALARM state.
124-
alarm_actions = ["arn:aws:sns:us-east-1:111111111111:Default_CloudWatch_Alarms_Topic"]
125-
namespace = "AWS/S3"
126-
statistic = "Average"
125+
alarm_actions = ['arn:aws:sns:us-east-1:111111111111:Default_CloudWatch_Alarms_Topic']
126+
namespace = 'AWS/S3'
127+
statistic = 'Average'
127128
dimensions = [
128129
{
129-
name: "BucketName",
130-
value: "amzn-s3-demo-doc-example-bucket"
130+
name: 'BucketName',
131+
value: 'amzn-s3-demo-doc-example-bucket'
131132
},
132133
{
133-
name: "StorageType",
134-
value: "AllStorageTypes"
134+
name: 'StorageType',
135+
value: 'AllStorageTypes'
135136
}
136137
]
137138
period = 86_400 # Daily (24 hours * 60 minutes * 60 seconds = 86400 seconds).
138-
unit = "Count"
139+
unit = 'Count'
139140
evaluation_periods = 1 # More than one day.
140141
threshold = 1 # One object.
141-
comparison_operator = "GreaterThanThreshold" # More than one object.
142+
comparison_operator = 'GreaterThanThreshold' # More than one object.
142143
# Replace us-west-2 with the AWS Region you're using for Amazon CloudWatch.
143-
region = "us-east-1"
144+
region = 'us-east-1'
144145

145146
cloudwatch_client = Aws::CloudWatch::Client.new(region: region)
146147

ruby/example_code/cloudwatch/alarm_basics.rb

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# 2. Create or update an alarm.
77
# 3. Delete an alarm.
88
# snippet-start:[cloudwatch.Ruby.getAlarmList]
9-
require "aws-sdk-cloudwatch"
9+
require 'aws-sdk-cloudwatch'
1010

1111
# Lists the names of available Amazon CloudWatch alarms.
1212
#
@@ -21,11 +21,12 @@ def list_alarms(cloudwatch_client)
2121
puts alarm.alarm_name
2222
end
2323
else
24-
puts "No alarms found."
24+
puts 'No alarms found.'
2525
end
2626
rescue StandardError => e
2727
puts "Error getting information about alarms: #{e.message}"
2828
end
29+
2930
# snippet-end:[cloudwatch.Ruby.getAlarmList]
3031
# snippet-start:[cloudwatch.Ruby.PutMetricAlarm]
3132
# Creates or updates an alarm in Amazon CloudWatch.
@@ -104,11 +105,12 @@ def alarm_created_or_updated?(
104105
threshold: threshold,
105106
comparison_operator: comparison_operator
106107
)
107-
return true
108+
true
108109
rescue StandardError => e
109110
puts "Error creating alarm: #{e.message}"
110-
return false
111+
false
111112
end
113+
112114
# snippet-end:[cloudwatch.Ruby.PutMetricAlarm]
113115
# snippet-start:[cloudwatch.Ruby.deleteAlarm]
114116
# Deletes an alarm in Amazon CloudWatch.
@@ -128,43 +130,43 @@ def alarm_created_or_updated?(
128130
# )
129131
def alarm_deleted?(cloudwatch_client, alarm_name)
130132
cloudwatch_client.delete_alarms(alarm_names: [alarm_name])
131-
return true
133+
true
132134
rescue StandardError => e
133135
puts "Error deleting alarm: #{e.message}"
134-
return false
136+
false
135137
end
136138

137139
# Example usage:
138140
def run_me
139-
alarm_name = "ObjectsInBucket"
140-
alarm_description = "Objects exist in this bucket for more than 1 day."
141-
metric_name = "NumberOfObjects"
141+
alarm_name = 'ObjectsInBucket'
142+
alarm_description = 'Objects exist in this bucket for more than 1 day.'
143+
metric_name = 'NumberOfObjects'
142144
# Notify this Amazon Simple Notification Service (Amazon SNS) topic when
143145
# the alarm transitions to the ALARM state.
144-
alarm_actions = ["arn:aws:sns:us-east-1:111111111111:Default_CloudWatch_Alarms_Topic"]
145-
namespace = "AWS/S3"
146-
statistic = "Average"
146+
alarm_actions = ['arn:aws:sns:us-east-1:111111111111:Default_CloudWatch_Alarms_Topic']
147+
namespace = 'AWS/S3'
148+
statistic = 'Average'
147149
dimensions = [
148150
{
149-
name: "BucketName",
150-
value: "amzn-s3-demo-doc-example-bucket"
151+
name: 'BucketName',
152+
value: 'amzn-s3-demo-doc-example-bucket'
151153
},
152154
{
153-
name: "StorageType",
154-
value: "AllStorageTypes"
155+
name: 'StorageType',
156+
value: 'AllStorageTypes'
155157
}
156158
]
157159
period = 86_400 # Daily (24 hours * 60 minutes * 60 seconds = 86400 seconds).
158-
unit = "Count"
160+
unit = 'Count'
159161
evaluation_periods = 1 # More than one day.
160162
threshold = 1 # One object.
161-
comparison_operator = "GreaterThanThreshold" # More than one object.
163+
comparison_operator = 'GreaterThanThreshold' # More than one object.
162164
# Replace us-west-2 with the AWS Region you're using for Amazon CloudWatch.
163-
region = "us-east-1"
165+
region = 'us-east-1'
164166

165167
cloudwatch_client = Aws::CloudWatch::Client.new(region: region)
166168

167-
puts "Available Amazon CloudWatch alarms:"
169+
puts 'Available Amazon CloudWatch alarms:'
168170
list_alarms(cloudwatch_client)
169171

170172
if alarm_created_or_updated?(

ruby/example_code/cloudwatch/create_alarm.rb

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
# snippet-start:[cloudwatch.Ruby.createAlarm]
77

8-
require "aws-sdk-cloudwatch"
8+
require 'aws-sdk-cloudwatch'
99

1010
# @param cloudwatch_client [Aws::CloudWatch::Client]
1111
# An initialized CloudWatch client.
@@ -81,39 +81,39 @@ def alarm_created_or_updated?(
8181
threshold: threshold,
8282
comparison_operator: comparison_operator
8383
)
84-
return true
84+
true
8585
rescue StandardError => e
8686
puts "Error creating alarm: #{e.message}"
87-
return false
87+
false
8888
end
8989

9090
# Example usage:
9191
def run_me
92-
alarm_name = "ObjectsInBucket"
93-
alarm_description = "Objects exist in this bucket for more than 1 day."
94-
metric_name = "NumberOfObjects"
92+
alarm_name = 'ObjectsInBucket'
93+
alarm_description = 'Objects exist in this bucket for more than 1 day.'
94+
metric_name = 'NumberOfObjects'
9595
# Notify this Amazon Simple Notification Service (Amazon SNS) topic when
9696
# the alarm transitions to the ALARM state.
97-
alarm_actions = ["arn:aws:sns:us-east-1:111111111111:Default_CloudWatch_Alarms_Topic"]
98-
namespace = "AWS/S3"
99-
statistic = "Average"
97+
alarm_actions = ['arn:aws:sns:us-east-1:111111111111:Default_CloudWatch_Alarms_Topic']
98+
namespace = 'AWS/S3'
99+
statistic = 'Average'
100100
dimensions = [
101101
{
102-
name: "BucketName",
103-
value: "amzn-s3-demo-doc-example-bucket"
102+
name: 'BucketName',
103+
value: 'amzn-s3-demo-doc-example-bucket'
104104
},
105105
{
106-
name: "StorageType",
107-
value: "AllStorageTypes"
106+
name: 'StorageType',
107+
value: 'AllStorageTypes'
108108
}
109109
]
110110
period = 86_400 # Daily (24 hours * 60 minutes * 60 seconds = 86400 seconds).
111-
unit = "Count"
111+
unit = 'Count'
112112
evaluation_periods = 1 # More than one day.
113113
threshold = 1 # One object.
114-
comparison_operator = "GreaterThanThreshold" # More than one object.
114+
comparison_operator = 'GreaterThanThreshold' # More than one object.
115115
# Replace us-west-2 with the AWS Region you're using for Amazon CloudWatch.
116-
region = "us-east-1"
116+
region = 'us-east-1'
117117

118118
cloudwatch_client = Aws::CloudWatch::Client.new(region: region)
119119

0 commit comments

Comments
 (0)