Skip to content

Commit

Permalink
rubocop fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryan Kulp committed Oct 10, 2023
1 parent 4f7a805 commit 9ef59cb
Show file tree
Hide file tree
Showing 18 changed files with 106 additions and 113 deletions.
46 changes: 23 additions & 23 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,36 +3,36 @@ git_source(:github) { |repo| "https://github.com/#{repo}.git" }

ruby '3.2.0'

gem 'rails', '7.1.0'
gem 'sprockets-rails'
gem 'pg'
gem 'puma', '6'
gem 'chartkick'
gem 'delayed' # delayed_job_active_record rails 7 fork: https://github.com/betterment/delayed
gem 'devise'
gem 'figaro', git: 'https://github.com/ryanckulp/figaro' # patched version for Ruby 3.2.0 File.exist?()
gem 'groupdate' # used by Chartkick
gem 'httparty'
gem 'importmap-rails'
gem 'turbo-rails'
gem 'stimulus-rails'
gem 'tailwindcss-rails'
gem 'jbuilder'
gem 'redis'
gem 'httparty'
gem 'figaro', git: 'https://github.com/ryanckulp/figaro' # patched version for Ruby 3.2.0 File.exist?()
gem 'rename', '1.1.3', git: 'https://github.com/ryanckulp/rename' # remove this gem after use
gem 'delayed' # delayed_job_active_record rails 7 fork: https://github.com/betterment/delayed
gem 'metamagic' # easily insert metatags for SEO / opengraph
gem 'rack-cors', :require => 'rack/cors'
gem 'pg'
gem 'postmark-rails'
gem 'devise'
gem 'puma', '6'
gem 'rack-cors', :require => 'rack/cors'
gem 'rails', '7.1.0'
gem 'redis'
gem 'rename', '1.1.3', git: 'https://github.com/ryanckulp/rename' # remove this gem after use
gem 'sprockets-rails'
gem 'stimulus-rails'
gem 'stripe'
gem 'chartkick'
gem 'groupdate' # used by Chartkick
gem 'tailwindcss-rails'
gem 'turbo-rails'

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: %i[ mingw mswin x64_mingw jruby ]
gem 'tzinfo-data', platforms: %i[mingw mswin x64_mingw jruby]

# Reduces boot times through caching; required in config/boot.rb
gem 'bootsnap', require: false

group :development, :test do
gem 'debug', platforms: %i[ mri mingw x64_mingw ]
gem 'debug', platforms: %i[mri mingw x64_mingw]
gem 'rubocop', require: false # code styling
gem 'rubocop-capybara', require: false
gem 'rubocop-factory_bot', require: false
Expand All @@ -41,17 +41,17 @@ group :development, :test do
end

group :development do
gem 'web-console'
gem 'letter_opener' # view mailers in browser
gem 'web-console'
end

group :test do
gem 'capybara'
gem 'selenium-webdriver'
gem 'webdrivers'
gem 'rspec-rails', '6.0.3'
gem 'factory_bot_rails'
gem 'faker'
gem 'rspec-rails', '6.0.3'
gem 'selenium-webdriver'
gem 'shoulda-callback-matchers'
gem 'shoulda-matchers'
gem 'faker'
gem 'webdrivers'
end
3 changes: 1 addition & 2 deletions app/controllers/account_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ class AccountController < ApplicationController
before_action :authenticate_user!
before_action :set_flashes

def index
end
def index; end

def update
current_user.update(account_update_params)
Expand Down
3 changes: 1 addition & 2 deletions app/controllers/admin/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ class Admin::UsersController < ApplicationController
before_action :authenticate_user!
before_action :set_user

def edit
end
def edit; end

def update
@user.update(user_params)
Expand Down
5 changes: 1 addition & 4 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,12 @@ class ApplicationController < ActionController::Base

def after_sign_in_path_for(resource)
resource.paying_customer? ? dashboard_index_path : subscribe_index_path # point these wherever you want
end
end

def maybe_skip_onboarding
redirect_to dashboard_index_path, notice: "You're already subscribed" if current_user.finished_onboarding?
end


protected

# whitelist extra User model params by uncommenting below and adding User attrs as keys
# def configure_permitted_parameters
# devise_parameter_sanitizer.permit(:sign_up, keys: [:username])
Expand Down
3 changes: 1 addition & 2 deletions app/controllers/dashboard_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ class DashboardController < ApplicationController
before_action :authenticate_user!
before_action :set_flashes

def index
end
def index; end

private

Expand Down
5 changes: 2 additions & 3 deletions app/controllers/pages_controller.rb
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
class PagesController < ApplicationController
before_action :authenticate_user!, only: [:logout]

def home
end
def home; end

def logout
sign_out(current_user)
redirect_to root_path
end

def page
@page_key = request.path[1..-1]
@page_key = request.path[1..]
render "pages/#{@page_key}"
end
end
3 changes: 1 addition & 2 deletions app/controllers/subscribe_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,5 @@ class SubscribeController < ApplicationController
before_action :authenticate_user!
before_action :maybe_skip_onboarding

def index
end
def index; end
end
4 changes: 3 additions & 1 deletion app/mailers/application_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ class ApplicationMailer < ActionMailer::Base
layout 'mailer'
default from: '"Support Team" <[email protected]>'

# mailer views live in views/mailers
# rubocop:disable Lint/MissingSuper
def self.inherited(subclass)
# lets mailer views live in views/mailers, much cleaner
subclass.default template_path: "mailers/#{subclass.name.to_s.underscore}"
end
# rubocop:enable Lint/MissingSuper
end
2 changes: 1 addition & 1 deletion app/models/concerns/signupable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module Signupable
# :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
# devise :database_authenticatable, :registerable, :recoverable, :rememberable
# validates :email, uniqueness: { case_sensitive: false }, presence: true

devise :database_authenticatable, :registerable, :recoverable, :rememberable
validates :email, uniqueness: { case_sensitive: false }, presence: true
end
Expand Down
5 changes: 2 additions & 3 deletions config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ class Application < Rails::Application
# Please, add to the `ignore` list any other `lib` subdirectories that do
# not contain `.rb` files, or that should not be reloaded or eager loaded.
# Common ones are `templates`, `generators`, or `middleware`, for example.
config.autoload_lib(ignore: %w(assets tasks))

config.autoload_lib(ignore: %w[assets tasks])

# allow cross origin requests
config.middleware.insert_before 0, Rack::Cors do
Expand All @@ -39,7 +38,7 @@ class Application < Rails::Application

# customize generators
config.generators do |g|
g.test_framework :rspec, :fixture => false
g.test_framework :rspec, :fixture => false
g.fixture_replacement :factory_bot, dir: 'spec/factories'
g.view_specs = false
g.helper_specs = false
Expand Down
8 changes: 4 additions & 4 deletions config/environments/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,12 @@
config.force_ssl = true

# Log to STDOUT by default
config.logger = ActiveSupport::Logger.new(STDOUT)
.tap { |logger| logger.formatter = ::Logger::Formatter.new }
.then { |logger| ActiveSupport::TaggedLogging.new(logger) }
config.logger = ActiveSupport::Logger.new($stdout)
.tap { |logger| logger.formatter = ::Logger::Formatter.new }
.then { |logger| ActiveSupport::TaggedLogging.new(logger) }

# Prepend all log lines with the following tags.
config.log_tags = [ :request_id ]
config.log_tags = [:request_id]

# Info include generic and useful information about system operation, but avoids logging too much
# information to avoid inadvertent exposure of personally identifiable information (PII). If you
Expand Down
4 changes: 2 additions & 2 deletions config/initializers/filter_parameter_logging.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Be sure to restart your server when you modify this file.

# Configure parameters to be partially matched (e.g. passw matches password) and filtered from the log file.
# Use this to limit dissemination of sensitive information.
# Configure parameters to be partially matched (e.g. passw matches password) and filtered from the log file.
# Use this to limit dissemination of sensitive information.
# See the ActiveSupport::ParameterFilter documentation for supported notations and behaviors.
Rails.application.config.filter_parameters += [
:passw, :secret, :token, :_key, :crypt, :salt, :certificate, :otp, :ssn
Expand Down
4 changes: 2 additions & 2 deletions config/puma.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# 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

Expand All @@ -15,7 +15,7 @@

# 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.
#
Expand Down
8 changes: 4 additions & 4 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@
match '/cancel' => 'billing_portal#destroy', via: [:get]

# static pages
pages = %w(
pages = %w[
privacy terms
)
]

pages.each do |page|
get "/#{page}", to: "pages##{page}", as: "#{page.gsub('-', '_')}"
get "/#{page}", to: "pages##{page}", as: page.gsub('-', '_').to_s
end

# admin panels
authenticated :user, -> user { user.admin? } do
authenticated :user, ->(user) { user.admin? } do
namespace :admin do
resources :dashboard, only: [:index]
resources :impersonations, only: [:new]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ def up
unless column_exists?(:active_storage_blobs, :service_name)
add_column :active_storage_blobs, :service_name, :string

if configured_service = ActiveStorage::Blob.service.name
if (configured_service = ActiveStorage::Blob.service.name)
ActiveStorage::Blob.unscoped.update_all(service_name: configured_service)
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,21 @@ def change
t.belongs_to :blob, null: false, index: false, type: blobs_primary_key_type
t.string :variation_digest, null: false

t.index %i[ blob_id variation_digest ], name: "index_active_storage_variant_records_uniqueness", unique: true
t.index %i[blob_id variation_digest], name: "index_active_storage_variant_records_uniqueness", unique: true
t.foreign_key :active_storage_blobs, column: :blob_id
end
end

private
def primary_key_type
config = Rails.configuration.generators
config.options[config.orm][:primary_key_type] || :primary_key
end

def blobs_primary_key_type
pkey_name = connection.primary_key(:active_storage_blobs)
pkey_column = connection.columns(:active_storage_blobs).find { |c| c.name == pkey_name }
pkey_column.bigint? ? :bigint : pkey_column.type
end
def primary_key_type
config = Rails.configuration.generators
config.options[config.orm][:primary_key_type] || :primary_key
end

def blobs_primary_key_type
pkey_name = connection.primary_key(:active_storage_blobs)
pkey_column = connection.columns(:active_storage_blobs).find { |c| c.name == pkey_name }
pkey_column.bigint? ? :bigint : pkey_column.type
end
end
1 change: 1 addition & 0 deletions lib/tasks/scheduler.rake
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ end
task :reminder_to_start_trial => :environment do
User.where(created_at: 24.hours.ago..23.hours.ago).each do |user|
next if user.paying_customer?

UserMailer.reminder_to_start_trial(user).deliver_later
end
end
Expand Down
Loading

0 comments on commit 9ef59cb

Please sign in to comment.