Format code with Elixir 1.12

This commit is contained in:
Marcel Otto 2021-05-22 16:08:19 +02:00
parent fc6ee4555f
commit 3b16a76ccd
12 changed files with 18 additions and 54 deletions

View file

@ -40,9 +40,7 @@ defimpl Inspect, for: RDF.Description do
caught_exception -> caught_exception ->
message = message =
"got #{inspect(caught_exception.__struct__)} with message " <> "got #{inspect(caught_exception.__struct__)} with message " <>
"#{inspect(Exception.message(caught_exception))} while inspecting RDF.Description #{ "#{inspect(Exception.message(caught_exception))} while inspecting RDF.Description #{description.subject}"
description.subject
}"
exception = Inspect.Error.exception(message: message) exception = Inspect.Error.exception(message: message)
@ -87,9 +85,7 @@ defimpl Inspect, for: RDF.Graph do
caught_exception -> caught_exception ->
message = message =
"got #{inspect(caught_exception.__struct__)} with message " <> "got #{inspect(caught_exception.__struct__)} with message " <>
"#{inspect(Exception.message(caught_exception))} while inspecting RDF.Graph #{ "#{inspect(Exception.message(caught_exception))} while inspecting RDF.Graph #{graph.name}"
graph.name
}"
exception = Inspect.Error.exception(message: message) exception = Inspect.Error.exception(message: message)

View file

@ -53,9 +53,7 @@ defmodule RDF.Literal.Generic do
literal literal
else else
raise ArgumentError, raise ArgumentError,
"#{inspect(value)} with datatype #{inspect(literal.literal.datatype)} is not a valid #{ "#{inspect(value)} with datatype #{inspect(literal.literal.datatype)} is not a valid #{inspect(__MODULE__)}"
inspect(__MODULE__)
}"
end end
end end

View file

@ -54,9 +54,7 @@ defmodule RDF.LangString do
literal literal
else else
raise ArgumentError, raise ArgumentError,
"#{inspect(value)} with language #{inspect(literal.literal.language)} is not a valid #{ "#{inspect(value)} with language #{inspect(literal.literal.language)} is not a valid #{inspect(__MODULE__)}"
inspect(__MODULE__)
}"
end end
end end

View file

@ -39,15 +39,11 @@ defmodule RDF.NQuads.Decoder do
else else
{:error, {error_line, :ntriples_lexer, error_descriptor}, _error_line_again} -> {:error, {error_line, :ntriples_lexer, error_descriptor}, _error_line_again} ->
{:error, {:error,
"N-Quad scanner error#{if error_with_line_number, do: " on line #{error_line}"}: #{ "N-Quad scanner error#{if error_with_line_number, do: " on line #{error_line}"}: #{error_description(error_descriptor)}"}
error_description(error_descriptor)
}"}
{:error, {error_line, :nquads_parser, error_descriptor}} -> {:error, {error_line, :nquads_parser, error_descriptor}} ->
{:error, {:error,
"N-Quad parser error#{if error_with_line_number, do: " on line #{error_line}"}: #{ "N-Quad parser error#{if error_with_line_number, do: " on line #{error_line}"}: #{error_description(error_descriptor)}"}
error_description(error_descriptor)
}"}
end end
end end

View file

@ -39,15 +39,11 @@ defmodule RDF.NTriples.Decoder do
else else
{:error, {error_line, :ntriples_lexer, error_descriptor}, _error_line_again} -> {:error, {error_line, :ntriples_lexer, error_descriptor}, _error_line_again} ->
{:error, {:error,
"N-Triple scanner error#{if error_with_line_number, do: " on line #{error_line}"}: #{ "N-Triple scanner error#{if error_with_line_number, do: " on line #{error_line}"}: #{error_description(error_descriptor)}"}
error_description(error_descriptor)
}"}
{:error, {error_line, :ntriples_parser, error_descriptor}} -> {:error, {error_line, :ntriples_parser, error_descriptor}} ->
{:error, {:error,
"N-Triple parser error#{if error_with_line_number, do: " on line #{error_line}"}: #{ "N-Triple parser error#{if error_with_line_number, do: " on line #{error_line}"}: #{error_description(error_descriptor)}"}
error_description(error_descriptor)
}"}
end end
end end

View file

@ -391,9 +391,7 @@ defmodule RDF.Turtle.Encoder do
defp based_name(_, _), do: nil defp based_name(_, _), do: nil
defp typed_literal_term(%Literal{} = literal, state, nesting) do defp typed_literal_term(%Literal{} = literal, state, nesting) do
~s["#{Literal.lexical(literal)}"^^#{ ~s["#{Literal.lexical(literal)}"^^#{literal |> Literal.datatype_id() |> term(state, :datatype, nesting)}]
literal |> Literal.datatype_id() |> term(state, :datatype, nesting)
}]
end end
def prefixed_name(iri, prefixes) do def prefixed_name(iri, prefixes) do

View file

@ -455,9 +455,7 @@ defmodule RDF.XSD.Datatype do
@datatype_name datatype_name @datatype_name datatype_name
def inspect(literal, _opts) do def inspect(literal, _opts) do
"%#{@datatype_name}{value: #{inspect(literal.value)}, lexical: #{ "%#{@datatype_name}{value: #{inspect(literal.value)}, lexical: #{literal |> literal.__struct__.lexical() |> inspect()}}"
literal |> literal.__struct__.lexical() |> inspect()
}}"
end end
end end
end end

View file

@ -275,9 +275,7 @@ defmodule RDF.XSD.Datatype.Test.Case do
Enum.each(@valid, fn {input, {_, _, canonicalized}} -> Enum.each(@valid, fn {input, {_, _, canonicalized}} ->
@tag example: %{input: input, canonicalized: canonicalized} @tag example: %{input: input, canonicalized: canonicalized}
test "lexical of canonicalized #{unquote(datatype)} #{inspect(input, limit: 4)} is #{ test "lexical of canonicalized #{unquote(datatype)} #{inspect(input, limit: 4)} is #{inspect(canonicalized, limit: 4)}",
inspect(canonicalized, limit: 4)
}",
%{example: example} do %{example: example} do
assert unquote(datatype).new(example.input) assert unquote(datatype).new(example.input)
|> unquote(datatype).canonical() |> unquote(datatype).canonical()

View file

@ -265,18 +265,14 @@ defmodule RDF.LangStringTest do
test "with a language tag and a matching non-'*' language range" do test "with a language tag and a matching non-'*' language range" do
Enum.each(@positive_examples, fn {language_tag, language_range} -> Enum.each(@positive_examples, fn {language_tag, language_range} ->
assert LangString.match_language?(language_tag, language_range), assert LangString.match_language?(language_tag, language_range),
"expected language range #{inspect(language_range)} to match language tag #{ "expected language range #{inspect(language_range)} to match language tag #{inspect(language_tag)}, but it didn't"
inspect(language_tag)
}, but it didn't"
end) end)
end end
test "with a language tag and a non-matching non-'*' language range" do test "with a language tag and a non-matching non-'*' language range" do
Enum.each(@negative_examples, fn {language_tag, language_range} -> Enum.each(@negative_examples, fn {language_tag, language_range} ->
refute LangString.match_language?(language_tag, language_range), refute LangString.match_language?(language_tag, language_range),
"expected language range #{inspect(language_range)} to not match language tag #{ "expected language range #{inspect(language_range)} to not match language tag #{inspect(language_tag)}, but it did"
inspect(language_tag)
}, but it did"
end) end)
end end
@ -308,9 +304,7 @@ defmodule RDF.LangStringTest do
literal = LangString.new("foo", language: language_tag) literal = LangString.new("foo", language: language_tag)
refute LangString.match_language?(literal, language_range), refute LangString.match_language?(literal, language_range),
"expected language range #{inspect(language_range)} to not match #{ "expected language range #{inspect(language_range)} to not match #{inspect(literal)}, but it did"
inspect(literal)
}, but it did"
end) end)
refute LangString.match_language?(LangString.new("foo", language: ""), "de") refute LangString.match_language?(LangString.new("foo", language: ""), "de")

View file

@ -511,9 +511,7 @@ defmodule RDF.LiteralTest do
result = Literal.matches?(literal, pattern) result = Literal.matches?(literal, pattern)
assert result == expected_result, assert result == expected_result,
"expected RDF.Literal.matches?(#{inspect(literal)}, #{inspect(pattern)}) to return #{ "expected RDF.Literal.matches?(#{inspect(literal)}, #{inspect(pattern)}) to return #{inspect(expected_result)}, but got #{result}"
inspect(expected_result)
}, but got #{result}"
end) end)
end end

View file

@ -210,9 +210,7 @@ defmodule RDF.XSD.BooleanTest do
] ]
|> Enum.each(fn {left, right, result} -> |> Enum.each(fn {left, right, result} ->
assert XSD.Boolean.logical_and(left, right) == result, assert XSD.Boolean.logical_and(left, right) == result,
"expected logical_and(#{inspect(left)}, #{inspect(right)}) to be #{inspect(result)}, but got #{ "expected logical_and(#{inspect(left)}, #{inspect(right)}) to be #{inspect(result)}, but got #{inspect(XSD.Boolean.logical_and(left, right))}"
inspect(XSD.Boolean.logical_and(left, right))
}"
end) end)
end end
@ -230,9 +228,7 @@ defmodule RDF.XSD.BooleanTest do
] ]
|> Enum.each(fn {left, right, result} -> |> Enum.each(fn {left, right, result} ->
assert XSD.Boolean.logical_or(left, right) == result, assert XSD.Boolean.logical_or(left, right) == result,
"expected logical_or(#{inspect(left)}, #{inspect(right)}) to be #{inspect(result)}, but got #{ "expected logical_or(#{inspect(left)}, #{inspect(right)}) to be #{inspect(result)}, but got #{inspect(XSD.Boolean.logical_and(left, right))}"
inspect(XSD.Boolean.logical_and(left, right))
}"
end) end)
end end
end end

View file

@ -32,9 +32,7 @@ defmodule RDF.XSD.Utils.RegexTest do
result = Regex.matches?(literal, pattern) result = Regex.matches?(literal, pattern)
assert result == expected_result, assert result == expected_result,
"expected XSD.Regex.matches?(#{inspect(literal)}, #{inspect(pattern)}) to return #{ "expected XSD.Regex.matches?(#{inspect(literal)}, #{inspect(pattern)}) to return #{inspect(expected_result)}, but got #{result}"
inspect(expected_result)
}, but got #{result}"
end) end)
end end