Skip to content

Commit ef81a2f

Browse files
marcotcStrech
andauthored
Upgrade steep and make it a bit more strict (#4221)
* Upgrade steep and make it a bit more strict * Update ruby-3.0.gemfile Co-authored-by: Sergey Fedorov <[email protected]> * Unlock rbs and steep --------- Co-authored-by: Sergey Fedorov <[email protected]>
1 parent 74d49f8 commit ef81a2f

File tree

7 files changed

+50
-13
lines changed

7 files changed

+50
-13
lines changed

Steepfile

+40
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,48 @@
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+
16
target :datadog do
27
signature 'sig'
38

49
check 'lib/'
510

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+
646
ignore 'lib/datadog/appsec.rb'
747
ignore 'lib/datadog/appsec/component.rb'
848
# Excluded due to https://github.com/soutaro/steep/issues/1232

lib/datadog/appsec/processor/rule_loader.rb

-3
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,6 @@ def passlist_exclusions(ip_passlist) # rubocop:disable Metrics/MethodLength
7474
when Hash
7575
pass = ip_passlist[:pass]
7676
monitor = ip_passlist[:monitor]
77-
else
78-
pass = []
79-
monitor = []
8077
end
8178

8279
exclusions = []

ruby-3.0.gemfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ gem 'webmock', '>= 3.10.0'
5353
gem 'webrick', '>= 1.7.0'
5454

5555
group :check do
56-
gem 'rbs', '~> 3.6', require: false
57-
gem 'steep', '~> 1.7.0', require: false
56+
gem 'rbs', '>= 3.6.1', require: false
57+
gem 'steep', '~> 1', '>= 1.7.1', require: false
5858
gem 'standard', require: false
5959
end
6060

ruby-3.1.gemfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ gem 'webmock', '>= 3.10.0'
5353
gem 'webrick', '>= 1.7.0'
5454

5555
group :check do
56-
gem 'rbs', '~> 3.6', require: false
57-
gem 'steep', '~> 1.7.0', require: false
56+
gem 'rbs', '>= 3.6.1', require: false
57+
gem 'steep', '~> 1', '>= 1.7.1', require: false
5858
gem 'standard', require: false
5959
end
6060

ruby-3.2.gemfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ gem 'webmock', '>= 3.10.0'
5252
gem 'webrick', '>= 1.7.0'
5353

5454
group :check do
55-
gem 'rbs', '~> 3.6', require: false
56-
gem 'steep', '~> 1.7.0', require: false
55+
gem 'rbs', '>= 3.6.1', require: false
56+
gem 'steep', '~> 1', '>= 1.7.1', require: false
5757
gem 'standard', require: false
5858
end
5959

ruby-3.3.gemfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ gem 'webmock', '>= 3.10.0'
5252
gem 'webrick', '>= 1.7.0'
5353

5454
group :check do
55-
gem 'rbs', '~> 3.6', require: false
56-
gem 'steep', '~> 1.7.0', require: false
55+
gem 'rbs', '>= 3.6.1', require: false
56+
gem 'steep', '~> 1', '>= 1.7.1', require: false
5757
gem 'standard', require: false
5858
end
5959

ruby-3.4.gemfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ gem 'webmock', '>= 3.10.0'
6363
gem 'webrick', '>= 1.8.2'
6464

6565
group :check do
66-
gem 'rbs', '~> 3.6', require: false
67-
gem 'steep', '~> 1.7.0', require: false
66+
gem 'rbs', '>= 3.6.1', require: false
67+
gem 'steep', '~> 1', '>= 1.7.1', require: false
6868
gem 'ruby_memcheck', '>= 3'
6969
gem 'standard', require: false
7070
end

0 commit comments

Comments
 (0)