Skip to content

Commit

Permalink
Formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
danschultzer committed Aug 16, 2023
1 parent 441808c commit 75ddae1
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
4 changes: 2 additions & 2 deletions lib/dialyxir/plt.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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 ->
Expand Down Expand Up @@ -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) ->
Expand Down
28 changes: 14 additions & 14 deletions test/dialyxir/formatter_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -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]}}
]

Expand All @@ -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]}}
]

Expand All @@ -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 ->
Expand All @@ -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 ->
Expand All @@ -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}]
Expand All @@ -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}]
Expand All @@ -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}]
Expand All @@ -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) ==
Expand All @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion test/warning_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 75ddae1

Please sign in to comment.