formatting-stack icon indicating copy to clipboard operation
formatting-stack copied to clipboard

Make some output homogeneous

Open vemv opened this issue 6 years ago • 3 comments

Drop ../, align:

Reformatting ../src/foo/server.clj                                                                                                            
Fixing src/foo/server.clj 

vemv avatar Mar 09 '19 18:03 vemv

an alternative would be to suppress any printing and expecting a report for any action (formatting/linting) which can be handled more fine grained.

These reports could be manipulated to provide different styled outputs (grouped per file, colorized, reporting-levels, summaries, etc).


clj-kondo has a pretty pleasant API which returns a map like;

{:findings [{:level :error,
             :type :unresolved-symbol,
             :filename "taoensso/truss/impl.cljs",
             :message "unresolved symbol e",
             :row 200,
             :col 35},
             ...],
  :summary {:error 52, :warning 0, :info 0, :type :summary, :duration 173}}

#93 has a minimal POC containing a similar approach for formatters

thumbnail avatar Dec 28 '19 21:12 thumbnail

Could be. Depends on what all formatters/linters actually do. I think some just println, w/o offering a data-oriented API

As you probably know with-serialized-output is a thing and it already successfully captures all 3rd party output. Out of that, mutating ../ (clojure.string/replace) seems easy.

...Aligning not so much, but alignment would be just as hard with either approach

vemv avatar Dec 28 '19 23:12 vemv

I think some just println, w/o offering a data-oriented API

That's true, but because we internally call the linters with 1 file only (usually), we could construct a bare minimum report {:filename ..., :message ..., col: 1, row: 1, :level :warning}.

Aligning not so much, but alignment would be just as hard with either approach

I think alignment isn't that big of an issue if you have control over the output. I think per-file grouping of all lint-errors and format-messages is ideal for a clean outout

thumbnail avatar Dec 29 '19 07:12 thumbnail