@@ -14,6 +14,46 @@ defmodule Dialyxir.FormatterTest do
1414 Mix.Project . in_project ( app , "test/fixtures/#{ Atom . to_string ( app ) } " , fn _ -> f . ( ) end )
1515 end
1616
17+ describe "formats dialyzer warning" do
18+ if System . otp_release ( ) >= "24" do
19+ for { formatter , message } <- % {
20+ Formatter.Dialyxir =>
21+ "lib/file/warning_type/line.ex:19:4:no_return\n Function format_long/1 has no local return." ,
22+ Formatter.Dialyzer =>
23+ "lib/file/warning_type/line.ex:19:4: Function format_long/1 has no local return" ,
24+ Formatter.Github =>
25+ "::warning file=lib/file/warning_type/line.ex,line=19,col=4,title=no_return::Function format_long/1 has no local return." ,
26+ Formatter.IgnoreFileStrict =>
27+ ~s| {"lib/file/warning_type/line.ex", "Function format_long/1 has no local return."},| ,
28+ Formatter.IgnoreFile => ~s| {"lib/file/warning_type/line.ex", :no_return},| ,
29+ # TODO: Remove if once only Elixir ~> 1.15 is supported
30+ Formatter.Raw =>
31+ if Version . match? ( System . version ( ) , "<= 1.15.0" ) do
32+ ~s| {:warn_return_no_exit, {'lib/file/warning_type/line.ex', {19, 4}}, {:no_return, [:only_normal, :format_long, 1]}}|
33+ else
34+ ~s| {:warn_return_no_exit, {~c"lib/file/warning_type/line.ex", {19, 4}}, {:no_return, [:only_normal, :format_long, 1]}}|
35+ end ,
36+ Formatter.Short =>
37+ "lib/file/warning_type/line.ex:19:4:no_return Function format_long/1 has no local return."
38+ } do
39+ test "file location including column for #{ formatter } formatter" do
40+ assert { :warn , [ message ] , _unused_filters } =
41+ Formatter . format_and_filter (
42+ [
43+ { :warn_return_no_exit , { ~c" lib/file/warning_type/line.ex" , { 19 , 4 } } ,
44+ { :no_return , [ :only_normal , :format_long , 1 ] } }
45+ ] ,
46+ Project ,
47+ [ ] ,
48+ unquote ( formatter )
49+ )
50+
51+ assert message =~ unquote ( message )
52+ end
53+ end
54+ end
55+ end
56+
1757 describe "exs ignore" do
1858 test "evaluates an ignore file and ignores warnings matching the pattern" do
1959 warnings = [
0 commit comments