diff --git a/.rubocop.yml b/.rubocop.yml
index 59f68245..3f9fdc3f 100644
--- a/.rubocop.yml
+++ b/.rubocop.yml
@@ -1,63 +1,232 @@
-inherit_mode:
- merge:
- - Exclude
require:
- rubocop-rails
+
AllCops:
Exclude:
- - bin/puma
- - bin/pumactl
- - bin/setup
- - bin/rainbows
- - bin/unicorn
- - bin/unicorn_rails
- - bin/update
- - bin/yarn
- - vendor/bundle/**/*
- TargetRubyVersion: 2.6
+ - 'bin/**/*'
+ - 'db/schema.rb'
+ - 'vendor/**/*'
+ - 'vendor/bundle/**/*'
+ DisabledByDefault: false
+ TargetRubyVersion: 2.7
+
+ NewCops: enable
+
+Rails/DynamicFindBy:
+ Enabled: true
+
+Rails/CreateTableWithTimestamps:
+ Enabled: false
+
+Style/BlockDelimiters:
+ Enabled: false
+
+# Checks if uses of quotes match the configured preference.
+Style/StringLiterals:
+ Enabled: false
+
+# Document classes and non-namespace modules.
+Style/Documentation:
+ Enabled: false
+
+# Check for conditionals that can be replaced with guard clauses
+Style/GuardClause:
+ Enabled: false
+
+# Checks the formatting of empty method definitions.
+Style/EmptyMethod:
+ Enabled: false
+
+# Checks for trailing comma in hash literals.
+Style/TrailingCommaInHashLiteral:
+ Enabled: false
+
+# Checks for trailing comma in argument lists.
+Style/TrailingCommaInArguments:
+ Enabled: false
+
+# Checks that `include`, `extend` and `prepend` exists at the top level.
+Style/MixinUsage:
+ Enabled: false
+
+# Use %i or %I for arrays of symbols.
+Style/SymbolArray:
+ Enabled: false
+
+# Don't use begin blocks when they are not needed.
+Style/RedundantBegin:
+ Enabled: false
+
+# Use `%`-literal delimiters consistently
+Style/PercentLiteralDelimiters:
+ Enabled: false
+
+# Only use if/unless modifiers on single line statements.
+Style/MultilineIfModifier:
+ Enabled: false
+
+# Checks for trailing comma in array literals.
+Style/TrailingCommaInArrayLiteral:
+ Enabled: false
+
+# Use `expand_path(__dir__)` instead of `expand_path('..', __FILE__)`.
+Style/ExpandPathArguments:
+ Enabled: false
+
+# Do not assign mutable objects to constants.
+Style/MutableConstant:
+ Enabled: false
+
+# Avoid rescuing without specifying an error class.
+Style/RescueStandardError:
+ Enabled: false
+
+# Align the elements of a hash literal if they span more than one line.
Layout/HashAlignment:
- EnforcedHashRocketStyle: [ key, table ]
- EnforcedColonStyle: [ key, table ]
+ Enabled: false
+
+# Align the parameters of a method definition if they span more than one line.
+Layout/ParameterAlignment:
+ Enabled: false
+
+# Align ends corresponding to defs correctly.
+Layout/EndAlignment:
+ Enabled: false
+
+# Align elses and elsifs correctly.
+Layout/ElseAlignment:
+ Enabled: false
+
+# Add empty line after guard clause.
+Layout/EmptyLineAfterGuardClause:
+ Enabled: false
+
+# Align the arguments of a method call if they span more than one line.
+Layout/ArgumentAlignment:
+ Enabled: false
+
+Layout/CaseIndentation:
+ Enabled: false
+
+Layout/EmptyLinesAroundAttributeAccessor:
+ Enabled: true
+
+Layout/IndentationWidth:
+ Enabled: false
+
+Layout/SpaceAroundMethodCallOperator:
+ Enabled: true
+
+
+# Avoid long blocks with many lines.
+Metrics/BlockLength:
+ Enabled: false
+
+# A complexity metric geared towards measuring complexity for a human reader.
+Metrics/PerceivedComplexity:
+ Max: 17
+ Exclude:
+ - app/models/recording.rb
+ - app/models/server.rb
+ - lib/server_sync.rb
+
+# Avoid classes longer than 100 lines of code.
+Metrics/ClassLength:
+ Enabled: false
+
+# Limit lines to 80 characters.
Layout/LineLength:
- Max: 128
-Layout/MultilineMethodCallIndentation:
- EnforcedStyle: indented
-Metrics:
+ Max: 130
+
+# Avoid methods longer than 10 lines of code.
+Metrics/MethodLength:
Enabled: false
+
+Metrics/ModuleLength:
+ Enabled: false
+
+# A calculated magnitude based on number of assignments,
+# branches, and conditions.
+Metrics/AbcSize:
+ Max: 60
+ Exclude:
+ - app/controllers/bigbluebutton_api_controller.rb
+ - app/models/recording.rb
+ - app/models/server.rb
+ - lib/recording_importer.rb
+ - lib/server_sync.rb
+
+# A complexity metric that is strongly correlated to the number
+# of test cases needed to validate a method.
+Metrics/CyclomaticComplexity:
+ Max: 20
+ Exclude:
+ - app/models/recording.rb
+ - app/models/server.rb
+ - lib/server_sync.rb
+
+# Checks for method parameter names that contain capital letters, end in numbers, or do not meet a minimal length.
+Naming/MethodParameterName:
+ Enabled: false
+
Naming/AccessorMethodName:
Exclude:
- app/controllers/bigbluebutton_api_controller.rb
+
Naming/PredicateName:
Exclude:
- app/controllers/bigbluebutton_api_controller.rb
-Rails:
+
+# Checks for ambiguous block association with method when param passed without parentheses.
+Lint/AmbiguousBlockAssociation:
+ Enabled: false
+
+Lint/ConstantDefinitionInBlock:
+ Enabled: false
+
+Lint/DeprecatedOpenSSLConstant:
Enabled: true
-Rails/DynamicFindBy:
- # The models used in this code aren't actually ActiveRecord
+
+Lint/DuplicateBranch:
Enabled: false
-Style/AsciiComments:
- AllowedChars: [ © ]
-Style/Documentation:
+
+Lint/EmptyBlock:
Enabled: false
-Style/DoubleNegation:
+
+Lint/LiteralInInterpolation:
Enabled: false
-Style/MethodCallWithArgsParentheses:
- Enabled: true
- IgnoredMethods:
- - desc
- - gem
- - include
- - require
- - require_relative
- - ruby
- - raise
- - source
- - throw
+
+Lint/RaiseException:
+ Enabled: true
+
+Lint/StructNewOverride:
+ Enabled: true
+
+Style/CombinableLoops:
Exclude:
- - "**/*.xml.builder"
-Style/SymbolArray:
- MinSize: 6
-Style/TrailingCommaInArrayLiteral:
- EnforcedStyleForMultiline: consistent_comma
-Style/TrailingCommaInHashLiteral:
- EnforcedStyleForMultiline: consistent_comma
+ - lib/server_sync.rb
+ - test/models/server_test.rb
+
+Style/DoubleNegation:
+ Enabled: false
+
+Style/ExponentialNotation:
+ Enabled: true
+
+Style/HashEachMethods:
+ Enabled: true
+
+Style/HashLikeCase:
+ Enabled: false
+
+Style/HashTransformKeys:
+ Enabled: true
+
+Style/HashTransformValues:
+ Enabled: true
+
+Style/OptionalBooleanParameter:
+ Enabled: false
+
+Style/SlicingWithRange:
+ Enabled: true
diff --git a/Gemfile b/Gemfile
index 48f989d4..1d2493de 100644
--- a/Gemfile
+++ b/Gemfile
@@ -45,11 +45,12 @@ group :development, :test do
gem 'dotenv-rails'
gem 'factory_bot_rails'
+
+ gem 'rubocop', '~> 1.10.0', require: false
+ gem 'rubocop-rails', '~> 2.4.0', require: false
end
group :development do
- gem 'rubocop', '~> 0.79.0', require: false
- gem 'rubocop-rails', '~> 2.4.0', require: false
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
gem 'spring-watcher-listen', '~> 2.0.0'
diff --git a/Gemfile.lock b/Gemfile.lock
index 8b80f965..5abaab6d 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -67,7 +67,7 @@ GEM
addressable (2.8.0)
public_suffix (>= 2.0.2, < 5.0)
ast (2.4.2)
- bootsnap (1.7.5)
+ bootsnap (1.9.1)
msgpack (~> 1.0)
builder (3.2.4)
byebug (11.1.3)
@@ -86,13 +86,12 @@ GEM
factory_bot_rails (6.2.0)
factory_bot (~> 6.2.0)
railties (>= 5.0.0)
- ffi (1.15.0)
+ ffi (1.15.4)
globalid (0.5.2)
activesupport (>= 5.0)
hashdiff (1.0.1)
i18n (1.8.10)
concurrent-ruby (~> 1.0)
- jaro_winkler (1.5.4)
jwt (2.2.3)
listen (3.1.5)
rb-fsevent (~> 0.9, >= 0.9.4)
@@ -103,9 +102,9 @@ GEM
nokogiri (>= 1.5.9)
mail (2.7.1)
mini_mime (>= 0.1.1)
- marcel (1.0.1)
+ marcel (1.0.2)
method_source (1.0.0)
- mini_mime (1.1.1)
+ mini_mime (1.1.2)
mini_portile2 (2.6.1)
minitest (5.14.4)
minitest-stub_any_instance (1.0.2)
@@ -114,14 +113,14 @@ GEM
nokogiri (1.12.5)
mini_portile2 (~> 2.6.1)
racc (~> 1.4)
- parallel (1.20.1)
- parser (3.0.1.1)
+ parallel (1.21.0)
+ parser (3.0.2.0)
ast (~> 2.4.1)
pg (1.2.3)
public_suffix (4.0.6)
- puma (5.5.1)
+ puma (5.5.2)
nio4r (~> 2.0)
- racc (1.5.2)
+ racc (1.6.0)
rack (2.2.3)
rack-test (1.1.0)
rack (>= 1.0, < 3)
@@ -156,17 +155,22 @@ GEM
rb-fsevent (0.11.0)
rb-inotify (0.10.1)
ffi (~> 1.0)
- redis (4.2.5)
+ redis (4.5.1)
redis-namespace (1.8.1)
redis (>= 3.0.4)
+ regexp_parser (2.1.1)
rexml (3.2.5)
- rubocop (0.79.0)
- jaro_winkler (~> 1.5.1)
+ rubocop (1.10.0)
parallel (~> 1.10)
- parser (>= 2.7.0.1)
+ parser (>= 3.0.0.0)
rainbow (>= 2.2.2, < 4.0)
+ regexp_parser (>= 1.8, < 3.0)
+ rexml
+ rubocop-ast (>= 1.2.0, < 2.0)
ruby-progressbar (~> 1.7)
- unicode-display_width (>= 1.4.0, < 1.7)
+ unicode-display_width (>= 1.4.0, < 3.0)
+ rubocop-ast (1.12.0)
+ parser (>= 3.0.1.1)
rubocop-rails (2.4.2)
rack (>= 1.1)
rubocop (>= 0.72.0)
@@ -193,14 +197,14 @@ GEM
tzinfo (1.2.9)
thread_safe (~> 0.1)
unicode-display_width (1.6.1)
- webmock (3.13.0)
- addressable (>= 2.3.6)
+ webmock (3.14.0)
+ addressable (>= 2.8.0)
crack (>= 0.3.2)
hashdiff (>= 0.4.0, < 2.0.0)
websocket-driver (0.7.5)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.5)
- zeitwerk (2.4.2)
+ zeitwerk (2.5.0)
PLATFORMS
ruby
@@ -220,7 +224,7 @@ DEPENDENCIES
rails (~> 6.0.4, >= 6.0.4.1)
redis (~> 4.2)
redis-namespace (~> 1.8)
- rubocop (~> 0.79.0)
+ rubocop (~> 1.10.0)
rubocop-rails (~> 2.4.0)
spring
spring-watcher-listen (~> 2.0.0)
diff --git a/app/controllers/bigbluebutton_api_controller.rb b/app/controllers/bigbluebutton_api_controller.rb
index 7f15a2c6..39e722f0 100644
--- a/app/controllers/bigbluebutton_api_controller.rb
+++ b/app/controllers/bigbluebutton_api_controller.rb
@@ -268,11 +268,10 @@ def join
end
def get_recordings
- if Rails.configuration.x.get_recordings_api_filtered
- if params[:recordID].blank? && params[:meetingID].blank?
- raise BBBError.new('missingParameters', 'param meetingID or recordID must be included.')
- end
+ if Rails.configuration.x.get_recordings_api_filtered && (params[:recordID].blank? && params[:meetingID].blank?)
+ raise BBBError.new('missingParameters', 'param meetingID or recordID must be included.')
end
+
query = Recording.includes(playback_formats: [:thumbnails], metadata: []).references(:metadata)
query = if params[:state].present?
states = params[:state].split(',')
@@ -284,7 +283,7 @@ def get_recordings
if meta_params.present?
meta_query = '(metadata.key = ? and metadata.value in (?))'
meta_values = [meta_params[0][0].remove('meta_'), meta_params[0][1].split(',')]
- meta_params[1..-1].each do |val|
+ meta_params[1..].each do |val|
meta_query += ' or (metadata.key = ? and metadata.value in (?))'
meta_values << val[0].remove('meta_')
meta_values << val[1].split(',')
@@ -361,7 +360,7 @@ def update_recordings
params.each do |key, value|
next unless key.start_with?('meta_')
- key = key[5..-1].downcase
+ key = key[5..].downcase
if value.blank?
remove_metadata << key
@@ -425,7 +424,7 @@ def analytics_callback
meeting_id = params['meeting_id']
logger.info("Making analytics callback for #{meeting_id}")
- callback_data = CallbackData.find_by_meeting_id(meeting_id)
+ callback_data = CallbackData.find_by(meeting_id: meeting_id)
analytics_callback_url = callback_data&.callback_attributes&.dig(:analytics_callback_url)
return if analytics_callback_url.nil?
@@ -449,7 +448,7 @@ def analytics_callback
# Has to be to_unsafe_hash since to_h only accepts permitted attributes
def pass_through_params(excluded_params)
params.except(*(excluded_params + [:format, :controller, :action, :checksum]))
- .to_unsafe_hash
+ .to_unsafe_hash
end
# Success response if there are no meetings on any servers
diff --git a/app/controllers/concerns/bbb_errors.rb b/app/controllers/concerns/bbb_errors.rb
index 3be15b78..6a7676cc 100644
--- a/app/controllers/concerns/bbb_errors.rb
+++ b/app/controllers/concerns/bbb_errors.rb
@@ -2,11 +2,10 @@
module BBBErrors
class BBBError < StandardError
- attr_accessor :return_code
- attr_accessor :message_key
- attr_accessor :message
+ attr_accessor :return_code, :message_key, :message
def initialize(message_key = '', message = '')
+ super()
@return_code = 'FAILED'
@message_key = message_key if message_key.present?
@message = message if message.present?
diff --git a/app/controllers/health_check_controller.rb b/app/controllers/health_check_controller.rb
index 70f5c3b0..e800fb18 100644
--- a/app/controllers/health_check_controller.rb
+++ b/app/controllers/health_check_controller.rb
@@ -24,9 +24,7 @@ def cache_check
end
def database_check
- if defined?(ActiveRecord)
- raise 'Database not responding' unless ActiveRecord::Migrator.current_version
- end
+ raise 'Database not responding' if defined?(ActiveRecord) && !ActiveRecord::Migrator.current_version
raise 'Pending migrations' unless ActiveRecord::Migration.check_pending!.nil?
end
end
diff --git a/app/controllers/playback_controller.rb b/app/controllers/playback_controller.rb
index 498ed60e..5bc72b92 100644
--- a/app/controllers/playback_controller.rb
+++ b/app/controllers/playback_controller.rb
@@ -15,16 +15,14 @@ class RecordingNotFoundError < StandardError
def play
@playback_format = PlaybackFormat
- .joins(:recording)
- .find_by!(format: params[:playback_format], recordings: { record_id: params[:record_id] })
+ .joins(:recording)
+ .find_by!(format: params[:playback_format], recordings: { record_id: params[:record_id] })
@recording = @playback_format.recording
if @recording.protected
# Consume the one-time-use token (return an error if missing/invalid)
payload = PlaybackFormat.consume_protector_token(params[:token])
- if payload['record_id'] != @recording.record_id || payload['format'] != @playback_format.format
- raise RecordingNotFoundError
- end
+ raise RecordingNotFoundError if payload['record_id'] != @recording.record_id || payload['format'] != @playback_format.format
# Set the cookie that will provide access to resources for this recording & playback format
create_cookie
@@ -35,8 +33,8 @@ def play
def resource
@playback_format = PlaybackFormat
- .joins(:recording)
- .find_by!(format: params[:playback_format], recordings: { record_id: params[:record_id] })
+ .joins(:recording)
+ .find_by!(format: params[:playback_format], recordings: { record_id: params[:record_id] })
@recording = @playback_format.recording
verify_cookie if @recording.protected
diff --git a/app/handlers/recording_ready_event_handler.rb b/app/handlers/recording_ready_event_handler.rb
index 8899297b..acb973d3 100644
--- a/app/handlers/recording_ready_event_handler.rb
+++ b/app/handlers/recording_ready_event_handler.rb
@@ -3,10 +3,6 @@
class RecordingReadyEventHandler < EventHandler
attr_accessor :callback_url
- def initialize(params, *args)
- super
- end
-
def handle
set_callback_url
return if callback_url.nil?
diff --git a/app/models/application_redis_record.rb b/app/models/application_redis_record.rb
index 6cf6671a..9b632947 100644
--- a/app/models/application_redis_record.rb
+++ b/app/models/application_redis_record.rb
@@ -122,15 +122,22 @@ def init_with_attributes(attributes, new_record = false)
def self.application_redis_attr(*syms)
attr_reader(*syms)
+
syms.each do |sym|
raise NameError, "invalid attribute name: #{sym}" unless /^[_A-Za-z]\w*$/.match?(sym)
- class_eval(<<-END_OF_RUBY, __FILE__, __LINE__ + 1)
- def #{sym}=(value)
- #{sym}_will_change! unless @#{sym} == value
- @#{sym} = value
- end
- END_OF_RUBY
+ class_eval(
+ # def #{sym}=(value)
+ # #{sym}_will_change! unless @#{sym} == value
+ # @#{sym} = value
+ # end
+ <<-END_OF_RUBY, __FILE__, __LINE__ + 1
+ def #{sym}=(value)
+ #{sym}_will_change! unless @#{sym} == value
+ @#{sym} = value
+ end
+ END_OF_RUBY
+ )
end
end
@@ -139,10 +146,8 @@ def self.connection_pool
end
delegate :connection_pool, to: 'self.class'
- def self.with_connection
- RedisStore.with_connection do |redis|
- yield(redis)
- end
+ def self.with_connection(&block)
+ RedisStore.with_connection(&block)
end
delegate :with_connection, to: 'self.class'
diff --git a/app/models/recording.rb b/app/models/recording.rb
index 079daf2c..a3e3c50d 100644
--- a/app/models/recording.rb
+++ b/app/models/recording.rb
@@ -16,7 +16,7 @@ class Recording < ApplicationRecord
def self.with_recording_id_prefixes(recording_ids)
return none if recording_ids.empty?
- rid_prefixes = recording_ids.map { |rid| sanitize_sql_like(rid, '|') + '%' }
+ rid_prefixes = recording_ids.map { |rid| "#{sanitize_sql_like(rid, '|')}%" }
query_string = Array.new(recording_ids.length, "record_id LIKE ? ESCAPE '|'").join(' OR ')
where(query_string, *rid_prefixes)
diff --git a/config/application.rb b/config/application.rb
index 7073c993..e27ace5e 100644
--- a/config/application.rb
+++ b/config/application.rb
@@ -65,20 +65,20 @@ class Application < Rails::Application
# Directory to monitor for recordings transferred from BigBlueButton servers
config.x.recording_spool_dir = File.absolute_path(
- ENV.fetch('RECORDING_SPOOL_DIR') { '/var/bigbluebutton/spool' }
+ ENV.fetch('RECORDING_SPOOL_DIR', '/var/bigbluebutton/spool')
)
# Working directory for temporary files when extracting recordings
config.x.recording_work_dir = File.absolute_path(
- ENV.fetch('RECORDING_WORK_DIR') { '/var/bigbluebutton/recording/scalelite' }
+ ENV.fetch('RECORDING_WORK_DIR', '/var/bigbluebutton/recording/scalelite')
)
# Published recording directory
config.x.recording_publish_dir = File.absolute_path(
- ENV.fetch('RECORDING_PUBLISH_DIR') { '/var/bigbluebutton/published' }
+ ENV.fetch('RECORDING_PUBLISH_DIR', '/var/bigbluebutton/published')
)
# Unpublished recording directory
config.x.recording_unpublish_dir = File.absolute_path(
- ENV.fetch('RECORDING_UNPUBLISH_DIR') { '/var/bigbluebutton/unpublished' }
+ ENV.fetch('RECORDING_UNPUBLISH_DIR', '/var/bigbluebutton/unpublished')
)
# Minimum user count of a meeting, used for calculating server load. Defaults to 15.
diff --git a/config/environments/development.rb b/config/environments/development.rb
index e5caef9b..f2bfe27e 100644
--- a/config/environments/development.rb
+++ b/config/environments/development.rb
@@ -38,7 +38,7 @@
config.active_record.verbose_query_logs = true
end
- Rails.logger = Logger.new(STDOUT)
+ Rails.logger = Logger.new($stdout)
# Raises error for missing translations.
# config.action_view.raise_on_missing_translations = true
diff --git a/config/environments/production.rb b/config/environments/production.rb
index ee160eda..076b57a7 100644
--- a/config/environments/production.rb
+++ b/config/environments/production.rb
@@ -67,8 +67,8 @@
if 'true'.casecmp?(ENV['RAILS_LOG_TO_STDOUT'])
# Disable output buffering when STDOUT isn't a tty (e.g. Docker images, systemd services)
- STDOUT.sync = true
- logger = ActiveSupport::Logger.new(STDOUT)
+ $stdout.sync = true
+ logger = ActiveSupport::Logger.new($stdout)
logger.formatter = config.log_formatter
config.logger = ActiveSupport::TaggedLogging.new(logger)
end
diff --git a/config/environments/test.rb b/config/environments/test.rb
index d9846a00..50ab61d5 100644
--- a/config/environments/test.rb
+++ b/config/environments/test.rb
@@ -39,5 +39,5 @@
# config.action_view.raise_on_missing_translations = true
# Ensure a dummy secret is set for testing
- config.x.loadbalancer_secrets = [ENV.fetch('LOADBALANCER_SECRET') { 'f830c18ee29c8531e0115c3da85db89b' }]
+ config.x.loadbalancer_secrets = [ENV.fetch('LOADBALANCER_SECRET', 'f830c18ee29c8531e0115c3da85db89b')]
end
diff --git a/config/puma.rb b/config/puma.rb
index 376e1c72..339fc130 100644
--- a/config/puma.rb
+++ b/config/puma.rb
@@ -5,23 +5,23 @@
# the concurrency of the application would be max `threads` * `workers`.
# Workers do not work on JRuby or Windows (both of which do not support
# processes).
-workers(ENV.fetch('WEB_CONCURRENCY') { 0 })
+workers(ENV.fetch('WEB_CONCURRENCY', 0))
# Puma can serve each request in a thread from an internal thread pool.
# The `threads` method setting takes two numbers: a minimum and maximum.
# Any libraries that use thread pools should be configured to match
# the maximum value specified for Puma. Default is set to 5 threads for minimum
# and maximum; this matches the default thread size of Active Record.
-max_threads_count = ENV.fetch('RAILS_MAX_THREADS') { 5 }
+max_threads_count = ENV.fetch('RAILS_MAX_THREADS', 5)
min_threads_count = ENV.fetch('RAILS_MIN_THREADS') { max_threads_count }
threads(min_threads_count, max_threads_count)
# Specifies the `port` that Puma will listen on to receive requests; default is 3000.
# You can either specify `BIND` with a full address (even unix socket) or just `PORT`
-bind(ENV.fetch('BIND') { "tcp://0.0.0.0:#{ENV.fetch('PORT') { 3000 }}" })
+bind(ENV.fetch('BIND') { "tcp://0.0.0.0:#{ENV.fetch('PORT', 3000)}" })
# Specifies the `environment` that Puma will run in.
-environment(ENV.fetch('RAILS_ENV') { 'development' })
+environment(ENV.fetch('RAILS_ENV', 'development'))
# Use the `preload_app!` method when specifying a `workers` number.
# This directive tells Puma to first boot the application and load code
diff --git a/db/migrate/20181123180008_init.rb b/db/migrate/20181123180008_init.rb
index 0cbd25e9..1e552898 100644
--- a/db/migrate/20181123180008_init.rb
+++ b/db/migrate/20181123180008_init.rb
@@ -1,17 +1,15 @@
# frozen_string_literal: true
-# rubocop:disable Rails/CreateTableWithTimestamps
-
class Init < ActiveRecord::Migration[6.0]
def change
- create_table :metadata, force: :cascade do |t|
+ create_table(:metadata, force: :cascade) do |t|
t.bigint(:recording_id)
t.string(:key)
t.string(:value)
t.index(%w[recording_id key], name: 'index_metadata_on_recording_id_and_key', unique: true)
end
- create_table :playback_formats, force: :cascade do |t|
+ create_table(:playback_formats, force: :cascade) do |t|
t.bigint(:recording_id)
t.string(:format)
t.string(:url)
@@ -20,7 +18,7 @@ def change
t.index(%w[recording_id format], name: 'index_playback_formats_on_recording_id_and_format', unique: true)
end
- create_table :recordings, force: :cascade do |t|
+ create_table(:recordings, force: :cascade) do |t|
t.string(:record_id)
t.string(:meeting_id)
t.string(:name)
@@ -34,7 +32,7 @@ def change
t.index(%w[record_id], name: 'index_recordings_on_record_id', unique: true)
end
- create_table :thumbnails, force: :cascade do |t|
+ create_table(:thumbnails, force: :cascade) do |t|
t.bigint(:playback_format_id)
t.integer(:width)
t.integer(:height)
@@ -45,5 +43,3 @@ def change
end
end
end
-
-# rubocop:enable Rails/CreateTableWithTimestamps
diff --git a/db/migrate/20210425184558_create_callback_data.rb b/db/migrate/20210425184558_create_callback_data.rb
index 5d9d7c99..4f21926b 100644
--- a/db/migrate/20210425184558_create_callback_data.rb
+++ b/db/migrate/20210425184558_create_callback_data.rb
@@ -2,7 +2,7 @@
class CreateCallbackData < ActiveRecord::Migration[6.0]
def change
- create_table :callback_data do |t|
+ create_table(:callback_data) do |t|
t.string(:meeting_id)
t.integer(:recording_id)
t.text(:callback_attributes)
diff --git a/lib/redis_store.rb b/lib/redis_store.rb
index ab852557..54340f05 100644
--- a/lib/redis_store.rb
+++ b/lib/redis_store.rb
@@ -31,7 +31,7 @@ def self.before_fork
end
end
- def self.with_connection
- connection_pool.with { |connection| yield(connection) }
+ def self.with_connection(&block)
+ connection_pool.with(&block)
end
end
diff --git a/lib/server_sync.rb b/lib/server_sync.rb
index 8f552251..8400f174 100644
--- a/lib/server_sync.rb
+++ b/lib/server_sync.rb
@@ -19,7 +19,7 @@ def self.logger
# contain a +servers+ hash mapping IDs to server parameters. For details,
# see +ServerSync.sync+
def self.sync_file(path, mode = 'cordon', dryrun = false)
- yaml = YAML.safe_load(path == '-' ? STDIN.read : File.read(path))
+ yaml = YAML.safe_load(path == '-' ? $stdin.read : File.read(path))
raise(SyncError, 'Invalid YAML document') unless yaml.is_a?(Hash)
servers = yaml['servers']
diff --git a/lib/tasks/meetings.rake b/lib/tasks/meetings.rake
index f2564a0e..155c09a4 100644
--- a/lib/tasks/meetings.rake
+++ b/lib/tasks/meetings.rake
@@ -43,7 +43,7 @@ namespace :meetings do
$stdout.sync = true
puts('WARNING: You are trying to clear active meetings.')
puts('If you still wish to continue please enter `yes`')
- response = STDIN.gets.chomp.casecmp('yes').zero?
+ response = $stdin.gets.chomp.casecmp('yes').zero?
if response
args.with_defaults(meeting_ids: '')
include ApiHelper
diff --git a/lib/tasks/servers.rake b/lib/tasks/servers.rake
index 7af79323..ca7d593e 100644
--- a/lib/tasks/servers.rake
+++ b/lib/tasks/servers.rake
@@ -97,7 +97,7 @@ namespace :servers do
puts("WARNING: You are trying to disable a server with active load. You should use the cordon option if
you do not want to clear all the meetings")
puts('If you still wish to continue please enter `yes`')
- response = STDIN.gets.chomp.casecmp('yes').zero?
+ response = $stdin.gets.chomp.casecmp('yes').zero?
if response
meetings = Meeting.all.select { |m| m.server_id == server.id }
meetings.each do |meeting|
@@ -167,8 +167,8 @@ namespace :servers do
servers = YAML.load_file(args.path)['servers']
servers.each do |server|
created = Server.create!(url: server['url'], secret: server['secret'])
- puts "server: #{created.url}"
- puts "id: #{created.id}"
+ puts("server: #{created.url}")
+ puts("id: #{created.id}")
end
rescue StandardError => e
puts(e)
diff --git a/test/controllers/bigbluebutton_api_controller_test.rb b/test/controllers/bigbluebutton_api_controller_test.rb
index e2142cb7..2595ae40 100644
--- a/test/controllers/bigbluebutton_api_controller_test.rb
+++ b/test/controllers/bigbluebutton_api_controller_test.rb
@@ -698,7 +698,7 @@ class BigBlueButtonApiControllerTest < ActionDispatch::IntegrationTest
'apmp')
mocked_method = MiniTest::Mock.new
- return_value = { 'meetingID': 'test-meeting-1', test4: '', test2: '' }
+ return_value = { meetingID: 'test-meeting-1', test4: '', test2: '' }
Rails.configuration.x.stub(:create_exclude_params, []) do
mocked_method.expect(:pass_through_params, return_value, [Rails.configuration.x.create_exclude_params])
@@ -1679,7 +1679,7 @@ class BigBlueButtonApiControllerTest < ActionDispatch::IntegrationTest
r1 = create(:recording)
r2 = create(:recording)
- params = encode_bbb_params('deleteRecordings', { recordID: [r.record_id, r1.record_id, r2.record_id].join(',') } .to_query)
+ params = encode_bbb_params('deleteRecordings', { recordID: [r.record_id, r1.record_id, r2.record_id].join(',') }.to_query)
get bigbluebutton_api_delete_recordings_url, params: params
assert_response :success
diff --git a/test/fixtures/files/servers.yml b/test/fixtures/files/servers.yml
index 4075f7d5..a6e2e0ff 100644
--- a/test/fixtures/files/servers.yml
+++ b/test/fixtures/files/servers.yml
@@ -1,7 +1,7 @@
servers:
- - url: "bbb1.example.com"
+ - url: "https://bbb1.example.com/bigbluebutton/api/"
secret: "1bdce5cbab581f3f20b199b970e53ae3c9d9df6392f79589bd58be020ed14535"
- - url: "bbb2.example.com"
+ - url: "https://bbb2.example.com/bigbluebutton/api/"
secret: "2bdce5cbab581f3f20b199b970e53ae3c9d9df6392f79589bd58be020ed14535"
- - url: "bbb3.example.com"
+ - url: "https://bbb3.example.com/bigbluebutton/api/"
secret: "3bdce5cbab581f3f20b199b970e53ae3c9d9df6392f79589bd58be020ed14535"
diff --git a/test/handlers/analytics_callback_event_handler_test.rb b/test/handlers/analytics_callback_event_handler_test.rb
index c1d58b22..3bfaf61f 100644
--- a/test/handlers/analytics_callback_event_handler_test.rb
+++ b/test/handlers/analytics_callback_event_handler_test.rb
@@ -6,14 +6,14 @@ class AnalyticsCallbackEventHandlerTest < ActiveSupport::TestCase
test 'creates record in CallbackData' do
params = { 'meta_analytics-callback-url' => 'https://test-1.example.com/' }
EventHandler.new(params, 'test-123').handle
- callbackdata = CallbackData.find_by_meeting_id('test-123')
+ callbackdata = CallbackData.find_by(meeting_id: 'test-123')
assert_equal callbackdata.callback_attributes[:analytics_callback_url], 'https://test-1.example.com/'
end
test 'does not create record in CallbackData if meta_analytics-callback-url is nil' do
params = { 'meta_analytics-callback-url' => nil }
EventHandler.new(params, 'test-123').handle
- callbackdata = CallbackData.find_by_meeting_id('test-123')
+ callbackdata = CallbackData.find_by(meeting_id: 'test-123')
assert_nil callbackdata
end
end
diff --git a/test/handlers/recording_ready_event_handler_test.rb b/test/handlers/recording_ready_event_handler_test.rb
index cdcedb01..ad9613bd 100644
--- a/test/handlers/recording_ready_event_handler_test.rb
+++ b/test/handlers/recording_ready_event_handler_test.rb
@@ -6,14 +6,14 @@ class RecordingReadyEventHandlerTest < ActiveSupport::TestCase
test 'creates record in CallbackData' do
params = { 'meta_bn-recording-ready-url' => 'https://test-1.example.com/' }
EventHandler.new(params, 'test-123').handle
- callbackdata = CallbackData.find_by_meeting_id('test-123')
+ callbackdata = CallbackData.find_by(meeting_id: 'test-123')
assert_equal callbackdata.callback_attributes[:recording_ready_url], 'https://test-1.example.com/'
end
test 'does not create record in CallbackData if meta_bn-recording-ready-url is nil' do
params = { 'meta_bn-recording-ready-url' => nil }
EventHandler.new(params, 'test-123').handle
- callbackdata = CallbackData.find_by_meeting_id('test-123')
+ callbackdata = CallbackData.find_by(meeting_id: 'test-123')
assert_nil callbackdata
end
diff --git a/test/services/recording_ready_notifier_service_test.rb b/test/services/recording_ready_notifier_service_test.rb
index 8cce3693..d60b406f 100644
--- a/test/services/recording_ready_notifier_service_test.rb
+++ b/test/services/recording_ready_notifier_service_test.rb
@@ -11,7 +11,7 @@ class RecordingReadyNotifierServiceTest < ActiveSupport::TestCase
stub_request(:post, url)
.to_return(status: 200, body: '', headers: {})
- return_val = JWT.stub(:encode, 'eyJhbGciOiJIUzI1NiJ9.eyJtZWV0aW5nX2lkIjoibWVldGluZzE5In0.Jlw1ND63QJ3j9TT0mgp_5fpmPA82FhMT_-mPU25PEFY') do # rubocop:disable LineLength
+ return_val = JWT.stub(:encode, 'eyJhbGciOiJIUzI1NiJ9.eyJtZWV0aW5nX2lkIjoibWVldGluZzE5In0.Jlw1ND63QJ3j9TT0mgp_5fpmPA82FhMT_-mPU25PEFY') do # rubocop:disable Layout/LineLength
RecordingReadyNotifierService.execute(recording.id)
end
@@ -26,7 +26,7 @@ class RecordingReadyNotifierServiceTest < ActiveSupport::TestCase
stub_request(:post, url).to_timeout
- return_val = JWT.stub(:encode, 'eyJhbGciOiJIUzI1NiJ9.eyJtZWV0aW5nX2lkIjoibWVldGluZzE5In0.Jlw1ND63QJ3j9TT0mgp_5fpmPA82FhMT_-mPU25PEFY') do # rubocop:disable LineLength
+ return_val = JWT.stub(:encode, 'eyJhbGciOiJIUzI1NiJ9.eyJtZWV0aW5nX2lkIjoibWVldGluZzE5In0.Jlw1ND63QJ3j9TT0mgp_5fpmPA82FhMT_-mPU25PEFY') do # rubocop:disable Layout/LineLength
RecordingReadyNotifierService.execute(recording.id)
end
diff --git a/test/services/server_sync_test.rb b/test/services/server_sync_test.rb
index 4b098fe3..d1eec496 100644
--- a/test/services/server_sync_test.rb
+++ b/test/services/server_sync_test.rb
@@ -1,9 +1,9 @@
# frozen_string_literal: true
-class ServerSyncTest < ActiveSupport::TestCase
- require 'rake'
- require 'test_helper'
+require 'rake'
+require 'test_helper'
+class ServerSyncTest < ActiveSupport::TestCase
test 'Sync all servers from yml file' do
ServerSync.sync_file('./test/fixtures/files/servers-sync-a.yml')
assert_equal 3, Server.all.size
diff --git a/test/tasks/Servers/add_all_task_test.rb b/test/tasks/Servers/add_all_task_test.rb
index 802ca79f..e9d3ec1d 100644
--- a/test/tasks/Servers/add_all_task_test.rb
+++ b/test/tasks/Servers/add_all_task_test.rb
@@ -1,13 +1,17 @@
# frozen_string_literal: true
+require 'rake'
+require 'test_helper'
+
class AddAllTaskTest < ActiveSupport::TestCase
- require 'rake'
- require 'test_helper'
+ Rails.application.load_tasks
test 'adds all servers from yml file' do
- server_count = Server.all.size
- STDOUT.stub(:puts, '.') do
- Rake::Task['servers:addAll'].invoke('./test/fixtures/files/servers.yml')
+ $stdout.stub(:puts, '.') do
+ server_count = Server.all.size
+ Rails.configuration.x.stub(:server_id_is_hostname, true) do
+ Rake::Task['servers:addAll'].invoke('./test/fixtures/files/servers.yml')
+ end
assert_equal Server.all.size, server_count + 3
end
end