|
| 1 | +# Declare shortcuts for Steep::Signature::Ruby to make this file easier to read |
| 2 | +# as well as facilitating the findability of violation types emitted by the CLI |
| 3 | +# (e.g. the CLI emits `Diagnostic ID: Ruby::UnknownConstant` when finding errors). |
| 4 | +Ruby = Steep::Diagnostic::Ruby |
| 5 | + |
1 | 6 | target :datadog do
|
2 | 7 | signature 'sig'
|
3 | 8 |
|
4 | 9 | check 'lib/'
|
5 | 10 |
|
| 11 | + # This makes Steep check the codebase with the strictest settings. |
| 12 | + # We are free to disable checks if needed inside the block. |
| 13 | + # |
| 14 | + # The default level is `Ruby.default`, and there's an even stricter level called `Ruby.all_error`. |
| 15 | + configure_code_diagnostics(Ruby.strict) do |hash| |
| 16 | + # These checks can be gradually enabled as the codebase cleans up. |
| 17 | + # The reporting levels are: |
| 18 | + # * `:error`, `:warning`: These will fail `rake typecheck` and are always reported by default. |
| 19 | + # * `:information`, `:hint`: To see these, run `rake 'typecheck[--severity-level=information]'` |
| 20 | + # or `rake 'typecheck[--severity-level=hint]'` |
| 21 | + |
| 22 | + # These first checks are likely the easiest to fix, given they capture a mismatch |
| 23 | + # between the already declared type in `.rbs` and the actual type inferred by Steep. |
| 24 | + hash[Ruby::DifferentMethodParameterKind] = :information |
| 25 | + hash[Ruby::IncompatibleAssignment] = :information |
| 26 | + |
| 27 | + # These checks are a bit harder, because they represent the lack of sufficient type information. |
| 28 | + hash[Ruby::FallbackAny] = :information |
| 29 | + hash[Ruby::UnknownInstanceVariable] = :information |
| 30 | + hash[Ruby::UnknownRecordKey] = :information |
| 31 | + |
| 32 | + # This check asks you to type every empty collection used in |
| 33 | + # local variables with an inline type annotation (e.g. `ret = {} #: Hash[Symbol,untyped]`). |
| 34 | + # This pollutes the code base, and demands seemingly unnecessary typing of internal variables. |
| 35 | + # Ideally, these empty collections automatically assume a signature based on its usage inside its method. |
| 36 | + # @see https://github.com/soutaro/steep/pull/1338 |
| 37 | + hash[Ruby::UnannotatedEmptyCollection] = :information |
| 38 | + |
| 39 | + # This one is funny: it is raised whenever we use `super` from a method in a Module. |
| 40 | + # Since there's no guarantee that the module will be included in a class with the matching method, |
| 41 | + # Steep cannot know if the `super` call will be valid. |
| 42 | + # But this is very common in the codebase, as such module are used for monkey-patching. |
| 43 | + hash[Ruby::UnexpectedSuper] = :information |
| 44 | + end |
| 45 | + |
6 | 46 | ignore 'lib/datadog/appsec.rb'
|
7 | 47 | ignore 'lib/datadog/appsec/component.rb'
|
8 | 48 | # Excluded due to https://github.com/soutaro/steep/issues/1232
|
|
0 commit comments