manual/cops_sorbet.md in rubocop-sorbet-0.6.1 vs manual/cops_sorbet.md in rubocop-sorbet-0.6.2

- old
+ new

@@ -39,10 +39,41 @@ # good FooOrBar = T.type_alias { T.any(Foo, Bar) } ``` +## Sorbet/CallbackConditionalsBinding + +Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged +--- | --- | --- | --- | --- +Enabled | Yes | Yes | 0.7.0 | - + +This cop ensures that callback conditionals are bound to the right type +so that they are type checked properly. + +### Examples + +```ruby +# bad +class Post < ApplicationRecord + before_create :do_it, if: -> { should_do_it? } + + def should_do_it? + true + end +end + +# good +class Post < ApplicationRecord + before_create :do_it, if: -> { T.bind(self, Post).should_do_it? } + + def should_do_it? + true + end +end +``` + ## Sorbet/CheckedTrueInSignature Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged --- | --- | --- | --- | --- Enabled | Yes | No | 0.2.0 | - @@ -165,11 +196,11 @@ ### Configurable attributes Name | Default value | Configurable values --- | --- | --- -SuggestedStrictness | `true` | Boolean +SuggestedStrictness | `false` | String Include | `**/*.rb`, `**/*.rbi`, `**/*.rake`, `**/*.ru` | Array Exclude | `bin/**/*`, `db/**/*.rb`, `script/**/*` | Array ## Sorbet/ForbidExtendTSigHelpersInShims @@ -211,10 +242,36 @@ --- | --- | --- | --- | --- Disabled | Yes | No | 0.2.0 | 0.5.0 No documentation +## Sorbet/ForbidRBIOutsideOfSorbetDir + +Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged +--- | --- | --- | --- | --- +Enabled | Yes | No | 0.6.1 | - + +This cop makes sure that RBI files are always located under sorbet/rbi/. + +### Examples + +```ruby +# bad +lib/some_file.rbi +other_file.rbi + +# good +sorbet/rbi/some_file.rbi +sorbet/rbi/any/path/for/file.rbi +``` + +### Configurable attributes + +Name | Default value | Configurable values +--- | --- | --- +Include | `**/*.rbi` | Array + ## Sorbet/ForbidSuperclassConstLiteral Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged --- | --- | --- | --- | --- Disabled | Yes | No | 0.2.0 | 0.6.1 @@ -225,10 +282,28 @@ Name | Default value | Configurable values --- | --- | --- Exclude | `db/migrate/*.rb` | Array +## Sorbet/ForbidTUnsafe + +Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged +--- | --- | --- | --- | --- +Disabled | Yes | No | 0.7.0 | 0.7.0 + +This cop disallows using `T.unsafe` anywhere. + +### Examples + +```ruby +# bad +T.unsafe(foo) + +# good +foo +``` + ## Sorbet/ForbidUntypedStructProps Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged --- | --- | --- | --- | --- Enabled | Yes | No | 0.4.0 | - @@ -265,18 +340,31 @@ * `SuggestedStrictness`: Sorbet strictness level suggested in offense messages (default: 'false') * `MinimumStrictness`: If set, make offense if the strictness level in the file is below this one If a `MinimumStrictness` level is specified, it will be used in offense messages and autocorrect. +### Configurable attributes + +Name | Default value | Configurable values +--- | --- | --- +SuggestedStrictness | `false` | String +MinimumStrictness | `false` | String + ## Sorbet/IgnoreSigil Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged --- | --- | --- | --- | --- Disabled | Yes | Yes | 0.3.3 | - This cop makes the Sorbet `ignore` sigil mandatory in all files. +### Configurable attributes + +Name | Default value | Configurable values +--- | --- | --- +SuggestedStrictness | `ignore` | String + ## Sorbet/KeywordArgumentOrdering Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged --- | --- | --- | --- | --- Enabled | Yes | No | 0.2.0 | - @@ -394,26 +482,44 @@ --- | --- | --- | --- | --- Disabled | Yes | Yes | 0.3.3 | - This cop makes the Sorbet `strict` sigil mandatory in all files. +### Configurable attributes + +Name | Default value | Configurable values +--- | --- | --- +SuggestedStrictness | `strict` | String + ## Sorbet/StrongSigil Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged --- | --- | --- | --- | --- Disabled | Yes | Yes | 0.3.3 | - This cop makes the Sorbet `strong` sigil mandatory in all files. +### Configurable attributes + +Name | Default value | Configurable values +--- | --- | --- +SuggestedStrictness | `strong` | String + ## Sorbet/TrueSigil Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged --- | --- | --- | --- | --- Disabled | Yes | Yes | 0.3.3 | - This cop makes the Sorbet `true` sigil mandatory in all files. +### Configurable attributes + +Name | Default value | Configurable values +--- | --- | --- +SuggestedStrictness | `true` | String + ## Sorbet/ValidSigil Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged --- | --- | --- | --- | --- Enabled | Yes | Yes | 0.3.3 | - @@ -426,5 +532,13 @@ * `RequireSigilOnAllFiles`: make offense if the Sorbet typed is not found in the file (default: false) * `SuggestedStrictness`: Sorbet strictness level suggested in offense messages (default: 'false') * `MinimumStrictness`: If set, make offense if the strictness level in the file is below this one If a `MinimumStrictness` level is specified, it will be used in offense messages and autocorrect. + +### Configurable attributes + +Name | Default value | Configurable values +--- | --- | --- +RequireSigilOnAllFiles | `false` | Boolean +SuggestedStrictness | `false` | String +MinimumStrictness | `false` | String