From fc701cf4852e67d6537194b54e27ea86e1c85736 Mon Sep 17 00:00:00 2001 From: Devin Howard Date: Mon, 16 Oct 2017 18:15:47 -0700 Subject: [PATCH] rubocop --- config/application.rb | 1 + config/boot.rb | 2 ++ config/environment.rb | 1 + config/environments/development.rb | 3 +- config/environments/production.rb | 5 ++- config/environments/test.rb | 1 + config/initializers/access_codes.rb | 1 + .../initializers/active_model_serializers.rb | 1 + .../application_controller_renderer.rb | 1 + config/initializers/assets.rb | 5 ++- config/initializers/backtrace_silencers.rb | 7 ++-- config/initializers/cookies_serializer.rb | 1 + config/initializers/cors.rb | 3 +- config/initializers/delayed_job.rb | 3 ++ config/initializers/devise.rb | 1 + config/initializers/doorkeeper.rb | 1 + config/initializers/exception_notification.rb | 5 +-- .../initializers/filter_parameter_logging.rb | 1 + config/initializers/internal_testers.rb | 11 ++++++- config/initializers/kaminari_config.rb | 1 + config/initializers/mime_types.rb | 1 + config/initializers/new_framework_defaults.rb | 1 + .../new_framework_defaults_5_1.rb | 2 ++ config/initializers/paperclip.rb | 1 + config/initializers/rack_attack.rb | 1 + config/initializers/secret_token.rb | 1 + config/initializers/session_store.rb | 1 + config/initializers/version.rb | 1 + config/initializers/warden_hooks.rb | 1 + config/initializers/wrap_parameters.rb | 1 + config/puma.rb | 8 +++-- config/routes.rb | 32 ++++++++++--------- config/spring.rb | 5 +-- 33 files changed, 82 insertions(+), 29 deletions(-) diff --git a/config/application.rb b/config/application.rb index 06842eb6..f7dbf17b 100644 --- a/config/application.rb +++ b/config/application.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require_relative 'boot' require 'csv' diff --git a/config/boot.rb b/config/boot.rb index 30f5120d..30e594e2 100644 --- a/config/boot.rb +++ b/config/boot.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) require 'bundler/setup' # Set up gems listed in the Gemfile. diff --git a/config/environment.rb b/config/environment.rb index 12ea62f8..d5abe558 100644 --- a/config/environment.rb +++ b/config/environment.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # Load the Rails application. require_relative 'application' diff --git a/config/environments/development.rb b/config/environments/development.rb index 381bca7b..c491510f 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb @@ -24,7 +25,7 @@ Rails.application.configure do # Print deprecation notices to the Rails logger config.active_support.deprecation = :log - config.action_mailer.preview_path = "#{Rails.root}/spec/mailers/previews" + config.action_mailer.preview_path = Rails.root.join('spec', 'mailers', 'previews') # Expands the lines which load the assets config.assets.debug = false diff --git a/config/environments/production.rb b/config/environments/production.rb index fd7ff05a..3dea4927 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -1,9 +1,12 @@ # frozen_string_literal: true + Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb - config.action_cable.allowed_request_origins = ['https://metamaps.herokuapp.com', 'http://metamaps.herokuapp.com', 'https://metamaps.cc'] + config.action_cable.allowed_request_origins = [ + 'https://metamaps.herokuapp.com', 'http://metamaps.herokuapp.com', 'https://metamaps.cc' + ] # log to stdout logger = Logger.new(STDOUT) diff --git a/config/environments/test.rb b/config/environments/test.rb index d85899fd..4c7426b7 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + Metamaps::Application.configure do # Settings specified here will take precedence over those in config/application.rb diff --git a/config/initializers/access_codes.rb b/config/initializers/access_codes.rb index fdf4e4b3..c735b13a 100644 --- a/config/initializers/access_codes.rb +++ b/config/initializers/access_codes.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + $codes = [] if ActiveRecord::Base.connection.data_source_exists? 'users' $codes = ActiveRecord::Base.connection diff --git a/config/initializers/active_model_serializers.rb b/config/initializers/active_model_serializers.rb index 929be340..84e882e4 100644 --- a/config/initializers/active_model_serializers.rb +++ b/config/initializers/active_model_serializers.rb @@ -1,2 +1,3 @@ # frozen_string_literal: true + ActiveModelSerializers.config.adapter = :json diff --git a/config/initializers/application_controller_renderer.rb b/config/initializers/application_controller_renderer.rb index 89d2efab..f4556db3 100644 --- a/config/initializers/application_controller_renderer.rb +++ b/config/initializers/application_controller_renderer.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true # Be sure to restart your server when you modify this file. # ActiveSupport::Reloader.to_prepare do diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb index 2c9cdbb8..c1f2c85a 100644 --- a/config/initializers/assets.rb +++ b/config/initializers/assets.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + Rails.application.configure do # Version of your assets, change this if you want to expire all your assets. config.assets.version = '2.0' @@ -9,5 +10,7 @@ Rails.application.configure do # Precompile additional assets. # application.js, application.css, and all non-JS/CSS in app/assets folder are already added. - config.assets.precompile += %w( application-secret.css application-secret.js webpacked/metamaps.bundle.js ) + config.assets.precompile += %w[ + application-secret.css application-secret.js webpacked/metamaps.bundle.js + ] end diff --git a/config/initializers/backtrace_silencers.rb b/config/initializers/backtrace_silencers.rb index 59385cdf..fbd1add6 100644 --- a/config/initializers/backtrace_silencers.rb +++ b/config/initializers/backtrace_silencers.rb @@ -1,7 +1,10 @@ +# frozen_string_literal: true # Be sure to restart your server when you modify this file. -# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces. +# You can add backtrace silencers for libraries that you're using but don't wish +# to see in your backtraces. # Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ } -# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code. +# You can also remove all the silencers if you're trying to debug a problem that +# might stem from framework code. # Rails.backtrace_cleaner.remove_silencers! diff --git a/config/initializers/cookies_serializer.rb b/config/initializers/cookies_serializer.rb index 74ea9274..046c7487 100644 --- a/config/initializers/cookies_serializer.rb +++ b/config/initializers/cookies_serializer.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # Be sure to restart your server when you modify this file. # Specify a serializer for the signed and encrypted cookie jars. diff --git a/config/initializers/cors.rb b/config/initializers/cors.rb index cb46d3ef..27f799d5 100644 --- a/config/initializers/cors.rb +++ b/config/initializers/cors.rb @@ -1,9 +1,10 @@ # frozen_string_literal: true + Rails.application.config.middleware.insert_before 0, Rack::Cors do allow do origins '*' resource '/api/*', headers: :any, - methods: [:get, :post, :put, :delete, :options, :head] + methods: %i[get post put delete options head] end end diff --git a/config/initializers/delayed_job.rb b/config/initializers/delayed_job.rb index d10a774e..599517c8 100644 --- a/config/initializers/delayed_job.rb +++ b/config/initializers/delayed_job.rb @@ -1,5 +1,8 @@ +# frozen_string_literal: true + module ExceptionNotifierInDelayedJob def handle_failed_job(job, error) + super ExceptionNotfier.notify_exception(error) end end diff --git a/config/initializers/devise.rb b/config/initializers/devise.rb index 6740cdc9..71f72490 100644 --- a/config/initializers/devise.rb +++ b/config/initializers/devise.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # Use this hook to configure devise mailer, warden hooks and so forth. # Many of these configuration options can be set straight in your model. Devise.setup do |config| diff --git a/config/initializers/doorkeeper.rb b/config/initializers/doorkeeper.rb index 21b08bc2..3182dd03 100644 --- a/config/initializers/doorkeeper.rb +++ b/config/initializers/doorkeeper.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + Doorkeeper.configure do # Change the ORM that doorkeeper will use (needs plugins) orm :active_record diff --git a/config/initializers/exception_notification.rb b/config/initializers/exception_notification.rb index 84c51be0..421974be 100644 --- a/config/initializers/exception_notification.rb +++ b/config/initializers/exception_notification.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'exception_notification/rails' module ExceptionNotifier @@ -50,11 +51,11 @@ ExceptionNotification.configure do |config| # Ignore additional exception types. # ActiveRecord::RecordNotFound, AbstractController::ActionNotFound and # ActionController::RoutingError are already added. - config.ignored_exceptions += %w( + config.ignored_exceptions += %w[ ActionView::TemplateError CustomError UnauthorizedException InvalidArgumentException InvalidEntityException InvalidRequestException NotFoundException ValidationException - ) + ] # Adds a condition to decide when an exception must be ignored or not. # The ignore_if method can be invoked multiple times to add extra conditions. diff --git a/config/initializers/filter_parameter_logging.rb b/config/initializers/filter_parameter_logging.rb index b7fe1231..7a4f47b4 100644 --- a/config/initializers/filter_parameter_logging.rb +++ b/config/initializers/filter_parameter_logging.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # Be sure to restart your server when you modify this file. # Configure sensitive parameters which will be filtered from the log file. diff --git a/config/initializers/internal_testers.rb b/config/initializers/internal_testers.rb index 079fc119..21abb6c0 100644 --- a/config/initializers/internal_testers.rb +++ b/config/initializers/internal_testers.rb @@ -1,3 +1,12 @@ +# frozen_string_literal: true + +TESTER_EMAILS = %w[ + connorturland@gmail.com devin@callysto.com chessscholar@gmail.com solaureum@gmail.com + ishanshapiro@gmail.com +].freeze + +# rubocop:disable Style/PredicateName def is_tester(user) - user && %w(connorturland@gmail.com devin@callysto.com chessscholar@gmail.com solaureum@gmail.com ishanshapiro@gmail.com).include?(user.email) + user && TESTER_EMAILS.include?(user.email) end +# rubocop:enable Style/PredicateName diff --git a/config/initializers/kaminari_config.rb b/config/initializers/kaminari_config.rb index 5b9883ab..fb53dfce 100644 --- a/config/initializers/kaminari_config.rb +++ b/config/initializers/kaminari_config.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + Kaminari.configure do |config| # config.default_per_page = 25 # config.max_per_page = nil diff --git a/config/initializers/mime_types.rb b/config/initializers/mime_types.rb index 2e0132a6..3d4dd77f 100644 --- a/config/initializers/mime_types.rb +++ b/config/initializers/mime_types.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # Be sure to restart your server when you modify this file. # Add new mime types for use in respond_to blocks: diff --git a/config/initializers/new_framework_defaults.rb b/config/initializers/new_framework_defaults.rb index d3c12d7b..69b31ed1 100644 --- a/config/initializers/new_framework_defaults.rb +++ b/config/initializers/new_framework_defaults.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # Be sure to restart your server when you modify this file. # # This file contains migration options to ease your Rails 5.0 upgrade. diff --git a/config/initializers/new_framework_defaults_5_1.rb b/config/initializers/new_framework_defaults_5_1.rb index 9010abd5..b33ee806 100644 --- a/config/initializers/new_framework_defaults_5_1.rb +++ b/config/initializers/new_framework_defaults_5_1.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Be sure to restart your server when you modify this file. # # This file contains migration options to ease your Rails 5.1 upgrade. diff --git a/config/initializers/paperclip.rb b/config/initializers/paperclip.rb index 6f094b7c..45b5e913 100644 --- a/config/initializers/paperclip.rb +++ b/config/initializers/paperclip.rb @@ -1,3 +1,4 @@ # frozen_string_literal: true + Paperclip::Attachment.default_options[:url] = ':s3_domain_url' Paperclip::Attachment.default_options[:path] = '/:class/:attachment/:id_partition/:style/:filename' diff --git a/config/initializers/rack_attack.rb b/config/initializers/rack_attack.rb index b79f0d10..83a978a8 100644 --- a/config/initializers/rack_attack.rb +++ b/config/initializers/rack_attack.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Rack class Attack Rack::Attack.cache.store = ActiveSupport::Cache::MemoryStore.new diff --git a/config/initializers/secret_token.rb b/config/initializers/secret_token.rb index 4da6fb50..3c3b0242 100644 --- a/config/initializers/secret_token.rb +++ b/config/initializers/secret_token.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # Be sure to restart your server when you modify this file. # Your secret key for verifying the integrity of signed cookies. diff --git a/config/initializers/session_store.rb b/config/initializers/session_store.rb index 57d69156..d7bb3be0 100644 --- a/config/initializers/session_store.rb +++ b/config/initializers/session_store.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # Be sure to restart your server when you modify this file. Rails.application.config.session_store :cookie_store, key: '_Metamaps_session' diff --git a/config/initializers/version.rb b/config/initializers/version.rb index 9a487067..7b848569 100644 --- a/config/initializers/version.rb +++ b/config/initializers/version.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + METAMAPS_VERSION = '3.5' METAMAPS_BUILD = `git log -1 --pretty=%H`.chomp[0..11].freeze METAMAPS_LAST_UPDATED = `git log -1 --pretty='%ad'`.split(' ').values_at(1, 2, 4).join(' ').freeze diff --git a/config/initializers/warden_hooks.rb b/config/initializers/warden_hooks.rb index a0d8fd88..3b212513 100644 --- a/config/initializers/warden_hooks.rb +++ b/config/initializers/warden_hooks.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + Warden::Manager.after_set_user do |user, auth, opts| scope = opts[:scope] auth.cookies.signed["#{scope}.id"] = user.id diff --git a/config/initializers/wrap_parameters.rb b/config/initializers/wrap_parameters.rb index d65576db..1dbadf48 100644 --- a/config/initializers/wrap_parameters.rb +++ b/config/initializers/wrap_parameters.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # Be sure to restart your server when you modify this file. # # This file contains settings for ActionController::ParamsWrapper which diff --git a/config/puma.rb b/config/puma.rb index 1e19380d..6ec461f5 100644 --- a/config/puma.rb +++ b/config/puma.rb @@ -1,19 +1,21 @@ +# frozen_string_literal: true + # 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. # -threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 } +threads_count = ENV.fetch('RAILS_MAX_THREADS') { 5 } threads threads_count, threads_count # Specifies the `port` that Puma will listen on to receive requests; default is 3000. # -port ENV.fetch("PORT") { 3000 } +port ENV.fetch('PORT') { 3000 } # Specifies the `environment` that Puma will run in. # -environment ENV.fetch("RAILS_ENV") { "development" } +environment ENV.fetch('RAILS_ENV') { 'development' } # Specifies the number of `workers` to boot in clustered mode. # Workers are forked webserver processes. If using threads and workers together diff --git a/config/routes.rb b/config/routes.rb index 80c0dbb4..9b4875aa 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,4 +1,6 @@ # frozen_string_literal: true + +# rubocop:disable Metrics/BlockLength Metamaps::Application.routes.draw do use_doorkeeper mount ActionCable.server => '/cable' @@ -16,7 +18,7 @@ Metamaps::Application.routes.draw do end get :explore, to: redirect('/') - resources :maps, except: [:index, :edit] do + resources :maps, except: %i[index edit] do member do get :conversation get :export @@ -54,10 +56,10 @@ Metamaps::Application.routes.draw do end end - resources :mappings, except: [:index, :new, :edit] + resources :mappings, except: %i[index new edit] - resources :messages, only: [:show, :create, :update, :destroy] - resources :notifications, only: [:index, :show] do + resources :messages, only: %i[show create update destroy] + resources :notifications, only: %i[index show] do collection do get :unsubscribe end @@ -79,9 +81,9 @@ Metamaps::Application.routes.draw do get :synapses end - resources :synapses, except: [:index, :new, :edit] + resources :synapses, except: %i[index new edit] - resources :topics, except: [:index, :new, :edit] do + resources :topics, except: %i[index new edit] do member do get :network get :relative_numbers @@ -110,7 +112,7 @@ Metamaps::Application.routes.draw do get 'join' => 'users/registrations#new', :as => :sign_up end - resources :users, except: [:index, :destroy] do + resources :users, except: %i[index destroy] do member do get :details end @@ -120,16 +122,16 @@ Metamaps::Application.routes.draw do namespace :api, path: '/api', default: { format: :json } do namespace :v2, path: '/v2' do - resources :metacodes, only: [:index, :show] - resources :mappings, only: [:index, :create, :show, :update, :destroy] - resources :maps, only: [:index, :create, :show, :update, :destroy] do + resources :metacodes, only: %i[index show] + resources :mappings, only: %i[index create show update destroy] + resources :maps, only: %i[index create show update destroy] do post :stars, to: 'stars#create', on: :member delete :stars, to: 'stars#destroy', on: :member end - resources :synapses, only: [:index, :create, :show, :update, :destroy] - resources :tokens, only: [:index, :create, :destroy] - resources :topics, only: [:index, :create, :show, :update, :destroy] - resources :users, only: [:index, :show] do + resources :synapses, only: %i[index create show update destroy] + resources :tokens, only: %i[index create destroy] + resources :topics, only: %i[index create show update destroy] + resources :users, only: %i[index show] do get :current, on: :collection end match '*path', to: 'restful#catch_404', via: :all @@ -145,4 +147,4 @@ Metamaps::Application.routes.draw do get 'load_url_title' end end -# rubocop:enable Rubocop/Metrics/BlockLength +# rubocop:enable Metrics/BlockLength diff --git a/config/spring.rb b/config/spring.rb index b0ca9589..ed3449f1 100644 --- a/config/spring.rb +++ b/config/spring.rb @@ -1,8 +1,9 @@ # frozen_string_literal: true -%w( + +%w[ .ruby-version .ruby-gemset .rbenv-vars tmp/restart.txt tmp/caching-dev.txt -).each { |path| Spring.watch(path) } +].each { |path| Spring.watch(path) }