forked from External/greenlight
Updated rubocop and fixed issues (#490)
This commit is contained in:
parent
bc57caa806
commit
a0c99dde47
1231
.rubocop.yml
1231
.rubocop.yml
File diff suppressed because it is too large
Load Diff
2
Gemfile
2
Gemfile
|
@ -76,7 +76,7 @@ group :production do
|
|||
end
|
||||
|
||||
# Ruby linting.
|
||||
gem 'rubocop', '0.57.1'
|
||||
gem 'rubocop'
|
||||
|
||||
group :development, :test do
|
||||
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
|
||||
|
|
10
Gemfile.lock
10
Gemfile.lock
|
@ -179,7 +179,6 @@ GEM
|
|||
ast (~> 2.4.0)
|
||||
pg (0.21.0)
|
||||
popper_js (1.14.5)
|
||||
powerpack (0.1.2)
|
||||
public_suffix (3.0.3)
|
||||
puma (3.11.4)
|
||||
pyu-ruby-sasl (0.0.3.3)
|
||||
|
@ -244,14 +243,13 @@ GEM
|
|||
rspec-mocks (~> 3.7.0)
|
||||
rspec-support (~> 3.7.0)
|
||||
rspec-support (3.7.1)
|
||||
rubocop (0.57.1)
|
||||
rubocop (0.68.1)
|
||||
jaro_winkler (~> 1.5.1)
|
||||
parallel (~> 1.10)
|
||||
parser (>= 2.5)
|
||||
powerpack (~> 0.1)
|
||||
parser (>= 2.5, != 2.5.1.1)
|
||||
rainbow (>= 2.2.2, < 4.0)
|
||||
ruby-progressbar (~> 1.7)
|
||||
unicode-display_width (~> 1.0, >= 1.0.1)
|
||||
unicode-display_width (>= 1.4.0, < 1.6)
|
||||
ruby-progressbar (1.10.0)
|
||||
rubyntlm (0.6.2)
|
||||
safe_yaml (1.0.4)
|
||||
|
@ -364,7 +362,7 @@ DEPENDENCIES
|
|||
redis (~> 3.0)
|
||||
remote_syslog_logger
|
||||
rspec-rails (~> 3.7)
|
||||
rubocop (= 0.57.1)
|
||||
rubocop
|
||||
sass-rails (~> 5.0)
|
||||
shoulda-matchers (~> 3.1)
|
||||
spring
|
||||
|
|
|
@ -75,9 +75,7 @@ class PasswordResetsController < ApplicationController
|
|||
|
||||
# Checks expiration of reset token.
|
||||
def check_expiration
|
||||
if current_user.password_reset_expired?
|
||||
redirect_to new_password_reset_url, alert: I18n.t("expired_reset_token")
|
||||
end
|
||||
redirect_to new_password_reset_url, alert: I18n.t("expired_reset_token") if current_user.password_reset_expired?
|
||||
end
|
||||
|
||||
def reset_link
|
||||
|
|
|
@ -144,8 +144,8 @@ class RoomsController < ApplicationController
|
|||
|
||||
begin
|
||||
redirect_to @room.join_path(current_user.name, opts, current_user.uid)
|
||||
rescue BigBlueButton::BigBlueButtonException => exc
|
||||
redirect_to room_path, alert: I18n.t(exc.key.to_s.underscore, default: I18n.t("bigbluebutton_exception"))
|
||||
rescue BigBlueButton::BigBlueButtonException => e
|
||||
redirect_to room_path, alert: I18n.t(e.key.to_s.underscore, default: I18n.t("bigbluebutton_exception"))
|
||||
end
|
||||
|
||||
# Notify users that the room has started.
|
||||
|
@ -192,7 +192,7 @@ class RoomsController < ApplicationController
|
|||
|
||||
def create_room_settings_string(mute_res, client_res)
|
||||
room_settings = {}
|
||||
room_settings["muteOnStart"] = mute_res == "1" ? true : false
|
||||
room_settings["muteOnStart"] = mute_res == "1"
|
||||
|
||||
if client_res.eql? "html5"
|
||||
room_settings["joinViaHtml5"] = true
|
||||
|
|
|
@ -84,8 +84,8 @@ module ApplicationHelper
|
|||
begin
|
||||
provider_info = retrieve_provider_info(@user_domain, 'api2', 'getUserGreenlightCredentials')
|
||||
provider_info['provider'] == 'greenlight'
|
||||
rescue => ex
|
||||
logger.info ex
|
||||
rescue => e
|
||||
logger.info e
|
||||
false
|
||||
end
|
||||
end
|
||||
|
|
|
@ -31,7 +31,7 @@ module RecordingsHelper
|
|||
len = valid_playbacks.first[:length]
|
||||
if len > 60
|
||||
"#{(len / 60).to_i} hrs #{len % 60} mins"
|
||||
elsif len == 0
|
||||
elsif len.zero?
|
||||
"< 1 min"
|
||||
else
|
||||
"#{len} min"
|
||||
|
|
|
@ -60,22 +60,20 @@ module SessionsHelper
|
|||
|
||||
def generate_checksum(user_domain, redirect_url, secret)
|
||||
string = user_domain + redirect_url + secret
|
||||
OpenSSL::Digest.digest('sha1', string).unpack("H*").first
|
||||
OpenSSL::Digest.digest('sha1', string).unpack1("H*")
|
||||
end
|
||||
|
||||
def parse_user_domain(hostname)
|
||||
return hostname.split('.').first if Rails.configuration.url_host.empty?
|
||||
Rails.configuration.url_host.split(',').each do |url_host|
|
||||
if hostname.include?(url_host)
|
||||
return hostname.chomp(url_host).chomp('.')
|
||||
end
|
||||
return hostname.chomp(url_host).chomp('.') if hostname.include?(url_host)
|
||||
end
|
||||
''
|
||||
end
|
||||
|
||||
def omniauth_options(env)
|
||||
gl_redirect_url = (Rails.env.production? ? "https" : env["rack.url_scheme"]) + "://" + env["SERVER_NAME"] + ":" +
|
||||
env["SERVER_PORT"]
|
||||
env["SERVER_PORT"]
|
||||
user_domain = parse_user_domain(env["SERVER_NAME"])
|
||||
env['omniauth.strategy'].options[:customer] = user_domain
|
||||
env['omniauth.strategy'].options[:gl_redirect_url] = gl_redirect_url
|
||||
|
|
|
@ -67,9 +67,9 @@ class Room < ApplicationRecord
|
|||
unless meeting[:messageKey] == 'duplicateWarning'
|
||||
update_attributes(sessions: sessions + 1, last_session: DateTime.now)
|
||||
end
|
||||
rescue BigBlueButton::BigBlueButtonException => exc
|
||||
puts "BigBlueButton failed on create: #{exc.key}: #{exc.message}"
|
||||
raise exc
|
||||
rescue BigBlueButton::BigBlueButtonException => e
|
||||
puts "BigBlueButton failed on create: #{e.key}: #{e.message}"
|
||||
raise e
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -225,7 +225,7 @@ class User < ApplicationRecord
|
|||
|
||||
# Initializes a room for the user and assign a BigBlueButton user id.
|
||||
def initialize_main_room
|
||||
self.uid = "gl-#{(0...12).map { (65 + rand(26)).chr }.join.downcase}"
|
||||
self.uid = "gl-#{(0...12).map { rand(65..90).chr }.join.downcase}"
|
||||
self.main_room = Room.create!(owner: self, name: I18n.t("home_room"))
|
||||
save
|
||||
end
|
||||
|
|
|
@ -101,6 +101,6 @@ module Greenlight
|
|||
config.room_features = ENV['ROOM_FEATURES'] || ""
|
||||
|
||||
# The maximum number of rooms included in one bbbapi call
|
||||
config.pagination_number = ENV['PAGINATION_NUMBER'].to_i == 0 ? 25 : ENV['PAGINATION_NUMBER'].to_i
|
||||
config.pagination_number = ENV['PAGINATION_NUMBER'].to_i.zero? ? 25 : ENV['PAGINATION_NUMBER'].to_i
|
||||
end
|
||||
end
|
||||
|
|
|
@ -113,7 +113,5 @@ Rails.application.configure do
|
|||
config.active_record.dump_schema_after_migration = false
|
||||
|
||||
# Set the relative url root for deployment to a subdirectory.
|
||||
if ENV['RELATIVE_URL_ROOT'] != "/"
|
||||
config.relative_url_root = ENV['RELATIVE_URL_ROOT'] || "/b"
|
||||
end
|
||||
config.relative_url_root = ENV['RELATIVE_URL_ROOT'] || "/b" if ENV['RELATIVE_URL_ROOT'] != "/"
|
||||
end
|
||||
|
|
|
@ -64,7 +64,7 @@ module BbbApi
|
|||
def encode_bbb_url(base_url, secret, params, route = 'getUser')
|
||||
encoded_params = params.to_param
|
||||
string = route + encoded_params + secret
|
||||
checksum = OpenSSL::Digest.digest('sha1', string).unpack('H*').first
|
||||
checksum = OpenSSL::Digest.digest('sha1', string).unpack1('H*')
|
||||
|
||||
URI.parse("#{base_url}#{route}?#{encoded_params}&checksum=#{checksum}")
|
||||
end
|
||||
|
|
|
@ -12,9 +12,7 @@ namespace :conf do
|
|||
# Initial check that variables are set
|
||||
print "\nChecking environment"
|
||||
ENV_VARIABLES.each do |var|
|
||||
if ENV[var].blank?
|
||||
failed("#{var} not set correctly")
|
||||
end
|
||||
failed("#{var} not set correctly") if ENV[var].blank?
|
||||
end
|
||||
passed
|
||||
|
||||
|
@ -48,8 +46,8 @@ def test_smtp
|
|||
ENV['SMTP_AUTH']) do |s|
|
||||
s.sendmail('test', ENV['SMTP_USERNAME'], 'notifications@example.com')
|
||||
end
|
||||
rescue => exc
|
||||
failed("Error connecting to SMTP - #{exc}")
|
||||
rescue => e
|
||||
failed("Error connecting to SMTP - #{e}")
|
||||
end
|
||||
|
||||
# Takes the full URL including the protocol
|
||||
|
@ -58,11 +56,9 @@ def test_request(url)
|
|||
res = Net::HTTP.get(uri)
|
||||
|
||||
doc = Nokogiri::XML(res)
|
||||
if doc.css("returncode").text != "SUCCESS"
|
||||
failed("Could not get a valid response from BigBlueButton server - #{res}")
|
||||
end
|
||||
rescue => exc
|
||||
failed("Error connecting to BigBlueButton server - #{exc}")
|
||||
failed("Could not get a valid response from BigBlueButton server - #{res}") if doc.css("returncode").text != "SUCCESS"
|
||||
rescue => e
|
||||
failed("Error connecting to BigBlueButton server - #{e}")
|
||||
end
|
||||
|
||||
def failed(msg)
|
||||
|
|
|
@ -102,7 +102,7 @@ describe Room, type: :model do
|
|||
query = fullname + meeting_id + password
|
||||
checksum_string = "join#{query + secret}"
|
||||
|
||||
checksum = OpenSSL::Digest.digest('sha1', checksum_string).unpack("H*").first
|
||||
checksum = OpenSSL::Digest.digest('sha1', checksum_string).unpack1("H*")
|
||||
expect(@room.join_path("Example")).to eql("#{endpoint}join?#{query}&checksum=#{checksum}")
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue