nedap / formatting-stack

An efficient, smart, graceful composition of Clojure formatters, linters and such.
Eclipse Public License 2.0
98 stars 2 forks source link

Make some output homogeneous #48

Open vemv opened 5 years ago

vemv commented 5 years ago

Drop ../, align:

Reformatting ../src/foo/server.clj                                                                                                            
Fixing src/foo/server.clj 
thumbnail commented 4 years ago

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

vemv commented 4 years ago

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

thumbnail commented 4 years ago

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