Skip to content

Commit

Permalink
Update standard rules (#5360)
Browse files Browse the repository at this point in the history
* update standard rules and run standard:fix

* Fix more standard errors

* standardize
  • Loading branch information
mperham authored Jun 5, 2022
1 parent 2d743d7 commit 55ced28
Show file tree
Hide file tree
Showing 40 changed files with 143 additions and 183 deletions.
8 changes: 4 additions & 4 deletions .standard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ ruby_version: 2.5.0
fix: true
parallel: true
ignore:
- test/**/*
- examples/**/*
- myapp/**/*
- 'lib/sidekiq.rb':
- Lint/InheritException
- 'lib/sidekiq/extensions/**/*':
- Style/MissingRespondToMissing
- 'lib/**/*':
- '**/*':
- Lint/RescueException
- Security/YAMLLoad
- Style/GlobalVars
- 'test/test*.rb':
- Lint/ConstantDefinitionInBlock

4 changes: 2 additions & 2 deletions examples/por.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require 'sidekiq'
require "sidekiq"

# Start up sidekiq via
# ./bin/sidekiq -r ./examples/por.rb
Expand All @@ -10,7 +10,7 @@
class PlainOldRuby
include Sidekiq::Job

def perform(how_hard="super hard", how_long=1)
def perform(how_hard = "super hard", how_long = 1)
sleep how_long
puts "Workin' #{how_hard}"
end
Expand Down
12 changes: 6 additions & 6 deletions myapp/Gemfile
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
source 'https://rubygems.org'
source "https://rubygems.org"

gem 'sidekiq', :path => '..'
gem 'rails'
gem 'puma'
gem "sidekiq", path: ".."
gem "rails"
gem "puma"

gem "redis-client"

# Ubuntu required packages to install rails
# apt-get install build-essential patch ruby-dev zlib1g-dev liblzma-dev libsqlite3-dev
platforms :ruby do
gem 'sqlite3'
gem "sqlite3"
end

gem 'after_commit_everywhere'
gem "after_commit_everywhere"
2 changes: 1 addition & 1 deletion myapp/Rakefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# 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'
require_relative "config/application"

Rails.application.load_tasks
28 changes: 14 additions & 14 deletions myapp/app/controllers/work_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,42 +3,42 @@ def index
@count = rand(100)
puts "Adding #{@count} jobs"
@count.times do |x|
HardWorker.perform_async('bubba', 0.01, x)
HardWorker.perform_async("bubba", 0.01, x)
end
end

def email
UserMailer.delay_for(30.seconds).greetings(Time.now)
render :plain => 'enqueued'
render plain: "enqueued"
end

def bulk
Sidekiq::Client.push_bulk('class' => HardWorker,
'args' => [['bob', 1, 1], ['mike', 1, 2]])
render :plain => 'enbulked'
Sidekiq::Client.push_bulk("class" => HardWorker,
"args" => [["bob", 1, 1], ["mike", 1, 2]])
render plain: "enbulked"
end

def long
50.times do |x|
HardWorker.perform_async('bob', 15, x)
HardWorker.perform_async("bob", 15, x)
end
render :plain => 'enqueued'
render plain: "enqueued"
end

def crash
HardWorker.perform_async('crash', 1, Time.now.to_f)
render :plain => 'enqueued'
HardWorker.perform_async("crash", 1, Time.now.to_f)
render plain: "enqueued"
end

def delayed_post
p = Post.first
unless p
p = Post.create!(:title => "Title!", :body => 'Body!')
p2 = Post.create!(:title => "Other!", :body => 'Second Body!')
else
if p
p2 = Post.second
else
p = Post.create!(title: "Title!", body: "Body!")
p2 = Post.create!(title: "Other!", body: "Second Body!")
end
p.delay.long_method(p2)
render :plain => 'enqueued'
render plain: "enqueued"
end
end
2 changes: 1 addition & 1 deletion myapp/app/mailers/user_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ class UserMailer < ActionMailer::Base
def greetings(now)
@now = now
@hostname = `hostname`.strip
mail(:to => '[email protected]', :subject => 'Ahoy Matey!')
mail(to: "[email protected]", subject: "Ahoy Matey!")
end
end
2 changes: 1 addition & 1 deletion myapp/app/models/post.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
class Post < ActiveRecord::Base
def long_method(other_post)
puts "Running long method with #{self.id} and #{other_post.id}"
puts "Running long method with #{id} and #{other_post.id}"
end

def self.testing
Expand Down
4 changes: 2 additions & 2 deletions myapp/app/workers/hard_worker.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
class HardWorker
include Sidekiq::Worker
sidekiq_options :backtrace => 5
sidekiq_options backtrace: 5

def perform(name, count, salt)
raise name if name == 'crash'
raise name if name == "crash"
logger.info Time.now
sleep count
end
Expand Down
4 changes: 2 additions & 2 deletions myapp/bin/bundle
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/usr/bin/env ruby
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
load Gem.bin_path('bundler', 'bundle')
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
load Gem.bin_path("bundler", "bundle")
10 changes: 5 additions & 5 deletions myapp/bin/rails
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#!/usr/bin/env ruby
begin
load File.expand_path('../spring', __FILE__)
load File.expand_path("../spring", __FILE__)
rescue LoadError => e
raise unless e.message.include?('spring')
raise unless e.message.include?("spring")
end
APP_PATH = File.expand_path('../config/application', __dir__)
require_relative '../config/boot'
require 'rails/commands'
APP_PATH = File.expand_path("../config/application", __dir__)
require_relative "../config/boot"
require "rails/commands"
8 changes: 4 additions & 4 deletions myapp/bin/rake
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#!/usr/bin/env ruby
begin
load File.expand_path('../spring', __FILE__)
load File.expand_path("../spring", __FILE__)
rescue LoadError => e
raise unless e.message.include?('spring')
raise unless e.message.include?("spring")
end
require_relative '../config/boot'
require 'rake'
require_relative "../config/boot"
require "rake"
Rake.application.run
36 changes: 0 additions & 36 deletions myapp/bin/setup

This file was deleted.

2 changes: 1 addition & 1 deletion myapp/config.ru
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# This file is used by Rack-based servers to start the application.

require_relative 'config/environment'
require_relative "config/environment"

run Rails.application
14 changes: 6 additions & 8 deletions myapp/config/application.rb
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
require_relative 'boot'
require_relative "boot"

require 'rails'
%w(
require "rails"
%w[
active_record/railtie
action_controller/railtie
action_view/railtie
action_mailer/railtie
active_job/railtie
sprockets/railtie
).each do |railtie|
begin
require railtie
rescue LoadError
end
].each do |railtie|
require railtie
rescue LoadError
end

# Require the gems listed in Gemfile, including any gems
Expand Down
4 changes: 2 additions & 2 deletions myapp/config/boot.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)

require 'bundler/setup' # Set up gems listed in the Gemfile.
require "bundler/setup" # Set up gems listed in the Gemfile.
2 changes: 1 addition & 1 deletion myapp/config/environment.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Load the Rails application.
require_relative 'application'
require_relative "application"

# Initialize the Rails application.
Rails.application.initialize!
8 changes: 4 additions & 4 deletions myapp/config/environments/development.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@

# Enable/disable caching. By default caching is disabled.
# Run rails dev:cache to toggle caching.
if Rails.root.join('tmp', 'caching-dev.txt').exist?
if Rails.root.join("tmp", "caching-dev.txt").exist?
config.action_controller.perform_caching = true

config.cache_store = :memory_store
config.public_file_server.headers = {
'Cache-Control' => "public, max-age=#{2.days.to_i}"
"Cache-Control" => "public, max-age=#{2.days.to_i}"
}
else
config.action_controller.perform_caching = false
Expand All @@ -28,7 +28,7 @@
end

# Store uploaded files on the local file system (see config/storage.yml for options)
#config.active_storage.service = :local
# config.active_storage.service = :local

# Don't care if the mailer can't send.
config.action_mailer.raise_delivery_errors = false
Expand Down Expand Up @@ -57,5 +57,5 @@

# 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
# config.file_watcher = ActiveSupport::EventedFileUpdateChecker
end
12 changes: 6 additions & 6 deletions myapp/config/environments/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
config.eager_load = true

# Full error reports are disabled and caching is turned on.
config.consider_all_requests_local = false
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"]
Expand All @@ -20,7 +20,7 @@

# 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?
config.public_file_server.enabled = ENV["RAILS_SERVE_STATIC_FILES"].present?

# Compress JavaScripts and CSS.
config.assets.js_compressor = :uglifier
Expand All @@ -39,7 +39,7 @@
# 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)
#config.active_storage.service = :local
# config.active_storage.service = :local

# Mount Action Cable outside main process or domain
# config.action_cable.mount_path = nil
Expand All @@ -54,7 +54,7 @@
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
Expand Down Expand Up @@ -84,9 +84,9 @@
# config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name')

if ENV["RAILS_LOG_TO_STDOUT"].present?
logger = ActiveSupport::Logger.new(STDOUT)
logger = ActiveSupport::Logger.new($stdout)
logger.formatter = config.log_formatter
config.logger = ActiveSupport::TaggedLogging.new(logger)
config.logger = ActiveSupport::TaggedLogging.new(logger)
end

# Do not dump schema after migrations.
Expand Down
6 changes: 3 additions & 3 deletions myapp/config/environments/test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
# 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}"
"Cache-Control" => "public, max-age=#{1.hour.to_i}"
}

# Show full error reports and disable caching.
config.consider_all_requests_local = true
config.consider_all_requests_local = true
config.action_controller.perform_caching = false

# Raise exceptions instead of rendering exception templates.
Expand All @@ -29,7 +29,7 @@
config.action_controller.allow_forgery_protection = false

# Store uploaded files on the local file system in a temporary directory
#config.active_storage.service = :test
# config.active_storage.service = :test

config.action_mailer.perform_caching = false

Expand Down
2 changes: 1 addition & 1 deletion myapp/config/initializers/secret_token.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
# If you change this key, all old signed cookies will become invalid!
# Make sure the secret is at least 30 characters and all random,
# no regular words or you'll be exposed to dictionary attacks.
Myapp::Application.config.secret_token = 'bdd335500c81ba1f279f9dd8198d1f334445d0193168ed73c1282502180dca27e3e102ec345e99b2acac6a63f7fe29da69c60cc9e76e8da34fb5d4989db24cd8'
Myapp::Application.config.secret_token = "bdd335500c81ba1f279f9dd8198d1f334445d0193168ed73c1282502180dca27e3e102ec345e99b2acac6a63f7fe29da69c60cc9e76e8da34fb5d4989db24cd8"
2 changes: 1 addition & 1 deletion myapp/config/initializers/session_store.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Be sure to restart your server when you modify this file.

Rails.application.config.session_store :cookie_store, key: '_myapp_session'
Rails.application.config.session_store :cookie_store, key: "_myapp_session"
Loading

0 comments on commit 55ced28

Please sign in to comment.