-
Notifications
You must be signed in to change notification settings - Fork 356
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ApplicationController: fix rubocop warnings #4658
ApplicationController: fix rubocop warnings #4658
Conversation
cc4c7b3
to
efa3fc3
Compare
@@ -650,14 +651,14 @@ def build_ae_tree(type = :ae, name = :ae_tree) | |||
|
|||
# moved this method here so it can be accessed from pxe_server controller as well | |||
def log_depot_set_verify_status | |||
if (@edit[:new][:log_password] == @edit[:new][:log_verify]) && @edit[:new][:uri_prefix] != "nfs" && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mzazrivec I would use extra variables to improve readability here:
- @edit[:log_verify_status] = if (@edit[:new][:log_password] == @edit[:new][:log_verify]) && @edit[:new][:uri_prefix] != "nfs" &&
- (@edit[:new][:uri].present? && @edit[:new][:log_userid].present? && @edit[:new][:log_password].present? && @edit[:new][:log_verify].present?)
- true
- elsif @edit[:new][:uri_prefix] == "nfs" && @edit[:new][:uri].present?
- true
- else
- false
- end
+ uri_filled = @edit[:new][:uri].present?
+ nfs_prefix = (@edit[:new][:uri_prefix] == "nfs")
+ passwords_match = (@edit[:new][:log_password] == @edit[:new][:log_verify])
+ authentication_credentials_filled = (
+ uri_filled &&
+ @edit[:new][:log_userid].present? &&
+ @edit[:new][:log_password].present? &&
+ @edit[:new][:log_verify].present?
+ )
+
+ @edit[:log_verify_status] = (
+ (nfs_prefix && uri_filled) ||
+ (!nfs_prefix && authentication_credentials_filled && passwords_match)
+ )
...what do you think?
Maybe in a separate PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I simplified the condition inside that routine and also moved the routine to PxeController
, since it's used only in that controller.
- rename the method to log_depot_verify_status() - don't set @edit[:log_verify_status] inside the routine - simplify the condition inside the routine
Checked commits mzazrivec/manageiq-ui-classic@efa3fc3~...63b6e72 with ruby 2.3.3, rubocop 0.52.1, haml-lint 0.20.0, and yamllint 1.10.0 app/controllers/application_controller.rb
|
end | ||
next if current.present? && (new[k][hk] == current[k][hk]) | ||
msg_arr << if password_field?(hk) # Asterisk out password fields | ||
"#{hk}:[*]#{' to [*]' unless current.nil?}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unless used inside a string interpolation 🤢
Probably a separate PR, right?
$ ag '"[^"]*#{[^}]*\b(unless|if)'
app/controllers/application_controller.rb
700: msg_arr << "#{k}:[*]#{' to [*]' unless current.nil?}"
708: msg_arr << "#{hk}:[*]#{' to [*]' unless current.nil?}"
app/controllers/report_controller/reports/editor.rb
811: (suffix ? " (#{MiqReport.date_time_break_suffixes.collect { |s| s.first i s.last == suffix }.compact.join})" : "") +
app/helpers/vm_helper/textual_summary.rb
259: :value => "#{s.name}#{" (main)" if s == main}",
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I'd rather address that in a separate PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here: #4671
No description provided.