Skip to content

Commit

Permalink
unsafe corrections
Browse files Browse the repository at this point in the history
  • Loading branch information
Stanislav Katkov committed Jan 3, 2024
1 parent 1055376 commit 67ea1cf
Show file tree
Hide file tree
Showing 83 changed files with 159 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ AllCops:
# These have been copied from the Rails repo
- test/unit/behaviors/*
# Don't second guess the generated schemas
- test/dummy/db/*schema.rb
- test/dummy/*

Performance:
Exclude:
Expand Down
2 changes: 2 additions & 0 deletions Appraisals
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

appraise "rails-7" do
gem "rails", github: "rails/rails", branch: "7-0-stable"
end
Expand Down
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

source "https://rubygems.org"
git_source(:github) { |repo| "https://github.com/#{repo}.git" }

Expand Down
2 changes: 2 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require "bundler/setup"

APP_RAKEFILE = File.expand_path("test/dummy/Rakefile", __dir__)
Expand Down
2 changes: 2 additions & 0 deletions app/jobs/solid_cache/expiry_job.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module SolidCache
class ExpiryJob < ActiveJob::Base
def perform(count, shard: nil, max_age:, max_entries:)
Expand Down
2 changes: 2 additions & 0 deletions app/models/solid_cache/entry.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module SolidCache
class Entry < Record
# This is all quite awkward but it achieves a couple of performance aims
Expand Down
2 changes: 2 additions & 0 deletions app/models/solid_cache/record.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module SolidCache
class Record < ActiveRecord::Base
NULL_INSTRUMENTER = ActiveSupport::Notifications::Instrumenter.new(ActiveSupport::Notifications::Fanout.new)
Expand Down
2 changes: 1 addition & 1 deletion bin/irb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
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))
if File.read(bundle_binstub, 300).include?("This file was generated by Bundler")
load(bundle_binstub)
else
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
Expand Down
2 changes: 2 additions & 0 deletions bin/rails
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

# This command will automatically be run when you run "rails" with Rails gems
# installed from the root of your application.

Expand Down
2 changes: 1 addition & 1 deletion bin/rake
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
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))
if File.read(bundle_binstub, 300).include?("This file was generated by Bundler")
load(bundle_binstub)
else
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
Expand Down
2 changes: 1 addition & 1 deletion bin/rdbg
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
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))
if File.read(bundle_binstub, 300).include?("This file was generated by Bundler")
load(bundle_binstub)
else
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
Expand Down
2 changes: 1 addition & 1 deletion bin/rubocop
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
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))
if File.read(bundle_binstub, 300).include?("This file was generated by Bundler")
load(bundle_binstub)
else
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
Expand Down
2 changes: 2 additions & 0 deletions db/migrate/20230724121448_create_solid_cache_entries.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class CreateSolidCacheEntries < ActiveRecord::Migration[7.0]
def change
create_table :solid_cache_entries do |t|
Expand Down
2 changes: 2 additions & 0 deletions gemfiles/rails_7.gemfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# This file was generated by Appraisal

source "https://rubygems.org"
Expand Down
2 changes: 2 additions & 0 deletions gemfiles/rails_7_1.gemfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# This file was generated by Appraisal

source "https://rubygems.org"
Expand Down
2 changes: 2 additions & 0 deletions gemfiles/rails_main.gemfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# This file was generated by Appraisal

source "https://rubygems.org"
Expand Down
2 changes: 2 additions & 0 deletions lib/active_support/cache/solid_cache_store.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module ActiveSupport
module Cache
SolidCacheStore = SolidCache::Store
Expand Down
2 changes: 2 additions & 0 deletions lib/generators/solid_cache/install/install_generator.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class SolidCache::InstallGenerator < Rails::Generators::Base
class_option :skip_migrations, type: :boolean, default: nil,
desc: "Skip migrations"
Expand Down
2 changes: 2 additions & 0 deletions lib/solid_cache.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require "zeitwerk"
require "solid_cache/engine"

Expand Down
2 changes: 2 additions & 0 deletions lib/solid_cache/cluster.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module SolidCache
class Cluster
include Connections, Execution, Expiry, Stats
Expand Down
2 changes: 2 additions & 0 deletions lib/solid_cache/cluster/connections.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module SolidCache
class Cluster
module Connections
Expand Down
2 changes: 2 additions & 0 deletions lib/solid_cache/cluster/execution.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module SolidCache
class Cluster
module Execution
Expand Down
2 changes: 2 additions & 0 deletions lib/solid_cache/cluster/expiry.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require "concurrent/atomic/atomic_fixnum"

module SolidCache
Expand Down
4 changes: 3 additions & 1 deletion lib/solid_cache/cluster/stats.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module SolidCache
class Cluster
module Stats
Expand All @@ -6,7 +8,7 @@ def initialize(options = {})
end

def stats
stats = {
{
connections: connections.count,
connection_stats: connections_stats
}
Expand Down
2 changes: 2 additions & 0 deletions lib/solid_cache/connections.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module SolidCache
module Connections
def self.from_config(options)
Expand Down
2 changes: 2 additions & 0 deletions lib/solid_cache/connections/sharded.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module SolidCache
module Connections
class Sharded
Expand Down
2 changes: 2 additions & 0 deletions lib/solid_cache/connections/single.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module SolidCache
module Connections
class Single
Expand Down
2 changes: 2 additions & 0 deletions lib/solid_cache/connections/unmanaged.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module SolidCache
module Connections
class Unmanaged
Expand Down
2 changes: 2 additions & 0 deletions lib/solid_cache/engine.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require "active_support"

module SolidCache
Expand Down
2 changes: 2 additions & 0 deletions lib/solid_cache/maglev_hash.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# See https://static.googleusercontent.com/media/research.google.com/en//pubs/archive/44824.pdf

module SolidCache
Expand Down
2 changes: 2 additions & 0 deletions lib/solid_cache/store.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module SolidCache
class Store < ActiveSupport::Cache::Store
include Api, Clusters, Entries, Failsafe
Expand Down
2 changes: 2 additions & 0 deletions lib/solid_cache/store/api.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module SolidCache
class Store
module Api
Expand Down
2 changes: 2 additions & 0 deletions lib/solid_cache/store/clusters.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module SolidCache
class Store
module Clusters
Expand Down
2 changes: 2 additions & 0 deletions lib/solid_cache/store/entries.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module SolidCache
class Store
module Entries
Expand Down
2 changes: 2 additions & 0 deletions lib/solid_cache/store/failsafe.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module SolidCache
class Store
module Failsafe
Expand Down
2 changes: 2 additions & 0 deletions lib/solid_cache/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module SolidCache
VERSION = "0.2.0"
end
2 changes: 2 additions & 0 deletions lib/tasks/solid_cache_tasks.rake
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

desc "Copy over the migration, and set cache"
namespace :solid_cache do
task :install do
Expand Down
2 changes: 2 additions & 0 deletions solid_cache.gemspec
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require_relative "lib/solid_cache/version"

Gem::Specification.new do |spec|
Expand Down
2 changes: 2 additions & 0 deletions test/dummy/Rakefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# 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.

Expand Down
2 changes: 2 additions & 0 deletions test/dummy/app/channels/application_cable/channel.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module ApplicationCable
class Channel < ActionCable::Channel::Base
end
Expand Down
2 changes: 2 additions & 0 deletions test/dummy/app/channels/application_cable/connection.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module ApplicationCable
class Connection < ActionCable::Connection::Base
end
Expand Down
2 changes: 2 additions & 0 deletions test/dummy/app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
# frozen_string_literal: true

class ApplicationController < ActionController::Base
end
2 changes: 2 additions & 0 deletions test/dummy/app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
# frozen_string_literal: true

module ApplicationHelper
end
2 changes: 2 additions & 0 deletions test/dummy/app/jobs/application_job.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class ApplicationJob < ActiveJob::Base
# Automatically retry jobs that encountered a deadlock
# retry_on ActiveRecord::Deadlocked
Expand Down
2 changes: 2 additions & 0 deletions test/dummy/app/mailers/application_mailer.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class ApplicationMailer < ActionMailer::Base
default from: "[email protected]"
layout "mailer"
Expand Down
2 changes: 2 additions & 0 deletions test/dummy/app/models/application_record.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class ApplicationRecord < ActiveRecord::Base
primary_abstract_class
end
2 changes: 2 additions & 0 deletions test/dummy/bin/rails
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

APP_PATH = File.expand_path("../config/application", __dir__)
require_relative "../config/boot"
require "rails/commands"
2 changes: 2 additions & 0 deletions test/dummy/bin/rake
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

require_relative "../config/boot"
require "rake"
Rake.application.run
2 changes: 2 additions & 0 deletions test/dummy/bin/setup
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

require "fileutils"

# path to your application root.
Expand Down
2 changes: 2 additions & 0 deletions test/dummy/config.ru
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# This file is used by Rack-based servers to start the application.

require_relative "config/environment"
Expand Down
2 changes: 2 additions & 0 deletions test/dummy/config/application.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require_relative "boot"

require "rails/all"
Expand Down
2 changes: 2 additions & 0 deletions test/dummy/config/boot.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# Set up gems listed in the Gemfile.
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../../Gemfile", __dir__)

Expand Down
2 changes: 2 additions & 0 deletions test/dummy/config/environment.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# Load the Rails application.
require_relative "application"

Expand Down
2 changes: 2 additions & 0 deletions test/dummy/config/environments/development.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require "active_support/core_ext/integer/time"

Rails.application.configure do
Expand Down
2 changes: 2 additions & 0 deletions test/dummy/config/environments/production.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require "active_support/core_ext/integer/time"

Rails.application.configure do
Expand Down
2 changes: 2 additions & 0 deletions test/dummy/config/environments/test.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require "active_support/core_ext/integer/time"

# The test environment is used exclusively to run your application's
Expand Down
2 changes: 2 additions & 0 deletions test/dummy/config/initializers/assets.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# Be sure to restart your server when you modify this file.

# Version of your assets, change this if you want to expire all your assets.
Expand Down
1 change: 1 addition & 0 deletions test/dummy/config/initializers/content_security_policy.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
# Be sure to restart your server when you modify this file.

# Define an application-wide content security policy.
Expand Down
2 changes: 2 additions & 0 deletions test/dummy/config/initializers/filter_parameter_logging.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# Be sure to restart your server when you modify this file.

# Configure parameters to be filtered from the log file. Use this to limit dissemination of
Expand Down
1 change: 1 addition & 0 deletions test/dummy/config/initializers/inflections.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
# Be sure to restart your server when you modify this file.

# Add new inflection rules using the following format. Inflections
Expand Down
1 change: 1 addition & 0 deletions test/dummy/config/initializers/permissions_policy.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
# Define an application-wide HTTP permissions policy. For further
# information see https://developers.google.com/web/updates/2018/06/feature-policy
#
Expand Down
2 changes: 2 additions & 0 deletions test/dummy/config/puma.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# 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
Expand Down
Loading

0 comments on commit 67ea1cf

Please sign in to comment.