Skip to content
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 rubocop offenses #614

Merged
merged 5 commits into from
May 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/controllers/api/v2/discovered_hosts_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ def auto_provision_all

total_count = 0
overall_errors = ""
Host::Discovered.all.each do |discovered_host|
Host::Discovered.all.find_each do |discovered_host|
if rule = find_discovery_rule(discovered_host)
result &= perform_auto_provision(discovered_host, rule)
unless discovered_host.errors.empty?
Expand Down
2 changes: 1 addition & 1 deletion app/helpers/discovered_hosts_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def multiple_discovered_hosts_actions_select
end

def turn_zero_to_not_available(value)
value == 0 ? 'N/A' : value
(value == 0) ? 'N/A' : value
end

def discovery_attribute(host, attr, default_value = _('N/A'))
Expand Down
2 changes: 1 addition & 1 deletion app/models/host/discovered.rb
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ def lookup_value_match
end

def self.normalize_string_for_hostname(hostname)
hostname = hostname.to_s.downcase.gsub(/(^[^a-z0-9]*|[^a-z0-9\-]|[^a-z0-9]*$)/,'')
hostname = hostname.to_s.downcase.gsub(/(^[^a-z0-9]*|[^a-z0-9-]|[^a-z0-9]*$)/,'')
raise(::Foreman::Exception.new(N_("Invalid hostname: Could not normalize the hostname"))) unless hostname && hostname.present?
hostname
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class FakeDiscoveredHost < ApplicationRecord

class FillDiscoveryAttributeSetsForExistingHosts < ActiveRecord::Migration[4.2]
def up
FakeDiscoveredHost.where(:type => "Host::Discovered").all.each do |host|
FakeDiscoveredHost.where(:type => "Host::Discovered").all.find_each do |host|
begin
say "Populating attribute set for discovered host #{host.name}"
ForemanDiscovery::ImportHooks::DiscoveryAttribute.new(host: host, facts: host.facts_hash).after_populate
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
class RemoveOldDiscoveryReaderPermissions < ActiveRecord::Migration[4.2]
def up
Permission.where("name like '%_discovery_rules' and resource_type is null").each do |permission|
Permission.where("name like '%_discovery_rules' and resource_type is null").find_each do |permission|
permission.update(:resource_type => 'DiscoveryRule')
end
end
Expand Down
6 changes: 1 addition & 5 deletions lib/foreman_discovery.rake
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,7 @@ namespace :test do
Rake::TestTask.new(:foreman_discovery) do |t|
test_dir = File.join(File.dirname(__FILE__), '..', 'test')
t.libs << ["test",test_dir]
if ENV['FILE'] || ENV['TEST']
t.pattern = ENV['FILE'] || ENV['TEST']
else
t.pattern = "#{test_dir}/**/*_test.rb"
end
t.pattern = ENV['FILE'] || ENV['TEST'] || "#{test_dir}/**/*_test.rb"
t.verbose = true
t.warning = false
end
Expand Down
2 changes: 1 addition & 1 deletion test/functional/discovered_hosts_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def test_show_multiple_actions
[:multiple_destroy, :select_multiple_organization, :select_multiple_location].each do |action|
process action, method: :post, params: {:host_ids => [host.id]}, session: set_session_user, xhr: true
assert_response :success
assert response.body =~ /#{host.name}/
assert_includes(response.body, host.name)
end
end

Expand Down