Skip to content

Commit 67ea1cf

Browse files
author
Stanislav Katkov
committed
unsafe corrections
1 parent 1055376 commit 67ea1cf

File tree

83 files changed

+159
-11
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+159
-11
lines changed

.rubocop.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ AllCops:
1515
# These have been copied from the Rails repo
1616
- test/unit/behaviors/*
1717
# Don't second guess the generated schemas
18-
- test/dummy/db/*schema.rb
18+
- test/dummy/*
1919

2020
Performance:
2121
Exclude:

Appraisals

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
appraise "rails-7" do
24
gem "rails", github: "rails/rails", branch: "7-0-stable"
35
end

Gemfile

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
source "https://rubygems.org"
24
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
35

Rakefile

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require "bundler/setup"
24

35
APP_RAKEFILE = File.expand_path("test/dummy/Rakefile", __dir__)

app/jobs/solid_cache/expiry_job.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module SolidCache
24
class ExpiryJob < ActiveJob::Base
35
def perform(count, shard: nil, max_age:, max_entries:)

app/models/solid_cache/entry.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module SolidCache
24
class Entry < Record
35
# This is all quite awkward but it achieves a couple of performance aims

app/models/solid_cache/record.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module SolidCache
24
class Record < ActiveRecord::Base
35
NULL_INSTRUMENTER = ActiveSupport::Notifications::Instrumenter.new(ActiveSupport::Notifications::Fanout.new)

bin/irb

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
1313
bundle_binstub = File.expand_path("bundle", __dir__)
1414

1515
if File.file?(bundle_binstub)
16-
if /This file was generated by Bundler/.match?(File.read(bundle_binstub, 300))
16+
if File.read(bundle_binstub, 300).include?("This file was generated by Bundler")
1717
load(bundle_binstub)
1818
else
1919
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.

bin/rails

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
#!/usr/bin/env ruby
2+
# frozen_string_literal: true
3+
24
# This command will automatically be run when you run "rails" with Rails gems
35
# installed from the root of your application.
46

bin/rake

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
1313
bundle_binstub = File.expand_path("bundle", __dir__)
1414

1515
if File.file?(bundle_binstub)
16-
if /This file was generated by Bundler/.match?(File.read(bundle_binstub, 300))
16+
if File.read(bundle_binstub, 300).include?("This file was generated by Bundler")
1717
load(bundle_binstub)
1818
else
1919
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.

bin/rdbg

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
1313
bundle_binstub = File.expand_path("bundle", __dir__)
1414

1515
if File.file?(bundle_binstub)
16-
if /This file was generated by Bundler/.match?(File.read(bundle_binstub, 300))
16+
if File.read(bundle_binstub, 300).include?("This file was generated by Bundler")
1717
load(bundle_binstub)
1818
else
1919
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.

bin/rubocop

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
1313
bundle_binstub = File.expand_path("bundle", __dir__)
1414

1515
if File.file?(bundle_binstub)
16-
if /This file was generated by Bundler/.match?(File.read(bundle_binstub, 300))
16+
if File.read(bundle_binstub, 300).include?("This file was generated by Bundler")
1717
load(bundle_binstub)
1818
else
1919
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.

db/migrate/20230724121448_create_solid_cache_entries.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
class CreateSolidCacheEntries < ActiveRecord::Migration[7.0]
24
def change
35
create_table :solid_cache_entries do |t|

gemfiles/rails_7.gemfile

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
# This file was generated by Appraisal
24

35
source "https://rubygems.org"

gemfiles/rails_7_1.gemfile

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
# This file was generated by Appraisal
24

35
source "https://rubygems.org"

gemfiles/rails_main.gemfile

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
# This file was generated by Appraisal
24

35
source "https://rubygems.org"

lib/active_support/cache/solid_cache_store.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module ActiveSupport
24
module Cache
35
SolidCacheStore = SolidCache::Store

lib/generators/solid_cache/install/install_generator.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
class SolidCache::InstallGenerator < Rails::Generators::Base
24
class_option :skip_migrations, type: :boolean, default: nil,
35
desc: "Skip migrations"

lib/solid_cache.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require "zeitwerk"
24
require "solid_cache/engine"
35

lib/solid_cache/cluster.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module SolidCache
24
class Cluster
35
include Connections, Execution, Expiry, Stats

lib/solid_cache/cluster/connections.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module SolidCache
24
class Cluster
35
module Connections

lib/solid_cache/cluster/execution.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module SolidCache
24
class Cluster
35
module Execution

lib/solid_cache/cluster/expiry.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require "concurrent/atomic/atomic_fixnum"
24

35
module SolidCache

lib/solid_cache/cluster/stats.rb

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module SolidCache
24
class Cluster
35
module Stats
@@ -6,7 +8,7 @@ def initialize(options = {})
68
end
79

810
def stats
9-
stats = {
11+
{
1012
connections: connections.count,
1113
connection_stats: connections_stats
1214
}

lib/solid_cache/connections.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module SolidCache
24
module Connections
35
def self.from_config(options)

lib/solid_cache/connections/sharded.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module SolidCache
24
module Connections
35
class Sharded

lib/solid_cache/connections/single.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module SolidCache
24
module Connections
35
class Single

lib/solid_cache/connections/unmanaged.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module SolidCache
24
module Connections
35
class Unmanaged

lib/solid_cache/engine.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require "active_support"
24

35
module SolidCache

lib/solid_cache/maglev_hash.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
# See https://static.googleusercontent.com/media/research.google.com/en//pubs/archive/44824.pdf
24

35
module SolidCache

lib/solid_cache/store.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module SolidCache
24
class Store < ActiveSupport::Cache::Store
35
include Api, Clusters, Entries, Failsafe

lib/solid_cache/store/api.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module SolidCache
24
class Store
35
module Api

lib/solid_cache/store/clusters.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module SolidCache
24
class Store
35
module Clusters

lib/solid_cache/store/entries.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module SolidCache
24
class Store
35
module Entries

lib/solid_cache/store/failsafe.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module SolidCache
24
class Store
35
module Failsafe

lib/solid_cache/version.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module SolidCache
24
VERSION = "0.2.0"
35
end

lib/tasks/solid_cache_tasks.rake

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
desc "Copy over the migration, and set cache"
24
namespace :solid_cache do
35
task :install do

solid_cache.gemspec

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require_relative "lib/solid_cache/version"
24

35
Gem::Specification.new do |spec|

test/dummy/Rakefile

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
# Add your own tasks in files placed in lib/tasks ending in .rake,
24
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
35

test/dummy/app/channels/application_cable/channel.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module ApplicationCable
24
class Channel < ActionCable::Channel::Base
35
end

test/dummy/app/channels/application_cable/connection.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module ApplicationCable
24
class Connection < ActionCable::Connection::Base
35
end
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
1+
# frozen_string_literal: true
2+
13
class ApplicationController < ActionController::Base
24
end
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
1+
# frozen_string_literal: true
2+
13
module ApplicationHelper
24
end

test/dummy/app/jobs/application_job.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
class ApplicationJob < ActiveJob::Base
24
# Automatically retry jobs that encountered a deadlock
35
# retry_on ActiveRecord::Deadlocked

test/dummy/app/mailers/application_mailer.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
class ApplicationMailer < ActionMailer::Base
24
default from: "[email protected]"
35
layout "mailer"
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
class ApplicationRecord < ActiveRecord::Base
24
primary_abstract_class
35
end

test/dummy/bin/rails

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
#!/usr/bin/env ruby
2+
# frozen_string_literal: true
3+
24
APP_PATH = File.expand_path("../config/application", __dir__)
35
require_relative "../config/boot"
46
require "rails/commands"

test/dummy/bin/rake

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
#!/usr/bin/env ruby
2+
# frozen_string_literal: true
3+
24
require_relative "../config/boot"
35
require "rake"
46
Rake.application.run

test/dummy/bin/setup

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
#!/usr/bin/env ruby
2+
# frozen_string_literal: true
3+
24
require "fileutils"
35

46
# path to your application root.

test/dummy/config.ru

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
# This file is used by Rack-based servers to start the application.
24

35
require_relative "config/environment"

test/dummy/config/application.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require_relative "boot"
24

35
require "rails/all"

test/dummy/config/boot.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
# Set up gems listed in the Gemfile.
24
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../../Gemfile", __dir__)
35

test/dummy/config/environment.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
# Load the Rails application.
24
require_relative "application"
35

test/dummy/config/environments/development.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require "active_support/core_ext/integer/time"
24

35
Rails.application.configure do

test/dummy/config/environments/production.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require "active_support/core_ext/integer/time"
24

35
Rails.application.configure do

test/dummy/config/environments/test.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require "active_support/core_ext/integer/time"
24

35
# The test environment is used exclusively to run your application's

test/dummy/config/initializers/assets.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
# Be sure to restart your server when you modify this file.
24

35
# Version of your assets, change this if you want to expire all your assets.

test/dummy/config/initializers/content_security_policy.rb

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# frozen_string_literal: true
12
# Be sure to restart your server when you modify this file.
23

34
# Define an application-wide content security policy.

test/dummy/config/initializers/filter_parameter_logging.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
# Be sure to restart your server when you modify this file.
24

35
# Configure parameters to be filtered from the log file. Use this to limit dissemination of

test/dummy/config/initializers/inflections.rb

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# frozen_string_literal: true
12
# Be sure to restart your server when you modify this file.
23

34
# Add new inflection rules using the following format. Inflections

test/dummy/config/initializers/permissions_policy.rb

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# frozen_string_literal: true
12
# Define an application-wide HTTP permissions policy. For further
23
# information see https://developers.google.com/web/updates/2018/06/feature-policy
34
#

test/dummy/config/puma.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
# Puma can serve each request in a thread from an internal thread pool.
24
# The `threads` method setting takes two numbers: a minimum and maximum.
35
# Any libraries that use thread pools should be configured to match

0 commit comments

Comments
 (0)