Skip to content

Commit e723d90

Browse files
committed
style(rubocop): fix issue with EmptyLineAfterGuardClause rule
1 parent bad726c commit e723d90

13 files changed

+300
-1
lines changed

lib/ibm_watson/assistant_v1.rb

Lines changed: 92 additions & 0 deletions
Large diffs are not rendered by default.

lib/ibm_watson/discovery_v1.rb

Lines changed: 99 additions & 0 deletions
Large diffs are not rendered by default.

lib/ibm_watson/iam_token_manager.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ def request(method:, url:, headers: nil, params: nil, data: nil)
4545
)
4646
end
4747
return JSON.parse(response.body.to_s) if (200..299).cover?(response.code)
48+
4849
require_relative("./watson_api_exception.rb")
4950
raise WatsonApiException.new(response: response)
5051
end
@@ -56,6 +57,7 @@ def request(method:, url:, headers: nil, params: nil, data: nil)
5657
# If this class is managing tokens and has a valid token stored, send it
5758
def token
5859
return @user_access_token unless @user_access_token.nil? || (@user_access_token.respond_to?(:empty?) && @user_access_token.empty?)
60+
5961
if @token_info.all? { |_k, v| v.nil? }
6062
token_info = _request_token
6163
_save_token_info(
@@ -122,6 +124,7 @@ def _refresh_token
122124
# The buffer will be a fraction of the total TTL. Using 80%.
123125
def _is_token_expired?
124126
return true if @token_info["expiration"].nil? || @token_info["expires_in"].nil?
127+
125128
fraction_of_ttl = 0.8
126129
time_to_live = @token_info["expires_in"].nil? ? 0 : @token_info["expires_in"]
127130
expire_time = @token_info["expiration"].nil? ? 0 : @token_info["expiration"]
@@ -135,6 +138,7 @@ def _is_token_expired?
135138
# if it has been at least 7 days and 1 hour since the last token was set
136139
def _is_refresh_token_expired?
137140
return true if @token_info["expiration"].nil?
141+
138142
seven_days = 7 * 24 * 3600
139143
current_time = Time.now.to_i
140144
new_token_time = @token_info["expiration"] + seven_days

lib/ibm_watson/language_translator_v3.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ def initialize(args = {})
108108
# @return [DetailedResponse] A `DetailedResponse` object representing the response.
109109
def translate(text:, model_id: nil, source: nil, target: nil)
110110
raise ArgumentError("text must be provided") if text.nil?
111+
111112
headers = {
112113
}
113114
params = {
@@ -165,6 +166,7 @@ def list_identifiable_languages
165166
# @return [DetailedResponse] A `DetailedResponse` object representing the response.
166167
def identify(text:)
167168
raise ArgumentError("text must be provided") if text.nil?
169+
168170
headers = {
169171
}
170172
params = {
@@ -256,6 +258,7 @@ def list_models(source: nil, target: nil, default_models: nil)
256258
# @return [DetailedResponse] A `DetailedResponse` object representing the response.
257259
def create_model(base_model_id:, name: nil, forced_glossary: nil, parallel_corpus: nil, forced_glossary_filename: nil, parallel_corpus_filename: nil)
258260
raise ArgumentError("base_model_id must be provided") if base_model_id.nil?
261+
259262
headers = {
260263
}
261264
params = {
@@ -308,6 +311,7 @@ def create_model(base_model_id:, name: nil, forced_glossary: nil, parallel_corpu
308311
# @return [DetailedResponse] A `DetailedResponse` object representing the response.
309312
def delete_model(model_id:)
310313
raise ArgumentError("model_id must be provided") if model_id.nil?
314+
311315
headers = {
312316
}
313317
params = {
@@ -334,6 +338,7 @@ def delete_model(model_id:)
334338
# @return [DetailedResponse] A `DetailedResponse` object representing the response.
335339
def get_model(model_id:)
336340
raise ArgumentError("model_id must be provided") if model_id.nil?
341+
337342
headers = {
338343
}
339344
params = {

lib/ibm_watson/natural_language_classifier_v1.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,9 @@ def initialize(args = {})
8787
# @return [DetailedResponse] A `DetailedResponse` object representing the response.
8888
def classify(classifier_id:, text:)
8989
raise ArgumentError("classifier_id must be provided") if classifier_id.nil?
90+
9091
raise ArgumentError("text must be provided") if text.nil?
92+
9193
headers = {
9294
}
9395
data = {
@@ -116,7 +118,9 @@ def classify(classifier_id:, text:)
116118
# @return [DetailedResponse] A `DetailedResponse` object representing the response.
117119
def classify_collection(classifier_id:, collection:)
118120
raise ArgumentError("classifier_id must be provided") if classifier_id.nil?
121+
119122
raise ArgumentError("collection must be provided") if collection.nil?
123+
120124
headers = {
121125
}
122126
data = {
@@ -156,7 +160,9 @@ def classify_collection(classifier_id:, collection:)
156160
# @return [DetailedResponse] A `DetailedResponse` object representing the response.
157161
def create_classifier(metadata:, training_data:, metadata_filename: nil, training_data_filename: nil)
158162
raise ArgumentError("metadata must be provided") if metadata.nil?
163+
159164
raise ArgumentError("training_data must be provided") if training_data.nil?
165+
160166
headers = {
161167
}
162168
mime_type = "application/json"
@@ -217,6 +223,7 @@ def list_classifiers
217223
# @return [DetailedResponse] A `DetailedResponse` object representing the response.
218224
def get_classifier(classifier_id:)
219225
raise ArgumentError("classifier_id must be provided") if classifier_id.nil?
226+
220227
headers = {
221228
}
222229
method_url = "/v1/classifiers/%s" % [ERB::Util.url_encode(classifier_id)]
@@ -236,6 +243,7 @@ def get_classifier(classifier_id:)
236243
# @return [nil]
237244
def delete_classifier(classifier_id:)
238245
raise ArgumentError("classifier_id must be provided") if classifier_id.nil?
246+
239247
headers = {
240248
}
241249
method_url = "/v1/classifiers/%s" % [ERB::Util.url_encode(classifier_id)]

lib/ibm_watson/natural_language_understanding_v1.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ def initialize(args = {})
166166
# @return [DetailedResponse] A `DetailedResponse` object representing the response.
167167
def analyze(features:, text: nil, html: nil, url: nil, clean: nil, xpath: nil, fallback_to_raw: nil, return_analyzed_text: nil, language: nil, limit_text_characters: nil)
168168
raise ArgumentError("features must be provided") if features.nil?
169+
169170
headers = {
170171
}
171172
params = {
@@ -230,6 +231,7 @@ def list_models
230231
# @return [DetailedResponse] A `DetailedResponse` object representing the response.
231232
def delete_model(model_id:)
232233
raise ArgumentError("model_id must be provided") if model_id.nil?
234+
233235
headers = {
234236
}
235237
params = {

lib/ibm_watson/personality_insights_v3.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,9 @@ def initialize(args = {})
169169
# @return [DetailedResponse] A `DetailedResponse` object representing the response.
170170
def profile(content:, content_type:, accept: nil, content_language: nil, accept_language: nil, raw_scores: nil, csv_headers: nil, consumption_preferences: nil)
171171
raise ArgumentError("content must be provided") if content.nil?
172+
172173
raise ArgumentError("content_type must be provided") if content_type.nil?
174+
173175
headers = {
174176
"Content-Type" => content_type,
175177
"Accept" => accept,

0 commit comments

Comments
 (0)