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
Fix Style/SoleNestedConditional cop #10068
base: develop
Are you sure you want to change the base?
Fix Style/SoleNestedConditional cop #10068
Conversation
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.
The failing tests appear to be related to your changes. Additionally, after applying these changes, there is a need to fix the indentations.
@@ -13,9 +13,9 @@ def resource_scope(options = {}) | |||
protected | |||
|
|||
def clear_session_locale_on_update | |||
if params[:user] && editing_self? | |||
if params[:user] && editing_self? && params[:user][:locale].try(:empty?) |
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.
if params[:user] && editing_self? && params[:user][:locale].try(:empty?) | |
user_params = params[:user] | |
if user_params && editing_self? && user_params[:locale].blank? |
@@ -619,11 +619,9 @@ def create_interfaces(vm, attrs, cluster_id) | |||
raise Foreman::Exception.new("Interface network or vnic profile are missing.") if (interface[:network].nil? && interface[:vnic_profile].nil?) | |||
interface[:network] = get_ovirt_id(cluster_networks, 'network', interface[:network]) if interface[:network].present? | |||
interface[:vnic_profile] = get_ovirt_id(profiles, 'vnic profile', interface[:vnic_profile]) if interface[:vnic_profile].present? | |||
if (interface[:network].present? && interface[:vnic_profile].present?) | |||
unless (profiles.select { |profile| profile.network.id == interface[:network] }).present? | |||
if (interface[:network].present? && interface[:vnic_profile].present?) && !(profiles.select { |profile| profile.network.id == interface[:network] }).present? |
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.
if (interface[:network].present? && interface[:vnic_profile].present?) && !(profiles.select { |profile| profile.network.id == interface[:network] }).present? | |
if interface[:network].present? && interface[:vnic_profile].present? && profiles.none? { |profile| profile.network.id == interface[:network] } | |
@@ -9,12 +9,10 @@ class << base | |||
module ClassMethods | |||
# ensures that the correct STI object is created when :type is passed. | |||
def new(attributes = nil, &block) | |||
if attributes.is_a?(Hash) && (type = attributes.with_indifferent_access.delete(:type)) && !type.empty? | |||
if (klass = type.constantize) != self | |||
if attributes.is_a?(Hash) && (type = attributes.with_indifferent_access.delete(:type)) && !type.empty? && ((klass = type.constantize) != self) |
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.
if attributes.is_a?(Hash) && (type = attributes.with_indifferent_access.delete(:type)) && !type.empty? && ((klass = type.constantize) != self) | |
if attributes.is_a?(Hash) && (type = attributes.with_indifferent_access.delete(:type)).present? && (klass = type.constantize) != self |
unless q.nil? | ||
if processed > 0 | ||
# rubocop:enable Rails/FindEach | ||
if !q.nil? && (processed > 0) |
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.
if !q.nil? && (processed > 0) | |
if q && processed.positive? |
if @condition.present? && !@condition.call | ||
return | ||
end |
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.
if @condition.present? && !@condition.call | |
return | |
end | |
return if @condition.present? && !@condition.call |
if notification_already_exists?(item) && !@force_repost | ||
next | ||
end |
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.
if notification_already_exists?(item) && !@force_repost | |
next | |
end | |
next if notification_already_exists?(item) && !@force_repost |
if legacy_dhcp_api? && (other.attrs[:hostname].present? && attrs[:hostname].present?) | ||
to_compare << :hostname | ||
end |
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.
if legacy_dhcp_api? && (other.attrs[:hostname].present? && attrs[:hostname].present?) | |
to_compare << :hostname | |
end | |
to_compare << :hostname if legacy_dhcp_api? && other.attrs[:hostname].present? && attrs[:hostname].present? |
Reviewed and optimized nested conditionals flagged by the Style/SoloNestedConditional cop.