Fix credo warnings

master
Marcin Kulik 7 years ago
parent 39e6fb31c0
commit 8c9e9f4c03

@ -98,7 +98,7 @@ defmodule Asciinema.Accounts do
def verify_signup_token(token) do
with {:ok, email} <- Token.verify(Endpoint, "signup", token, max_age: @login_token_max_age),
{:ok, %User{} = user} <- User.signup_changeset(%{email: email}) |> Repo.insert do
{:ok, %User{} = user} <- Repo.insert(User.signup_changeset(%{email: email})) do
{:ok, user}
else
{:error, :invalid} ->

@ -164,9 +164,9 @@ defmodule Asciinema.Asciicasts do
header = File.open!(path, [:read], fn file -> IO.binread(file, 2) end)
case header do
<<0x1f,0x8b>> -> # gzip
<<0x1f, 0x8b>> -> # gzip
File.open!(path, [:read, :compressed])
<<0x42,0x5a>> -> # bzip
<<0x42, 0x5a>> -> # bzip
{:ok, tmp_path} = Briefly.create()
{_, 0} = System.cmd("sh", ["-c", "bzip2 -d -k -c #{path} >#{tmp_path}"])
File.open!(tmp_path, [:read])

@ -5,7 +5,7 @@ defmodule Asciinema.FileStore.S3 do
def put_file(dst_path, src_local_path, content_type, compress \\ false) do
{body, opts} = if compress do
body = File.read!(src_local_path) |> :zlib.gzip
body = src_local_path |> File.read! |> :zlib.gzip
opts = [{:content_type, content_type}, {:content_encoding, "gzip"}]
{body, opts}
else
@ -36,7 +36,7 @@ defmodule Asciinema.FileStore.S3 do
end
def open_file(path, function \\ nil) do
response = S3.get_object(bucket(), base_path() <> path) |> make_request
response = bucket() |> S3.get_object(base_path() <> path) |> make_request
case response do
{:ok, %{headers: headers, body: body}} ->

@ -6,8 +6,8 @@ defmodule Asciinema.PngGenerator.A2png do
@pool_name :worker
@acquire_timeout 5000
@a2png_timeout 30000
@result_timeout 35000
@a2png_timeout 30_000
@result_timeout 35_000
def generate(%Asciicast{} = asciicast, %PngParams{} = png_params) do
{:ok, tmp_dir_path} = Briefly.create(directory: true)

@ -65,7 +65,7 @@ defmodule Asciinema.Vt.Worker do
end
defp send_cmd(port, cmd, data \\ %{}) do
json = Map.put(data, :cmd, cmd) |> Poison.encode!
json = data |> Map.put(:cmd, cmd) |> Poison.encode!
true = Port.command(port, "#{json}\n")
end
end

@ -4,7 +4,7 @@ defmodule AsciinemaWeb.Auth do
alias Asciinema.Repo
@user_key "warden.user.user.key"
@one_year_in_secs 31557600
@one_year_in_secs 31_557_600
def init(opts) do
opts

@ -3,7 +3,7 @@ defmodule AsciinemaWeb.AsciicastImageController do
alias Asciinema.{Asciicasts, PngGenerator}
alias Asciinema.Asciicasts.Asciicast
@max_age 604800 # 7 days
@max_age 604_800 # 7 days
def show(conn, %{"id" => id} = _params) do
asciicast = Asciicasts.get_asciicast!(id)

@ -89,22 +89,26 @@ defmodule AsciinemaWeb.Router.Helpers.Extra do
end
def asciicast_file_download_path(conn, asciicast) do
H.asciicast_file_path(conn, :show, asciicast)
conn
|> H.asciicast_file_path(:show, asciicast)
|> String.replace_suffix("/json", ".json")
end
def asciicast_file_download_url(conn, asciicast) do
H.asciicast_file_url(conn, :show, asciicast)
conn
|> H.asciicast_file_url(:show, asciicast)
|> String.replace_suffix("/json", ".json")
end
def asciicast_image_download_path(conn, asciicast) do
H.asciicast_image_path(conn, :show, asciicast)
conn
|> H.asciicast_image_path(:show, asciicast)
|> String.replace_suffix("/png", ".png")
end
def asciicast_animation_download_path(conn, asciicast) do
H.asciicast_animation_path(conn, :show, asciicast)
conn
|> H.asciicast_animation_path(:show, asciicast)
|> String.replace_suffix("/gif", ".gif")
end
end

@ -57,6 +57,7 @@ defmodule Asciinema.Mixfile do
{:briefly, "~> 0.3"},
{:bugsnag, "~> 1.5.0"},
{:cowboy, "~> 1.0"},
{:credo, "~> 0.8", only: [:dev, :test], runtime: false},
{:ex_aws, "~> 1.0"},
{:exq, "~> 0.9.0"},
{:exq_ui, "~> 0.9.0"},

@ -2,11 +2,13 @@
"bamboo_smtp": {:hex, :bamboo_smtp, "1.4.0", "a01d91406f3a46b3452c84d345d50f75d6facca5e06337358287a97da0426240", [:mix], [{:bamboo, "~> 0.8.0", [hex: :bamboo, repo: "hexpm", optional: false]}, {:gen_smtp, "~> 0.12.0", [hex: :gen_smtp, repo: "hexpm", optional: false]}], "hexpm"},
"briefly": {:hex, :briefly, "0.3.0", "16e6b76d2070ebc9cbd025fa85cf5dbaf52368c4bd896fb482b5a6b95a540c2f", [:mix], [], "hexpm"},
"bugsnag": {:hex, :bugsnag, "1.5.0", "e761b3c4c198d01d4b04b85298ea7756632c70610ed0b1a57f04c2f528a3e3ab", [:mix], [{:httpoison, "~> 0.9", [hex: :httpoison, repo: "hexpm", optional: false]}, {:poison, "~> 1.5 or ~> 2.0 or ~> 3.0", [hex: :poison, repo: "hexpm", optional: false]}], "hexpm"},
"bunt": {:hex, :bunt, "0.2.0", "951c6e801e8b1d2cbe58ebbd3e616a869061ddadcc4863d0a2182541acae9a38", [:mix], [], "hexpm"},
"certifi": {:hex, :certifi, "1.0.0", "1c787a85b1855ba354f0b8920392c19aa1d06b0ee1362f9141279620a5be2039", [:rebar3], [], "hexpm"},
"combine": {:hex, :combine, "0.9.6", "8d1034a127d4cbf6924c8a5010d3534d958085575fa4d9b878f200d79ac78335", [:mix], [], "hexpm"},
"connection": {:hex, :connection, "1.0.4", "a1cae72211f0eef17705aaededacac3eb30e6625b04a6117c1b2db6ace7d5976", [:mix], [], "hexpm"},
"cowboy": {:hex, :cowboy, "1.1.2", "61ac29ea970389a88eca5a65601460162d370a70018afe6f949a29dca91f3bb0", [:rebar3], [{:cowlib, "~> 1.0.2", [hex: :cowlib, repo: "hexpm", optional: false]}, {:ranch, "~> 1.3.2", [hex: :ranch, repo: "hexpm", optional: false]}], "hexpm"},
"cowlib": {:hex, :cowlib, "1.0.2", "9d769a1d062c9c3ac753096f868ca121e2730b9a377de23dec0f7e08b1df84ee", [:make], [], "hexpm"},
"credo": {:hex, :credo, "0.8.4", "4e50acac058cf6292d6066e5b0d03da5e1483702e1ccde39abba385c9f03ead4", [:mix], [{:bunt, "~> 0.2.0", [hex: :bunt, repo: "hexpm", optional: false]}], "hexpm"},
"db_connection": {:hex, :db_connection, "1.1.2", "2865c2a4bae0714e2213a0ce60a1b12d76a6efba0c51fbda59c9ab8d1accc7a8", [:mix], [{:connection, "~> 1.0.2", [hex: :connection, repo: "hexpm", optional: false]}, {:poolboy, "~> 1.5", [hex: :poolboy, repo: "hexpm", optional: true]}, {:sbroker, "~> 1.0", [hex: :sbroker, repo: "hexpm", optional: true]}], "hexpm"},
"decimal": {:hex, :decimal, "1.4.0", "fac965ce71a46aab53d3a6ce45662806bdd708a4a95a65cde8a12eb0124a1333", [:mix], [], "hexpm"},
"earmark": {:hex, :earmark, "1.2.2", "f718159d6b65068e8daeef709ccddae5f7fdc770707d82e7d126f584cd925b74", [:mix], [], "hexpm"},

Loading…
Cancel
Save