Apply credo suggestions #3

Merged
joao.dubas merged 1 commits from jpd-apply-static-code-suggestions into main 2022-04-22 00:49:00 +00:00
20 changed files with 67 additions and 13 deletions
Showing only changes of commit 4112757696 - Show all commits

View File

@ -1,4 +1,7 @@
defmodule Wabanex.Exercise do
@moduledoc """
Schema of a exercise contained within a training.
"""
use Ecto.Schema
import Ecto.Changeset

View File

@ -1,4 +1,8 @@
defmodule Wabanex.IMC do
@moduledoc """
Body mass index calculation
"""
def calculate(%{"filename" => filename}) do
filename
|> File.read()
@ -7,11 +11,7 @@ defmodule Wabanex.IMC do
defp handle_file({:ok, content}) do
data =
content
|> String.trim()
|> String.split("\n")
|> Enum.map(&parse_line/1)
|> Enum.into(%{})
content |> String.trim() |> String.split("\n") |> Enum.map(&parse_line/1) |> Enum.into(%{})
{:ok, data}
end

View File

@ -1,4 +1,7 @@
defmodule Wabanex.Training do
@moduledoc """
Schema of a training routine for a given period of time.
"""
use Ecto.Schema
import Ecto.Changeset

View File

@ -1,5 +1,8 @@
defmodule Wabanex.Trainings.Create do
alias Wabanex.{Training, Repo}
@moduledoc """
Context to create a training routine.
"""
alias Wabanex.{Repo, Training}
def call(params) do
params

View File

@ -1,4 +1,7 @@
defmodule Wabanex.User do
@moduledoc """
Schema of a user in the system.
"""
use Ecto.Schema
import Ecto.Changeset

View File

@ -1,4 +1,7 @@
defmodule Wabanex.Users.Create do
@moduledoc """
Context for user creation.
"""
alias Wabanex.{Repo, User}
def call(params) do

View File

@ -1,4 +1,7 @@
defmodule Wabanex.Users.Get do
@moduledoc """
Context to fetch a given user and its current training.
"""
import Ecto.Query
alias Wabanex.{Repo, Training, User}

View File

@ -1,4 +1,7 @@
defmodule WabanexWeb.Resolvers.Training do
@moduledoc """
GraphQL resolver for training operations.
"""
alias Wabanex.Trainings
def create(%{input: params}, _context), do: Trainings.Create.call(params)

View File

@ -1,4 +1,7 @@
defmodule WabanexWeb.Resolvers.User do
@moduledoc """
GraphQL resolver for user operations.
"""
alias Wabanex.Users
def get(%{id: user_id}, _context), do: Users.Get.call(user_id)

View File

@ -1,4 +1,7 @@
defmodule WabanexWeb.Schema do
@moduledoc """
GraphQL schema definition
"""
use Absinthe.Schema
import_types WabanexWeb.Schema.Types.Root

View File

@ -1,4 +1,7 @@
defmodule WabanexWeb.Schema.Types.Custom.DateRange do
@moduledoc """
Graphql date range custom type.
"""
use Absinthe.Schema.Notation
alias Absinthe.Blueprint.Input

View File

@ -1,4 +1,7 @@
defmodule WabanexWeb.Schema.Types.Custom.UUID4 do
@moduledoc """
GraphQL uuid v4 custom type.
"""
use Absinthe.Schema.Notation
alias Ecto.UUID

View File

@ -1,4 +1,7 @@
defmodule WabanexWeb.Schema.Types.Exercise do
@moduledoc """
GraphQL exercise type definition.
"""
use Absinthe.Schema.Notation
@desc "Logic exercise representation"

View File

@ -1,10 +1,13 @@
defmodule WabanexWeb.Schema.Types.Root do
@moduledoc """
GraphQL root query/mutation aggregator.
"""
use Absinthe.Schema.Notation
alias Crudry.Middlewares.TranslateErrors
alias WabanexWeb.Resolvers.User, as: UserResolver
alias WabanexWeb.Resolvers.Training, as: TrainingResolver
alias WabanexWeb.Resolvers.User, as: UserResolver
alias WabanexWeb.Schema.Types
import_types Types.Custom.UUID4

View File

@ -1,4 +1,7 @@
defmodule WabanexWeb.Schema.Types.Training do
@moduledoc """
GraphQL training type definition.
"""
use Absinthe.Schema.Notation
import_types WabanexWeb.Schema.Types.Custom.DateRange

View File

@ -1,4 +1,7 @@
defmodule WabanexWeb.Schema.Types.User do
@moduledoc """
GraphQL user type definition.
"""
use Absinthe.Schema.Notation
@desc "Logic user representation"

View File

@ -1,4 +1,7 @@
defmodule WabanexWeb.Telemetry do
@moduledoc """
Telemetry implementation
"""
use Supervisor
import Telemetry.Metrics

View File

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

View File

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

View File

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