Skip to content

Commit

Permalink
Fixed Style/MultilineIfModifier
Browse files Browse the repository at this point in the history
  • Loading branch information
bobbrodie committed Apr 29, 2024
1 parent 98affed commit 5c9ccfc
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 10 deletions.
24 changes: 16 additions & 8 deletions lib/jira/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -122,14 +122,20 @@ def initialize(options = {})
raise ArgumentError, "Unknown option(s) given: #{unknown_options}" unless unknown_options.empty?

if options[:use_client_cert]
@options[:ssl_client_cert] =
OpenSSL::X509::Certificate.new(File.read(@options[:cert_path])) if @options[:cert_path]
if @options[:cert_path]
@options[:ssl_client_cert] =
OpenSSL::X509::Certificate.new(File.read(@options[:cert_path]))
end
@options[:ssl_client_key] = OpenSSL::PKey::RSA.new(File.read(@options[:key_path])) if @options[:key_path]

raise ArgumentError,
'Options: :cert_path or :ssl_client_cert must be set when :use_client_cert is true' unless @options[:ssl_client_cert]
raise ArgumentError,
'Options: :key_path or :ssl_client_key must be set when :use_client_cert is true' unless @options[:ssl_client_key]
unless @options[:ssl_client_cert]
raise ArgumentError,
'Options: :cert_path or :ssl_client_cert must be set when :use_client_cert is true'
end
unless @options[:ssl_client_key]
raise ArgumentError,
'Options: :key_path or :ssl_client_key must be set when :use_client_cert is true'
end
end

case options[:auth_type]
Expand All @@ -141,8 +147,10 @@ def initialize(options = {})
when :basic
@request_client = HttpClient.new(@options)
when :cookie
raise ArgumentError,
'Options: :use_cookies must be true for :cookie authorization type' if @options.key?(:use_cookies) && !@options[:use_cookies]
if @options.key?(:use_cookies) && !@options[:use_cookies]
raise ArgumentError,
'Options: :use_cookies must be true for :cookie authorization type'
end

@options[:use_cookies] = true
@request_client = HttpClient.new(@options)
Expand Down
6 changes: 4 additions & 2 deletions lib/jira/resource/issue.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,11 @@ def self.jql(client, jql, options = { fields: nil, start_at: nil, max_results: n
validate_query: true })
url = client.options[:rest_base_path] + "/search?jql=#{CGI.escape(jql)}"

url << "&fields=#{options[:fields].map do |value|
if options[:fields]
url << "&fields=#{options[:fields].map do |value|
CGI.escape(client.Field.name_to_id(value))
end.join(',')}" if options[:fields]
end.join(',')}"
end
url << "&startAt=#{CGI.escape(options[:start_at].to_s)}" if options[:start_at]
url << "&maxResults=#{CGI.escape(options[:max_results].to_s)}" if options[:max_results]
url << '&validateQuery=false' if options[:validate_query] === false
Expand Down

0 comments on commit 5c9ccfc

Please sign in to comment.