From dd5da0bd8198a050e2eac548157f0e8e453d1c56 Mon Sep 17 00:00:00 2001 From: fauno Date: Fri, 5 Apr 2019 17:52:04 -0300 Subject: [PATCH] rubocop y gemas extra --- .rubocop.yml | 22 ++++ .rubocop_todo.yml | 80 +++++++++++++ Gemfile | 26 ++--- Gemfile.lock | 41 ++++++- Rakefile | 7 +- app/channels/application_cable/channel.rb | 2 + app/channels/application_cable/connection.rb | 2 + app/controllers/application_controller.rb | 2 + app/jobs/application_job.rb | 2 + app/mailers/application_mailer.rb | 3 + app/models/application_record.rb | 3 + bin/bundle | 110 +++++++++++++++++- bin/rails | 4 +- bin/rake | 4 +- bin/rubocop | 29 +++++ bin/setup | 2 + bin/spring | 3 +- bin/update | 2 + config.ru | 2 + config/application.rb | 23 ++-- config/boot.rb | 2 + config/environment.rb | 2 + config/environments/development.rb | 23 ++-- config/environments/production.rb | 58 +++++---- config/environments/test.rb | 23 ++-- .../application_controller_renderer.rb | 2 + config/initializers/backtrace_silencers.rb | 11 +- config/initializers/cors.rb | 2 + .../initializers/filter_parameter_logging.rb | 2 + config/initializers/inflections.rb | 2 + config/initializers/mime_types.rb | 2 + config/initializers/wrap_parameters.rb | 5 +- config/puma.rb | 23 ++-- config/routes.rb | 2 + config/spring.rb | 2 + db/seeds.rb | 8 +- test/test_helper.rb | 13 ++- 37 files changed, 449 insertions(+), 102 deletions(-) create mode 100644 .rubocop.yml create mode 100644 .rubocop_todo.yml create mode 100755 bin/rubocop diff --git a/.rubocop.yml b/.rubocop.yml new file mode 100644 index 0000000..f77b4a3 --- /dev/null +++ b/.rubocop.yml @@ -0,0 +1,22 @@ +inherit_from: .rubocop_todo.yml + +# No siempre queremos metadatear los modelos +Rails/CreateTableWithTimestamps: + Enabled: false +# Queremos poder hacer comentarios en castellano, esto quiere que +# saquemos las tildes +Style/AsciiComments: + Enabled: false +# El estilo de módulo y clases anidados agrega mucha indentación para +# nuestros gusto +Style/ClassAndModuleChildren: + Enabled: false +Metrics/LineLength: + Exclude: + - 'db/schema.rb' +Metrics/BlockLength: + Exclude: + - 'db/schema.rb' + - 'config/routes.rb' + - 'db/seeds.rb' + - 'config/environments/production.rb' diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml new file mode 100644 index 0000000..08012f6 --- /dev/null +++ b/.rubocop_todo.yml @@ -0,0 +1,80 @@ +# This configuration was generated by +# `rubocop --auto-gen-config` +# on 2019-04-05 17:51:53 -0300 using RuboCop version 0.66.0. +# The point is for the user to remove these configuration records +# one by one as the offenses are removed from the code base. +# Note that changes in the inspected code, or installation of new +# versions of RuboCop, may require this file to be generated again. + +# Offense count: 2 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: empty_lines, no_empty_lines +Layout/EmptyLinesAroundBlockBody: + Exclude: + - 'db/schema.rb' + +# Offense count: 1 +Metrics/AbcSize: + Max: 18 + +# Offense count: 1 +Metrics/CyclomaticComplexity: + Max: 9 + +# Offense count: 2 +# Configuration parameters: CountComments, ExcludedMethods. +Metrics/MethodLength: + Max: 13 + +# Offense count: 1 +Metrics/PerceivedComplexity: + Max: 9 + +# Offense count: 1 +Style/Documentation: + Exclude: + - 'spec/**/*' + - 'test/**/*' + - 'config/application.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: when_needed, always, never +Style/FrozenStringLiteralComment: + Exclude: + - 'db/schema.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +Style/IfUnlessModifier: + Exclude: + - 'bin/bundle' + +# Offense count: 2 +Style/MixinUsage: + Exclude: + - 'bin/setup' + - 'bin/update' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: MinDigits, Strict. +Style/NumericLiterals: + Exclude: + - 'db/schema.rb' + +# Offense count: 4 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, ConsistentQuotesInMultiline. +# SupportedStyles: single_quotes, double_quotes +Style/StringLiterals: + Exclude: + - 'db/schema.rb' + +# Offense count: 12 +# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns. +# URISchemes: http, https +Metrics/LineLength: + Max: 190 diff --git a/Gemfile b/Gemfile index 36e2537..6fe2f1a 100644 --- a/Gemfile +++ b/Gemfile @@ -1,3 +1,5 @@ +# frozen_string_literal: true + source 'https://rubygems.org' git_source(:github) { |repo| "https://github.com/#{repo}.git" } @@ -10,36 +12,32 @@ gem 'sqlite3' # Use Puma as the app server gem 'puma', '~> 3.11' # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder -# gem 'jbuilder', '~> 2.5' +gem 'jbuilder', '~> 2.5' # Use Redis adapter to run Action Cable in production # gem 'redis', '~> 4.0' # Use ActiveModel has_secure_password -# gem 'bcrypt', '~> 3.1.7' +gem 'bcrypt', '~> 3.1.7' # Use ActiveStorage variant # gem 'mini_magick', '~> 4.8' -# Use Capistrano for deployment -# gem 'capistrano-rails', group: :development - # Reduces boot times through caching; required in config/boot.rb gem 'bootsnap', '>= 1.1.0', require: false -# Use Rack CORS for handling Cross-Origin Resource Sharing (CORS), making cross-origin AJAX possible -# gem 'rack-cors' +# Use Rack CORS for handling Cross-Origin Resource Sharing (CORS), +# making cross-origin AJAX possible +gem 'rack-cors' group :development, :test do - # Call 'byebug' anywhere in the code to stop execution and get a debugger console - gem 'byebug', platforms: [:mri, :mingw, :x64_mingw] + gem 'factory_bot_rails' + gem 'pry' end group :development do gem 'listen', '>= 3.0.5', '< 3.2' - # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring + # Spring speeds up development by keeping your application running in + # the background. Read more: https://github.com/rails/spring + gem 'rubocop' gem 'spring' gem 'spring-watcher-listen', '~> 2.0.0' end - - -# Windows does not include zoneinfo files, so bundle the tzinfo-data gem -gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] diff --git a/Gemfile.lock b/Gemfile.lock index 38f2c72..c6e74d0 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -43,18 +43,29 @@ GEM minitest (~> 5.1) tzinfo (~> 1.1) arel (9.0.0) + ast (2.4.0) + bcrypt (3.1.12) bootsnap (1.4.2) msgpack (~> 1.0) builder (3.2.3) - byebug (11.0.1) + coderay (1.1.2) concurrent-ruby (1.1.5) crass (1.0.4) erubi (1.8.0) + factory_bot (5.0.2) + activesupport (>= 4.2.0) + factory_bot_rails (5.0.1) + factory_bot (~> 5.0.0) + railties (>= 4.2.0) ffi (1.10.0) globalid (0.4.2) activesupport (>= 4.2.0) i18n (1.6.0) concurrent-ruby (~> 1.0) + jaro_winkler (1.5.2) + jbuilder (2.8.0) + activesupport (>= 4.2.0) + multi_json (>= 1.2) listen (3.1.5) rb-fsevent (~> 0.9, >= 0.9.4) rb-inotify (~> 0.9, >= 0.9.7) @@ -72,11 +83,20 @@ GEM mini_portile2 (2.4.0) minitest (5.11.3) msgpack (1.2.9) + multi_json (1.13.1) nio4r (2.3.1) nokogiri (1.10.2) mini_portile2 (~> 2.4.0) + parallel (1.16.2) + parser (2.6.2.0) + ast (~> 2.4.0) + pry (0.12.2) + coderay (~> 1.1.0) + method_source (~> 0.9.0) + psych (3.1.0) puma (3.12.1) rack (2.0.7) + rack-cors (1.0.3) rack-test (1.1.0) rack (>= 1.0, < 3) rails (5.2.3) @@ -103,10 +123,20 @@ GEM method_source rake (>= 0.8.7) thor (>= 0.19.0, < 2.0) + rainbow (3.0.0) rake (12.3.2) rb-fsevent (0.10.3) rb-inotify (0.10.0) ffi (~> 1.0) + rubocop (0.66.0) + jaro_winkler (~> 1.5.1) + parallel (~> 1.10) + parser (>= 2.5, != 2.5.1.1) + psych (>= 3.1.0) + rainbow (>= 2.2.2, < 4.0) + ruby-progressbar (~> 1.7) + unicode-display_width (>= 1.4.0, < 1.6) + ruby-progressbar (1.10.0) ruby_dep (1.5.0) spring (2.0.2) activesupport (>= 4.2) @@ -125,6 +155,7 @@ GEM thread_safe (0.3.6) tzinfo (1.2.5) thread_safe (~> 0.1) + unicode-display_width (1.5.0) websocket-driver (0.7.0) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.3) @@ -133,15 +164,19 @@ PLATFORMS ruby DEPENDENCIES + bcrypt (~> 3.1.7) bootsnap (>= 1.1.0) - byebug + factory_bot_rails + jbuilder (~> 2.5) listen (>= 3.0.5, < 3.2) + pry puma (~> 3.11) + rack-cors rails (~> 5.2.3) + rubocop spring spring-watcher-listen (~> 2.0.0) sqlite3 - tzinfo-data RUBY VERSION ruby 2.5.5p157 diff --git a/Rakefile b/Rakefile index e85f913..84df238 100644 --- a/Rakefile +++ b/Rakefile @@ -1,5 +1,8 @@ -# Add your own tasks in files placed in lib/tasks ending in .rake, -# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. +# frozen_string_literal: true + +# Add your own tasks in files placed in lib/tasks ending in .rake, for +# example lib/tasks/capistrano.rake, and they will automatically be +# available to Rake. require_relative 'config/application' diff --git a/app/channels/application_cable/channel.rb b/app/channels/application_cable/channel.rb index d672697..9aec230 100644 --- a/app/channels/application_cable/channel.rb +++ b/app/channels/application_cable/channel.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module ApplicationCable class Channel < ActionCable::Channel::Base end diff --git a/app/channels/application_cable/connection.rb b/app/channels/application_cable/connection.rb index 0ff5442..8d6c2a1 100644 --- a/app/channels/application_cable/connection.rb +++ b/app/channels/application_cable/connection.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module ApplicationCable class Connection < ActionCable::Connection::Base end diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 4ac8823..13c271f 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,2 +1,4 @@ +# frozen_string_literal: true + class ApplicationController < ActionController::API end diff --git a/app/jobs/application_job.rb b/app/jobs/application_job.rb index a009ace..d92ffdd 100644 --- a/app/jobs/application_job.rb +++ b/app/jobs/application_job.rb @@ -1,2 +1,4 @@ +# frozen_string_literal: true + class ApplicationJob < ActiveJob::Base end diff --git a/app/mailers/application_mailer.rb b/app/mailers/application_mailer.rb index 286b223..5ddc43d 100644 --- a/app/mailers/application_mailer.rb +++ b/app/mailers/application_mailer.rb @@ -1,3 +1,6 @@ +# frozen_string_literal: true + +# Enviar correos class ApplicationMailer < ActionMailer::Base default from: 'from@example.com' layout 'mailer' diff --git a/app/models/application_record.rb b/app/models/application_record.rb index 10a4cba..d6a5583 100644 --- a/app/models/application_record.rb +++ b/app/models/application_record.rb @@ -1,3 +1,6 @@ +# frozen_string_literal: true + +# No sé para qué instanciamos de acá la verdad :P class ApplicationRecord < ActiveRecord::Base self.abstract_class = true end diff --git a/bin/bundle b/bin/bundle index f19acf5..6965387 100755 --- a/bin/bundle +++ b/bin/bundle @@ -1,3 +1,109 @@ #!/usr/bin/env ruby -ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) -load Gem.bin_path('bundler', 'bundle') +# frozen_string_literal: true + +# +# This file was generated by Bundler. +# +# The application 'bundle' is installed as part of a gem, and +# this file is here to facilitate running it. +# + +require 'rubygems' + +m = Module.new do + module_function + + def invoked_as_script? + File.expand_path($PROGRAM_NAME) == File.expand_path(__FILE__) + end + + def env_var_version + ENV['BUNDLER_VERSION'] + end + + def cli_arg_version + return unless invoked_as_script? # don't want to hijack other binstubs + return unless 'update'.start_with?(ARGV.first || ' ') # must be running `bundle update` + + bundler_version = nil + update_index = nil + ARGV.each_with_index do |a, i| + if update_index && update_index.succ == i && a =~ Gem::Version::ANCHORED_VERSION_PATTERN + bundler_version = a + end + next unless a =~ /\A--bundler(?:[= ](#{Gem::Version::VERSION_PATTERN}))?\z/ + + bundler_version = Regexp.last_match(1) || '>= 0.a' + update_index = i + end + bundler_version + end + + def gemfile + gemfile = ENV['BUNDLE_GEMFILE'] + return gemfile if gemfile && !gemfile.empty? + + File.expand_path('../Gemfile', __dir__) + end + + def lockfile + lockfile = + case File.basename(gemfile) + when 'gems.rb' then gemfile.sub(/\.rb$/, gemfile) + else "#{gemfile}.lock" + end + File.expand_path(lockfile) + end + + def lockfile_version + return unless File.file?(lockfile) + + lockfile_contents = File.read(lockfile) + return unless lockfile_contents =~ /\n\nBUNDLED WITH\n\s{2,}(#{Gem::Version::VERSION_PATTERN})\n/ + + Regexp.last_match(1) + end + + def bundler_version + @bundler_version ||= begin + env_var_version || cli_arg_version || + lockfile_version || "#{Gem::Requirement.default}.a" + end + end + + def load_bundler! + ENV['BUNDLE_GEMFILE'] ||= gemfile + + # must dup string for RG < 1.8 compatibility + activate_bundler(bundler_version.dup) + end + + def activate_bundler(bundler_version) + if Gem::Version.correct?(bundler_version) && Gem::Version.new(bundler_version).release < Gem::Version.new('2.0') + bundler_version = '< 2' + end + gem_error = activation_error_handling do + gem 'bundler', bundler_version + end + return if gem_error.nil? + + require_error = activation_error_handling do + require 'bundler/version' + end + return if require_error.nil? && Gem::Requirement.new(bundler_version).satisfied_by?(Gem::Version.new(Bundler::VERSION)) + + warn "Activating bundler (#{bundler_version}) failed:\n#{gem_error.message}\n\nTo install the version of bundler this project requires, run `gem install bundler -v '#{bundler_version}'`" + exit 42 + end + + def activation_error_handling + yield + nil + rescue StandardError, LoadError => e + e + end +end + +m.load_bundler! + +load Gem.bin_path('bundler', 'bundle') if m.invoked_as_script? diff --git a/bin/rails b/bin/rails index 5badb2f..3504c3f 100755 --- a/bin/rails +++ b/bin/rails @@ -1,6 +1,8 @@ #!/usr/bin/env ruby +# frozen_string_literal: true + begin - load File.expand_path('../spring', __FILE__) + load File.expand_path('spring', __dir__) rescue LoadError => e raise unless e.message.include?('spring') end diff --git a/bin/rake b/bin/rake index d87d5f5..1fe6cf0 100755 --- a/bin/rake +++ b/bin/rake @@ -1,6 +1,8 @@ #!/usr/bin/env ruby +# frozen_string_literal: true + begin - load File.expand_path('../spring', __FILE__) + load File.expand_path('spring', __dir__) rescue LoadError => e raise unless e.message.include?('spring') end diff --git a/bin/rubocop b/bin/rubocop new file mode 100755 index 0000000..73e5cb7 --- /dev/null +++ b/bin/rubocop @@ -0,0 +1,29 @@ +#!/usr/bin/env ruby +# frozen_string_literal: true + +# +# This file was generated by Bundler. +# +# The application 'rubocop' is installed as part of a gem, and +# this file is here to facilitate running it. +# + +require 'pathname' +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', + Pathname.new(__FILE__).realpath) + +bundle_binstub = File.expand_path('bundle', __dir__) + +if File.file?(bundle_binstub) + if /This file was generated by Bundler/.match?(File.read(bundle_binstub, 300)) + load(bundle_binstub) + else + abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run. +Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.") + end +end + +require 'rubygems' +require 'bundler/setup' + +load Gem.bin_path('rubocop', 'rubocop') diff --git a/bin/setup b/bin/setup index a334d86..f17c566 100755 --- a/bin/setup +++ b/bin/setup @@ -1,4 +1,6 @@ #!/usr/bin/env ruby +# frozen_string_literal: true + require 'fileutils' include FileUtils diff --git a/bin/spring b/bin/spring index fb2ec2e..9bd27ec 100755 --- a/bin/spring +++ b/bin/spring @@ -1,4 +1,5 @@ #!/usr/bin/env ruby +# frozen_string_literal: true # This file loads spring without using Bundler, in order to be fast. # It gets overwritten when you run the `spring binstub` command. @@ -8,7 +9,7 @@ unless defined?(Spring) require 'bundler' lockfile = Bundler::LockfileParser.new(Bundler.default_lockfile.read) - spring = lockfile.specs.detect { |spec| spec.name == "spring" } + spring = lockfile.specs.detect { |spec| spec.name == 'spring' } if spring Gem.use_paths Gem.dir, Bundler.bundle_path.to_s, *Gem.path gem 'spring', spring.version diff --git a/bin/update b/bin/update index 67d0d49..0b5306f 100755 --- a/bin/update +++ b/bin/update @@ -1,4 +1,6 @@ #!/usr/bin/env ruby +# frozen_string_literal: true + require 'fileutils' include FileUtils diff --git a/config.ru b/config.ru index f7ba0b5..842bccc 100644 --- a/config.ru +++ b/config.ru @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # This file is used by Rack-based servers to start the application. require_relative 'config/environment' diff --git a/config/application.rb b/config/application.rb index 69d1d7d..b6e6718 100644 --- a/config/application.rb +++ b/config/application.rb @@ -1,22 +1,25 @@ +# frozen_string_literal: true + require_relative 'boot' -require "rails" +require 'rails' # Pick the frameworks you want: -require "active_model/railtie" -require "active_job/railtie" -require "active_record/railtie" -require "active_storage/engine" -require "action_controller/railtie" -require "action_mailer/railtie" -require "action_view/railtie" -require "action_cable/engine" +require 'active_model/railtie' +require 'active_job/railtie' +require 'active_record/railtie' +require 'active_storage/engine' +require 'action_controller/railtie' +require 'action_mailer/railtie' +require 'action_view/railtie' +require 'action_cable/engine' # require "sprockets/railtie" -require "rails/test_unit/railtie" +require 'rails/test_unit/railtie' # Require the gems listed in Gemfile, including any gems # you've limited to :test, :development, or :production. Bundler.require(*Rails.groups) +# MiniLoom! module MiniloomApi class Application < Rails::Application # Initialize configuration defaults for originally generated Rails version. diff --git a/config/boot.rb b/config/boot.rb index b9e460c..c04863f 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 426333b..d5abe55 100644 --- a/config/environment.rb +++ b/config/environment.rb @@ -1,3 +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 d52ec9e..57350f2 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -1,9 +1,13 @@ -Rails.application.configure do - # Settings specified here will take precedence over those in config/application.rb. +# frozen_string_literal: true - # In the development environment your application's code is reloaded on - # every request. This slows down response time but is perfect for development - # since you don't have to restart the web server when you make code changes. +Rails.application.configure do + # Settings specified here will take precedence over those in + # config/application.rb. + + # In the development environment your application's code is reloaded + # on every request. This slows down response time but is perfect for + # development since you don't have to restart the web server when you + # make code changes. config.cache_classes = false # Do not eager load code on boot. @@ -27,7 +31,8 @@ Rails.application.configure do config.cache_store = :null_store end - # Store uploaded files on the local file system (see config/storage.yml for options) + # Store uploaded files on the local file system (see + # config/storage.yml for options) config.active_storage.service = :local # Don't care if the mailer can't send. @@ -44,11 +49,11 @@ Rails.application.configure do # Highlight code that triggered database queries in logs. config.active_record.verbose_query_logs = true - # Raises error for missing translations # config.action_view.raise_on_missing_translations = true - # Use an evented file watcher to asynchronously detect changes in source code, - # routes, locales, etc. This feature depends on the listen gem. + # Use an evented file watcher to asynchronously detect changes in + # source code, routes, locales, etc. This feature depends on the + # listen gem. config.file_watcher = ActiveSupport::EventedFileUpdateChecker end diff --git a/config/environments/production.rb b/config/environments/production.rb index f888b1a..bd428d2 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -1,5 +1,8 @@ +# frozen_string_literal: true + Rails.application.configure do - # Settings specified here will take precedence over those in config/application.rb. + # Settings specified here will take precedence over those in + # config/application.rb. # Code is not reloaded between requests. config.cache_classes = true @@ -14,67 +17,72 @@ Rails.application.configure do config.consider_all_requests_local = false config.action_controller.perform_caching = true - # Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"] - # or in config/master.key. This key is used to decrypt credentials (and other encrypted files). + # Ensures that a master key has been made available in either + # ENV["RAILS_MASTER_KEY"] or in config/master.key. This key is used to + # decrypt credentials (and other encrypted files). # config.require_master_key = true - # Disable serving static files from the `/public` folder by default since - # Apache or NGINX already handles this. - config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present? + # Disable serving static files from the `/public` folder by default + # since Apache or NGINX already handles this. + config.public_file_server.enabled = + ENV['RAILS_SERVE_STATIC_FILES'].present? - # Enable serving of images, stylesheets, and JavaScripts from an asset server. + # Enable serving of images, stylesheets, and JavaScripts from an asset + # server. # config.action_controller.asset_host = 'http://assets.example.com' # Specifies the header that your server uses for sending files. # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX - # Store uploaded files on the local file system (see config/storage.yml for options) + # Store uploaded files on the local file system (see + # config/storage.yml for options) config.active_storage.service = :local # Mount Action Cable outside main process or domain # config.action_cable.mount_path = nil # config.action_cable.url = 'wss://example.com/cable' - # config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ] + # config.action_cable.allowed_request_origins = [ 'http://example.com', + # /http:\/\/example.*/ ] - # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. - # config.force_ssl = true + # Force all access to the app over SSL, use Strict-Transport-Security, + # and use secure cookies. + config.force_ssl = true - # Use the lowest log level to ensure availability of diagnostic information - # when problems arise. + # Use the lowest log level to ensure availability of diagnostic + # information when problems arise. config.log_level = :debug # Prepend all log lines with the following tags. - config.log_tags = [ :request_id ] + config.log_tags = [:request_id] # Use a different cache store in production. # config.cache_store = :mem_cache_store - # Use a real queuing backend for Active Job (and separate queues per environment) + # Use a real queuing backend for Active Job (and separate queues per + # environment) # config.active_job.queue_adapter = :resque # config.active_job.queue_name_prefix = "miniloom-api_#{Rails.env}" config.action_mailer.perform_caching = false # Ignore bad email addresses and do not raise email delivery errors. - # Set this to true and configure the email server for immediate delivery to raise delivery errors. + # Set this to true and configure the email server for immediate + # delivery to raise delivery errors. + # # config.action_mailer.raise_delivery_errors = false - # Enable locale fallbacks for I18n (makes lookups for any locale fall back to - # the I18n.default_locale when a translation cannot be found). + # Enable locale fallbacks for I18n (makes lookups for any locale fall + # back to the I18n.default_locale when a translation cannot be found). config.i18n.fallbacks = true # Send deprecation notices to registered listeners. config.active_support.deprecation = :notify - - # Use default logging formatter so that PID and timestamp are not suppressed. - config.log_formatter = ::Logger::Formatter.new - # Use a different logger for distributed setups. - # require 'syslog/logger' - # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name') + require 'syslog/logger' + config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new('miniloom')) - if ENV["RAILS_LOG_TO_STDOUT"].present? + if ENV['RAILS_LOG_TO_STDOUT'].present? logger = ActiveSupport::Logger.new(STDOUT) logger.formatter = config.log_formatter config.logger = ActiveSupport::TaggedLogging.new(logger) diff --git a/config/environments/test.rb b/config/environments/test.rb index 0a38fd3..5f9329d 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -1,5 +1,8 @@ +# frozen_string_literal: true + Rails.application.configure do - # Settings specified here will take precedence over those in config/application.rb. + # Settings specified here will take precedence over those in + # config/application.rb. # The test environment is used exclusively to run your application's # test suite. You never need to work with it otherwise. Remember that @@ -7,16 +10,17 @@ Rails.application.configure do # and recreated between test runs. Don't rely on the data there! config.cache_classes = true - # Do not eager load code on boot. This avoids loading your whole application - # just for the purpose of running a single test. If you are using a tool that - # preloads Rails for running tests, you may have to set it to true. + # Do not eager load code on boot. This avoids loading your whole + # application just for the purpose of running a single test. If you + # are using a tool that preloads Rails for running tests, you may have + # to set it to true. config.eager_load = false - # Configure public file server for tests with Cache-Control for performance. + # Configure public file server for tests with Cache-Control for + # performance. config.public_file_server.enabled = true - config.public_file_server.headers = { - 'Cache-Control' => "public, max-age=#{1.hour.to_i}" - } + config.public_file_server.headers = { 'Cache-Control' => "public, + max-age=#{1.hour.to_i}" } # Show full error reports and disable caching. config.consider_all_requests_local = true @@ -28,7 +32,8 @@ Rails.application.configure do # Disable request forgery protection in test environment. config.action_controller.allow_forgery_protection = false - # Store uploaded files on the local file system in a temporary directory + # Store uploaded files on the local file system in a temporary + # directory config.active_storage.service = :test config.action_mailer.perform_caching = false diff --git a/config/initializers/application_controller_renderer.rb b/config/initializers/application_controller_renderer.rb index 89d2efa..6d56e43 100644 --- a/config/initializers/application_controller_renderer.rb +++ b/config/initializers/application_controller_renderer.rb @@ -1,3 +1,5 @@ +# 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/backtrace_silencers.rb b/config/initializers/backtrace_silencers.rb index 59385cd..dc60ac8 100644 --- a/config/initializers/backtrace_silencers.rb +++ b/config/initializers/backtrace_silencers.rb @@ -1,7 +1,12 @@ +# 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. -# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ } +# 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/cors.rb b/config/initializers/cors.rb index 3b1c1b5..82eafe5 100644 --- a/config/initializers/cors.rb +++ b/config/initializers/cors.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Be sure to restart your server when you modify this file. # Avoid CORS issues when API is called from the frontend app. diff --git a/config/initializers/filter_parameter_logging.rb b/config/initializers/filter_parameter_logging.rb index 4a994e1..7a4f47b 100644 --- a/config/initializers/filter_parameter_logging.rb +++ b/config/initializers/filter_parameter_logging.rb @@ -1,3 +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/inflections.rb b/config/initializers/inflections.rb index ac033bf..dc84742 100644 --- a/config/initializers/inflections.rb +++ b/config/initializers/inflections.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Be sure to restart your server when you modify this file. # Add new inflection rules using the following format. Inflections diff --git a/config/initializers/mime_types.rb b/config/initializers/mime_types.rb index dc18996..be6fedc 100644 --- a/config/initializers/mime_types.rb +++ b/config/initializers/mime_types.rb @@ -1,3 +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/wrap_parameters.rb b/config/initializers/wrap_parameters.rb index bbfc396..b5fe52c 100644 --- a/config/initializers/wrap_parameters.rb +++ b/config/initializers/wrap_parameters.rb @@ -1,9 +1,12 @@ +# frozen_string_literal: true + # Be sure to restart your server when you modify this file. # This file contains settings for ActionController::ParamsWrapper which # is enabled by default. -# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array. +# Enable parameter wrapping for JSON. You can disable this by setting +# :format to an empty array. ActiveSupport.on_load(:action_controller) do wrap_parameters format: [:json] end diff --git a/config/puma.rb b/config/puma.rb index a5eccf8..134e88b 100644 --- a/config/puma.rb +++ b/config/puma.rb @@ -1,22 +1,25 @@ +# 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 } +# 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 threads_count, threads_count -# Specifies the `port` that Puma will listen on to receive requests; default is 3000. +# 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 +# Specifies the number of `workers` to boot in clustered mode. Workers +# are forked webserver processes. If using threads and workers together # 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). diff --git a/config/routes.rb b/config/routes.rb index 787824f..47cc16e 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + Rails.application.routes.draw do # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html end diff --git a/config/spring.rb b/config/spring.rb index 9fa7863..c5933e4 100644 --- a/config/spring.rb +++ b/config/spring.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + %w[ .ruby-version .rbenv-vars diff --git a/db/seeds.rb b/db/seeds.rb index 1beea2a..8e9b8f9 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -1,7 +1 @@ -# This file should contain all the record creation needed to seed the database with its default values. -# The data can then be loaded with the rails db:seed command (or created alongside the database with db:setup). -# -# Examples: -# -# movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }]) -# Character.create(name: 'Luke', movie: movies.first) +# frozen_string_literal: true diff --git a/test/test_helper.rb b/test/test_helper.rb index 3ab84e3..47606bd 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -1,10 +1,15 @@ +# frozen_string_literal: true + ENV['RAILS_ENV'] ||= 'test' require_relative '../config/environment' require 'rails/test_help' -class ActiveSupport::TestCase - # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order. - fixtures :all +module ActiveSupport + class TestCase + # Setup all fixtures in test/fixtures/*.yml for all tests in + # alphabetical order. + fixtures :all - # Add more helper methods to be used by all tests here... + # Add more helper methods to be used by all tests here... + end end