Coder Social home page Coder Social logo

Comments (2)

Morriar avatar Morriar commented on July 26, 2024

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.

Morriar avatar Morriar commented on July 26, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.