Signed-off-by: Wu Zhende wuzhende666@163.com --- src/lib/job.cr | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/src/lib/job.cr b/src/lib/job.cr index 03ca5af..db9616b 100644 --- a/src/lib/job.cr +++ b/src/lib/job.cr @@ -392,15 +392,15 @@ class Job private def check_account_info error_msg = "Failed to verify the account.\n" error_msg += "Please refer to https://gitee.com/wu_fengguang/compass-ci/blob/master/doc/manual/apply-accou..." + account_info = @es.get_account(self["my_email"]) - # raise account_info unless account_info.is_a?(JSON::Any) + raise error_msg unless account_info.is_a?(JSON::Any)
- # @account_info = account_info.as_h - @account_info = account_info.as_h if account_info.is_a?(JSON::Any) + @account_info = account_info.as_h
- # raise error_msg if @account_info["found"]? == false - # raise error_msg unless self["my_name"] == @account_info["my_name"].to_s - # raise error_msg unless self["my_token"] == @account_info["my_token"] + raise error_msg if @account_info["found"]? == false + raise error_msg if self["my_name"] != @account_info["my_name"].to_s + raise error_msg if self["my_token"] != @account_info["my_token"]
@hash.delete("my_uuid") @hash.delete("my_token")
private def check_account_info error_msg = "Failed to verify the account.\n" error_msg += "Please refer to https://gitee.com/wu_fengguang/compass-ci/blob/master/doc/manual/apply-accou..."
- account_info = @es.get_account(self["my_email"])
- # raise account_info unless account_info.is_a?(JSON::Any)
- raise error_msg unless account_info.is_a?(JSON::Any)
- # @account_info = account_info.as_h
- @account_info = account_info.as_h if account_info.is_a?(JSON::Any)
- @account_info = account_info.as_h
- # raise error_msg if @account_info["found"]? == false
- # raise error_msg unless self["my_name"] == @account_info["my_name"].to_s
- # raise error_msg unless self["my_token"] == @account_info["my_token"]
- raise error_msg if @account_info["found"]? == false
don't need to use '==' to do the test if its value is false/true directly test the expression itself
- raise error_msg if self["my_name"] != @account_info["my_name"].to_s
- raise error_msg if self["my_token"] != @account_info["my_token"]
use unless if better than if for the three lines above =>
raise error_msg unless @account_info["found"]? == false raise error_msg unless self["my_name"] == @account_info["my_name"].to_s raise error_msg unless self["my_token"] == @account_info["my_token"]
Thanks, Luan Shengde