Skip to content

Commit

Permalink
Make column/line optional in reporting (#163)
Browse files Browse the repository at this point in the history
* Do not require :column and :line in reports.

fixes #162

* print ? for missing column or line

* v4.2.3-alpha1

* add comment
  • Loading branch information
thumbnail authored May 19, 2020
1 parent 57e4651 commit 4e9cbd7
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 10 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ As you can see in the screenshot, **formatting-stack** presents linters' outputs
#### Coordinates

```clojure
[formatting-stack "4.2.2"]
[formatting-stack "4.2.3-alpha1"]
```

**Also** you might have to add the [refactor-nrepl](https://github.com/clojure-emacs/refactor-nrepl) dependency.
Expand Down
2 changes: 1 addition & 1 deletion project.clj
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
;; Please don't bump the library version by hand - use ci.release-workflow instead.
(defproject formatting-stack "4.2.2"
(defproject formatting-stack "4.2.3-alpha1"
;; Please keep the dependencies sorted a-z.
:dependencies [[clj-kondo "2020.01.13"]
[cljfmt "0.6.5" :exclusions [rewrite-clj]]
Expand Down
10 changes: 5 additions & 5 deletions src/formatting_stack/protocols/spec.clj
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ so that final users can locate them and configure them."

(spec/def ::column nat-int?)

(spec/def ::line ::column)
(spec/def ::line nat-int?)

(spec/def ::warning-details-url present-string?)

Expand All @@ -53,10 +53,10 @@ so that final users can locate them and configure them."
(spec/keys :req-un [::filename
::source
::msg
::level
::column
::line]
:opt-un [::msg-extra-data
::level]
:opt-un [::column ;; not every linter reports column/line, see https://git.io/JfuoJ
::line
::msg-extra-data
::warning-details-url]))

(spec/def ::report
Expand Down
4 changes: 2 additions & 2 deletions src/formatting_stack/reporters/pretty_printer.clj
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@
(cond-> (str " See: " url)
colorize? (colorize :grey)
true println))]
{:keys [msg column line source level msg-extra-data warning-details-url]} (->> group-entries
(sort-by :line))]
{:keys [msg column line msg-extra-data] :or {column "?", line "?"}} (->> group-entries
(sort-by :line))]

(println (cond-> (str " " line ":" column)
colorize? (colorize :grey))
Expand Down
6 changes: 5 additions & 1 deletion test/unit/formatting_stack/reporters/pretty_printer.clj
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,11 @@

"Can print `:msg-extra-data` (at the correct indentation level)"
[{:filename "filename", :msg "message", :source ::source, :level :warning, :line 0 :column 0, :msg-extra-data ["Foo" "Bar"]}]
"filename\n :unit.formatting-stack.reporters.pretty-printer/source\n 0:0 message\n Foo\n Bar\n\n"))
"filename\n :unit.formatting-stack.reporters.pretty-printer/source\n 0:0 message\n Foo\n Bar\n\n"

"Can print missing `:column` and `:line`"
[{:filename "filename", :msg "message", :source ::source, :level :warning}]
"filename\n :unit.formatting-stack.reporters.pretty-printer/source\n ?:? message\n\n"))

(deftest print-summary
(are [input expected] (= expected
Expand Down

0 comments on commit 4e9cbd7

Please sign in to comment.