From 37eeb4d8f26088ae813f311aff34e721b4af48fd Mon Sep 17 00:00:00 2001 From: Andrea Leopardi Date: Tue, 20 Sep 2016 13:14:29 +0200 Subject: [PATCH] Fix a bunch of Elixir 1.4 warnings They're about parens in local 0-arity functions. --- lib/mariaex/connection/ssl.ex | 4 ++-- lib/mariaex/connection/tcp.ex | 4 ++-- lib/mariaex/lru_cache.ex | 4 ++-- lib/mariaex/protocol.ex | 18 +++++++++--------- mix.exs | 6 +++--- 5 files changed, 18 insertions(+), 18 deletions(-) diff --git a/lib/mariaex/connection/ssl.ex b/lib/mariaex/connection/ssl.ex index 6a9293f..2055bec 100644 --- a/lib/mariaex/connection/ssl.ex +++ b/lib/mariaex/connection/ssl.ex @@ -7,9 +7,9 @@ defmodule Mariaex.Connection.Ssl do {:ssl, ^sock, buffer} -> {:ok, buffer} {:ssl_closed, ^sock} -> - {:disconnect, {tag, "async_recv", :closed, buffer}} + {:disconnect, {tag(), "async_recv", :closed, buffer}} {:ssl_error, ^sock, reason} -> - {:disconnect, {tag, "async_recv", reason, buffer}} + {:disconnect, {tag(), "async_recv", reason, buffer}} after timeout -> {:ok, <<>>} diff --git a/lib/mariaex/connection/tcp.ex b/lib/mariaex/connection/tcp.ex index 0241f8b..789e479 100644 --- a/lib/mariaex/connection/tcp.ex +++ b/lib/mariaex/connection/tcp.ex @@ -24,9 +24,9 @@ defmodule Mariaex.Connection.Tcp do {:tcp, ^sock, buffer} -> {:ok, buffer} {:tcp_closed, ^sock} -> - {:disconnect, {tag, "async_recv", :closed, buffer}} + {:disconnect, {tag(), "async_recv", :closed, buffer}} {:tcp_error, ^sock, reason} -> - {:disconnect, {tag, "async_recv", reason, buffer}} + {:disconnect, {tag(), "async_recv", reason, buffer}} after timeout -> {:ok, <<>>} diff --git a/lib/mariaex/lru_cache.ex b/lib/mariaex/lru_cache.ex index 2fd11d1..756c753 100644 --- a/lib/mariaex/lru_cache.ex +++ b/lib/mariaex/lru_cache.ex @@ -27,11 +27,11 @@ defmodule Mariaex.LruCache do def insert({size, cache}, statement, data, cleanup) do if :ets.info(cache, :size) > size, do: remove_oldest(cache, cleanup) - :ets.insert(cache, {statement, timestamp, data}) + :ets.insert(cache, {statement, timestamp(), data}) end def update({_, cache}, statement, data) do - :ets.insert(cache, {statement, timestamp, data}) + :ets.insert(cache, {statement, timestamp(), data}) end defp remove_oldest(cache, cleanup) do diff --git a/lib/mariaex/protocol.ex b/lib/mariaex/protocol.ex index c6f4f67..e15819a 100644 --- a/lib/mariaex/protocol.ex +++ b/lib/mariaex/protocol.ex @@ -74,8 +74,8 @@ defmodule Mariaex.Protocol do s = %__MODULE__{binary_as: binary_as, state: :handshake, ssl_conn_state: set_initial_ssl_conn_state(opts), - connection_id: self, - connection_ref: make_ref, + connection_id: self(), + connection_ref: make_ref(), sock: {sock_mod, sock}, cache: Cache.new(), lru_cache: LruCache.new(opts[:cache_size]), @@ -213,7 +213,7 @@ defmodule Mariaex.Protocol do DBConnection callback """ def disconnect(_, state = %{sock: {sock_mod, sock}}) do - msg_send(text_cmd(command: com_quit, statement: ""), state, 0) + msg_send(text_cmd(command: com_quit(), statement: ""), state, 0) case msg_recv(state) do {:ok, packet(msg: ok_resp())} -> sock_mod.close(sock) @@ -290,7 +290,7 @@ defmodule Mariaex.Protocol do {id, types, parameter_types} -> {:ok, %{query | binary_as: s.binary_as, statement_id: id, types: types, parameter_types: parameter_types, connection_ref: ref}, s} nil -> - msg_send(text_cmd(command: com_stmt_prepare, statement: statement), s, 0) + msg_send(text_cmd(command: com_stmt_prepare(), statement: statement), s, 0) prepare_recv(%{s | binary_as: s.binary_as, state: :prepare_send}, query) end end @@ -375,7 +375,7 @@ defmodule Mariaex.Protocol do send_text_query(state, statement) |> text_query_recv(query) end def handle_execute(%Query{type: :binary, statement_id: id, connection_ref: ref} = query, params, _opts, %{connection_ref: ref} = state) do - msg_send(stmt_execute(command: com_stmt_execute, parameters: params, statement_id: id, flags: 0, iteration_count: 1), state, 0) + msg_send(stmt_execute(command: com_stmt_execute(), parameters: params, statement_id: id, flags: 0, iteration_count: 1), state, 0) binary_query_recv(%{state | state: :column_count}, query) end def handle_execute(%Query{type: :binary} = query, params, opts, state) do @@ -623,13 +623,13 @@ defmodule Mariaex.Protocol do DBConnection callback """ def ping(%{buffer: buffer} = state) when is_binary(buffer) do - msg_send(text_cmd(command: com_ping, statement: ""), state, 0) + msg_send(text_cmd(command: com_ping(), statement: ""), state, 0) ping_recv(state, :ping) end def ping(state) do case checkout(state) do {:ok, state} -> - msg_send(text_cmd(command: com_ping, statement: ""), state, 0) + msg_send(text_cmd(command: com_ping(), statement: ""), state, 0) {:ok, state} = ping_recv(state, :ping) checkin(state) disconnect -> @@ -642,7 +642,7 @@ defmodule Mariaex.Protocol do end defp send_text_query(s, statement) do - msg_send(text_cmd(command: com_query, statement: statement), s, 0) + msg_send(text_cmd(command: com_query(), statement: statement), s, 0) %{s | state: :column_count} end @@ -658,7 +658,7 @@ defmodule Mariaex.Protocol do end def close_statement(_statement, {id, _, _}, sock) do - msg_send(stmt_close(command: com_stmt_close, statement_id: id), sock, 0) + msg_send(stmt_close(command: com_stmt_close(), statement_id: id), sock, 0) end def close_statement(s = %{sock: sock, lru_cache: cache}, %{statement: statement}) do diff --git a/mix.exs b/mix.exs index f8a1a32..d3b2b26 100644 --- a/mix.exs +++ b/mix.exs @@ -5,12 +5,12 @@ defmodule Mariaex.Mixfile do [app: :mariaex, version: "0.7.8", elixir: "~> 1.0", - deps: deps, + deps: deps(), name: "Mariaex", source_url: "https://github.com/liveforeverx/mariaex", test_coverage: [tool: Coverex.Task, coveralls: true], - description: description, - package: package] + description: description(), + package: package()] end # Configuration for the OTP application