From 13eed6d802862f1485202ed733fb29c3696d355e Mon Sep 17 00:00:00 2001 From: Fabian Muscariello Date: Sun, 2 Sep 2018 12:04:56 +0200 Subject: [PATCH] Format everything --- .formatter.exs | 7 ++----- config/config.exs | 8 +++++--- config/test.exs | 3 ++- lib/paracusia/message_parser.ex | 6 ++++-- lib/paracusia/mpd_client.ex | 4 ++-- 5 files changed, 15 insertions(+), 13 deletions(-) diff --git a/.formatter.exs b/.formatter.exs index 8632f81..525446d 100644 --- a/.formatter.exs +++ b/.formatter.exs @@ -1,7 +1,4 @@ +# Used by "mix format" [ - inputs: [ - "lib/**/*.{ex,exs}", - "test/**/*.{ex,exs}", - "mix.exs" - ] + inputs: ["mix.exs", "{config,lib,test}/**/*.{ex,exs}"] ] diff --git a/config/config.exs b/config/config.exs index f97c8e7..28fa942 100644 --- a/config/config.exs +++ b/config/config.exs @@ -3,8 +3,10 @@ use Mix.Config config :paracusia, - retry_after: 100, # if connecting to MPD failed, try again after x milliseconds - max_retry_attempts: 3 # Give up if no connection could be established after x attempts. + # if connecting to MPD failed, try again after x milliseconds + retry_after: 100, + # Give up if no connection could be established after x attempts. + max_retry_attempts: 3 # This configuration is loaded before any dependency and is restricted # to this project. If another project depends on this project, this @@ -31,4 +33,4 @@ config :paracusia, # Configuration from the imported file will override the ones defined # here (which is why it is important to import them last). # -import_config "#{Mix.env}.exs" +import_config "#{Mix.env()}.exs" diff --git a/config/test.exs b/config/test.exs index 2ff057c..092afc9 100644 --- a/config/test.exs +++ b/config/test.exs @@ -2,4 +2,5 @@ use Mix.Config config :paracusia, hostname: "localhost", - port: 9091 # port the mock server will listen on + # port the mock server will listen on + port: 9091 diff --git a/lib/paracusia/message_parser.ex b/lib/paracusia/message_parser.ex index 658c289..2d9bd50 100644 --- a/lib/paracusia/message_parser.ex +++ b/lib/paracusia/message_parser.ex @@ -42,7 +42,8 @@ defmodule Paracusia.MessageParser do [{"foo", "bar"}, {"baz", "fam"}] """ def parse_uris(m) do - m |> String.split("\n", trim: true) + m + |> String.split("\n", trim: true) |> Enum.map(fn item -> case item |> String.split(": ", parts: 2) do [first, second] -> {first, second} @@ -60,7 +61,8 @@ defmodule Paracusia.MessageParser do ["Beatles", "Lady Gaga"] """ def parse_newline_separated_enum(m) do - m |> parse_uris + m + |> parse_uris |> Enum.map(fn {_, value} -> value end) end diff --git a/lib/paracusia/mpd_client.ex b/lib/paracusia/mpd_client.ex index 22c6c9a..6f71719 100644 --- a/lib/paracusia/mpd_client.ex +++ b/lib/paracusia/mpd_client.ex @@ -92,7 +92,7 @@ defmodule Paracusia.MpdClient do # closing its connection to Paracusia), connecting to MPD may fail if MPD takes longer to # restart than Paracusia. For that reason, we retry connection establishment. ip_addrs = ip_addresses(hostname) - if ip_addrs == [], do: raise "Unable to resolve IP address for hostname #{inspect hostname}" + if ip_addrs == [], do: raise("Unable to resolve IP address for hostname #{inspect(hostname)}") sock = connect_retry(ip_addresses(hostname), port, 1, 0, retry_after, max_attempts) {:ok, "OK MPD" <> _} = :gen_tcp.recv(sock, 0) @@ -238,7 +238,7 @@ defmodule Paracusia.MpdClient do end def handle_info({:tcp_closed, _}, state) do - _ = Logger.warn "TCP connection closed by server." + _ = Logger.warn("TCP connection closed by server.") {:stop, :disconnect_by_server, state} end