Skip to content

Commit

Permalink
Fix Rails/CompactBlank cop
Browse files Browse the repository at this point in the history
  • Loading branch information
danidoni committed Dec 28, 2021
1 parent 0d50387 commit e0e8487
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 7 deletions.
Expand Up @@ -106,6 +106,6 @@ def set_required_check

def names
result = (Xmlhash.parse(request.body.read) || {}).with_indifferent_access
[result[:name]].flatten.reject(&:blank?)
[result[:name]].flatten.compact_blank
end
end
Expand Up @@ -33,7 +33,7 @@ def strip_params
def bs_request_params
# We remove any key from the empty nested attribute if its value is empty
# This is for target_package which might be empty since it's not required
params[:bs_request][:bs_request_actions_attributes]['0'].reject! { |_key, value| value.empty? }
params[:bs_request][:bs_request_actions_attributes]['0'].compact_blank

params.require(:bs_request).permit(:description,
bs_request_actions_attributes: [:target_package, :target_project,
Expand Down
6 changes: 3 additions & 3 deletions src/api/app/jobs/consistency_check_job.rb
Expand Up @@ -8,7 +8,7 @@ def perform
def check_one_project(project, fix = false)
package_existence_consistency_check(project, fix)
@errors << project_meta_check(project, fix)
@errors.flatten.reject(&:empty?).join("\n")
@errors.flatten.compact_blank.join("\n")
end

# method called by the rake task `fix_project`
Expand All @@ -28,7 +28,7 @@ def check_project(project_name, fix = false)
answer = import_project_from_backend(project_name)
if answer.present?
@errors << answer
return @errors.flatten.reject(&:empty?).join("\n")
return @errors.flatten.compact_blank.join("\n")
end
ensure
project = Project.get_by_name(project_name)
Expand All @@ -48,7 +48,7 @@ def check_project(project_name, fix = false)
private

def errors
@errors.flatten.reject(&:empty?)
@errors.flatten.compact_blank
end

def initialize
Expand Down
2 changes: 1 addition & 1 deletion src/api/app/lib/backend/instrumentation.rb
Expand Up @@ -35,7 +35,7 @@ def backend_location
result = [
Thread.current[:_influxdb_obs_backend_api_module],
Thread.current[:_influxdb_obs_backend_api_method]
].reject(&:blank?)
].compact_blank
result.empty? ? :raw : result.join('#')
end
end
Expand Down
2 changes: 1 addition & 1 deletion src/api/app/mailers/event_mailer.rb
Expand Up @@ -21,7 +21,7 @@ def event(subscribers, e)
subscribers = subscribers.to_a
return if subscribers.empty?

recipients = subscribers.map(&:display_name).reject(&:blank?)
recipients = subscribers.map(&:display_name).compact_blank
return if recipients.empty?

set_headers
Expand Down

0 comments on commit e0e8487

Please sign in to comment.