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

Use StructuredWarning to disable builtin and deprecations used with it

Oliver Güntherf63d0c981de4
diff --git a/Gemfile b/Gemfile
index 55fccf670d5..841ead2cbed 100644
--- a/Gemfile
+++ b/Gemfile
@@ -135,6 +135,9 @@ gem 'gon', '~> 6.3.2'
# Lograge to provide sane and non-verbose logging
gem 'lograge', '~> 0.11.0'
+# Structured warnings to selectively disable them in production
+gem 'structured_warnings', '~> 0.4.0'
+
# catch exceptions and send them to any airbrake compatible backend
# don't require by default, instead load on-demand when actually configured
gem 'airbrake', '~> 11.0.0', require: false
diff --git a/Gemfile.lock b/Gemfile.lock
index b70d384d6f7..333cad176da 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -1125,6 +1125,7 @@ DEPENDENCIES
sprockets (~> 3.7.0)
stackprof
stringex (~> 2.8.5)
+ structured_warnings (~> 0.4.0)
svg-graph (~> 2.2.0)
sys-filesystem (~> 1.3.3)
table_print (~> 1.5.6)
diff --git a/config/boot.rb b/config/boot.rb
index 613030149a5..357542e488c 100644
--- a/config/boot.rb
+++ b/config/boot.rb
@@ -37,12 +37,18 @@ end
require 'bundler/setup' # Set up gems listed in the Gemfile.
-case ENV['RAILS_ENV']
-when 'production'
- # Disable deprecation warnings early on (before loading gems), which behaves as RUBYOPT="-w0"
- # to disable the Ruby 2.7 warnings in production
- Warning[:deprecated] = ENV['OPENPROJECT_PROD_DEPRECATIONS'] == 'true'
-when 'development'
+env = ENV['RAILS_ENV']
+# Disable deprecation warnings early on (before loading gems), which behaves as RUBYOPT="-w0"
+# to disable the Ruby 2.7 warnings in production.
+# Set OPENPROJECT_PROD_DEPRECATIONS=true if you want to see them for debugging purposes
+if env == 'production' && ENV['OPENPROJECT_PROD_DEPRECATIONS'] != 'true'
+ require 'structured_warnings'
+ Warning[:deprecated] = false
+ StructuredWarnings::BuiltInWarning.disable
+ StructuredWarnings::DeprecationWarning.disable
+end
+
+if env == 'development'
$stderr.puts "Starting with bootsnap."
require 'bootsnap/setup' # Speed up boot time by caching expensive operations.
end