tech(Sorbet): prepare usage of sorbet to avoid defensive programming style [casting date to datetime]
This commit is contained in:
parent
ec78340c06
commit
d6d9db9721
5 changed files with 23 additions and 1 deletions
2
Gemfile
2
Gemfile
|
@ -120,6 +120,8 @@ group :development do
|
||||||
end
|
end
|
||||||
|
|
||||||
group :development, :test do
|
group :development, :test do
|
||||||
|
gem 'sorbet'
|
||||||
|
gem 'sorbet-runtime'
|
||||||
gem 'graphql-schema_comparator'
|
gem 'graphql-schema_comparator'
|
||||||
gem 'mina', require: false # Deploy
|
gem 'mina', require: false # Deploy
|
||||||
gem 'pry-byebug' # Call 'byebug' anywhere in the code to stop execution and get a debugger console
|
gem 'pry-byebug' # Call 'byebug' anywhere in the code to stop execution and get a debugger console
|
||||||
|
|
14
Gemfile.lock
14
Gemfile.lock
|
@ -677,6 +677,18 @@ GEM
|
||||||
tilt (~> 2.0)
|
tilt (~> 2.0)
|
||||||
skylight (5.0.1)
|
skylight (5.0.1)
|
||||||
activesupport (>= 5.2.0)
|
activesupport (>= 5.2.0)
|
||||||
|
sorbet (0.5.9827)
|
||||||
|
sorbet-static (= 0.5.9827)
|
||||||
|
sorbet-runtime (0.5.9827)
|
||||||
|
sorbet-static (0.5.9827-universal-darwin-14)
|
||||||
|
sorbet-static (0.5.9827-universal-darwin-15)
|
||||||
|
sorbet-static (0.5.9827-universal-darwin-16)
|
||||||
|
sorbet-static (0.5.9827-universal-darwin-17)
|
||||||
|
sorbet-static (0.5.9827-universal-darwin-18)
|
||||||
|
sorbet-static (0.5.9827-universal-darwin-19)
|
||||||
|
sorbet-static (0.5.9827-universal-darwin-20)
|
||||||
|
sorbet-static (0.5.9827-universal-darwin-21)
|
||||||
|
sorbet-static (0.5.9827-x86_64-linux)
|
||||||
spreadsheet_architect (4.1.0)
|
spreadsheet_architect (4.1.0)
|
||||||
axlsx_styler (>= 1.0.0, < 2)
|
axlsx_styler (>= 1.0.0, < 2)
|
||||||
caxlsx (>= 2.0.2, < 4)
|
caxlsx (>= 2.0.2, < 4)
|
||||||
|
@ -874,6 +886,8 @@ DEPENDENCIES
|
||||||
sib-api-v3-sdk
|
sib-api-v3-sdk
|
||||||
simple_xlsx_reader
|
simple_xlsx_reader
|
||||||
skylight
|
skylight
|
||||||
|
sorbet
|
||||||
|
sorbet-runtime
|
||||||
spreadsheet_architect
|
spreadsheet_architect
|
||||||
spring
|
spring
|
||||||
spring-commands-rspec
|
spring-commands-rspec
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
# typed: true
|
||||||
# == Schema Information
|
# == Schema Information
|
||||||
#
|
#
|
||||||
# Table name: dossiers
|
# Table name: dossiers
|
||||||
|
@ -38,6 +39,7 @@
|
||||||
# user_id :integer
|
# user_id :integer
|
||||||
#
|
#
|
||||||
class Dossier < ApplicationRecord
|
class Dossier < ApplicationRecord
|
||||||
|
extend T::Sig
|
||||||
self.ignored_columns = [:en_construction_conservation_extension]
|
self.ignored_columns = [:en_construction_conservation_extension]
|
||||||
include DossierFilteringConcern
|
include DossierFilteringConcern
|
||||||
include DossierRebaseConcern
|
include DossierRebaseConcern
|
||||||
|
@ -233,8 +235,8 @@ class Dossier < ApplicationRecord
|
||||||
scope :en_instruction, -> { not_archived.state_en_instruction }
|
scope :en_instruction, -> { not_archived.state_en_instruction }
|
||||||
scope :termine, -> { not_archived.state_termine }
|
scope :termine, -> { not_archived.state_termine }
|
||||||
|
|
||||||
|
sig { params(args: DateTime).returns(T.untyped) }
|
||||||
scope :processed_in_month, -> (date) do
|
scope :processed_in_month, -> (date) do
|
||||||
date = date.to_datetime
|
|
||||||
state_termine
|
state_termine
|
||||||
.joins(:traitements)
|
.joins(:traitements)
|
||||||
.where(traitements: { processed_at: date.beginning_of_month..date.end_of_month })
|
.where(traitements: { processed_at: date.beginning_of_month..date.end_of_month })
|
||||||
|
|
3
sorbet/config
Normal file
3
sorbet/config
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
--dir
|
||||||
|
.
|
||||||
|
--ignore=/vendor/bundle
|
|
@ -13,6 +13,7 @@ require 'rspec/rails'
|
||||||
require 'axe-rspec'
|
require 'axe-rspec'
|
||||||
require 'devise'
|
require 'devise'
|
||||||
require 'shoulda-matchers'
|
require 'shoulda-matchers'
|
||||||
|
require 'sorbet-runtime'
|
||||||
|
|
||||||
# Requires supporting ruby files with custom matchers and macros, etc, in
|
# Requires supporting ruby files with custom matchers and macros, etc, in
|
||||||
# spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are
|
# spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are
|
||||||
|
|
Loading…
Reference in a new issue