Skip to content
This repository was archived by the owner on Dec 17, 2018. It is now read-only.

Commit 3c6bbb1

Browse files
Connor RigbyConnorRigby
authored andcommitted
Sprinkle some more CI
1 parent 8d01a9c commit 3c6bbb1

File tree

6 files changed

+26
-16
lines changed

6 files changed

+26
-16
lines changed

.circleci/config.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ jobs:
2424
- v3-plt-cache
2525
- run: mix dialyzer --plt
2626
- run: mix dialyzer --halt-exit-status
27+
- run: mix credo -a
2728
- run:
2829
command: mix coveralls.circle
2930
environment:

lib/esqlite3/esqlite3.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ defmodule Esqlite3 do
332332

333333
{:esqlite3, _ref, _resp} = stale ->
334334
:ok = Logger.warn("Ignoring stale answer: #{inspect(stale)}")
335-
passed_mics = :timer.now_diff(:os.timestamp(), start) |> div(1000)
335+
passed_mics = :os.timestamp() |> :timer.now_diff(start) |> div(1000)
336336

337337
new_timeout =
338338
case timeout - passed_mics do

lib/sqlite.ex

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,9 @@ defmodule Sqlite do
7878
def query(conn, sql, params, opts \\ []) do
7979
opts = opts |> defaults()
8080

81-
GenServer.call(conn.pid, {:query, sql, params, opts}, call_timeout(opts))
82-
|> case do
81+
r = GenServer.call(conn.pid, {:query, sql, params, opts}, call_timeout(opts))
82+
83+
case r do
8384
{:ok, %Sqlite.Result{}} = ok -> ok
8485
{:error, %Sqlite.Error{}} = ok -> ok
8586
end
@@ -110,8 +111,9 @@ defmodule Sqlite do
110111
def prepare(conn, sql, opts \\ []) do
111112
opts = opts |> defaults()
112113

113-
GenServer.call(conn.pid, {:prepare, sql, opts}, call_timeout(opts))
114-
|> case do
114+
r = GenServer.call(conn.pid, {:prepare, sql, opts}, call_timeout(opts))
115+
116+
case r do
115117
{:ok, %Sqlite.Query{}} = ok -> ok
116118
{:error, %Sqlite.Error{}} = ok -> ok
117119
end
@@ -140,8 +142,9 @@ defmodule Sqlite do
140142
def release_query(conn, query, opts \\ []) do
141143
opts = opts |> defaults()
142144

143-
GenServer.call(conn.pid, {:release_query, query, opts}, call_timeout(opts))
144-
|> case do
145+
r = GenServer.call(conn.pid, {:release_query, query, opts}, call_timeout(opts))
146+
147+
case r do
145148
:ok -> :ok
146149
{:error, %Sqlite.Error{}} = ok -> ok
147150
end
@@ -184,8 +187,9 @@ defmodule Sqlite do
184187
def execute(conn, query, params, opts \\ []) do
185188
opts = defaults(opts)
186189

187-
GenServer.call(conn.pid, {:execute, query, params, opts}, call_timeout(opts))
188-
|> case do
190+
r = GenServer.call(conn.pid, {:execute, query, params, opts}, call_timeout(opts))
191+
192+
case r do
189193
{:ok, %Sqlite.Result{}} = ok -> ok
190194
{:error, %Sqlite.Error{}} = ok -> ok
191195
end
@@ -210,8 +214,9 @@ defmodule Sqlite do
210214
def close(conn, opts \\ []) when is_list(opts) do
211215
opts = defaults(opts)
212216

213-
GenServer.call(conn.pid, {:close, opts}, call_timeout(opts))
214-
|> case do
217+
r = GenServer.call(conn.pid, {:close, opts}, call_timeout(opts))
218+
219+
case r do
215220
:ok -> :ok
216221
{:error, %Sqlite.Error{}} = ok -> ok
217222
end

lib/sqlite/server.ex

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ defmodule Sqlite.Server do
4141
try do
4242
with {:ok, %Query{} = q} <- build_query(sql, opts, state.database),
4343
:ok <- Esqlite3.bind(q.statement, params) do
44-
r = Esqlite3.fetchall(q.statement) |> build_result(q, state)
44+
r = q.statement |> Esqlite3.fetchall() |> build_result(q, state)
4545
{:reply, r, state}
4646
else
4747
err -> {:reply, error(err, state), state}
@@ -67,6 +67,7 @@ defmodule Sqlite.Server do
6767
case build_query(sql, opts, state.database) do
6868
{:ok, %Query{} = q} ->
6969
{:reply, {:ok, q}, state}
70+
7071
err ->
7172
{:reply, error(err, state), state}
7273
end
@@ -79,7 +80,7 @@ defmodule Sqlite.Server do
7980
try do
8081
case Esqlite3.bind(query.statement, params, opts[:timeout]) do
8182
:ok ->
82-
r = Esqlite3.fetchall(query.statement) |> build_result(query, state)
83+
r = query.statement |> Esqlite3.fetchall() |> build_result(query, state)
8384
{:reply, r, state}
8485

8586
err ->
@@ -117,8 +118,8 @@ defmodule Sqlite.Server do
117118

118119
case Esqlite3.prepare(sql, database, timeout) do
119120
{:ok, statement} ->
120-
cn = Esqlite3.column_names(statement, timeout) |> Tuple.to_list()
121-
ct = Esqlite3.column_types(statement, timeout) |> Tuple.to_list()
121+
cn = statement |> Esqlite3.column_names(timeout) |> Tuple.to_list()
122+
ct = statement |> Esqlite3.column_types(timeout) |> Tuple.to_list()
122123
{:ok, %Sqlite.Query{column_names: cn, column_types: ct, statement: statement, sql: sql}}
123124

124125
err ->

mix.exs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ defmodule Esqlite.MixProject do
5656
{:dialyxir, "~> 0.5.1", runtime: false, only: :dev},
5757
{:excoveralls, "~> 0.8", only: :test, optional: true},
5858
{:ex_doc, "~> 0.18.3", runtime: false, only: :docs},
59-
{:inch_ex, only: :docs, runtime: false}
59+
{:inch_ex, only: :docs, runtime: false},
60+
{:credo, "~> 0.9.0-rc1", only: [:dev, :test], runtime: false}
6061
]
6162
end
6263
end

mix.lock

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
%{
2+
"bunt": {:hex, :bunt, "0.2.0", "951c6e801e8b1d2cbe58ebbd3e616a869061ddadcc4863d0a2182541acae9a38", [:mix], [], "hexpm"},
23
"certifi": {:hex, :certifi, "2.0.0", "a0c0e475107135f76b8c1d5bc7efb33cd3815cb3cf3dea7aefdd174dabead064", [:rebar3], [], "hexpm"},
4+
"credo": {:hex, :credo, "0.9.0-rc8", "30d8633408353d08db03f3ea5a14a2aaee84268c19b5198f5963916634a16558", [:mix], [{:bunt, "~> 0.2.0", [hex: :bunt, repo: "hexpm", optional: false]}, {:poison, ">= 0.0.0", [hex: :poison, repo: "hexpm", optional: false]}], "hexpm"},
35
"dialyxir": {:hex, :dialyxir, "0.5.1", "b331b091720fd93e878137add264bac4f644e1ddae07a70bf7062c7862c4b952", [:mix], [], "hexpm"},
46
"earmark": {:hex, :earmark, "1.2.4", "99b637c62a4d65a20a9fb674b8cffb8baa771c04605a80c911c4418c69b75439", [:mix], [], "hexpm"},
57
"elixir_make": {:hex, :elixir_make, "0.4.1", "6628b86053190a80b9072382bb9756a6c78624f208ec0ff22cb94c8977d80060", [:mix], [], "hexpm"},

0 commit comments

Comments
 (0)