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

- old
+ new

@@ -43,15 +43,19 @@ ## Sorbet/CallbackConditionalsBinding Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged --- | --- | --- | --- | --- -Enabled | Yes | Yes | 0.7.0 | - +Disabled | No | Yes | 0.7.0 | - This cop ensures that callback conditionals are bound to the right type so that they are type checked properly. +Auto-correction is unsafe because other libraries define similar style callbacks as Rails, but don't always need +binding to the attached class. Auto-correcting those usages can lead to false positives and auto-correction +introduces new typing errors. + ### Examples ```ruby # bad class Post < ApplicationRecord @@ -62,11 +66,14 @@ end end # good class Post < ApplicationRecord - before_create :do_it, if: -> { T.bind(self, Post).should_do_it? } + before_create :do_it, if: -> { + T.bind(self, Post) + should_do_it? + } def should_do_it? true end end @@ -184,10 +191,37 @@ You can configure the placeholders used by changing the following options: * `ParameterTypePlaceholder`: placeholders used for parameter types (default: 'T.untyped') * `ReturnTypePlaceholder`: placeholders used for return types (default: 'T.untyped') +## Sorbet/EnforceSingleSigil + +Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged +--- | --- | --- | --- | --- +Enabled | Yes | Yes | <<next>> | - + +This cop checks that there is only one Sorbet sigil in a given file + +For example, the following class with two sigils + +```ruby +# typed: true +# typed: true +# frozen_string_literal: true +class Foo; end +``` + +Will be corrected as: + +```ruby +# typed: true +# frozen_string_literal: true +class Foo; end +``` + +Other comments or magic comments are left in place. + ## Sorbet/FalseSigil Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged --- | --- | --- | --- | --- Enabled | Yes | Yes | 0.3.3 | - @@ -197,11 +231,11 @@ ### Configurable attributes Name | Default value | Configurable values --- | --- | --- SuggestedStrictness | `false` | String -Include | `**/*.rb`, `**/*.rbi`, `**/*.rake`, `**/*.ru` | Array +Include | `**/*.{rb,rbi,rake,ru}` | Array Exclude | `bin/**/*`, `db/**/*.rb`, `script/**/*` | Array ## Sorbet/ForbidExtendTSigHelpersInShims Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged @@ -242,34 +276,39 @@ --- | --- | --- | --- | --- Disabled | Yes | No | 0.2.0 | 0.5.0 No documentation -## Sorbet/ForbidRBIOutsideOfSorbetDir +## Sorbet/ForbidRBIOutsideOfAllowedPaths 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/. +This cop makes sure that RBI files are always located under the defined allowed paths +Options: + +* `AllowedPaths`: A list of the paths where RBI files are allowed (default: ["sorbet/rbi/**"]) + ### Examples ```ruby # bad -lib/some_file.rbi -other_file.rbi +# lib/some_file.rbi +# other_file.rbi # good -sorbet/rbi/some_file.rbi -sorbet/rbi/any/path/for/file.rbi +# sorbet/rbi/some_file.rbi +# sorbet/rbi/any/path/for/file.rbi ``` ### Configurable attributes Name | Default value | Configurable values --- | --- | --- +AllowedPaths | `sorbet/rbi/**` | Array Include | `**/*.rbi` | Array ## Sorbet/ForbidSuperclassConstLiteral Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged @@ -346,10 +385,12 @@ Name | Default value | Configurable values --- | --- | --- SuggestedStrictness | `false` | String MinimumStrictness | `false` | String +Include | `**/*.{rb,rbi,rake,ru}` | Array +Exclude | `bin/**/*`, `db/**/*.rb`, `script/**/*` | Array ## Sorbet/IgnoreSigil Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged --- | --- | --- | --- | --- @@ -360,10 +401,12 @@ ### Configurable attributes Name | Default value | Configurable values --- | --- | --- SuggestedStrictness | `ignore` | String +Include | `**/*.{rb,rbi,rake,ru}` | Array +Exclude | `bin/**/*`, `db/**/*.rb`, `script/**/*` | Array ## Sorbet/KeywordArgumentOrdering Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged --- | --- | --- | --- | --- @@ -408,32 +451,10 @@ requires_ancestor Kernel requires_ancestor Minitest::Assertions end ``` -## Sorbet/ParametersOrderingInSignature - -Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged ---- | --- | --- | --- | --- -Enabled | Yes | No | 0.2.0 | - - -This cop checks for inconsistent ordering of parameters between the -signature and the method definition. The sorbet-runtime gem raises -when such inconsistency occurs. - -### Examples - -```ruby -# bad -sig { params(a: Integer, b: String).void } -def foo(b:, a:); end - -# good -sig { params(a: Integer, b: String).void } -def foo(a:, b:); end -``` - ## Sorbet/SignatureBuildOrder Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged --- | --- | --- | --- | --- Enabled | Yes | Yes | 0.3.0 | - @@ -487,10 +508,12 @@ ### Configurable attributes Name | Default value | Configurable values --- | --- | --- SuggestedStrictness | `strict` | String +Include | `**/*.{rb,rbi,rake,ru}` | Array +Exclude | `bin/**/*`, `db/**/*.rb`, `script/**/*` | Array ## Sorbet/StrongSigil Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged --- | --- | --- | --- | --- @@ -501,10 +524,12 @@ ### Configurable attributes Name | Default value | Configurable values --- | --- | --- SuggestedStrictness | `strong` | String +Include | `**/*.{rb,rbi,rake,ru}` | Array +Exclude | `bin/**/*`, `db/**/*.rb`, `script/**/*` | Array ## Sorbet/TrueSigil Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged --- | --- | --- | --- | --- @@ -515,10 +540,12 @@ ### Configurable attributes Name | Default value | Configurable values --- | --- | --- SuggestedStrictness | `true` | String +Include | `**/*.{rb,rbi,rake,ru}` | Array +Exclude | `bin/**/*`, `db/**/*.rb`, `script/**/*` | Array ## Sorbet/ValidSigil Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged --- | --- | --- | --- | --- @@ -540,5 +567,7 @@ Name | Default value | Configurable values --- | --- | --- RequireSigilOnAllFiles | `false` | Boolean SuggestedStrictness | `false` | String MinimumStrictness | `false` | String +Include | `**/*.{rb,rbi,rake,ru}` | Array +Exclude | `bin/**/*`, `db/**/*.rb`, `script/**/*` | Array