From 75ddae10509dc17ab7a6a09187374cba852cc6aa Mon Sep 17 00:00:00 2001 From: Dan Schultzer <1254724+danschultzer@users.noreply.github.com> Date: Sat, 22 Jul 2023 16:56:25 -0700 Subject: [PATCH] Formatter --- lib/dialyxir/plt.ex | 4 ++-- test/dialyxir/formatter_test.exs | 28 ++++++++++++++-------------- test/warning_test.exs | 2 +- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/lib/dialyxir/plt.ex b/lib/dialyxir/plt.ex index 43dc0c9f..a345c249 100644 --- a/lib/dialyxir/plt.ex +++ b/lib/dialyxir/plt.ex @@ -63,7 +63,7 @@ defmodule Dialyxir.Plt do end defp app_info(app) do - app_file = Atom.to_charlist(app) ++ '.app' + app_file = Atom.to_charlist(app) ++ ~c".app" case :code.where_is_file(app_file) do :non_existing -> @@ -111,7 +111,7 @@ defmodule Dialyxir.Plt do end defp resolve_module(module, beams) do - beam = Atom.to_charlist(module) ++ '.beam' + beam = Atom.to_charlist(module) ++ ~c".beam" case :code.where_is_file(beam) do path when is_list(path) -> diff --git a/test/dialyxir/formatter_test.exs b/test/dialyxir/formatter_test.exs index a76db820..cbc7bdf5 100644 --- a/test/dialyxir/formatter_test.exs +++ b/test/dialyxir/formatter_test.exs @@ -17,11 +17,11 @@ defmodule Dialyxir.FormatterTest do describe "exs ignore" do test "evaluates an ignore file and ignores warnings matching the pattern" do warnings = [ - {:warn_return_no_exit, {'lib/short_description.ex', 17}, + {:warn_return_no_exit, {~c"lib/short_description.ex", 17}, {:no_return, [:only_normal, :format_long, 1]}}, - {:warn_return_no_exit, {'lib/file/warning_type.ex', 18}, + {:warn_return_no_exit, {~c"lib/file/warning_type.ex", 18}, {:no_return, [:only_normal, :format_long, 1]}}, - {:warn_return_no_exit, {'lib/file/warning_type/line.ex', 19}, + {:warn_return_no_exit, {~c"lib/file/warning_type/line.ex", 19}, {:no_return, [:only_normal, :format_long, 1]}} ] @@ -35,11 +35,11 @@ defmodule Dialyxir.FormatterTest do test "evaluates an ignore file of the form {file, short_description} and ignores warnings matching the pattern" do warnings = [ - {:warn_return_no_exit, {'lib/poorly_written_code.ex', 10}, + {:warn_return_no_exit, {~c"lib/poorly_written_code.ex", 10}, {:no_return, [:only_normal, :do_a_thing, 1]}}, - {:warn_return_no_exit, {'lib/poorly_written_code.ex', 20}, + {:warn_return_no_exit, {~c"lib/poorly_written_code.ex", 20}, {:no_return, [:only_normal, :do_something_else, 2]}}, - {:warn_return_no_exit, {'lib/poorly_written_code.ex', 30}, + {:warn_return_no_exit, {~c"lib/poorly_written_code.ex", 30}, {:no_return, [:only_normal, :do_many_things, 3]}} ] @@ -53,7 +53,7 @@ defmodule Dialyxir.FormatterTest do test "does not filter lines not matching the pattern" do warning = - {:warn_return_no_exit, {'a/different_file.ex', 17}, + {:warn_return_no_exit, {~c"a/different_file.ex", 17}, {:no_return, [:only_normal, :format_long, 1]}} in_project(:ignore, fn -> @@ -66,7 +66,7 @@ defmodule Dialyxir.FormatterTest do test "can filter by regex" do warning = - {:warn_return_no_exit, {'a/regex_file.ex', 17}, + {:warn_return_no_exit, {~c"a/regex_file.ex", 17}, {:no_return, [:only_normal, :format_long, 1]}} in_project(:ignore, fn -> @@ -79,7 +79,7 @@ defmodule Dialyxir.FormatterTest do test "lists unnecessary skips as warnings if ignoring exit status" do warning = - {:warn_return_no_exit, {'a/regex_file.ex', 17}, + {:warn_return_no_exit, {~c"a/regex_file.ex", 17}, {:no_return, [:only_normal, :format_long, 1]}} filter_args = [{:ignore_exit_status, true}] @@ -94,7 +94,7 @@ defmodule Dialyxir.FormatterTest do test "error on unnecessary skips without ignore_exit_status" do warning = - {:warn_return_no_exit, {'a/regex_file.ex', 17}, + {:warn_return_no_exit, {~c"a/regex_file.ex", 17}, {:no_return, [:only_normal, :format_long, 1]}} filter_args = [{:ignore_exit_status, false}] @@ -109,7 +109,7 @@ defmodule Dialyxir.FormatterTest do test "overwrite ':list_unused_filters_present'" do warning = - {:warn_return_no_exit, {'a/regex_file.ex', 17}, + {:warn_return_no_exit, {~c"a/regex_file.ex", 17}, {:no_return, [:only_normal, :format_long, 1]}} filter_args = [{:list_unused_filters, false}] @@ -126,7 +126,7 @@ defmodule Dialyxir.FormatterTest do describe "simple string ignore" do test "evaluates an ignore file and ignores warnings matching the pattern" do warning = - {:warn_matching, {'a/file.ex', 17}, {:pattern_match, ['pattern \'ok\'', '\'error\'']}} + {:warn_matching, {~c"a/file.ex", 17}, {:pattern_match, [~c"pattern 'ok'", ~c"'error'"]}} in_project(:ignore_string, fn -> assert Formatter.format_and_filter([warning], Project, [], :dialyzer) == @@ -137,9 +137,9 @@ defmodule Dialyxir.FormatterTest do test "listing unused filter behaves the same for different formats" do warnings = [ - {:warn_return_no_exit, {'a/regex_file.ex', 17}, + {:warn_return_no_exit, {~c"a/regex_file.ex", 17}, {:no_return, [:only_normal, :format_long, 1]}}, - {:warn_return_no_exit, {'a/another-file.ex', 18}, {:unknown_type, {:M, :F, :A}}} + {:warn_return_no_exit, {~c"a/another-file.ex", 18}, {:unknown_type, {:M, :F, :A}}} ] expected_warning = "a/another-file.ex:18" diff --git a/test/warning_test.exs b/test/warning_test.exs index d958cb7b..4473e7e7 100644 --- a/test/warning_test.exs +++ b/test/warning_test.exs @@ -4,7 +4,7 @@ defmodule Dialyxir.Test.WarningTest do # Don't test output in here, just that it can succeed. test "pattern match warning succeeds on valid input" do - arguments = ['pattern {\'ok\', Vuser@1}', '{\'error\',<<_:64,_:_*8>>}'] + arguments = [~c"pattern {'ok', Vuser@1}", ~c"{'error',<<_:64,_:_*8>>}"] assert(Dialyxir.Warnings.PatternMatch.format_long(arguments)) end end