From eeffceb16d611a3a94446479dbe3690061e99994 Mon Sep 17 00:00:00 2001 From: Marcel Otto Date: Fri, 11 Aug 2017 18:33:12 +0200 Subject: [PATCH] Fix some warnings --- lib/rdf/serialization/parse_helper.ex | 4 +-- lib/rdf/serializations/turtle_encoder.ex | 4 +-- .../serializations/turtle_encoder_state.ex | 2 +- lib/rdf/vocabulary_namespace.ex | 28 ++++++++----------- 4 files changed, 17 insertions(+), 21 deletions(-) diff --git a/lib/rdf/serialization/parse_helper.ex b/lib/rdf/serialization/parse_helper.ex index 22db1e5..42dbf23 100644 --- a/lib/rdf/serialization/parse_helper.ex +++ b/lib/rdf/serialization/parse_helper.ex @@ -7,7 +7,7 @@ defmodule RDF.Serialization.ParseHelper do def rdf_type, do: @rdf_type - def to_uri_string({:iriref, line, value}), do: value |> iri_unescape + def to_uri_string({:iriref, _line, value}), do: value |> iri_unescape def to_uri({:iriref, line, value}) do case URI.parse(iri_unescape(value)) do @@ -22,7 +22,7 @@ defmodule RDF.Serialization.ParseHelper do end end - def to_absolute_or_relative_uri({:iriref, line, value}) do + def to_absolute_or_relative_uri({:iriref, _line, value}) do case URI.parse(iri_unescape(value)) do uri = %URI{scheme: scheme} when not is_nil(scheme) -> if String.ends_with?(value, "#") do diff --git a/lib/rdf/serializations/turtle_encoder.ex b/lib/rdf/serializations/turtle_encoder.ex index eb6acf2..576da77 100644 --- a/lib/rdf/serializations/turtle_encoder.ex +++ b/lib/rdf/serializations/turtle_encoder.ex @@ -4,7 +4,7 @@ defmodule RDF.Turtle.Encoder do use RDF.Serialization.Encoder alias RDF.Turtle.Encoder.State - alias RDF.{Literal, BlankNode, Description, List} + alias RDF.{Literal, BlankNode, Description} @indentation_char " " @indentation 4 @@ -117,7 +117,7 @@ defmodule RDF.Turtle.Encoder do defp predications(description, state, nesting) do description.predications - |> order_predications + |> order_predications() |> Enum.map(&predication(&1, state, nesting)) |> Enum.join(" ;" <> newline_indent(nesting)) end diff --git a/lib/rdf/serializations/turtle_encoder_state.ex b/lib/rdf/serializations/turtle_encoder_state.ex index 9644528..4b65b79 100644 --- a/lib/rdf/serializations/turtle_encoder_state.ex +++ b/lib/rdf/serializations/turtle_encoder_state.ex @@ -1,7 +1,7 @@ defmodule RDF.Turtle.Encoder.State do @moduledoc false - alias RDF.{Literal, BlankNode, Description, List} + alias RDF.{BlankNode, Description} def start_link(data, base, prefixes) do diff --git a/lib/rdf/vocabulary_namespace.ex b/lib/rdf/vocabulary_namespace.ex index 43661c6..afebca4 100644 --- a/lib/rdf/vocabulary_namespace.ex +++ b/lib/rdf/vocabulary_namespace.ex @@ -129,8 +129,8 @@ defmodule RDF.Vocabulary.Namespace do defmacro define_vocab_terms(terms, base_uri) do terms |> Stream.filter(fn - {term, true} -> valid_term?(term) - {term, original_term} -> true + {term, true} -> valid_term?(term) + {_, _} -> true end) |> Stream.map(fn {term, true} -> {term, term} @@ -288,14 +288,12 @@ defmodule RDF.Vocabulary.Namespace do def invalid_terms, do: @invalid_terms defp validate_terms!(terms) do - aliased_terms = aliased_terms(terms) - terms - |> Enum.filter_map( - fn {term, _} -> - not term in aliased_terms and not valid_term?(term) - end, - fn {term, _} -> term end) - |> handle_invalid_terms! + with aliased_terms = aliased_terms(terms) do + for {term, _} <- terms, not term in aliased_terms and not valid_term?(term) do + term + end + |> handle_invalid_terms! + end terms end @@ -331,12 +329,10 @@ defmodule RDF.Vocabulary.Namespace do end defp detect_invalid_characters(terms) do - aliased_terms = aliased_terms(terms) - Enum.filter_map terms, - fn {term, _} -> - not term in aliased_terms and not valid_characters?(term) - end, - fn {term, _} -> term end + with aliased_terms = aliased_terms(terms) do + for {term, _} <- terms, not term in aliased_terms and not valid_characters?(term), + do: term + end end defp handle_invalid_characters([], _, terms), do: terms