Skip to content

Commit

Permalink
Document SignatureBuildOrder cop
Browse files Browse the repository at this point in the history
Not having documentation means that `rubocop:todo` comments attached to
the class end up erroneously treated as documentation, and the simplest
way to avoid that is to document the doc, which we should be doing
anyway.
  • Loading branch information
sambostock committed Oct 13, 2023
1 parent c2bb447 commit e570049
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
19 changes: 19 additions & 0 deletions lib/rubocop/cop/sorbet/signatures/signature_build_order.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,25 @@
module RuboCop
module Cop
module Sorbet
# Checks for the correct order of sig builder methods:
# - abstract, override, or overridable
# - type_parameters
# - params
# - returns, or void
# - soft, checked, or on_failure
#
# @example
# # bad
# sig { void.abstract }
#
# # good
# sig { abstract.void }
#
# # bad
# sig { returns(Integer).params(x: Integer) }
#
# # good
# sig { params(x: Integer).returns(Integer) }
class SignatureBuildOrder < SignatureCop
ORDER =
[
Expand Down
23 changes: 22 additions & 1 deletion manual/cops_sorbet.md
Original file line number Diff line number Diff line change
Expand Up @@ -710,7 +710,28 @@ Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChan
--- | --- | --- | --- | ---
Enabled | Yes | Yes | 0.3.0 | -
No documentation
Checks for the correct order of sig builder methods:
- abstract, override, or overridable
- type_parameters
- params
- returns, or void
- soft, checked, or on_failure
# bad
sig { returns(Integer).params(x: Integer) }
# good
sig { params(x: Integer).returns(Integer) }
### Examples
```ruby
# bad
sig { void.abstract }
# good
sig { abstract.void }
```
## Sorbet/SignatureCop
Expand Down

0 comments on commit e570049

Please sign in to comment.