Skip to content

Commit

Permalink
Merge pull request #423 from soutaro/typing-options
Browse files Browse the repository at this point in the history
Print instruction to update configuration
  • Loading branch information
soutaro committed Aug 30, 2021
2 parents b3c65f0 + b695481 commit de906fc
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 2 deletions.
46 changes: 45 additions & 1 deletion lib/steep/project/dsl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,51 @@ def library(*args)
end

def typing_options(level = nil, **hash)
Steep.logger.error "#typing_options is deprecated and has no effect as of version 0.46.0"
Steep.logger.error "#typing_options is deprecated and has no effect as of version 0.46.0. Update your Steepfile as follows for (almost) equivalent setting:"

messages = []

messages << "# D = Steep::Diagnostic # Define a constant to shorten namespace"

case level
when :strict
messages << "configure_code_diagnostics(D::Ruby.strict) # :strict"
when :default
messages << "configure_code_diagnostics(D::Ruby.default) # :default"
when :lenient
messages << "configure_code_diagnostics(D::Ruby.lenient) # :lenient"
end

messages.each do |msg|
Steep.logger.error " #{msg}"
end

config = []

if hash[:allow_missing_definitions]
config << "hash[D::Ruby::MethodDefinitionMissing] = nil # allow_missing_definitions"
end

if hash[:allow_fallback_any]
config << "hash[D::Ruby::FallbackAny] = nil # allow_fallback_any"
end

if hash[:allow_unknown_constant_assignment]
config << "hash[D::Ruby::UnknownConstantAssigned] = nil # allow_unknown_constant_assignment"
end

if hash[:allow_unknown_method_calls]
config << "hash[D::Ruby::NoMethod] = nil # allow_unknown_method_calls"
end

unless config.empty?
Steep.logger.error " configure_code_diagnostics do |hash|"
config.each do |c|
Steep.logger.error " #{c}"
end
Steep.logger.error " end"
end

end

def signature(*args)
Expand Down
5 changes: 4 additions & 1 deletion test/steepfile_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,10 @@ def test_config_typing_options
end
RUBY

assert_match(/\[Steepfile\] \[target=app\] #typing_options is deprecated and has no effect as of version 0\.46\.0/, Steep.log_output.string)
assert_match(/\[Steepfile\] \[target=app\] #typing_options is deprecated and has no effect as of version 0\.46\.0\. Update your Steepfile as follows for \(almost\) equivalent setting:/, Steep.log_output.string)
assert_match(/configure_code_diagnostics\(D::Ruby\.strict\)/, Steep.log_output.string)
assert_match(/hash\[D::Ruby::MethodDefinitionMissing\] = nil/, Steep.log_output.string)
assert_match(/hash\[D::Ruby::FallbackAny\] = nil/, Steep.log_output.string)
ensure
Steep.log_output = STDERR
end
Expand Down

0 comments on commit de906fc

Please sign in to comment.