Skip to content

Commit e76833f

Browse files
committed
More fixes
1 parent 4143536 commit e76833f

File tree

12 files changed

+103
-154
lines changed

12 files changed

+103
-154
lines changed

.rubocop_todo.yml

Lines changed: 25 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# This configuration was generated by
22
# `rubocop --auto-gen-config`
3-
# on 2023-03-08 09:07:11 UTC using RuboCop version 1.45.1.
3+
# on 2023-03-08 09:38:19 UTC using RuboCop version 1.45.1.
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
77
# versions of RuboCop, may require this file to be generated again.
88

9-
# Offense count: 11
9+
# Offense count: 18
1010
# This cop supports safe autocorrection (--autocorrect).
1111
Layout/EmptyLineAfterGuardClause:
1212
Exclude:
@@ -16,6 +16,7 @@ Layout/EmptyLineAfterGuardClause:
1616
- 'lib/onelogin/ruby-saml/logoutresponse.rb'
1717
- 'lib/onelogin/ruby-saml/response.rb'
1818
- 'lib/onelogin/ruby-saml/saml_message.rb'
19+
- 'lib/onelogin/ruby-saml/slo_logoutrequest.rb'
1920
- 'lib/onelogin/ruby-saml/slo_logoutresponse.rb'
2021

2122
# Offense count: 10
@@ -94,7 +95,7 @@ Layout/IndentationConsistency:
9495
Exclude:
9596
- 'lib/onelogin/ruby-saml/authrequest.rb'
9697

97-
# Offense count: 3
98+
# Offense count: 6
9899
# This cop supports safe autocorrection (--autocorrect).
99100
# Configuration parameters: Width, AllowedPatterns.
100101
Layout/IndentationWidth:
@@ -205,23 +206,18 @@ Lint/UselessAssignment:
205206
# Offense count: 39
206207
# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes.
207208
Metrics/AbcSize:
208-
Max: 101
209+
Max: 100
209210

210211
# Offense count: 1
211212
# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
212213
# AllowedMethods: refine
213214
Metrics/BlockLength:
214215
Max: 27
215216

216-
# Offense count: 4
217-
# Configuration parameters: CountBlocks.
218-
Metrics/BlockNesting:
219-
Max: 4
220-
221217
# Offense count: 9
222218
# Configuration parameters: CountComments, CountAsOne.
223219
Metrics/ClassLength:
224-
Max: 668
220+
Max: 652
225221

226222
# Offense count: 23
227223
# Configuration parameters: AllowedMethods, AllowedPatterns.
@@ -231,7 +227,7 @@ Metrics/CyclomaticComplexity:
231227
# Offense count: 58
232228
# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
233229
Metrics/MethodLength:
234-
Max: 68
230+
Max: 63
235231

236232
# Offense count: 2
237233
# Configuration parameters: Max, CountKeywordArgs.
@@ -379,15 +375,14 @@ Style/Documentation:
379375
- 'lib/onelogin/ruby-saml/logging.rb'
380376
- 'lib/xml_security.rb'
381377

382-
# Offense count: 3
378+
# Offense count: 1
383379
# This cop supports safe autocorrection (--autocorrect).
384380
# Configuration parameters: MinBodyLength, AllowConsecutiveConditionals.
385381
Style/GuardClause:
386382
Exclude:
387383
- 'lib/onelogin/ruby-saml/response.rb'
388-
- 'lib/onelogin/ruby-saml/utils.rb'
389384

390-
# Offense count: 69
385+
# Offense count: 60
391386
# This cop supports safe autocorrection (--autocorrect).
392387
Style/IfUnlessModifier:
393388
Exclude:
@@ -403,24 +398,30 @@ Style/IfUnlessModifier:
403398
- 'lib/onelogin/ruby-saml/utils.rb'
404399
- 'lib/xml_security.rb'
405400

406-
# Offense count: 1
407-
# This cop supports safe autocorrection (--autocorrect).
408-
Style/NegatedIfElseCondition:
401+
# Offense count: 15
402+
# Configuration parameters: AllowedMethods.
403+
# AllowedMethods: respond_to_missing?
404+
Style/OptionalBooleanParameter:
409405
Exclude:
410-
- 'lib/onelogin/ruby-saml/authrequest.rb'
406+
- 'lib/onelogin/ruby-saml/idp_metadata_parser.rb'
407+
- 'lib/onelogin/ruby-saml/logoutresponse.rb'
408+
- 'lib/onelogin/ruby-saml/metadata.rb'
409+
- 'lib/onelogin/ruby-saml/response.rb'
410+
- 'lib/onelogin/ruby-saml/saml_message.rb'
411+
- 'lib/onelogin/ruby-saml/settings.rb'
412+
- 'lib/onelogin/ruby-saml/slo_logoutrequest.rb'
413+
- 'lib/onelogin/ruby-saml/utils.rb'
414+
- 'lib/xml_security.rb'
411415

412-
# Offense count: 7
416+
# Offense count: 2
413417
# This cop supports unsafe autocorrection (--autocorrect-all).
414418
# Configuration parameters: Mode.
415419
Style/StringConcatenation:
416420
Exclude:
417-
- 'lib/onelogin/ruby-saml/idp_metadata_parser.rb'
418-
- 'lib/onelogin/ruby-saml/metadata.rb'
419421
- 'lib/onelogin/ruby-saml/response.rb'
420422
- 'lib/onelogin/ruby-saml/saml_message.rb'
421-
- 'lib/onelogin/ruby-saml/utils.rb'
422423

423-
# Offense count: 452
424+
# Offense count: 450
424425
# This cop supports safe autocorrection (--autocorrect).
425426
# Configuration parameters: EnforcedStyle, ConsistentQuotesInMultiline.
426427
# SupportedStyles: single_quotes, double_quotes
@@ -442,41 +443,7 @@ Style/StringLiterals:
442443
- 'lib/onelogin/ruby-saml/utils.rb'
443444
- 'lib/xml_security.rb'
444445

445-
# Offense count: 8
446-
# This cop supports safe autocorrection (--autocorrect).
447-
# Configuration parameters: MinSize.
448-
# SupportedStyles: percent, brackets
449-
Style/SymbolArray:
450-
EnforcedStyle: brackets
451-
452-
# Offense count: 3
453-
# This cop supports safe autocorrection (--autocorrect).
454-
# Configuration parameters: EnforcedStyle, AllowSafeAssignment.
455-
# SupportedStyles: require_parentheses, require_no_parentheses, require_parentheses_when_complex
456-
Style/TernaryParentheses:
457-
Exclude:
458-
- 'lib/onelogin/ruby-saml/authrequest.rb'
459-
- 'lib/onelogin/ruby-saml/logoutrequest.rb'
460-
- 'lib/onelogin/ruby-saml/slo_logoutresponse.rb'
461-
462-
# Offense count: 3
463-
# This cop supports safe autocorrection (--autocorrect).
464-
# Configuration parameters: EnforcedStyleForMultiline.
465-
# SupportedStylesForMultiline: comma, consistent_comma, no_comma
466-
Style/TrailingCommaInHashLiteral:
467-
Exclude:
468-
- 'lib/onelogin/ruby-saml/authrequest.rb'
469-
- 'lib/onelogin/ruby-saml/idp_metadata_parser.rb'
470-
- 'lib/onelogin/ruby-saml/metadata.rb'
471-
472-
# Offense count: 4
473-
# This cop supports unsafe autocorrection (--autocorrect-all).
474-
Style/ZeroLengthPredicate:
475-
Exclude:
476-
- 'lib/onelogin/ruby-saml/attribute_service.rb'
477-
- 'lib/onelogin/ruby-saml/response.rb'
478-
479-
# Offense count: 96
446+
# Offense count: 100
480447
# This cop supports safe autocorrection (--autocorrect).
481448
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns.
482449
# URISchemes: http, https

lib/onelogin/ruby-saml/attribute_service.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def configure(&block)
2424
# @return [Boolean] True if the AttributeService object has been initialized and set with the required values
2525
# (has attributes and a name)
2626
def configured?
27-
@attributes.length > 0 && !@name.nil?
27+
!@attributes.empty? && !@name.nil?
2828
end
2929

3030
# Set a name to the service

lib/onelogin/ruby-saml/authrequest.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def request_id
3838
#
3939
def create(settings, params = {})
4040
params = create_params(settings, params)
41-
params_prefix = (settings.idp_sso_service_url =~ /\?/) ? '&' : '?'
41+
params_prefix = /\?/.match?(settings.idp_sso_service_url) ? '&' : '?'
4242
saml_request = CGI.escape(params.delete("SAMLRequest"))
4343
request_params = +"#{params_prefix}SAMLRequest=#{saml_request}"
4444
params.each_pair do |key, value|
@@ -152,14 +152,14 @@ def create_xml_document(settings)
152152

153153
if settings.authn_context || settings.authn_context_decl_ref
154154

155-
if !settings.authn_context_comparison.nil?
156-
comparison = settings.authn_context_comparison
157-
else
155+
if settings.authn_context_comparison.nil?
158156
comparison = 'exact'
157+
else
158+
comparison = settings.authn_context_comparison
159159
end
160160

161161
requested_context = root.add_element "samlp:RequestedAuthnContext", {
162-
"Comparison" => comparison,
162+
"Comparison" => comparison
163163
}
164164

165165
unless settings.authn_context.nil?

lib/onelogin/ruby-saml/idp_metadata_parser.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ module Vocabulary
4242

4343
# fetch IdP descriptors from a metadata document
4444
def self.get_idps(metadata_document, only_entity_id=nil)
45-
path = "//md:EntityDescriptor#{('[@entityID="' + only_entity_id + '"]') if only_entity_id}/md:IDPSSODescriptor"
45+
path = "//md:EntityDescriptor#{"[@entityID=\"#{only_entity_id}\"]" if only_entity_id}/md:IDPSSODescriptor"
4646
REXML::XPath.match(
4747
metadata_document,
4848
path,
@@ -238,7 +238,7 @@ def to_hash(options = {})
238238
idp_cert_fingerprint: nil,
239239
idp_cert_multi: nil,
240240
valid_until: valid_until,
241-
cache_duration: cache_duration,
241+
cache_duration: cache_duration
242242
}.tap do |response_hash|
243243
merge_certificates_into(response_hash) unless certificates.nil?
244244
end

lib/onelogin/ruby-saml/logoutrequest.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def request_id
3535
#
3636
def create(settings, params={})
3737
params = create_params(settings, params)
38-
params_prefix = (settings.idp_slo_service_url =~ /\?/) ? '&' : '?'
38+
params_prefix = /\?/.match?(settings.idp_slo_service_url) ? '&' : '?'
3939
saml_request = CGI.escape(params.delete("SAMLRequest"))
4040
request_params = +"#{params_prefix}SAMLRequest=#{saml_request}"
4141
params.each_pair do |key, value|

lib/onelogin/ruby-saml/logoutresponse.rb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -116,13 +116,13 @@ def status_message
116116
def validate(collect_errors = false)
117117
reset_errors!
118118

119-
validations = [
120-
:valid_state?,
121-
:validate_success_status,
122-
:validate_structure,
123-
:valid_in_response_to?,
124-
:valid_issuer?,
125-
:validate_signature
119+
validations = %i[
120+
valid_state?
121+
validate_success_status
122+
validate_structure
123+
valid_in_response_to?
124+
valid_issuer?
125+
validate_signature
126126
]
127127

128128
if collect_errors

lib/onelogin/ruby-saml/metadata.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,15 @@ def add_root_element(meta_doc, settings, valid_until, cache_duration)
5252
root.attributes["ID"] = OneLogin::RubySaml::Utils.uuid
5353
root.attributes["entityID"] = settings.sp_entity_id if settings.sp_entity_id
5454
root.attributes["validUntil"] = valid_until.utc.strftime('%Y-%m-%dT%H:%M:%SZ') if valid_until
55-
root.attributes["cacheDuration"] = "PT" + cache_duration.to_s + "S" if cache_duration
55+
root.attributes["cacheDuration"] = "PT#{cache_duration}S" if cache_duration
5656
root
5757
end
5858

5959
def add_sp_sso_element(root, settings)
6060
root.add_element "md:SPSSODescriptor", {
6161
"protocolSupportEnumeration" => "urn:oasis:names:tc:SAML:2.0:protocol",
6262
"AuthnRequestsSigned" => settings.security[:authn_requests_signed],
63-
"WantAssertionsSigned" => settings.security[:want_assertions_signed],
63+
"WantAssertionsSigned" => settings.security[:want_assertions_signed]
6464
}
6565
end
6666

0 commit comments

Comments
 (0)