Comments (2)
However, it doesn't make sense to add them on
typed: false
files as they won't be validated anyway.
This is actually incorrect, consider the following files:
# file false.rb
# typed: false
extend T::Sig
sig { params(x: Integer).void }
def foo(x); end
# file true.rb
# typed: true
foo("1")
If you run Sorbet on those files, you'll notice that the calls from true.rb
are actually checked against the signatures from false.rb
:
true.rb:3: Expected `Integer` but found `String("1")` for argument `x` https://srb.help/7002
3 |foo("1")
^^^
Expected `Integer` for argument `x` of method `Object#foo`:
false.rb:5:
5 |sig { params(x: Integer).void }
^
Got `String("1")` originating from:
true.rb:3:
3 |foo("1")
^^^
Errors: 1
Can an option be added to not do so? e.g.
Sorbet/EnforceSignatures: Enabled: true EnforcedStyle: ignore_typed_false
This is a good idea! Do you want to take a shot at it? You can take a look at how we read the configuration of the cop in https://github.com/Shopify/rubocop-sorbet/blob/main/lib/rubocop/cop/sorbet/rbi/forbid_rbi_outside_of_allowed_paths.rb#L58 for example.
from rubocop-sorbet.
Closing this. Please feel free to open a separate issue (or even better a pull-request) to add an option to the cop.
from rubocop-sorbet.
Related Issues (20)
- Integration with the Sorbet LSP
- Sigil cops ignore double commented sigils
- Discourage references to `ActiveRecord::Associations::CollectionProxy` and other synthetic constants
- EmptyLineAfterSig does't recognize `attr` declarations
- Consider a cop to detect stubbing of `is_a?`
- Forbid defining implicit conversion methods (to_ary, to_hash, to_int, to_str) HOT 1
- ValidSigil parsing behaves differently than sorbet sigil parsing
- Sorbet/AllowIncompatibleOverride inspection error HOT 2
- Suggestion: Cop for `sig` as a single or multi-line block
- Sorbet/ForbidTStruct - autocorrect does not handle optional params without default or factory HOT 1
- Enforce parentheses around return values in signatures HOT 1
- Suggestion: Cop for missing `require "sorbet-runtime"` HOT 6
- Patch `Performance/RedundantBlockCall` to teach it about Sorbet `sig`s HOT 1
- Discourage misuses of `T::Enum` HOT 3
- Suggested cop: prefer `first`/`drop`/`last` over `[]` with particular kinds of ranges
- Explain EnforceSigilOrder better in documentation HOT 5
- Cop suggestion: Sorbet/StructPropName for T::Struct properties HOT 1
- New deprecation warning after upgrading rubocop to 1.65 HOT 4
- Deprecation Warnings: `Cop.registry` is deprecated. Use `Registry.global` instead. HOT 2
- Add cop to suggest `grep` over `select` when using only for type narrowing HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rubocop-sorbet.