soutaro / steep

Static type checker for Ruby
MIT License
1.38k stars 87 forks source link

Steep Should not exit with status 1 on warning #1277

Open aaronmallen opened 1 month ago

aaronmallen commented 1 month ago

Currently steep will exit with code 1 on warning:

Run ./.github/actions/lint/types
Run bundle exec steep check --jobs 5
# Type checking files:

.....................................................................................................................................................................................................F..

Warning: type/lib/domainic/type/constraint/parameter.rb:108:66: [warning] Cannot pass a value of type `::Proc` as a block-pass-argument of type `^ [self: (singleton(::Domainic::Type::Constraint::BaseConstraint) | ::Domainic::Type::Constraint::BaseConstraint)] -> U(48)`
│   ::Proc <: ^ [self: (singleton(::Domainic::Type::Constraint::BaseConstraint) | ::Domainic::Type::Constraint::BaseConstraint)] -> U(48)
│
│ Diagnostic ID: Ruby::BlockTypeMismatch
│
└           callbacks.each { |callback| @base.instance_exec(@value, &callback) }
                                                                    ~~~~~~~~~

Warning: type/lib/domainic/type/constraint/parameter.rb:136:44: [warning] Cannot pass a value of type `::Proc` as a block-pass-argument of type `^ [self: (singleton(::Domainic::Type::Constraint::BaseConstraint) | ::Domainic::Type::Constraint::BaseConstraint)] -> U(49)`
│   ::Proc <: ^ [self: (singleton(::Domainic::Type::Constraint::BaseConstraint) | ::Domainic::Type::Constraint::BaseConstraint)] -> U(49)
│
│ Diagnostic ID: Ruby::BlockTypeMismatch
│
└           return base.instance_exec(result, &coercer) if coercer.is_a?(Proc)
                                              ~~~~~~~~

Warning: type/lib/domainic/type/constraint/parameter.rb:169:43: [warning] Cannot pass a value of type `::Proc` as a block-pass-argument of type `^ [self: (singleton(::Domainic::Type::Constraint::BaseConstraint) | ::Domainic::Type::Constraint::BaseConstraint)] -> U(51)`
│   ::Proc <: ^ [self: (singleton(::Domainic::Type::Constraint::BaseConstraint) | ::Domainic::Type::Constraint::BaseConstraint)] -> U(51)
│
│ Diagnostic ID: Ruby::BlockTypeMismatch
│
└           return base.instance_exec(value, &validator) if validator.is_a?(Proc)
                                             ~~~~~~~~~~

Detected 3 problems from 1 file
Error: Process completed with exit code 1.
aaronmallen commented 1 month ago

My current work around:

# Steepfile

configure_code_diagnostics do |config|
  config[Steep::Diagnostic::Ruby::BlockTypeMismatch] = :hint
end
soutaro commented 1 month ago

It exits with error when it prints diagnostics. So, passing --severity-level to steep check would be another workaround.

I don't think giving Error diagnostics a special treatment is a good way. Adding a command line option like --fail-severity-level=error?

p-datadog commented 2 weeks ago

The convention is that exit status 0 means success. Warning is not a failure. Compilers have an option to treat warnings as errors, I suggest following the same logic with steep: add an option to exit with 1 if any warnings are emitted, by default warnings should exit with 0.