Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

rubocop autofix for cops added in 1.31.0

ulferts3f8ca138302f
diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb
index 298ff056b88..ab85305fc13 100644
--- a/app/controllers/repositories_controller.rb
+++ b/app/controllers/repositories_controller.rb
@@ -348,7 +348,7 @@ class RepositoriesController < ApplicationController
end
changes_by_day = Change.includes(:changeset)
- .where(["#{Changeset.table_name}.repository_id = ? "\
+ .where(["#{Changeset.table_name}.repository_id = ? " \
"AND #{Changeset.table_name}.commit_date BETWEEN ? AND ?",
repository.id, @date_from, @date_to])
.references(:changesets)
diff --git a/app/mailers/application_mailer.rb b/app/mailers/application_mailer.rb
index 44398d2fefc..56cd2374277 100644
--- a/app/mailers/application_mailer.rb
+++ b/app/mailers/application_mailer.rb
@@ -140,12 +140,12 @@ class ApplicationMailer < ActionMailer::Base
else
"#{object.class.name.demodulize.underscore}-#{object.id}"
end
- hash = 'op'\
- '.'\
- "#{object_reference}"\
- '.'\
- "#{Time.current.strftime('%Y%m%d%H%M%S')}"\
- '.'\
+ hash = 'op' \
+ '.' \
+ "#{object_reference}" \
+ '.' \
+ "#{Time.current.strftime('%Y%m%d%H%M%S')}" \
+ '.' \
"#{recipient.id}"
"#{hash}@#{header_host_value}"
@@ -160,8 +160,8 @@ class ApplicationMailer < ActionMailer::Base
# It in fact is aimed not not so that similar messages (i.e. those belonging to the same
# work package and journal) end up being grouped together.
def references_value(object)
- hash = 'op'\
- '.'\
+ hash = 'op' \
+ '.' \
"#{object.class.name.demodulize.underscore}-#{object.id}"
"#{hash}@#{header_host_value}"
diff --git a/app/workers/attachments/finish_direct_upload_job.rb b/app/workers/attachments/finish_direct_upload_job.rb
index fd30d6d7fc2..28f56a74211 100644
--- a/app/workers/attachments/finish_direct_upload_job.rb
+++ b/app/workers/attachments/finish_direct_upload_job.rb
@@ -57,7 +57,7 @@ class Attachments::FinishDirectUploadJob < ApplicationJob
::OpenProject.logger.error e
attachment.destroy
ensure
- File.unlink(local_file.path) if File.exist?(local_file.path)
+ FileUtils.rm_rf(local_file.path)
end
def set_attributes_from_file(attachment, local_file)
diff --git a/app/workers/backup_job.rb b/app/workers/backup_job.rb
index fca6e363928..c5040584a8c 100644
--- a/app/workers/backup_job.rb
+++ b/app/workers/backup_job.rb
@@ -121,7 +121,7 @@ class BackupJob < ::ApplicationJob
def remove_files!(*files)
Array(files).each do |file|
- FileUtils.rm file if File.exist? file
+ FileUtils.rm_rf file
end
end
diff --git a/app/workers/copy_project_job.rb b/app/workers/copy_project_job.rb
index fadb863442e..de5a543bdff 100644
--- a/app/workers/copy_project_job.rb
+++ b/app/workers/copy_project_job.rb
@@ -138,11 +138,11 @@ class CopyProjectJob < ApplicationJob
rescue ActiveRecord::RecordNotFound => e
logger.error("Entity missing: #{e.message} #{e.backtrace.join("\n")}")
rescue StandardError => e
- logger.error('Encountered an error when trying to copy project '\
+ logger.error('Encountered an error when trying to copy project ' \
"'#{source_project_id}' : #{e.message} #{e.backtrace.join("\n")}")
ensure
unless errors.empty?
- logger.error('Encountered an errors while trying to copy related objects for '\
+ logger.error('Encountered an errors while trying to copy related objects for ' \
"project '#{source_project_id}': #{errors.inspect}")
end
end
diff --git a/app/workers/projects/delete_project_job.rb b/app/workers/projects/delete_project_job.rb
index c2a72909ccb..37d59b06767 100644
--- a/app/workers/projects/delete_project_job.rb
+++ b/app/workers/projects/delete_project_job.rb
@@ -54,7 +54,7 @@ module Projects
end
def log_standard_error(e)
- logger.error('Encountered an error when trying to delete project '\
+ logger.error('Encountered an error when trying to delete project ' \
"'#{project}' : #{e.message} #{e.backtrace.join("\n")}")
end
diff --git a/lib/open_project/patches/fog_file.rb b/lib/open_project/patches/fog_file.rb
index 9f6cd7ef146..4465503ffca 100644
--- a/lib/open_project/patches/fog_file.rb
+++ b/lib/open_project/patches/fog_file.rb
@@ -9,7 +9,7 @@ module OpenProject::Patches::CarrierwaveSanitizedFile
def mkdir!(path, directory_permissions)
options = {}
options[:mode] = directory_permissions if directory_permissions
- FileUtils.mkdir_p(File.dirname(path), **options) unless File.exist?(File.dirname(path))
+ FileUtils.mkdir_p(File.dirname(path), **options)
end
end
end
diff --git a/modules/bim/app/contracts/bim/ifc_models/base_contract.rb b/modules/bim/app/contracts/bim/ifc_models/base_contract.rb
index e83c88668af..b2a8f702998 100644
--- a/modules/bim/app/contracts/bim/ifc_models/base_contract.rb
+++ b/modules/bim/app/contracts/bim/ifc_models/base_contract.rb
@@ -80,7 +80,7 @@ module Bim
# For local uploads the file must remain to be copied later to its final (local) destination from the cache.
return unless OpenProject::Configuration.direct_uploads?
- FileUtils.rm file_path if File.exist? file_path
+ FileUtils.rm_rf file_path
end
def uploader_is_ifc_attachment_author
diff --git a/spec/lib/open_project/scm/adapters/git_adapter_spec.rb b/spec/lib/open_project/scm/adapters/git_adapter_spec.rb
index ab502ba3d36..671b2b1148d 100644
--- a/spec/lib/open_project/scm/adapters/git_adapter_spec.rb
+++ b/spec/lib/open_project/scm/adapters/git_adapter_spec.rb
@@ -432,7 +432,7 @@ describe OpenProject::SCM::Adapters::Git do
annotate = adapter.annotate('sources/watchers_controller.rb')
expect(annotate).to be_kind_of(OpenProject::SCM::Adapters::Annotate)
expect(annotate.lines.length).to eq(41)
- expect(annotate.lines[4].strip).to eq('# This program is free software; '\
+ expect(annotate.lines[4].strip).to eq('# This program is free software; ' \
'you can redistribute it and/or')
expect(annotate.revisions[4].identifier).to eq('7234cb2750b63f47bff735edc50a1c0a433c2518')
expect(annotate.revisions[4].author).to eq('jsmith')
diff --git a/spec/lib/open_project/scm/adapters/subversion_adapter_spec.rb b/spec/lib/open_project/scm/adapters/subversion_adapter_spec.rb
index 1618341a2d2..97b2a62436e 100644
--- a/spec/lib/open_project/scm/adapters/subversion_adapter_spec.rb
+++ b/spec/lib/open_project/scm/adapters/subversion_adapter_spec.rb
@@ -358,7 +358,7 @@ describe OpenProject::SCM::Adapters::Subversion do
describe '.cat' do
it 'outputs the given file' do
out = adapter.cat('subversion_test/[folder_with_brackets]/README.txt', 11)
- expect(out).to eq('This file should be accessible for Redmine, '\
+ expect(out).to eq('This file should be accessible for Redmine, ' \
"although its folder contains square\nbrackets.\n")
end
diff --git a/spec/models/work_packages/scopes/relatable_spec.rb b/spec/models/work_packages/scopes/relatable_spec.rb
index 970c9f425f7..afbba556ab4 100644
--- a/spec/models/work_packages/scopes/relatable_spec.rb
+++ b/spec/models/work_packages/scopes/relatable_spec.rb
@@ -103,7 +103,7 @@ describe WorkPackages::Scopes::Relatable, '.relatable scope' do
end
end
- context "for the '#{current_type}' type with the other project being in a different project "\
+ context "for the '#{current_type}' type with the other project being in a different project " \
"and having cross project relations disabled", with_settings: { cross_project_work_package_relations: false } do
let(:relation_type) { current_type }
let(:unrelated_work_package) { create(:work_package, project: create(:project)) }
@@ -114,7 +114,7 @@ describe WorkPackages::Scopes::Relatable, '.relatable scope' do
end
end
- context "for the '#{current_type}' type with the other project being in a different project "\
+ context "for the '#{current_type}' type with the other project being in a different project " \
"and having cross project relations enabled", with_settings: { cross_project_work_package_relations: true } do
let(:relation_type) { current_type }
let(:unrelated_work_package) { create(:work_package, project: create(:project)) }
diff --git a/spec/requests/api/v3/render_resource_spec.rb b/spec/requests/api/v3/render_resource_spec.rb
index d80ce743da7..798238e639f 100644
--- a/spec/requests/api/v3/render_resource_spec.rb
+++ b/spec/requests/api/v3/render_resource_spec.rb
@@ -81,8 +81,8 @@ describe 'API v3 Render resource', type: :request do
let(:id) { work_package.id }
let(:href) { "/work_packages/#{id}" }
let(:text) do
- '<p class="op-uc-p">Hello World! Have a look at <a '\
- "class=\"issue work_package preview-trigger op-uc-link\" "\
+ '<p class="op-uc-p">Hello World! Have a look at <a ' \
+ "class=\"issue work_package preview-trigger op-uc-link\" " \
"href=\"#{href}\">##{id}</a></p>"
end
diff --git a/spec/workers/backup_job_spec.rb b/spec/workers/backup_job_spec.rb
index 2b10ffef078..ab8f1a1bd94 100644
--- a/spec/workers/backup_job_spec.rb
+++ b/spec/workers/backup_job_spec.rb
@@ -179,7 +179,7 @@ describe BackupJob, type: :model do
end
after do
- FileUtils.rm dummy_path if File.exist? dummy_path
+ FileUtils.rm_rf dummy_path
end
it_behaves_like "it creates a backup", remote_storage: true