Add credo woohoo linting

This commit is contained in:
Jamil Bou Kheir
2020-05-04 22:59:24 -07:00
parent e92ab1cc77
commit 66af1a18f8
17 changed files with 52 additions and 15 deletions

View File

@@ -1,3 +1,3 @@
elixir 1.10.2-otp-22
erlang 22.3.2
nodejs 10.20.0
elixir 1.10.3-otp-22
erlang 22.3.3
nodejs 10.20.1

View File

@@ -1 +0,0 @@
elixir 1.9.1-otp-21

View File

@@ -1,4 +1,8 @@
defmodule CfHttp.Devices.Device do
@moduledoc """
Handles Device stuff when it comes to the DB
"""
use Ecto.Schema
import Ecto.Changeset

View File

@@ -1,4 +1,8 @@
defmodule CfHttp.FirewallRules.FirewallRule do
@moduledoc """
Not really sure what to write here. I'll update this later.
"""
use Ecto.Schema
import Ecto.Changeset

View File

@@ -1,4 +1,8 @@
defmodule CfHttp.Release do
@moduledoc """
Configures the Mix Release or something
"""
@app :cf_http
def migrate do

View File

@@ -1,4 +1,8 @@
defmodule CfHttp.User do
@moduledoc """
Represents a User I guess
"""
use Ecto.Schema
import Ecto.Changeset

View File

@@ -1,9 +1,13 @@
defmodule CfHttpWeb.FirewallRuleController do
@moduledoc """
Controller logic for FirewallRules
"""
use CfHttpWeb, :controller
alias CfHttp.Devices
alias CfHttp.FirewallRules
alias CfHttp.FirewallRules.FirewallRule
alias CfHttp.Devices
plug CfHttpWeb.Plugs.Authenticator
@@ -30,7 +34,7 @@ defmodule CfHttpWeb.FirewallRuleController do
{:error, %Ecto.Changeset{} = changeset} ->
render(conn, "new.html", changeset: changeset)
end
end
end
def show(conn, %{"id" => id}) do
firewall_rule = FirewallRules.get_firewall_rule!(id)

View File

@@ -11,6 +11,7 @@ defmodule CfHttpWeb.UserController do
# GET /users/new
def new(conn, _params) do
changeset = User.changeset(%User{})
conn
|> render("new.html", changeset: changeset)
end
@@ -25,6 +26,7 @@ defmodule CfHttpWeb.UserController do
|> assign(:current_user, user)
|> put_flash(:info, "User created successfully")
|> redirect(to: Routes.device_path(conn, :index))
{:error, changeset} ->
conn
|> put_flash(:error, "Error creating user.")
@@ -35,6 +37,7 @@ defmodule CfHttpWeb.UserController do
# GET /user/edit
def edit(conn, _params) do
changeset = User.changeset(conn.current_user)
conn
|> render("edit.html", changeset: changeset)
end
@@ -55,6 +58,7 @@ defmodule CfHttpWeb.UserController do
|> assign(:current_user, user)
|> put_flash(:info, "User updated successfully.")
|> redirect(to: Routes.user_path(conn, :show, conn.current_user))
{:error, changeset} ->
conn
|> put_flash(:error, "Error updating user.")
@@ -70,6 +74,7 @@ defmodule CfHttpWeb.UserController do
|> assign(:current_user, nil)
|> put_flash(:info, "User deleted successfully.")
|> redirect(to: Routes.page_path(conn, :index))
{:error, _changeset} ->
conn
|> put_flash(:error, "Error deleting User.")

View File

@@ -20,9 +20,11 @@ defmodule CfHttpWeb.Router do
resources "/user", UserController, singleton: true, only: [:show, :edit, :update, :delete]
resources "/users", UserController, only: [:new, :create]
resources "/devices", DeviceController, except: [:create] do
resources "/firewall_rules", FirewallRuleController, only: [:new, :index, :create]
end
resources "/firewall_rules", FirewallRuleController, only: [:show, :update, :delete, :edit]
end

View File

@@ -41,7 +41,8 @@ defmodule CfHttp.MixProject do
{:phoenix_pubsub, "~> 2.0"},
{:phoenix_ecto, "~> 4.0"},
{:ecto_sql, "~> 3.1"},
{:ecto_network, "~> 1.3.0"}, # Exposes Postgres inet, cidr, macaddr types
# Exposes Postgres inet, cidr, macaddr types
{:ecto_network, "~> 1.3.0"},
{:postgrex, ">= 0.0.0"},
{:phoenix_html, "~> 2.11"},
{:phoenix_live_reload, "~> 1.2", only: :dev},

View File

@@ -10,6 +10,5 @@ defmodule CfHttp.Repo.Migrations.CreateFirewallRules do
timestamps()
end
end
end

View File

@@ -58,6 +58,7 @@ defmodule CfHttpWeb.DeviceControllerTest do
test "deletes chosen device", %{conn: conn, device: device} do
conn = delete(conn, Routes.device_path(conn, :delete, device))
assert redirected_to(conn) == Routes.device_path(conn, :index)
assert_error_sent 404, fn ->
get(conn, Routes.device_path(conn, :show, device))
end

View File

@@ -17,6 +17,8 @@ defmodule CfHttpWeb.ChannelCase do
use ExUnit.CaseTemplate
alias Ecto.Adapters.SQL.Sandbox
using do
quote do
# Import conveniences for testing with channels
@@ -28,10 +30,10 @@ defmodule CfHttpWeb.ChannelCase do
end
setup tags do
:ok = Ecto.Adapters.SQL.Sandbox.checkout(CfHttp.Repo)
:ok = Sandbox.checkout(CfHttp.Repo)
unless tags[:async] do
Ecto.Adapters.SQL.Sandbox.mode(CfHttp.Repo, {:shared, self()})
Sandbox.mode(CfHttp.Repo, {:shared, self()})
end
:ok

View File

@@ -17,6 +17,8 @@ defmodule CfHttpWeb.ConnCase do
use ExUnit.CaseTemplate
alias Ecto.Adapters.SQL.Sandbox
using do
quote do
# Import conveniences for testing with connections
@@ -30,10 +32,10 @@ defmodule CfHttpWeb.ConnCase do
end
setup tags do
:ok = Ecto.Adapters.SQL.Sandbox.checkout(CfHttp.Repo)
:ok = Sandbox.checkout(CfHttp.Repo)
unless tags[:async] do
Ecto.Adapters.SQL.Sandbox.mode(CfHttp.Repo, {:shared, self()})
Sandbox.mode(CfHttp.Repo, {:shared, self()})
end
{:ok, conn: Phoenix.ConnTest.build_conn()}

View File

@@ -16,6 +16,8 @@ defmodule CfHttp.DataCase do
use ExUnit.CaseTemplate
alias Ecto.Adapters.SQL.Sandbox
using do
quote do
alias CfHttp.Repo
@@ -28,10 +30,10 @@ defmodule CfHttp.DataCase do
end
setup tags do
:ok = Ecto.Adapters.SQL.Sandbox.checkout(CfHttp.Repo)
:ok = Sandbox.checkout(CfHttp.Repo)
unless tags[:async] do
Ecto.Adapters.SQL.Sandbox.mode(CfHttp.Repo, {:shared, self()})
Sandbox.mode(CfHttp.Repo, {:shared, self()})
end
:ok

View File

@@ -28,6 +28,8 @@ defmodule CloudfireUmbrella.MixProject do
#
# Run "mix help deps" for examples and options.
defp deps do
[]
[
{:credo, "~> 1.4", only: [:dev, :test], runtime: false}
]
end
end

View File

@@ -1,7 +1,9 @@
%{
"bunt": {:hex, :bunt, "0.2.0", "951c6e801e8b1d2cbe58ebbd3e616a869061ddadcc4863d0a2182541acae9a38", [:mix], [], "hexpm", "7af5c7e09fe1d40f76c8e4f9dd2be7cebd83909f31fee7cd0e9eadc567da8353"},
"connection": {:hex, :connection, "1.0.4", "a1cae72211f0eef17705aaededacac3eb30e6625b04a6117c1b2db6ace7d5976", [:mix], [], "hexpm", "4a0850c9be22a43af9920a71ab17c051f5f7d45c209e40269a1938832510e4d9"},
"cowboy": {:hex, :cowboy, "2.7.0", "91ed100138a764355f43316b1d23d7ff6bdb0de4ea618cb5d8677c93a7a2f115", [:rebar3], [{:cowlib, "~> 2.8.0", [hex: :cowlib, repo: "hexpm", optional: false]}, {:ranch, "~> 1.7.1", [hex: :ranch, repo: "hexpm", optional: false]}], "hexpm", "04fd8c6a39edc6aaa9c26123009200fc61f92a3a94f3178c527b70b767c6e605"},
"cowlib": {:hex, :cowlib, "2.8.0", "fd0ff1787db84ac415b8211573e9a30a3ebe71b5cbff7f720089972b2319c8a4", [:rebar3], [], "hexpm", "79f954a7021b302186a950a32869dbc185523d99d3e44ce430cd1f3289f41ed4"},
"credo": {:hex, :credo, "1.4.0", "92339d4cbadd1e88b5ee43d427b639b68a11071b6f73854e33638e30a0ea11f5", [:mix], [{:bunt, "~> 0.2.0", [hex: :bunt, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "1fd3b70dce216574ce3c18bdf510b57e7c4c85c2ec9cad4bff854abaf7e58658"},
"db_connection": {:hex, :db_connection, "2.2.1", "caee17725495f5129cb7faebde001dc4406796f12a62b8949f4ac69315080566", [:mix], [{:connection, "~> 1.0.2", [hex: :connection, repo: "hexpm", optional: false]}], "hexpm", "2b02ece62d9f983fcd40954e443b7d9e6589664380e5546b2b9b523cd0fb59e1"},
"decimal": {:hex, :decimal, "1.8.1", "a4ef3f5f3428bdbc0d35374029ffcf4ede8533536fa79896dd450168d9acdf3c", [:mix], [], "hexpm", "3cb154b00225ac687f6cbd4acc4b7960027c757a5152b369923ead9ddbca7aec"},
"ecto": {:hex, :ecto, "3.4.1", "ca5b5f6314eebd7fa2e52c6d78abb1ef955005dd60cc7a047b963ee23ee14a6c", [:mix], [{:decimal, "~> 1.6 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "748a317a2eacac0b7b6540cb7d2198b79457ede9cec2b4d1582117f90ac309d5"},