diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 0a4eca46..c9f93a30 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -25,7 +25,7 @@ class ApplicationController < ActionController::Base !request.xhr?) # don't store ajax calls session[:return_to] = request.fullpath end - end + end def after_sign_in_path_for(_resource) if (can? :view, Conference) && diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 0bf44f49..55af84df 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -31,7 +31,9 @@ class UsersController < ApplicationController end # Somewhat of a hack: users/current/edit + # rubocop:disable Naming/MemoizedInstanceVariableName def load_user @user ||= (params[:id] && params[:id] != 'current' && User.find(params[:id]) || current_user) end + # rubocop:enable Naming/MemoizedInstanceVariableName end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 90b3fa2b..1c7f5da6 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -112,7 +112,7 @@ module ApplicationHelper concurrent_events << other_event_schedule.event end end - concurrent_events.sort_by { |event_schedule| event_schedule.room&.order } + concurrent_events.sort_by { |schedule| schedule.room&.order } end def speaker_links(event) diff --git a/app/helpers/events_helper.rb b/app/helpers/events_helper.rb index c920c16f..eebaa4fe 100644 --- a/app/helpers/events_helper.rb +++ b/app/helpers/events_helper.rb @@ -1,5 +1,7 @@ # frozen_string_literal: true +# TODO: Split this module into smaller modules +# rubocop:disable Metrics/ModuleLength module EventsHelper ## # Includes functions related to events @@ -193,7 +195,7 @@ module EventsHelper end end - def calendar_timestamp(timestamp, timezone) + def calendar_timestamp(timestamp, _timezone) timestamp = timestamp.in_time_zone('GMT') timestamp -= timestamp.utc_offset timestamp.strftime('%Y%m%dT%H%M%S') @@ -221,7 +223,7 @@ module EventsHelper def calendar_event_text(event, event_schedule, conference) <<~TEXT #{conference.title} - #{event.title} - #{event_schedule.start_time.strftime("%Y %B %e - %H:%M")} #{event_schedule.timezone} + #{event_schedule.start_time.strftime('%Y %B %e - %H:%M')} #{event_schedule.timezone} More Info: #{conference_program_proposal_url(conference, event)} Join: #{event.url} @@ -256,3 +258,4 @@ module EventsHelper end end end +# rubocop:enable Metrics/ModuleLength diff --git a/app/models/ability.rb b/app/models/ability.rb index 9db7bacf..ec17e14c 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -68,6 +68,8 @@ class Ability end # Abilities for signed in users + # TODO: Refactor into multiple functions + # rubocop:disable Metrics/AbcSize def signed_in(user) # Abilities from not_signed_in user are also inherited not_signed_in @@ -140,6 +142,7 @@ class Ability user == track.submitter && !(track.accepted? || track.confirmed?) end end + # rubocop:enable Metrics/AbcSize # Abilities for users with roles wandering around in non-admin views. def common_abilities_for_admins(user) diff --git a/app/models/commercial.rb b/app/models/commercial.rb index 1d39f9c5..64631052 100644 --- a/app/models/commercial.rb +++ b/app/models/commercial.rb @@ -30,7 +30,7 @@ class Commercial < ApplicationRecord begin resource = OEmbed::Providers.get(url, maxwidth: 560, maxheight: 315) { html: resource.html.html_safe } - rescue StandardError => exception + rescue StandardError { html: iframe_fallback(url) } # { error: exception.message } end diff --git a/app/models/conference.rb b/app/models/conference.rb index 3e197280..44224ab7 100644 --- a/app/models/conference.rb +++ b/app/models/conference.rb @@ -35,6 +35,7 @@ # # index_conferences_on_organization_id (organization_id) # +# rubocop:disable Metrics/ClassLength class Conference < ApplicationRecord include RevisionCount require 'uri' @@ -1234,3 +1235,4 @@ class Conference < ApplicationRecord ] end end +# rubocop:enable Metrics/ClassLength diff --git a/app/models/user.rb b/app/models/user.rb index 147c2fe6..9bd1bf80 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -305,7 +305,7 @@ class User < ApplicationRecord # TODO: Use a real authorization in the right place.... def manages_volunteers?(conference) organizer_roles = get_roles['organizer'] - organizer_roles&.include?(conference.short_title) # TODO or Volunteer Coorinator. + organizer_roles&.include?(conference.short_title) # TODO: or Volunteer Coorinator. end def registered diff --git a/config/application.rb b/config/application.rb index 874f4456..18f917aa 100644 --- a/config/application.rb +++ b/config/application.rb @@ -68,9 +68,11 @@ module Osem config.before_configuration do env_file = File.join(Rails.root, 'config', 'local_env.yml') - YAML.load(File.open(env_file)).each do |key, value| - ENV[key.to_s] = value - end if File.exists?(env_file) + if File.exist?(env_file) + YAML.safe_load(File.open(env_file)).each do |key, value| + ENV[key.to_s] = value + end + end end end end diff --git a/config/puma.rb b/config/puma.rb index 0d3b583f..c6f137da 100644 --- a/config/puma.rb +++ b/config/puma.rb @@ -46,9 +46,9 @@ end lowlevel_error_handler do |ex, env| Sentry.capture_exception( ex, - :message => ex.message, - :extra => { :puma => env }, - :transaction => "Puma" + message: ex.message, + extra: { puma: env }, + transaction: "Puma" ) # note the below is just a Rack response [500, {}, ["An error has occurred, and engineers have been informed. Please reload the page. If you continue to have problems, contact conference@snap.berkeley.edu\n"]] diff --git a/config/routes.rb b/config/routes.rb index ef984ca9..362b762c 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,6 +1,6 @@ Osem::Application.routes.draw do - mount LetterOpenerWeb::Engine, at: "/letter_opener" if Rails.env.development? + mount LetterOpenerWeb::Engine, at: '/letter_opener' if Rails.env.development? if ENV['OSEM_ICHAIN_ENABLED'] == 'true' devise_for :users, controllers: { registrations: :registrations } diff --git a/db/migrate/20180409170433_add_visible_to_tickets.rb b/db/migrate/20180409170433_add_visible_to_tickets.rb index 199f7a48..2286a065 100644 --- a/db/migrate/20180409170433_add_visible_to_tickets.rb +++ b/db/migrate/20180409170433_add_visible_to_tickets.rb @@ -2,7 +2,7 @@ class AddVisibleToTickets < ActiveRecord::Migration[5.0] def up add_column :tickets, :visible, :boolean, default: true Ticket.reset_column_information - Ticket.update_all(visible: true) # rubocop:disable Rails/SkipsModelValidations + Ticket.update_all(visible: true) end def down diff --git a/lib/tasks/db.rake b/lib/tasks/db.rake index 3c9cded7..bed74e53 100644 --- a/lib/tasks/db.rake +++ b/lib/tasks/db.rake @@ -13,24 +13,24 @@ namespace :db do end end - desc "Import a given file into the database" + desc 'Import a given file into the database' task :import, [:path] => :environment do |_t, args| dump_path = args.path connection_config = ActiveRecord::Base.connection_config case connection_config[:adapter] - when "postgresql" + when 'postgresql' system("PGPASSWORD=#{connection_config[:password]} pg_restore " \ - "--verbose --clean --no-acl --no-owner " \ + '--verbose --clean --no-acl --no-owner ' \ "--username=#{connection_config[:username]} " \ "-d #{connection_config[:database]} #{dump_path}") - when "mysql", "mysql2" + when 'mysql', 'mysql2' system("mysql -u #{connection_config[:username]} " \ "-p#{connection_config[:password]} " \ "#{connection_config[:database]} < #{dump_path}") else - raise NotImplementedError, "An importer hasn't been implemented for: " \ - "#{connection_config[:adapter]}" + raise NotImplementedError.new("An importer hasn't been implemented for: " \ + "#{connection_config[:adapter]}") end end end diff --git a/lib/tasks/registrations.rake b/lib/tasks/registrations.rake index f94bb3ae..709e13e0 100644 --- a/lib/tasks/registrations.rake +++ b/lib/tasks/registrations.rake @@ -1,17 +1,17 @@ # frozen_string_literal: true namespace :registrations do - desc "Create missing registrations for those how have a registration ticket." - task :create_missing, [:conference] => :environment do |t, args| + desc 'Create missing registrations for those how have a registration ticket.' + task :create_missing, [:conference] => :environment do |_t, args| - fail 'Please supply a conference short name.' unless args.conference + raise 'Please supply a conference short name.' unless args.conference conf = Conference.find_by(short_title: args.conference) # Check if a user is found based on the supplied email address - fail "Coud not find conference #{args.conference}" unless conf + raise "Coud not find conference #{args.conference}" unless conf purchases = conf.ticket_purchases.where(ticket: conf.registration_tickets, paid: true) - unregistered = purchases.select { |tp| !conf.user_registered?(tp.user) } + unregistered = purchases.reject { |tp| conf.user_registered?(tp.user) } puts "Found #{unregistered.count} unregistered users for #{purchases.count} ticket purchases." puts "There are currently #{conf.participants.count} registered users." @@ -19,17 +19,17 @@ namespace :registrations do puts "Creating registration for #{tp.user.email}" Registration.create(user: tp.user, conference: conf) end - puts "Done." + puts 'Done.' end - desc "Show User emails who have not paid, but did register" - task :list_unpaid, [:conference] => :environment do |t, args| + desc 'Show User emails who have not paid, but did register' + task :list_unpaid, [:conference] => :environment do |_t, args| - fail 'Please supply a conference short name.' unless args.conference + raise 'Please supply a conference short name.' unless args.conference conf = Conference.find_by(short_title: args.conference) # Check if a user is found based on the supplied email address - fail "Coud not find conference #{args.conference}" unless conf + raise "Coud not find conference #{args.conference}" unless conf registered = conf.participants unpaid = registered.select do |user| @@ -41,6 +41,6 @@ namespace :registrations do unpaid.each do |user| puts "'#{user.name}'<#{user.email}>, " end - puts "" + puts '' end end diff --git a/spec/features/commercials_spec.rb b/spec/features/commercials_spec.rb index 13c46f3b..d6fc7f38 100644 --- a/spec/features/commercials_spec.rb +++ b/spec/features/commercials_spec.rb @@ -69,7 +69,7 @@ feature Commercial do scenario 'does not add an invalid commercial of an event', feature: true, js: true do # TODO-SNAPCON - skip("Snap!Con allows all materials to be saved.") + skip('Snap!Con allows all materials to be saved.') visit edit_conference_program_proposal_path(conference.short_title, event.id) click_link 'Materials' fill_in 'commercial_url', with: 'invalid_commercial_url' diff --git a/spec/support/external_request.rb b/spec/support/external_request.rb index b9a61e85..83eb47db 100644 --- a/spec/support/external_request.rb +++ b/spec/support/external_request.rb @@ -35,6 +35,6 @@ def mock_commercial_request end def mock_image_request - WebMock.stub_request(:post, "https://api.cloudinary.com/v1_1/snapcon/image/destroy") + WebMock.stub_request(:post, 'https://api.cloudinary.com/v1_1/snapcon/image/destroy') .to_return(status: 200, body: {}.to_json, headers: {}) end diff --git a/spec/support/omniauth_macros.rb b/spec/support/omniauth_macros.rb index 25c6f039..2696f005 100644 --- a/spec/support/omniauth_macros.rb +++ b/spec/support/omniauth_macros.rb @@ -88,6 +88,10 @@ module OmniauthMacros # account is available for every supported omniauth provider. # These must be identical to the ones in /config/environments/development.rb # Remember to keep them in sync with development.rb + # + # Note that the method length check is disabled to allow for better formatting + # of the user params. + # rubocop:disable Metrics/MethodLength def mock_auth_accounts OmniAuth.config.mock_auth[:facebook] = OmniAuth::AuthHash.new( @@ -164,4 +168,5 @@ module OmniauthMacros } ) end + # rubocop:enable Metrics/MethodLength end