rubocop-sorbet 0.6.1 → 0.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
 - data/.github/workflows/ci.yml +26 -0
 - data/.gitignore +1 -0
 - data/Gemfile +1 -0
 - data/Gemfile.lock +5 -3
 - data/README.md +7 -0
 - data/bin/rubocop +29 -0
 - data/config/default.yml +28 -1
 - data/dev.yml +1 -1
 - data/lib/rubocop/cop/sorbet/callback_conditionals_binding.rb +138 -0
 - data/lib/rubocop/cop/sorbet/forbid_t_unsafe.rb +26 -0
 - data/lib/rubocop/cop/sorbet/{forbid_extend_t_sig_helpers_in_shims.rb → rbi/forbid_extend_t_sig_helpers_in_shims.rb} +0 -0
 - data/lib/rubocop/cop/sorbet/rbi/forbid_rbi_outside_of_sorbet_dir.rb +31 -0
 - data/lib/rubocop/cop/sorbet/{single_line_rbi_class_module_definitions.rb → rbi/single_line_rbi_class_module_definitions.rb} +0 -0
 - data/lib/rubocop/cop/sorbet/sigils/valid_sigil.rb +4 -2
 - data/lib/rubocop/cop/sorbet_cops.rb +6 -2
 - data/lib/rubocop/sorbet/version.rb +1 -1
 - data/manual/cops.md +3 -0
 - data/manual/cops_sorbet.md +115 -1
 - data/service.yml +1 -4
 - metadata +10 -7
 - data/.shopify-build/VERSION +0 -1
 - data/.shopify-build/rubocop-sorbet.yml +0 -16
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 309687789d8de94ff0cc8c0d64361cd227ab332ffdd16ab0248d588639dfcd80
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: ca39d50843f2e577ed0a0328c9707e21af175daacd8c92b9b4403bc2195c4cff
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: f774385eec35af24755af1cc5e7f5de554bedf0f6a475e3235879aee61a2c68a818ea87ca4663daa17bb807c862d911264284d1f3270e852166c3e84cde32e7d
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: d6d91114e9c70bc64fa5adf6679a689c12263caa352f7f38b6d96d36609a81e90bc18f369e42b1605259262626114aac6fd5d50f7c91bced3e2f24e2f606fbc4
         
     | 
| 
         @@ -0,0 +1,26 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            name: CI
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            on: [push, pull_request]
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            env:
         
     | 
| 
      
 6 
     | 
    
         
            +
              SRB_SKIP_GEM_RBIS: true
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
            jobs:
         
     | 
| 
      
 9 
     | 
    
         
            +
              build:
         
     | 
| 
      
 10 
     | 
    
         
            +
                runs-on: ubuntu-latest
         
     | 
| 
      
 11 
     | 
    
         
            +
                strategy:
         
     | 
| 
      
 12 
     | 
    
         
            +
                  fail-fast: false
         
     | 
| 
      
 13 
     | 
    
         
            +
                  matrix:
         
     | 
| 
      
 14 
     | 
    
         
            +
                    ruby: [ 2.5, 2.6, 2.7, 3.0 ]
         
     | 
| 
      
 15 
     | 
    
         
            +
                name: Test Ruby ${{ matrix.ruby }}
         
     | 
| 
      
 16 
     | 
    
         
            +
                steps:
         
     | 
| 
      
 17 
     | 
    
         
            +
                  - uses: actions/checkout@v2
         
     | 
| 
      
 18 
     | 
    
         
            +
                  - name: Set up Ruby
         
     | 
| 
      
 19 
     | 
    
         
            +
                    uses: ruby/setup-ruby@v1
         
     | 
| 
      
 20 
     | 
    
         
            +
                    with:
         
     | 
| 
      
 21 
     | 
    
         
            +
                      ruby-version: ${{ matrix.ruby }}
         
     | 
| 
      
 22 
     | 
    
         
            +
                      bundler-cache: true
         
     | 
| 
      
 23 
     | 
    
         
            +
                  - name: Lint Ruby files
         
     | 
| 
      
 24 
     | 
    
         
            +
                    run: bin/rubocop
         
     | 
| 
      
 25 
     | 
    
         
            +
                  - name: Run tests
         
     | 
| 
      
 26 
     | 
    
         
            +
                    run: bin/rspec
         
     | 
    
        data/.gitignore
    CHANGED
    
    
    
        data/Gemfile
    CHANGED
    
    
    
        data/Gemfile.lock
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            PATH
         
     | 
| 
       2 
2 
     | 
    
         
             
              remote: .
         
     | 
| 
       3 
3 
     | 
    
         
             
              specs:
         
     | 
| 
       4 
     | 
    
         
            -
                rubocop-sorbet (0.6. 
     | 
| 
      
 4 
     | 
    
         
            +
                rubocop-sorbet (0.6.2)
         
     | 
| 
       5 
5 
     | 
    
         
             
                  rubocop
         
     | 
| 
       6 
6 
     | 
    
         | 
| 
       7 
7 
     | 
    
         
             
            GEM
         
     | 
| 
         @@ -12,6 +12,7 @@ GEM 
     | 
|
| 
       12 
12 
     | 
    
         
             
                  ice_nine (~> 0.11.0)
         
     | 
| 
       13 
13 
     | 
    
         
             
                  memoizable (~> 0.4.0)
         
     | 
| 
       14 
14 
     | 
    
         
             
                ast (2.4.0)
         
     | 
| 
      
 15 
     | 
    
         
            +
                byebug (11.1.3)
         
     | 
| 
       15 
16 
     | 
    
         
             
                concord (0.1.5)
         
     | 
| 
       16 
17 
     | 
    
         
             
                  adamantium (~> 0.2.0)
         
     | 
| 
       17 
18 
     | 
    
         
             
                  equalizer (~> 0.0.9)
         
     | 
| 
         @@ -27,7 +28,7 @@ GEM 
     | 
|
| 
       27 
28 
     | 
    
         
             
                rainbow (3.0.0)
         
     | 
| 
       28 
29 
     | 
    
         
             
                rake (13.0.1)
         
     | 
| 
       29 
30 
     | 
    
         
             
                regexp_parser (1.7.0)
         
     | 
| 
       30 
     | 
    
         
            -
                rexml (3.2. 
     | 
| 
      
 31 
     | 
    
         
            +
                rexml (3.2.5)
         
     | 
| 
       31 
32 
     | 
    
         
             
                rspec (3.8.0)
         
     | 
| 
       32 
33 
     | 
    
         
             
                  rspec-core (~> 3.8.0)
         
     | 
| 
       33 
34 
     | 
    
         
             
                  rspec-expectations (~> 3.8.0)
         
     | 
| 
         @@ -71,6 +72,7 @@ PLATFORMS 
     | 
|
| 
       71 
72 
     | 
    
         
             
              ruby
         
     | 
| 
       72 
73 
     | 
    
         | 
| 
       73 
74 
     | 
    
         
             
            DEPENDENCIES
         
     | 
| 
      
 75 
     | 
    
         
            +
              byebug
         
     | 
| 
       74 
76 
     | 
    
         
             
              rake (>= 12.3.3)
         
     | 
| 
       75 
77 
     | 
    
         
             
              rspec
         
     | 
| 
       76 
78 
     | 
    
         
             
              rubocop-shopify
         
     | 
| 
         @@ -79,4 +81,4 @@ DEPENDENCIES 
     | 
|
| 
       79 
81 
     | 
    
         
             
              yard (~> 0.9)
         
     | 
| 
       80 
82 
     | 
    
         | 
| 
       81 
83 
     | 
    
         
             
            BUNDLED WITH
         
     | 
| 
       82 
     | 
    
         
            -
                
     | 
| 
      
 84 
     | 
    
         
            +
               2.2.16
         
     | 
    
        data/README.md
    CHANGED
    
    | 
         @@ -17,6 +17,13 @@ or, if you use `Bundler`, add this line your application's `Gemfile`: 
     | 
|
| 
       17 
17 
     | 
    
         
             
            gem 'rubocop-sorbet', require: false
         
     | 
| 
       18 
18 
     | 
    
         
             
            ```
         
     | 
| 
       19 
19 
     | 
    
         | 
| 
      
 20 
     | 
    
         
            +
            Note: in order to use the [Sorbet/SignatureBuildOrder](https://github.com/Shopify/rubocop-sorbet/blob/master/manual/cops_sorbet.md#sorbetsignaturebuildorder) cop autocorrect feature, it is necessary
         
     | 
| 
      
 21 
     | 
    
         
            +
            to install `unparser` in addition to `rubocop-sorbet`.
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
            ```ruby
         
     | 
| 
      
 24 
     | 
    
         
            +
            gem "unparser", require: false
         
     | 
| 
      
 25 
     | 
    
         
            +
            ```
         
     | 
| 
      
 26 
     | 
    
         
            +
             
     | 
| 
       20 
27 
     | 
    
         
             
            ## Usage
         
     | 
| 
       21 
28 
     | 
    
         | 
| 
       22 
29 
     | 
    
         
             
            You need to tell RuboCop to load the Sorbet extension. There are three ways to do this:
         
     | 
    
        data/bin/rubocop
    ADDED
    
    | 
         @@ -0,0 +1,29 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            #!/usr/bin/env ruby
         
     | 
| 
      
 2 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
            #
         
     | 
| 
      
 5 
     | 
    
         
            +
            # This file was generated by Bundler.
         
     | 
| 
      
 6 
     | 
    
         
            +
            #
         
     | 
| 
      
 7 
     | 
    
         
            +
            # The application 'rubocop' is installed as part of a gem, and
         
     | 
| 
      
 8 
     | 
    
         
            +
            # this file is here to facilitate running it.
         
     | 
| 
      
 9 
     | 
    
         
            +
            #
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
            require "pathname"
         
     | 
| 
      
 12 
     | 
    
         
            +
            ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
         
     | 
| 
      
 13 
     | 
    
         
            +
              Pathname.new(__FILE__).realpath)
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
            bundle_binstub = File.expand_path("../bundle", __FILE__)
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
            if File.file?(bundle_binstub)
         
     | 
| 
      
 18 
     | 
    
         
            +
              if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
         
     | 
| 
      
 19 
     | 
    
         
            +
                load(bundle_binstub)
         
     | 
| 
      
 20 
     | 
    
         
            +
              else
         
     | 
| 
      
 21 
     | 
    
         
            +
                abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
         
     | 
| 
      
 22 
     | 
    
         
            +
            Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
         
     | 
| 
      
 23 
     | 
    
         
            +
              end
         
     | 
| 
      
 24 
     | 
    
         
            +
            end
         
     | 
| 
      
 25 
     | 
    
         
            +
             
     | 
| 
      
 26 
     | 
    
         
            +
            require "rubygems"
         
     | 
| 
      
 27 
     | 
    
         
            +
            require "bundler/setup"
         
     | 
| 
      
 28 
     | 
    
         
            +
             
     | 
| 
      
 29 
     | 
    
         
            +
            load(Gem.bin_path("rubocop", "rubocop"))
         
     | 
    
        data/config/default.yml
    CHANGED
    
    | 
         @@ -14,6 +14,11 @@ Sorbet/BindingConstantWithoutTypeAlias: 
     | 
|
| 
       14 
14 
     | 
    
         
             
              Enabled: true
         
     | 
| 
       15 
15 
     | 
    
         
             
              VersionAdded: 0.2.0
         
     | 
| 
       16 
16 
     | 
    
         | 
| 
      
 17 
     | 
    
         
            +
            Sorbet/CallbackConditionalsBinding:
         
     | 
| 
      
 18 
     | 
    
         
            +
              Description: 'Ensures callback conditionals are bound to the right type.'
         
     | 
| 
      
 19 
     | 
    
         
            +
              Enabled: true
         
     | 
| 
      
 20 
     | 
    
         
            +
              VersionAdded: 0.7.0
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
       17 
22 
     | 
    
         
             
            Sorbet/CheckedTrueInSignature:
         
     | 
| 
       18 
23 
     | 
    
         
             
              Description: 'Disallows the usage of `checked(true)` in signatures.'
         
     | 
| 
       19 
24 
     | 
    
         
             
              Enabled: true
         
     | 
| 
         @@ -42,7 +47,7 @@ Sorbet/FalseSigil: 
     | 
|
| 
       42 
47 
     | 
    
         
             
              Description: 'All files must be at least at strictness `false`.'
         
     | 
| 
       43 
48 
     | 
    
         
             
              Enabled: true
         
     | 
| 
       44 
49 
     | 
    
         
             
              VersionAdded: 0.3.3
         
     | 
| 
       45 
     | 
    
         
            -
              SuggestedStrictness:  
     | 
| 
      
 50 
     | 
    
         
            +
              SuggestedStrictness: "false"
         
     | 
| 
       46 
51 
     | 
    
         
             
              Include:
         
     | 
| 
       47 
52 
     | 
    
         
             
              - "**/*.rb"
         
     | 
| 
       48 
53 
     | 
    
         
             
              - "**/*.rbi"
         
     | 
| 
         @@ -60,6 +65,13 @@ Sorbet/ForbidExtendTSigHelpersInShims: 
     | 
|
| 
       60 
65 
     | 
    
         
             
              Include:
         
     | 
| 
       61 
66 
     | 
    
         
             
              - "**/*.rbi"
         
     | 
| 
       62 
67 
     | 
    
         | 
| 
      
 68 
     | 
    
         
            +
            Sorbet/ForbidRBIOutsideOfSorbetDir:
         
     | 
| 
      
 69 
     | 
    
         
            +
              Description: 'Forbids RBI files outside of the sorbet/ directory.'
         
     | 
| 
      
 70 
     | 
    
         
            +
              Enabled: true
         
     | 
| 
      
 71 
     | 
    
         
            +
              VersionAdded: 0.6.1
         
     | 
| 
      
 72 
     | 
    
         
            +
              Include:
         
     | 
| 
      
 73 
     | 
    
         
            +
              - "**/*.rbi"
         
     | 
| 
      
 74 
     | 
    
         
            +
             
     | 
| 
       63 
75 
     | 
    
         
             
            Sorbet/ForbidIncludeConstLiteral:
         
     | 
| 
       64 
76 
     | 
    
         
             
              Description: 'Forbids include of non-literal constants.'
         
     | 
| 
       65 
77 
     | 
    
         
             
              Enabled: false
         
     | 
| 
         @@ -74,6 +86,12 @@ Sorbet/ForbidSuperclassConstLiteral: 
     | 
|
| 
       74 
86 
     | 
    
         
             
              Exclude:
         
     | 
| 
       75 
87 
     | 
    
         
             
              - db/migrate/*.rb
         
     | 
| 
       76 
88 
     | 
    
         | 
| 
      
 89 
     | 
    
         
            +
            Sorbet/ForbidTUnsafe:
         
     | 
| 
      
 90 
     | 
    
         
            +
              Description: 'Forbid usage of T.unsafe.'
         
     | 
| 
      
 91 
     | 
    
         
            +
              Enabled: false
         
     | 
| 
      
 92 
     | 
    
         
            +
              VersionAdded: 0.7.0
         
     | 
| 
      
 93 
     | 
    
         
            +
              VersionChanged: 0.7.0
         
     | 
| 
      
 94 
     | 
    
         
            +
             
     | 
| 
       77 
95 
     | 
    
         
             
            Sorbet/ForbidUntypedStructProps:
         
     | 
| 
       78 
96 
     | 
    
         
             
              Description: >-
         
     | 
| 
       79 
97 
     | 
    
         
             
                              Disallows use of `T.untyped` or `T.nilable(T.untyped)` as a
         
     | 
| 
         @@ -84,11 +102,14 @@ Sorbet/ForbidUntypedStructProps: 
     | 
|
| 
       84 
102 
     | 
    
         
             
            Sorbet/HasSigil:
         
     | 
| 
       85 
103 
     | 
    
         
             
              Description: 'Makes the Sorbet typed sigil mandatory in all files.'
         
     | 
| 
       86 
104 
     | 
    
         
             
              Enabled: false
         
     | 
| 
      
 105 
     | 
    
         
            +
              SuggestedStrictness: "false"
         
     | 
| 
      
 106 
     | 
    
         
            +
              MinimumStrictness: "false"
         
     | 
| 
       87 
107 
     | 
    
         
             
              VersionAdded: 0.3.3
         
     | 
| 
       88 
108 
     | 
    
         | 
| 
       89 
109 
     | 
    
         
             
            Sorbet/IgnoreSigil:
         
     | 
| 
       90 
110 
     | 
    
         
             
              Description: 'All files must be at least at strictness `ignore`.'
         
     | 
| 
       91 
111 
     | 
    
         
             
              Enabled: false
         
     | 
| 
      
 112 
     | 
    
         
            +
              SuggestedStrictness: "ignore"
         
     | 
| 
       92 
113 
     | 
    
         
             
              VersionAdded: 0.3.3
         
     | 
| 
       93 
114 
     | 
    
         | 
| 
       94 
115 
     | 
    
         
             
            Sorbet/KeywordArgumentOrdering:
         
     | 
| 
         @@ -131,19 +152,25 @@ Sorbet/SingleLineRbiClassModuleDefinitions: 
     | 
|
| 
       131 
152 
     | 
    
         
             
            Sorbet/StrictSigil:
         
     | 
| 
       132 
153 
     | 
    
         
             
              Description: 'All files must be at least at strictness `strict`.'
         
     | 
| 
       133 
154 
     | 
    
         
             
              Enabled: false
         
     | 
| 
      
 155 
     | 
    
         
            +
              SuggestedStrictness: "strict"
         
     | 
| 
       134 
156 
     | 
    
         
             
              VersionAdded: 0.3.3
         
     | 
| 
       135 
157 
     | 
    
         | 
| 
       136 
158 
     | 
    
         
             
            Sorbet/StrongSigil:
         
     | 
| 
       137 
159 
     | 
    
         
             
              Description: 'All files must be at least at strictness `strong`.'
         
     | 
| 
       138 
160 
     | 
    
         
             
              Enabled: false
         
     | 
| 
      
 161 
     | 
    
         
            +
              SuggestedStrictness: "strong"
         
     | 
| 
       139 
162 
     | 
    
         
             
              VersionAdded: 0.3.3
         
     | 
| 
       140 
163 
     | 
    
         | 
| 
       141 
164 
     | 
    
         
             
            Sorbet/TrueSigil:
         
     | 
| 
       142 
165 
     | 
    
         
             
              Description: 'All files must be at least at strictness `true`.'
         
     | 
| 
       143 
166 
     | 
    
         
             
              Enabled: false
         
     | 
| 
      
 167 
     | 
    
         
            +
              SuggestedStrictness: "true"
         
     | 
| 
       144 
168 
     | 
    
         
             
              VersionAdded: 0.3.3
         
     | 
| 
       145 
169 
     | 
    
         | 
| 
       146 
170 
     | 
    
         
             
            Sorbet/ValidSigil:
         
     | 
| 
       147 
171 
     | 
    
         
             
              Description: 'All files must have a valid sigil.'
         
     | 
| 
       148 
172 
     | 
    
         
             
              Enabled: true
         
     | 
| 
      
 173 
     | 
    
         
            +
              RequireSigilOnAllFiles: false
         
     | 
| 
      
 174 
     | 
    
         
            +
              SuggestedStrictness: "false"
         
     | 
| 
      
 175 
     | 
    
         
            +
              MinimumStrictness: "false"
         
     | 
| 
       149 
176 
     | 
    
         
             
              VersionAdded: 0.3.3
         
     | 
    
        data/dev.yml
    CHANGED
    
    
| 
         @@ -0,0 +1,138 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            module RuboCop
         
     | 
| 
      
 4 
     | 
    
         
            +
              module Cop
         
     | 
| 
      
 5 
     | 
    
         
            +
                module Sorbet
         
     | 
| 
      
 6 
     | 
    
         
            +
                  # This cop ensures that callback conditionals are bound to the right type
         
     | 
| 
      
 7 
     | 
    
         
            +
                  # so that they are type checked properly.
         
     | 
| 
      
 8 
     | 
    
         
            +
                  #
         
     | 
| 
      
 9 
     | 
    
         
            +
                  # @example
         
     | 
| 
      
 10 
     | 
    
         
            +
                  #
         
     | 
| 
      
 11 
     | 
    
         
            +
                  #   # bad
         
     | 
| 
      
 12 
     | 
    
         
            +
                  #   class Post < ApplicationRecord
         
     | 
| 
      
 13 
     | 
    
         
            +
                  #     before_create :do_it, if: -> { should_do_it? }
         
     | 
| 
      
 14 
     | 
    
         
            +
                  #
         
     | 
| 
      
 15 
     | 
    
         
            +
                  #     def should_do_it?
         
     | 
| 
      
 16 
     | 
    
         
            +
                  #       true
         
     | 
| 
      
 17 
     | 
    
         
            +
                  #     end
         
     | 
| 
      
 18 
     | 
    
         
            +
                  #   end
         
     | 
| 
      
 19 
     | 
    
         
            +
                  #
         
     | 
| 
      
 20 
     | 
    
         
            +
                  #   # good
         
     | 
| 
      
 21 
     | 
    
         
            +
                  #   class Post < ApplicationRecord
         
     | 
| 
      
 22 
     | 
    
         
            +
                  #     before_create :do_it, if: -> { T.bind(self, Post).should_do_it? }
         
     | 
| 
      
 23 
     | 
    
         
            +
                  #
         
     | 
| 
      
 24 
     | 
    
         
            +
                  #     def should_do_it?
         
     | 
| 
      
 25 
     | 
    
         
            +
                  #       true
         
     | 
| 
      
 26 
     | 
    
         
            +
                  #     end
         
     | 
| 
      
 27 
     | 
    
         
            +
                  #   end
         
     | 
| 
      
 28 
     | 
    
         
            +
                  class CallbackConditionalsBinding < RuboCop::Cop::Cop
         
     | 
| 
      
 29 
     | 
    
         
            +
                    CALLBACKS = %i(
         
     | 
| 
      
 30 
     | 
    
         
            +
                      validate
         
     | 
| 
      
 31 
     | 
    
         
            +
                      validates
         
     | 
| 
      
 32 
     | 
    
         
            +
                      validates_with
         
     | 
| 
      
 33 
     | 
    
         
            +
                      before_validation
         
     | 
| 
      
 34 
     | 
    
         
            +
                      around_validation
         
     | 
| 
      
 35 
     | 
    
         
            +
             
     | 
| 
      
 36 
     | 
    
         
            +
                      before_create
         
     | 
| 
      
 37 
     | 
    
         
            +
                      before_save
         
     | 
| 
      
 38 
     | 
    
         
            +
                      before_destroy
         
     | 
| 
      
 39 
     | 
    
         
            +
                      before_update
         
     | 
| 
      
 40 
     | 
    
         
            +
             
     | 
| 
      
 41 
     | 
    
         
            +
                      after_create
         
     | 
| 
      
 42 
     | 
    
         
            +
                      after_save
         
     | 
| 
      
 43 
     | 
    
         
            +
                      after_destroy
         
     | 
| 
      
 44 
     | 
    
         
            +
                      after_update
         
     | 
| 
      
 45 
     | 
    
         
            +
                      after_touch
         
     | 
| 
      
 46 
     | 
    
         
            +
                      after_initialize
         
     | 
| 
      
 47 
     | 
    
         
            +
                      after_find
         
     | 
| 
      
 48 
     | 
    
         
            +
             
     | 
| 
      
 49 
     | 
    
         
            +
                      around_create
         
     | 
| 
      
 50 
     | 
    
         
            +
                      around_save
         
     | 
| 
      
 51 
     | 
    
         
            +
                      around_destroy
         
     | 
| 
      
 52 
     | 
    
         
            +
                      around_update
         
     | 
| 
      
 53 
     | 
    
         
            +
             
     | 
| 
      
 54 
     | 
    
         
            +
                      before_commit
         
     | 
| 
      
 55 
     | 
    
         
            +
             
     | 
| 
      
 56 
     | 
    
         
            +
                      after_commit
         
     | 
| 
      
 57 
     | 
    
         
            +
                      after_create_commit
         
     | 
| 
      
 58 
     | 
    
         
            +
                      after_destroy_commit
         
     | 
| 
      
 59 
     | 
    
         
            +
                      after_rollback
         
     | 
| 
      
 60 
     | 
    
         
            +
                      after_save_commit
         
     | 
| 
      
 61 
     | 
    
         
            +
                      after_update_commit
         
     | 
| 
      
 62 
     | 
    
         
            +
             
     | 
| 
      
 63 
     | 
    
         
            +
                      before_action
         
     | 
| 
      
 64 
     | 
    
         
            +
                      prepend_before_action
         
     | 
| 
      
 65 
     | 
    
         
            +
                      append_before_action
         
     | 
| 
      
 66 
     | 
    
         
            +
             
     | 
| 
      
 67 
     | 
    
         
            +
                      around_action
         
     | 
| 
      
 68 
     | 
    
         
            +
                      prepend_around_action
         
     | 
| 
      
 69 
     | 
    
         
            +
                      append_around_action
         
     | 
| 
      
 70 
     | 
    
         
            +
             
     | 
| 
      
 71 
     | 
    
         
            +
                      after_action
         
     | 
| 
      
 72 
     | 
    
         
            +
                      prepend_after_action
         
     | 
| 
      
 73 
     | 
    
         
            +
                      append_after_action
         
     | 
| 
      
 74 
     | 
    
         
            +
                    ).freeze
         
     | 
| 
      
 75 
     | 
    
         
            +
             
     | 
| 
      
 76 
     | 
    
         
            +
                    def autocorrect(node)
         
     | 
| 
      
 77 
     | 
    
         
            +
                      lambda do |corrector|
         
     | 
| 
      
 78 
     | 
    
         
            +
                        options = node.each_child_node.find(&:hash_type?)
         
     | 
| 
      
 79 
     | 
    
         
            +
             
     | 
| 
      
 80 
     | 
    
         
            +
                        conditional = nil
         
     | 
| 
      
 81 
     | 
    
         
            +
                        options.each_pair do |keyword, block|
         
     | 
| 
      
 82 
     | 
    
         
            +
                          if keyword.value == :if || keyword.value == :unless
         
     | 
| 
      
 83 
     | 
    
         
            +
                            conditional = block
         
     | 
| 
      
 84 
     | 
    
         
            +
                            break
         
     | 
| 
      
 85 
     | 
    
         
            +
                          end
         
     | 
| 
      
 86 
     | 
    
         
            +
                        end
         
     | 
| 
      
 87 
     | 
    
         
            +
             
     | 
| 
      
 88 
     | 
    
         
            +
                        _, _, block = conditional.child_nodes
         
     | 
| 
      
 89 
     | 
    
         
            +
                        expected_class = node.parent_module_name
         
     | 
| 
      
 90 
     | 
    
         
            +
             
     | 
| 
      
 91 
     | 
    
         
            +
                        bind = if block.begin_type?
         
     | 
| 
      
 92 
     | 
    
         
            +
                          indentation = " " * block.child_nodes.first.loc.column
         
     | 
| 
      
 93 
     | 
    
         
            +
                          "T.bind(self, #{expected_class})\n#{indentation}"
         
     | 
| 
      
 94 
     | 
    
         
            +
                        elsif block.child_nodes.empty? && !block.ivar_type?
         
     | 
| 
      
 95 
     | 
    
         
            +
                          "T.bind(self, #{expected_class})."
         
     | 
| 
      
 96 
     | 
    
         
            +
                        else
         
     | 
| 
      
 97 
     | 
    
         
            +
                          "T.bind(self, #{expected_class}); "
         
     | 
| 
      
 98 
     | 
    
         
            +
                        end
         
     | 
| 
      
 99 
     | 
    
         
            +
             
     | 
| 
      
 100 
     | 
    
         
            +
                        corrector.insert_before(block, bind)
         
     | 
| 
      
 101 
     | 
    
         
            +
                      end
         
     | 
| 
      
 102 
     | 
    
         
            +
                    end
         
     | 
| 
      
 103 
     | 
    
         
            +
             
     | 
| 
      
 104 
     | 
    
         
            +
                    def on_send(node)
         
     | 
| 
      
 105 
     | 
    
         
            +
                      return unless CALLBACKS.include?(node.method_name)
         
     | 
| 
      
 106 
     | 
    
         
            +
             
     | 
| 
      
 107 
     | 
    
         
            +
                      options = node.each_child_node.find(&:hash_type?)
         
     | 
| 
      
 108 
     | 
    
         
            +
                      return if options.nil?
         
     | 
| 
      
 109 
     | 
    
         
            +
             
     | 
| 
      
 110 
     | 
    
         
            +
                      conditional = nil
         
     | 
| 
      
 111 
     | 
    
         
            +
                      options.each_pair do |keyword, block|
         
     | 
| 
      
 112 
     | 
    
         
            +
                        next unless keyword.sym_type?
         
     | 
| 
      
 113 
     | 
    
         
            +
             
     | 
| 
      
 114 
     | 
    
         
            +
                        if keyword.value == :if || keyword.value == :unless
         
     | 
| 
      
 115 
     | 
    
         
            +
                          conditional = block
         
     | 
| 
      
 116 
     | 
    
         
            +
                          break
         
     | 
| 
      
 117 
     | 
    
         
            +
                        end
         
     | 
| 
      
 118 
     | 
    
         
            +
                      end
         
     | 
| 
      
 119 
     | 
    
         
            +
             
     | 
| 
      
 120 
     | 
    
         
            +
                      return if conditional.nil? || conditional.child_nodes.empty?
         
     | 
| 
      
 121 
     | 
    
         
            +
             
     | 
| 
      
 122 
     | 
    
         
            +
                      type, _, block = conditional.child_nodes
         
     | 
| 
      
 123 
     | 
    
         
            +
                      return unless type.lambda_or_proc?
         
     | 
| 
      
 124 
     | 
    
         
            +
             
     | 
| 
      
 125 
     | 
    
         
            +
                      expected_class = node.parent_module_name
         
     | 
| 
      
 126 
     | 
    
         
            +
                      return if expected_class.nil?
         
     | 
| 
      
 127 
     | 
    
         
            +
             
     | 
| 
      
 128 
     | 
    
         
            +
                      unless block.source.include?("T.bind(self, #{expected_class})")
         
     | 
| 
      
 129 
     | 
    
         
            +
                        add_offense(
         
     | 
| 
      
 130 
     | 
    
         
            +
                          node,
         
     | 
| 
      
 131 
     | 
    
         
            +
                          message: "Callback conditionals should be bound to the right type. Use T.bind(self, #{expected_class})"
         
     | 
| 
      
 132 
     | 
    
         
            +
                        )
         
     | 
| 
      
 133 
     | 
    
         
            +
                      end
         
     | 
| 
      
 134 
     | 
    
         
            +
                    end
         
     | 
| 
      
 135 
     | 
    
         
            +
                  end
         
     | 
| 
      
 136 
     | 
    
         
            +
                end
         
     | 
| 
      
 137 
     | 
    
         
            +
              end
         
     | 
| 
      
 138 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,26 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            require 'rubocop'
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            module RuboCop
         
     | 
| 
      
 6 
     | 
    
         
            +
              module Cop
         
     | 
| 
      
 7 
     | 
    
         
            +
                module Sorbet
         
     | 
| 
      
 8 
     | 
    
         
            +
                  # This cop disallows using `T.unsafe` anywhere.
         
     | 
| 
      
 9 
     | 
    
         
            +
                  #
         
     | 
| 
      
 10 
     | 
    
         
            +
                  # @example
         
     | 
| 
      
 11 
     | 
    
         
            +
                  #
         
     | 
| 
      
 12 
     | 
    
         
            +
                  #   # bad
         
     | 
| 
      
 13 
     | 
    
         
            +
                  #   T.unsafe(foo)
         
     | 
| 
      
 14 
     | 
    
         
            +
                  #
         
     | 
| 
      
 15 
     | 
    
         
            +
                  #   # good
         
     | 
| 
      
 16 
     | 
    
         
            +
                  #   foo
         
     | 
| 
      
 17 
     | 
    
         
            +
                  class ForbidTUnsafe < RuboCop::Cop::Cop
         
     | 
| 
      
 18 
     | 
    
         
            +
                    def_node_matcher(:t_unsafe?, '(send (const nil? :T) :unsafe _)')
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
                    def on_send(node)
         
     | 
| 
      
 21 
     | 
    
         
            +
                      add_offense(node, message: "Do not use `T.unsafe`.") if t_unsafe?(node)
         
     | 
| 
      
 22 
     | 
    
         
            +
                    end
         
     | 
| 
      
 23 
     | 
    
         
            +
                  end
         
     | 
| 
      
 24 
     | 
    
         
            +
                end
         
     | 
| 
      
 25 
     | 
    
         
            +
              end
         
     | 
| 
      
 26 
     | 
    
         
            +
            end
         
     | 
| 
         
            File without changes
         
     | 
| 
         @@ -0,0 +1,31 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            module RuboCop
         
     | 
| 
      
 4 
     | 
    
         
            +
              module Cop
         
     | 
| 
      
 5 
     | 
    
         
            +
                module Sorbet
         
     | 
| 
      
 6 
     | 
    
         
            +
                  # This cop makes sure that RBI files are always located under sorbet/rbi/.
         
     | 
| 
      
 7 
     | 
    
         
            +
                  #
         
     | 
| 
      
 8 
     | 
    
         
            +
                  # @example
         
     | 
| 
      
 9 
     | 
    
         
            +
                  #   # bad
         
     | 
| 
      
 10 
     | 
    
         
            +
                  #   lib/some_file.rbi
         
     | 
| 
      
 11 
     | 
    
         
            +
                  #   other_file.rbi
         
     | 
| 
      
 12 
     | 
    
         
            +
                  #
         
     | 
| 
      
 13 
     | 
    
         
            +
                  #   # good
         
     | 
| 
      
 14 
     | 
    
         
            +
                  #   sorbet/rbi/some_file.rbi
         
     | 
| 
      
 15 
     | 
    
         
            +
                  #   sorbet/rbi/any/path/for/file.rbi
         
     | 
| 
      
 16 
     | 
    
         
            +
                  class ForbidRBIOutsideOfSorbetDir < RuboCop::Cop::Cop
         
     | 
| 
      
 17 
     | 
    
         
            +
                    include RangeHelp
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
                    PATH_REGEXP = %r{sorbet/rbi}
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
                    def investigate(processed_source)
         
     | 
| 
      
 22 
     | 
    
         
            +
                      add_offense(
         
     | 
| 
      
 23 
     | 
    
         
            +
                        nil,
         
     | 
| 
      
 24 
     | 
    
         
            +
                        location: source_range(processed_source.buffer, 1, 0),
         
     | 
| 
      
 25 
     | 
    
         
            +
                        message: "RBI files are only accepted in the sorbet/rbi/ directory."
         
     | 
| 
      
 26 
     | 
    
         
            +
                      ) unless processed_source.file_path =~ PATH_REGEXP
         
     | 
| 
      
 27 
     | 
    
         
            +
                    end
         
     | 
| 
      
 28 
     | 
    
         
            +
                  end
         
     | 
| 
      
 29 
     | 
    
         
            +
                end
         
     | 
| 
      
 30 
     | 
    
         
            +
              end
         
     | 
| 
      
 31 
     | 
    
         
            +
            end
         
     | 
| 
         
            File without changes
         
     | 
| 
         @@ -147,12 +147,14 @@ module RuboCop 
     | 
|
| 
       147 
147 
     | 
    
         | 
| 
       148 
148 
     | 
    
         
             
                    # Default is `'false'`
         
     | 
| 
       149 
149 
     | 
    
         
             
                    def suggested_strictness
         
     | 
| 
       150 
     | 
    
         
            -
                       
     | 
| 
      
 150 
     | 
    
         
            +
                      config = cop_config['SuggestedStrictness'].to_s
         
     | 
| 
      
 151 
     | 
    
         
            +
                      STRICTNESS_LEVELS.include?(config) ? config : 'false'
         
     | 
| 
       151 
152 
     | 
    
         
             
                    end
         
     | 
| 
       152 
153 
     | 
    
         | 
| 
       153 
154 
     | 
    
         
             
                    # Default is `nil`
         
     | 
| 
       154 
155 
     | 
    
         
             
                    def minimum_strictness
         
     | 
| 
       155 
     | 
    
         
            -
                       
     | 
| 
      
 156 
     | 
    
         
            +
                      config = cop_config['MinimumStrictness'].to_s
         
     | 
| 
      
 157 
     | 
    
         
            +
                      config if STRICTNESS_LEVELS.include?(config)
         
     | 
| 
       156 
158 
     | 
    
         
             
                    end
         
     | 
| 
       157 
159 
     | 
    
         
             
                  end
         
     | 
| 
       158 
160 
     | 
    
         
             
                end
         
     | 
| 
         @@ -1,12 +1,16 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            # frozen_string_literal: true
         
     | 
| 
       2 
2 
     | 
    
         
             
            require_relative 'sorbet/binding_constants_without_type_alias'
         
     | 
| 
       3 
3 
     | 
    
         
             
            require_relative 'sorbet/constants_from_strings'
         
     | 
| 
       4 
     | 
    
         
            -
            require_relative 'sorbet/forbid_extend_t_sig_helpers_in_shims'
         
     | 
| 
       5 
4 
     | 
    
         
             
            require_relative 'sorbet/forbid_superclass_const_literal'
         
     | 
| 
       6 
5 
     | 
    
         
             
            require_relative 'sorbet/forbid_include_const_literal'
         
     | 
| 
       7 
6 
     | 
    
         
             
            require_relative 'sorbet/forbid_untyped_struct_props'
         
     | 
| 
       8 
     | 
    
         
            -
            require_relative 'sorbet/single_line_rbi_class_module_definitions'
         
     | 
| 
       9 
7 
     | 
    
         
             
            require_relative 'sorbet/one_ancestor_per_line'
         
     | 
| 
      
 8 
     | 
    
         
            +
            require_relative 'sorbet/callback_conditionals_binding'
         
     | 
| 
      
 9 
     | 
    
         
            +
            require_relative 'sorbet/forbid_t_unsafe'
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
            require_relative 'sorbet/rbi/forbid_extend_t_sig_helpers_in_shims'
         
     | 
| 
      
 12 
     | 
    
         
            +
            require_relative 'sorbet/rbi/forbid_rbi_outside_of_sorbet_dir'
         
     | 
| 
      
 13 
     | 
    
         
            +
            require_relative 'sorbet/rbi/single_line_rbi_class_module_definitions'
         
     | 
| 
       10 
14 
     | 
    
         | 
| 
       11 
15 
     | 
    
         
             
            require_relative 'sorbet/signatures/allow_incompatible_override'
         
     | 
| 
       12 
16 
     | 
    
         
             
            require_relative 'sorbet/signatures/checked_true_in_signature'
         
     | 
    
        data/manual/cops.md
    CHANGED
    
    | 
         @@ -7,6 +7,7 @@ In the following section you find all available cops: 
     | 
|
| 
       7 
7 
     | 
    
         | 
| 
       8 
8 
     | 
    
         
             
            * [Sorbet/AllowIncompatibleOverride](cops_sorbet.md#sorbetallowincompatibleoverride)
         
     | 
| 
       9 
9 
     | 
    
         
             
            * [Sorbet/BindingConstantWithoutTypeAlias](cops_sorbet.md#sorbetbindingconstantwithouttypealias)
         
     | 
| 
      
 10 
     | 
    
         
            +
            * [Sorbet/CallbackConditionalsBinding](cops_sorbet.md#sorbetcallbackconditionalsbinding)
         
     | 
| 
       10 
11 
     | 
    
         
             
            * [Sorbet/CheckedTrueInSignature](cops_sorbet.md#sorbetcheckedtrueinsignature)
         
     | 
| 
       11 
12 
     | 
    
         
             
            * [Sorbet/ConstantsFromStrings](cops_sorbet.md#sorbetconstantsfromstrings)
         
     | 
| 
       12 
13 
     | 
    
         
             
            * [Sorbet/EnforceSigilOrder](cops_sorbet.md#sorbetenforcesigilorder)
         
     | 
| 
         @@ -14,7 +15,9 @@ In the following section you find all available cops: 
     | 
|
| 
       14 
15 
     | 
    
         
             
            * [Sorbet/FalseSigil](cops_sorbet.md#sorbetfalsesigil)
         
     | 
| 
       15 
16 
     | 
    
         
             
            * [Sorbet/ForbidExtendTSigHelpersInShims](cops_sorbet.md#sorbetforbidextendtsighelpersinshims)
         
     | 
| 
       16 
17 
     | 
    
         
             
            * [Sorbet/ForbidIncludeConstLiteral](cops_sorbet.md#sorbetforbidincludeconstliteral)
         
     | 
| 
      
 18 
     | 
    
         
            +
            * [Sorbet/ForbidRBIOutsideOfSorbetDir](cops_sorbet.md#sorbetforbidrbioutsideofsorbetdir)
         
     | 
| 
       17 
19 
     | 
    
         
             
            * [Sorbet/ForbidSuperclassConstLiteral](cops_sorbet.md#sorbetforbidsuperclassconstliteral)
         
     | 
| 
      
 20 
     | 
    
         
            +
            * [Sorbet/ForbidTUnsafe](cops_sorbet.md#sorbetforbidtunsafe)
         
     | 
| 
       18 
21 
     | 
    
         
             
            * [Sorbet/ForbidUntypedStructProps](cops_sorbet.md#sorbetforbiduntypedstructprops)
         
     | 
| 
       19 
22 
     | 
    
         
             
            * [Sorbet/HasSigil](cops_sorbet.md#sorbethassigil)
         
     | 
| 
       20 
23 
     | 
    
         
             
            * [Sorbet/IgnoreSigil](cops_sorbet.md#sorbetignoresigil)
         
     | 
    
        data/manual/cops_sorbet.md
    CHANGED
    
    | 
         @@ -41,6 +41,37 @@ FooOrBar = T.any(Foo, Bar) 
     | 
|
| 
       41 
41 
     | 
    
         
             
            FooOrBar = T.type_alias { T.any(Foo, Bar) }
         
     | 
| 
       42 
42 
     | 
    
         
             
            ```
         
     | 
| 
       43 
43 
     | 
    
         | 
| 
      
 44 
     | 
    
         
            +
            ## Sorbet/CallbackConditionalsBinding
         
     | 
| 
      
 45 
     | 
    
         
            +
             
     | 
| 
      
 46 
     | 
    
         
            +
            Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
         
     | 
| 
      
 47 
     | 
    
         
            +
            --- | --- | --- | --- | ---
         
     | 
| 
      
 48 
     | 
    
         
            +
            Enabled | Yes | Yes  | 0.7.0 | -
         
     | 
| 
      
 49 
     | 
    
         
            +
             
     | 
| 
      
 50 
     | 
    
         
            +
            This cop ensures that callback conditionals are bound to the right type
         
     | 
| 
      
 51 
     | 
    
         
            +
            so that they are type checked properly.
         
     | 
| 
      
 52 
     | 
    
         
            +
             
     | 
| 
      
 53 
     | 
    
         
            +
            ### Examples
         
     | 
| 
      
 54 
     | 
    
         
            +
             
     | 
| 
      
 55 
     | 
    
         
            +
            ```ruby
         
     | 
| 
      
 56 
     | 
    
         
            +
            # bad
         
     | 
| 
      
 57 
     | 
    
         
            +
            class Post < ApplicationRecord
         
     | 
| 
      
 58 
     | 
    
         
            +
              before_create :do_it, if: -> { should_do_it? }
         
     | 
| 
      
 59 
     | 
    
         
            +
             
     | 
| 
      
 60 
     | 
    
         
            +
              def should_do_it?
         
     | 
| 
      
 61 
     | 
    
         
            +
                true
         
     | 
| 
      
 62 
     | 
    
         
            +
              end
         
     | 
| 
      
 63 
     | 
    
         
            +
            end
         
     | 
| 
      
 64 
     | 
    
         
            +
             
     | 
| 
      
 65 
     | 
    
         
            +
            # good
         
     | 
| 
      
 66 
     | 
    
         
            +
            class Post < ApplicationRecord
         
     | 
| 
      
 67 
     | 
    
         
            +
              before_create :do_it, if: -> { T.bind(self, Post).should_do_it? }
         
     | 
| 
      
 68 
     | 
    
         
            +
             
     | 
| 
      
 69 
     | 
    
         
            +
              def should_do_it?
         
     | 
| 
      
 70 
     | 
    
         
            +
                true
         
     | 
| 
      
 71 
     | 
    
         
            +
              end
         
     | 
| 
      
 72 
     | 
    
         
            +
            end
         
     | 
| 
      
 73 
     | 
    
         
            +
            ```
         
     | 
| 
      
 74 
     | 
    
         
            +
             
     | 
| 
       44 
75 
     | 
    
         
             
            ## Sorbet/CheckedTrueInSignature
         
     | 
| 
       45 
76 
     | 
    
         | 
| 
       46 
77 
     | 
    
         
             
            Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
         
     | 
| 
         @@ -167,7 +198,7 @@ This cop makes the Sorbet `false` sigil mandatory in all files. 
     | 
|
| 
       167 
198 
     | 
    
         | 
| 
       168 
199 
     | 
    
         
             
            Name | Default value | Configurable values
         
     | 
| 
       169 
200 
     | 
    
         
             
            --- | --- | ---
         
     | 
| 
       170 
     | 
    
         
            -
            SuggestedStrictness | ` 
     | 
| 
      
 201 
     | 
    
         
            +
            SuggestedStrictness | `false` | String
         
     | 
| 
       171 
202 
     | 
    
         
             
            Include | `**/*.rb`, `**/*.rbi`, `**/*.rake`, `**/*.ru` | Array
         
     | 
| 
       172 
203 
     | 
    
         
             
            Exclude | `bin/**/*`, `db/**/*.rb`, `script/**/*` | Array
         
     | 
| 
       173 
204 
     | 
    
         | 
| 
         @@ -213,6 +244,32 @@ Disabled | Yes | No | 0.2.0 | 0.5.0 
     | 
|
| 
       213 
244 
     | 
    
         | 
| 
       214 
245 
     | 
    
         
             
            No documentation
         
     | 
| 
       215 
246 
     | 
    
         | 
| 
      
 247 
     | 
    
         
            +
            ## Sorbet/ForbidRBIOutsideOfSorbetDir
         
     | 
| 
      
 248 
     | 
    
         
            +
             
     | 
| 
      
 249 
     | 
    
         
            +
            Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
         
     | 
| 
      
 250 
     | 
    
         
            +
            --- | --- | --- | --- | ---
         
     | 
| 
      
 251 
     | 
    
         
            +
            Enabled | Yes | No | 0.6.1 | -
         
     | 
| 
      
 252 
     | 
    
         
            +
             
     | 
| 
      
 253 
     | 
    
         
            +
            This cop makes sure that RBI files are always located under sorbet/rbi/.
         
     | 
| 
      
 254 
     | 
    
         
            +
             
     | 
| 
      
 255 
     | 
    
         
            +
            ### Examples
         
     | 
| 
      
 256 
     | 
    
         
            +
             
     | 
| 
      
 257 
     | 
    
         
            +
            ```ruby
         
     | 
| 
      
 258 
     | 
    
         
            +
            # bad
         
     | 
| 
      
 259 
     | 
    
         
            +
            lib/some_file.rbi
         
     | 
| 
      
 260 
     | 
    
         
            +
            other_file.rbi
         
     | 
| 
      
 261 
     | 
    
         
            +
             
     | 
| 
      
 262 
     | 
    
         
            +
            # good
         
     | 
| 
      
 263 
     | 
    
         
            +
            sorbet/rbi/some_file.rbi
         
     | 
| 
      
 264 
     | 
    
         
            +
            sorbet/rbi/any/path/for/file.rbi
         
     | 
| 
      
 265 
     | 
    
         
            +
            ```
         
     | 
| 
      
 266 
     | 
    
         
            +
             
     | 
| 
      
 267 
     | 
    
         
            +
            ### Configurable attributes
         
     | 
| 
      
 268 
     | 
    
         
            +
             
     | 
| 
      
 269 
     | 
    
         
            +
            Name | Default value | Configurable values
         
     | 
| 
      
 270 
     | 
    
         
            +
            --- | --- | ---
         
     | 
| 
      
 271 
     | 
    
         
            +
            Include | `**/*.rbi` | Array
         
     | 
| 
      
 272 
     | 
    
         
            +
             
     | 
| 
       216 
273 
     | 
    
         
             
            ## Sorbet/ForbidSuperclassConstLiteral
         
     | 
| 
       217 
274 
     | 
    
         | 
| 
       218 
275 
     | 
    
         
             
            Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
         
     | 
| 
         @@ -227,6 +284,24 @@ Name | Default value | Configurable values 
     | 
|
| 
       227 
284 
     | 
    
         
             
            --- | --- | ---
         
     | 
| 
       228 
285 
     | 
    
         
             
            Exclude | `db/migrate/*.rb` | Array
         
     | 
| 
       229 
286 
     | 
    
         | 
| 
      
 287 
     | 
    
         
            +
            ## Sorbet/ForbidTUnsafe
         
     | 
| 
      
 288 
     | 
    
         
            +
             
     | 
| 
      
 289 
     | 
    
         
            +
            Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
         
     | 
| 
      
 290 
     | 
    
         
            +
            --- | --- | --- | --- | ---
         
     | 
| 
      
 291 
     | 
    
         
            +
            Disabled | Yes | No | 0.7.0 | 0.7.0
         
     | 
| 
      
 292 
     | 
    
         
            +
             
     | 
| 
      
 293 
     | 
    
         
            +
            This cop disallows using `T.unsafe` anywhere.
         
     | 
| 
      
 294 
     | 
    
         
            +
             
     | 
| 
      
 295 
     | 
    
         
            +
            ### Examples
         
     | 
| 
      
 296 
     | 
    
         
            +
             
     | 
| 
      
 297 
     | 
    
         
            +
            ```ruby
         
     | 
| 
      
 298 
     | 
    
         
            +
            # bad
         
     | 
| 
      
 299 
     | 
    
         
            +
            T.unsafe(foo)
         
     | 
| 
      
 300 
     | 
    
         
            +
             
     | 
| 
      
 301 
     | 
    
         
            +
            # good
         
     | 
| 
      
 302 
     | 
    
         
            +
            foo
         
     | 
| 
      
 303 
     | 
    
         
            +
            ```
         
     | 
| 
      
 304 
     | 
    
         
            +
             
     | 
| 
       230 
305 
     | 
    
         
             
            ## Sorbet/ForbidUntypedStructProps
         
     | 
| 
       231 
306 
     | 
    
         | 
| 
       232 
307 
     | 
    
         
             
            Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
         
     | 
| 
         @@ -267,6 +342,13 @@ Options: 
     | 
|
| 
       267 
342 
     | 
    
         | 
| 
       268 
343 
     | 
    
         
             
            If a `MinimumStrictness` level is specified, it will be used in offense messages and autocorrect.
         
     | 
| 
       269 
344 
     | 
    
         | 
| 
      
 345 
     | 
    
         
            +
            ### Configurable attributes
         
     | 
| 
      
 346 
     | 
    
         
            +
             
     | 
| 
      
 347 
     | 
    
         
            +
            Name | Default value | Configurable values
         
     | 
| 
      
 348 
     | 
    
         
            +
            --- | --- | ---
         
     | 
| 
      
 349 
     | 
    
         
            +
            SuggestedStrictness | `false` | String
         
     | 
| 
      
 350 
     | 
    
         
            +
            MinimumStrictness | `false` | String
         
     | 
| 
      
 351 
     | 
    
         
            +
             
     | 
| 
       270 
352 
     | 
    
         
             
            ## Sorbet/IgnoreSigil
         
     | 
| 
       271 
353 
     | 
    
         | 
| 
       272 
354 
     | 
    
         
             
            Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
         
     | 
| 
         @@ -275,6 +357,12 @@ Disabled | Yes | Yes  | 0.3.3 | - 
     | 
|
| 
       275 
357 
     | 
    
         | 
| 
       276 
358 
     | 
    
         
             
            This cop makes the Sorbet `ignore` sigil mandatory in all files.
         
     | 
| 
       277 
359 
     | 
    
         | 
| 
      
 360 
     | 
    
         
            +
            ### Configurable attributes
         
     | 
| 
      
 361 
     | 
    
         
            +
             
     | 
| 
      
 362 
     | 
    
         
            +
            Name | Default value | Configurable values
         
     | 
| 
      
 363 
     | 
    
         
            +
            --- | --- | ---
         
     | 
| 
      
 364 
     | 
    
         
            +
            SuggestedStrictness | `ignore` | String
         
     | 
| 
      
 365 
     | 
    
         
            +
             
     | 
| 
       278 
366 
     | 
    
         
             
            ## Sorbet/KeywordArgumentOrdering
         
     | 
| 
       279 
367 
     | 
    
         | 
| 
       280 
368 
     | 
    
         
             
            Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
         
     | 
| 
         @@ -396,6 +484,12 @@ Disabled | Yes | Yes  | 0.3.3 | - 
     | 
|
| 
       396 
484 
     | 
    
         | 
| 
       397 
485 
     | 
    
         
             
            This cop makes the Sorbet `strict` sigil mandatory in all files.
         
     | 
| 
       398 
486 
     | 
    
         | 
| 
      
 487 
     | 
    
         
            +
            ### Configurable attributes
         
     | 
| 
      
 488 
     | 
    
         
            +
             
     | 
| 
      
 489 
     | 
    
         
            +
            Name | Default value | Configurable values
         
     | 
| 
      
 490 
     | 
    
         
            +
            --- | --- | ---
         
     | 
| 
      
 491 
     | 
    
         
            +
            SuggestedStrictness | `strict` | String
         
     | 
| 
      
 492 
     | 
    
         
            +
             
     | 
| 
       399 
493 
     | 
    
         
             
            ## Sorbet/StrongSigil
         
     | 
| 
       400 
494 
     | 
    
         | 
| 
       401 
495 
     | 
    
         
             
            Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
         
     | 
| 
         @@ -404,6 +498,12 @@ Disabled | Yes | Yes  | 0.3.3 | - 
     | 
|
| 
       404 
498 
     | 
    
         | 
| 
       405 
499 
     | 
    
         
             
            This cop makes the Sorbet `strong` sigil mandatory in all files.
         
     | 
| 
       406 
500 
     | 
    
         | 
| 
      
 501 
     | 
    
         
            +
            ### Configurable attributes
         
     | 
| 
      
 502 
     | 
    
         
            +
             
     | 
| 
      
 503 
     | 
    
         
            +
            Name | Default value | Configurable values
         
     | 
| 
      
 504 
     | 
    
         
            +
            --- | --- | ---
         
     | 
| 
      
 505 
     | 
    
         
            +
            SuggestedStrictness | `strong` | String
         
     | 
| 
      
 506 
     | 
    
         
            +
             
     | 
| 
       407 
507 
     | 
    
         
             
            ## Sorbet/TrueSigil
         
     | 
| 
       408 
508 
     | 
    
         | 
| 
       409 
509 
     | 
    
         
             
            Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
         
     | 
| 
         @@ -412,6 +512,12 @@ Disabled | Yes | Yes  | 0.3.3 | - 
     | 
|
| 
       412 
512 
     | 
    
         | 
| 
       413 
513 
     | 
    
         
             
            This cop makes the Sorbet `true` sigil mandatory in all files.
         
     | 
| 
       414 
514 
     | 
    
         | 
| 
      
 515 
     | 
    
         
            +
            ### Configurable attributes
         
     | 
| 
      
 516 
     | 
    
         
            +
             
     | 
| 
      
 517 
     | 
    
         
            +
            Name | Default value | Configurable values
         
     | 
| 
      
 518 
     | 
    
         
            +
            --- | --- | ---
         
     | 
| 
      
 519 
     | 
    
         
            +
            SuggestedStrictness | `true` | String
         
     | 
| 
      
 520 
     | 
    
         
            +
             
     | 
| 
       415 
521 
     | 
    
         
             
            ## Sorbet/ValidSigil
         
     | 
| 
       416 
522 
     | 
    
         | 
| 
       417 
523 
     | 
    
         
             
            Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
         
     | 
| 
         @@ -428,3 +534,11 @@ Options: 
     | 
|
| 
       428 
534 
     | 
    
         
             
            * `MinimumStrictness`: If set, make offense if the strictness level in the file is below this one
         
     | 
| 
       429 
535 
     | 
    
         | 
| 
       430 
536 
     | 
    
         
             
            If a `MinimumStrictness` level is specified, it will be used in offense messages and autocorrect.
         
     | 
| 
      
 537 
     | 
    
         
            +
             
     | 
| 
      
 538 
     | 
    
         
            +
            ### Configurable attributes
         
     | 
| 
      
 539 
     | 
    
         
            +
             
     | 
| 
      
 540 
     | 
    
         
            +
            Name | Default value | Configurable values
         
     | 
| 
      
 541 
     | 
    
         
            +
            --- | --- | ---
         
     | 
| 
      
 542 
     | 
    
         
            +
            RequireSigilOnAllFiles | `false` | Boolean
         
     | 
| 
      
 543 
     | 
    
         
            +
            SuggestedStrictness | `false` | String
         
     | 
| 
      
 544 
     | 
    
         
            +
            MinimumStrictness | `false` | String
         
     | 
    
        data/service.yml
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: rubocop-sorbet
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0.6. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.6.2
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Ufuk Kayserilioglu
         
     | 
| 
         @@ -11,7 +11,7 @@ authors: 
     | 
|
| 
       11 
11 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       12 
12 
     | 
    
         
             
            bindir: exe
         
     | 
| 
       13 
13 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       14 
     | 
    
         
            -
            date: 2021- 
     | 
| 
      
 14 
     | 
    
         
            +
            date: 2021-06-04 00:00:00.000000000 Z
         
     | 
| 
       15 
15 
     | 
    
         
             
            dependencies:
         
     | 
| 
       16 
16 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       17 
17 
     | 
    
         
             
              name: rspec
         
     | 
| 
         @@ -65,11 +65,10 @@ files: 
     | 
|
| 
       65 
65 
     | 
    
         
             
            - ".github/CODEOWNERS"
         
     | 
| 
       66 
66 
     | 
    
         
             
            - ".github/probots.yml"
         
     | 
| 
       67 
67 
     | 
    
         
             
            - ".github/stale.yml"
         
     | 
| 
      
 68 
     | 
    
         
            +
            - ".github/workflows/ci.yml"
         
     | 
| 
       68 
69 
     | 
    
         
             
            - ".gitignore"
         
     | 
| 
       69 
70 
     | 
    
         
             
            - ".rspec"
         
     | 
| 
       70 
71 
     | 
    
         
             
            - ".rubocop.yml"
         
     | 
| 
       71 
     | 
    
         
            -
            - ".shopify-build/VERSION"
         
     | 
| 
       72 
     | 
    
         
            -
            - ".shopify-build/rubocop-sorbet.yml"
         
     | 
| 
       73 
72 
     | 
    
         
             
            - ".travis.yml"
         
     | 
| 
       74 
73 
     | 
    
         
             
            - CODE_OF_CONDUCT.md
         
     | 
| 
       75 
74 
     | 
    
         
             
            - Gemfile
         
     | 
| 
         @@ -79,17 +78,22 @@ files: 
     | 
|
| 
       79 
78 
     | 
    
         
             
            - Rakefile
         
     | 
| 
       80 
79 
     | 
    
         
             
            - bin/console
         
     | 
| 
       81 
80 
     | 
    
         
             
            - bin/rspec
         
     | 
| 
      
 81 
     | 
    
         
            +
            - bin/rubocop
         
     | 
| 
       82 
82 
     | 
    
         
             
            - bin/setup
         
     | 
| 
       83 
83 
     | 
    
         
             
            - config/default.yml
         
     | 
| 
       84 
84 
     | 
    
         
             
            - dev.yml
         
     | 
| 
       85 
85 
     | 
    
         
             
            - lib/rubocop-sorbet.rb
         
     | 
| 
       86 
86 
     | 
    
         
             
            - lib/rubocop/cop/sorbet/binding_constants_without_type_alias.rb
         
     | 
| 
      
 87 
     | 
    
         
            +
            - lib/rubocop/cop/sorbet/callback_conditionals_binding.rb
         
     | 
| 
       87 
88 
     | 
    
         
             
            - lib/rubocop/cop/sorbet/constants_from_strings.rb
         
     | 
| 
       88 
     | 
    
         
            -
            - lib/rubocop/cop/sorbet/forbid_extend_t_sig_helpers_in_shims.rb
         
     | 
| 
       89 
89 
     | 
    
         
             
            - lib/rubocop/cop/sorbet/forbid_include_const_literal.rb
         
     | 
| 
       90 
90 
     | 
    
         
             
            - lib/rubocop/cop/sorbet/forbid_superclass_const_literal.rb
         
     | 
| 
      
 91 
     | 
    
         
            +
            - lib/rubocop/cop/sorbet/forbid_t_unsafe.rb
         
     | 
| 
       91 
92 
     | 
    
         
             
            - lib/rubocop/cop/sorbet/forbid_untyped_struct_props.rb
         
     | 
| 
       92 
93 
     | 
    
         
             
            - lib/rubocop/cop/sorbet/one_ancestor_per_line.rb
         
     | 
| 
      
 94 
     | 
    
         
            +
            - lib/rubocop/cop/sorbet/rbi/forbid_extend_t_sig_helpers_in_shims.rb
         
     | 
| 
      
 95 
     | 
    
         
            +
            - lib/rubocop/cop/sorbet/rbi/forbid_rbi_outside_of_sorbet_dir.rb
         
     | 
| 
      
 96 
     | 
    
         
            +
            - lib/rubocop/cop/sorbet/rbi/single_line_rbi_class_module_definitions.rb
         
     | 
| 
       93 
97 
     | 
    
         
             
            - lib/rubocop/cop/sorbet/sigils/enforce_sigil_order.rb
         
     | 
| 
       94 
98 
     | 
    
         
             
            - lib/rubocop/cop/sorbet/sigils/false_sigil.rb
         
     | 
| 
       95 
99 
     | 
    
         
             
            - lib/rubocop/cop/sorbet/sigils/has_sigil.rb
         
     | 
| 
         @@ -105,7 +109,6 @@ files: 
     | 
|
| 
       105 
109 
     | 
    
         
             
            - lib/rubocop/cop/sorbet/signatures/parameters_ordering_in_signature.rb
         
     | 
| 
       106 
110 
     | 
    
         
             
            - lib/rubocop/cop/sorbet/signatures/signature_build_order.rb
         
     | 
| 
       107 
111 
     | 
    
         
             
            - lib/rubocop/cop/sorbet/signatures/signature_cop.rb
         
     | 
| 
       108 
     | 
    
         
            -
            - lib/rubocop/cop/sorbet/single_line_rbi_class_module_definitions.rb
         
     | 
| 
       109 
112 
     | 
    
         
             
            - lib/rubocop/cop/sorbet_cops.rb
         
     | 
| 
       110 
113 
     | 
    
         
             
            - lib/rubocop/sorbet.rb
         
     | 
| 
       111 
114 
     | 
    
         
             
            - lib/rubocop/sorbet/inject.rb
         
     | 
| 
         @@ -138,7 +141,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement 
     | 
|
| 
       138 
141 
     | 
    
         
             
                - !ruby/object:Gem::Version
         
     | 
| 
       139 
142 
     | 
    
         
             
                  version: '0'
         
     | 
| 
       140 
143 
     | 
    
         
             
            requirements: []
         
     | 
| 
       141 
     | 
    
         
            -
            rubygems_version: 3. 
     | 
| 
      
 144 
     | 
    
         
            +
            rubygems_version: 3.2.17
         
     | 
| 
       142 
145 
     | 
    
         
             
            signing_key: 
         
     | 
| 
       143 
146 
     | 
    
         
             
            specification_version: 4
         
     | 
| 
       144 
147 
     | 
    
         
             
            summary: Automatic Sorbet code style checking tool.
         
     | 
    
        data/.shopify-build/VERSION
    DELETED
    
    | 
         @@ -1 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            v1
         
     | 
| 
         @@ -1,16 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            containers:
         
     | 
| 
       2 
     | 
    
         
            -
              default:
         
     | 
| 
       3 
     | 
    
         
            -
                docker: "circleci/ruby:2.5.5"
         
     | 
| 
       4 
     | 
    
         
            -
             
     | 
| 
       5 
     | 
    
         
            -
            steps:
         
     | 
| 
       6 
     | 
    
         
            -
            - label: ":ruby: Specs"
         
     | 
| 
       7 
     | 
    
         
            -
              dependencies:
         
     | 
| 
       8 
     | 
    
         
            -
              - "bundler"
         
     | 
| 
       9 
     | 
    
         
            -
              timeout: "5m"
         
     | 
| 
       10 
     | 
    
         
            -
              run:
         
     | 
| 
       11 
     | 
    
         
            -
              - "bundle exec rspec"
         
     | 
| 
       12 
     | 
    
         
            -
            - label: "Rubocop"
         
     | 
| 
       13 
     | 
    
         
            -
              dependencies:
         
     | 
| 
       14 
     | 
    
         
            -
              - "bundler"
         
     | 
| 
       15 
     | 
    
         
            -
              timeout: "5m"
         
     | 
| 
       16 
     | 
    
         
            -
              run: "bundle exec rubocop"
         
     |