manual/cops_sorbet.md in rubocop-sorbet-0.6.11 vs manual/cops_sorbet.md in rubocop-sorbet-0.7.0

- old
+ new

@@ -136,19 +136,42 @@ # good { "User" => User }.fetch(class_name) ``` +## Sorbet/EmptyLineAfterSig + +Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged +--- | --- | --- | --- | --- +Enabled | Yes | Yes | 0.7.0 | - + +This cop checks for blank lines after signatures. + +It also suggests an autocorrect + +### Examples + +```ruby +# bad +sig { void } + +def foo; end + +# good +sig { void } +def foo; end +``` + ## Sorbet/EnforceSigilOrder Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged --- | --- | --- | --- | --- Enabled | Yes | Yes | 0.3.4 | - This cop checks that the Sorbet sigil comes as the first magic comment in the file. -The expected order for magic comments is: typed, (en)?coding, warn_indent then frozen_string_literal. +The expected order for magic comments is: (en)?coding, typed, warn_indent then frozen_string_literal. For example, the following bad ordering: ```ruby # frozen_string_literal: true @@ -162,11 +185,11 @@ # typed: true # frozen_string_literal: true class Foo; end ``` -Only `typed`, `(en)?coding`, `warn_indent` and `frozen_string_literal` magic comments are considered, +Only `(en)?coding`, `typed`, `warn_indent` and `frozen_string_literal` magic comments are considered, other comments or magic comments are left in the same place. ## Sorbet/EnforceSignatures Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged @@ -195,11 +218,11 @@ ## Sorbet/EnforceSingleSigil Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged --- | --- | --- | --- | --- -Enabled | Yes | Yes | <<next>> | - +Enabled | Yes | Yes | 0.7.0 | - This cop checks that there is only one Sorbet sigil in a given file For example, the following class with two sigils @@ -286,29 +309,30 @@ 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/**"]) +* `AllowedPaths`: A list of the paths where RBI files are allowed (default: ["rbi/**", "sorbet/rbi/**"]) ### Examples ```ruby # bad # lib/some_file.rbi # other_file.rbi # good +# rbi/external_interface.rbi # sorbet/rbi/some_file.rbi # sorbet/rbi/any/path/for/file.rbi ``` ### Configurable attributes Name | Default value | Configurable values --- | --- | --- -AllowedPaths | `sorbet/rbi/**` | Array +AllowedPaths | `rbi/**`, `sorbet/rbi/**` | Array Include | `**/*.rbi` | Array ## Sorbet/ForbidSuperclassConstLiteral Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged @@ -366,23 +390,23 @@ Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged --- | --- | --- | --- | --- Enabled | Yes | No | 0.4.0 | - This cop disallows use of `T.untyped` or `T.nilable(T.untyped)` -as a prop type for `T::Struct`. +as a prop type for `T::Struct` or `T::ImmutableStruct`. ### Examples ```ruby # bad -class SomeClass +class SomeClass < T::Struct const :foo, T.untyped prop :bar, T.nilable(T.untyped) end # good -class SomeClass +class SomeClass < T::Struct const :foo, Integer prop :bar, T.nilable(String) end ``` @@ -468,9 +492,36 @@ # good module SomeModule requires_ancestor Kernel requires_ancestor Minitest::Assertions +end +``` + +## Sorbet/RedundantExtendTSig + +Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged +--- | --- | --- | --- | --- +Disabled | No | Yes | 0.7.0 | - + +Forbids the use of redundant `extend T::Sig`. Only for use in +applications that monkey patch `Module.include(T::Sig)` globally, +which would make it redundant. + +### Examples + +```ruby +# bad +class Example + extend T::Sig + sig { void } + def no_op; end +end + +# good +class Example + sig { void } + def no_op; end end ``` ## Sorbet/SignatureBuildOrder