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

Linting

Oliver Günther6e5b92c45728
diff --git a/config/initializers/grape.rb b/config/initializers/grape.rb
index d3b68e29b2f..bad5b6e72db 100644
--- a/config/initializers/grape.rb
+++ b/config/initializers/grape.rb
@@ -26,9 +26,11 @@
# See COPYRIGHT and LICENSE files for more details.
#++
Rails.application.reloader.to_prepare do
+ # rubocop:disable Lint/ConstantDefinitionInBlock
module Grape
class Endpoint
include ::API::V3::Utilities::PathHelper
end
end
+ # rubocop:enable Lint/ConstantDefinitionInBlock
end
diff --git a/config/initializers/rack_timeout.rb b/config/initializers/rack_timeout.rb
index 947c035b2fd..9d93c6a8b7f 100644
--- a/config/initializers/rack_timeout.rb
+++ b/config/initializers/rack_timeout.rb
@@ -30,6 +30,7 @@ if OpenProject::Configuration.web_workers >= 2
# report the generic internal server error too as it doesn't
# add any more information. Even worse, it's not immediately
# clear that the two reports are related.
+ # rubocop:disable Lint/ConstantDefinitionInBlock
module SuppressInternalErrorReportOnTimeout
def op_handle_error(message_or_exception, context = {})
return if request && request.env[Rack::Timeout::ENV_INFO_KEY].try(:state) == :timed_out
@@ -40,6 +41,7 @@ if OpenProject::Configuration.web_workers >= 2
OpenProjectErrorHelper.prepend SuppressInternalErrorReportOnTimeout
end
+ # rubocop:enable Lint/ConstantDefinitionInBlock
else
Rails.logger.debug { "Not enabling Rack::Timeout since we are not running in cluster mode with at least 2 workers" }
end
diff --git a/config/initializers/secure_headers.rb b/config/initializers/secure_headers.rb
index c3caf8765d8..99b259db0a5 100644
--- a/config/initializers/secure_headers.rb
+++ b/config/initializers/secure_headers.rb
@@ -1,3 +1,4 @@
+# rubocop:disable Lint/PercentStringArray
Rails.application.reloader.to_prepare do
SecureHeaders::Configuration.default do |config|
config.cookies = {
@@ -42,7 +43,7 @@ Rails.application.reloader.to_prepare do
script_src = assets_src
# Allow unsafe-eval for rack-mini-profiler
- if Rails.env.development? && ENV['OPENPROJECT_RACK_PROFILER_ENABLED']
+ if Rails.env.development? && ENV.fetch('OPENPROJECT_RACK_PROFILER_ENABLED', false)
script_src += %w('unsafe-eval')
end
@@ -75,3 +76,4 @@ Rails.application.reloader.to_prepare do
}
end
end
+# rubocop:enable Lint/PercentStringArray
diff --git a/config/initializers/warden.rb b/config/initializers/warden.rb
index efc05c9bf64..53762fad9c2 100644
--- a/config/initializers/warden.rb
+++ b/config/initializers/warden.rb
@@ -1,13 +1,13 @@
Rails.application.config.after_initialize do
- WS = OpenProject::Authentication::Strategies::Warden
+ namespace = OpenProject::Authentication::Strategies::Warden
strategies = [
- [:basic_auth_failure, WS::BasicAuthFailure, 'Basic'],
- [:global_basic_auth, WS::GlobalBasicAuth, 'Basic'],
- [:user_basic_auth, WS::UserBasicAuth, 'Basic'],
- [:oauth, WS::DoorkeeperOAuth, 'OAuth'],
- [:anonymous_fallback, WS::AnonymousFallback, 'Basic'],
- [:session, WS::Session, 'Session']
+ [:basic_auth_failure, namespace::BasicAuthFailure, 'Basic'],
+ [:global_basic_auth, namespace::GlobalBasicAuth, 'Basic'],
+ [:user_basic_auth, namespace::UserBasicAuth, 'Basic'],
+ [:oauth, namespace::DoorkeeperOAuth, 'OAuth'],
+ [:anonymous_fallback, namespace::AnonymousFallback, 'Basic'],
+ [:session, namespace::Session, 'Session']
]
strategies.each do |name, clazz, auth_scheme|
diff --git a/modules/bim/lib/open_project/bim/engine.rb b/modules/bim/lib/open_project/bim/engine.rb
index 878a9f2780d..ff9cfb1c2e9 100644
--- a/modules/bim/lib/open_project/bim/engine.rb
+++ b/modules/bim/lib/open_project/bim/engine.rb
@@ -199,11 +199,12 @@ module OpenProject::Bim
Mime::Type.register "application/octet-stream", :bcfzip unless Mime::Type.lookup_by_extension(:bcfzip)
end
+ # rubocop:disable Naming/VariableNumber
config.to_prepare do
Doorkeeper.configuration.scopes.add(:bcf_v2_1)
module OpenProject::Authentication::Scope
- BCF_V2_1 = :bcf_v2_1
+ BCF_V2_1 = :bcf_v2_1 # rubocop:disable Lint/ConstantDefinitionInBlock
end
OpenProject::Authentication.update_strategies(OpenProject::Authentication::Scope::BCF_V2_1,
@@ -211,6 +212,7 @@ module OpenProject::Bim
%i[oauth session]
end
end
+ # rubocop:enable Naming/VariableNumber
config.to_prepare do
::Exports::Register.register do