Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Sorbet to linter #760

Merged
merged 8 commits into from
Jul 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }

ruby_version = ENV.fetch('GEMFILE_RUBY_VERSION', nil)
ruby ruby_version if ruby_version

# Declare your gem's dependencies in good_job.gemspec.
# Bundler will treat runtime dependencies like base dependencies, and
# development dependencies will be added by default to the :development group.
Expand All @@ -22,6 +19,10 @@ gem 'nokogiri'
gem 'pg', platforms: [:mri, :mingw, :x64_mingw]
gem 'rack', '~> 2.0'
gem 'rails'
gem "sorbet", group: :development
gem "sorbet-runtime"
gem "spoom", require: false, group: :development
gem "tapioca", require: false, group: :development

platforms :ruby do
gem "activerecord-explain-analyze", require: false
Expand Down
51 changes: 51 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ GEM
timeout
net-smtp (0.3.3)
net-protocol
netrc (0.11.0)
nio4r (2.5.9)
nio4r (2.5.9-java)
nokogiri (1.15.2)
Expand All @@ -271,6 +272,7 @@ GEM
ast (~> 2.4.1)
racc
pg (1.5.3)
prettier_print (1.2.1)
protocol-hpack (1.4.2)
protocol-http (0.24.3)
protocol-http1 (0.15.0)
Expand Down Expand Up @@ -336,6 +338,11 @@ GEM
zeitwerk (~> 2.5)
rainbow (3.1.1)
rake (13.0.6)
rbi (0.0.16)
ast
parser (>= 2.6.4.0)
sorbet-runtime (>= 0.5.9204)
unparser
rbtrace (0.4.14)
ffi (>= 1.0.6)
msgpack (>= 0.4.3)
Expand Down Expand Up @@ -398,9 +405,43 @@ GEM
rubyzip (>= 1.2.2, < 3.0)
websocket (~> 1.0)
smart_properties (1.17.0)
sorbet (0.5.10908)
sorbet-static (= 0.5.10908)
sorbet-runtime (0.5.10908)
sorbet-static (0.5.10908-java)
sorbet-static (0.5.10908-universal-darwin-14)
sorbet-static (0.5.10908-universal-darwin-15)
sorbet-static (0.5.10908-universal-darwin-16)
sorbet-static (0.5.10908-universal-darwin-17)
sorbet-static (0.5.10908-universal-darwin-18)
sorbet-static (0.5.10908-universal-darwin-19)
sorbet-static (0.5.10908-universal-darwin-20)
sorbet-static (0.5.10908-universal-darwin-21)
sorbet-static (0.5.10908-universal-darwin-22)
sorbet-static (0.5.10908-x86_64-linux)
sorbet-static-and-runtime (0.5.10908)
sorbet (= 0.5.10908)
sorbet-runtime (= 0.5.10908)
spoom (1.2.2)
erubi (>= 1.10.0)
sorbet (>= 0.5.10187)
sorbet-runtime (>= 0.5.9204)
syntax_tree (>= 6.1.1)
thor (>= 0.19.2)
spoon (0.0.6)
ffi
stackprof (0.2.25)
syntax_tree (6.1.1)
prettier_print (>= 1.2.0)
tapioca (0.11.7)
bundler (>= 2.2.25)
netrc (>= 0.11.0)
parallel (>= 1.21.0)
rbi (~> 0.0.0, >= 0.0.16)
sorbet-static-and-runtime (>= 0.5.10187)
spoom (~> 1.2.0, >= 1.2.0)
thor (>= 1.2.0)
yard-sorbet
terminal-table (3.0.2)
unicode-display_width (>= 1.1.1, < 3)
thor (1.2.2)
Expand All @@ -414,6 +455,9 @@ GEM
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
unicode-display_width (2.4.2)
unparser (0.6.8)
diff-lcs (~> 1.3)
parser (>= 3.2.0)
webrick (1.8.1)
websocket (1.2.9)
websocket-driver (0.7.5)
Expand All @@ -426,6 +470,9 @@ GEM
yard (0.9.34)
yard-activesupport-concern (0.0.1)
yard (>= 0.8)
yard-sorbet (0.8.1)
sorbet-runtime (>= 0.5)
yard (>= 0.9)
zeitwerk (2.6.8)

PLATFORMS
Expand Down Expand Up @@ -473,7 +520,11 @@ DEPENDENCIES
rubocop-rails
rubocop-rspec
selenium-webdriver
sorbet
sorbet-runtime
spoom
stackprof
tapioca
yard
yard-activesupport-concern

Expand Down
4 changes: 3 additions & 1 deletion app/models/good_job/base_record.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
# frozen_string_literal: true
module GoodJob
ACTIVE_RECORD_PARENT_CLASS = Object.const_get(GoodJob.active_record_parent_class)

# Base ActiveRecord class that all GoodJob models inherit from.
# Parent class can be configured with +GoodJob.active_record_parent_class+.
# @!parse
# class BaseRecord < ActiveRecord::Base; end
class BaseRecord < Object.const_get(GoodJob.active_record_parent_class)
class BaseRecord < ACTIVE_RECORD_PARENT_CLASS
self.abstract_class = true

def self.migration_pending_warning!
Expand Down
4 changes: 4 additions & 0 deletions bin/lint
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ def system!(*args)
end

FileUtils.chdir GEM_ROOT do
puts "\n== Sorbet =="

system! "bundle exec srb tc"

puts "\n== Rubocop =="

flags = []
Expand Down
27 changes: 27 additions & 0 deletions bin/tapioca
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

#
# This file was generated by Bundler.
#
# The application 'tapioca' is installed as part of a gem, and
# this file is here to facilitate running it.
#

ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)

bundle_binstub = File.expand_path("bundle", __dir__)

if File.file?(bundle_binstub)
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.
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("tapioca", "tapioca")
4 changes: 2 additions & 2 deletions lib/good_job/scheduler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ def remaining_cache_count

# Custom sub-class of +Concurrent::ThreadPoolExecutor+ to add additional worker status.
# @private
class ThreadPoolExecutor < Concurrent::ThreadPoolExecutor
class ThreadPoolExecutor < ::Concurrent::ThreadPoolExecutor
# Number of inactive threads available to execute tasks.
# https://github.com/ruby-concurrency/concurrent-ruby/issues/684#issuecomment-427594437
# @return [Integer]
Expand All @@ -353,7 +353,7 @@ def ready_worker_count

# Custom sub-class of +Concurrent::TimerSet+ for additional behavior.
# @private
class TimerSet < Concurrent::TimerSet
class TimerSet < ::Concurrent::TimerSet
# Number of scheduled jobs in the queue
# @return [Integer]
def length
Expand Down
3 changes: 3 additions & 0 deletions sorbet/config
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
--dir
.
--ignore=vendor/
10 changes: 10 additions & 0 deletions sorbet/rbi/annotations/actionmailer.rbi

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading