soutaro / steep

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

Output format selection and improved automation formats #977

Open lloeki opened 11 months ago

lloeki commented 11 months ago

Steep outputs pretty errors for humans to consume:

Steepfile:4:2: [error] Type `::Steep::Project::DSL` does not have method `check`
│ Diagnostic ID: Ruby::NoMethod
│
└   check '.'
    ~~~~~

Steepfile:5:2: [error] Type `::Steep::Project::DSL` does not have method `check`
│ Diagnostic ID: Ruby::NoMethod
│
└   check 'Steepfile'
    ~~~~~

But when plugging Steep into tools it's possible yet unwieldy to parse... I did that for ALE and was able to get a surprising amount of information: start/end of multiline message, file, row, column start, severity, message, code, column end via length from the squiggly underlining. Although it works (and was fun) it's also brittle in the sense that if the pretty output changes it's going to break.

Sure there's langserver but in this specific case LSP doesn't quite cut it, and in some automation scenarios langserver just doesn't make sense.

It would be quite nice if steep check would accept a --format parameter, defaulting to pretty but also having stable programmatic formats such as:

soutaro commented 11 months ago

Hi!

Currently, you can use --save-expectations to generate the reports in YAML format.

I'm also open to add another output format support. YAML can be relatively easily implemented on the top of the expectations output feature.

I think the location can be represented with four-attributes in structured formats -- JSON or YAML.

lloeki commented 11 months ago

I think the location can be represented with four-attributes in structured formats

Oh yeah, I just took Rubocop's outpout directly and tweaked it a bit to sort of make sense in a Steep+RBS context. I was a bit surprised by all these apparently redundant values! I don't know if they're legacy carried over for backwards compatibility or if they can differ in certain corner cases.