Fix Credo code readability issues
This commit is contained in:
parent
97651e88e9
commit
3505736705
@ -10,7 +10,7 @@ defmodule Mobilizon.Federation.ActivityPub do
|
||||
|
||||
import Mobilizon.Federation.ActivityPub.Utils
|
||||
|
||||
alias Mobilizon.{Actors, Config, Events, Reports, Users, Share}
|
||||
alias Mobilizon.{Actors, Config, Events, Reports, Share, Users}
|
||||
alias Mobilizon.Actors.{Actor, Follower}
|
||||
alias Mobilizon.Events.{Comment, Event, Participant}
|
||||
alias Mobilizon.Reports.Report
|
||||
|
@ -21,7 +21,7 @@ defmodule Mobilizon.Federation.ActivityPub.Relay do
|
||||
|
||||
require Logger
|
||||
|
||||
def init() do
|
||||
def init do
|
||||
# Wait for everything to settle.
|
||||
Process.sleep(1000 * 5)
|
||||
get_actor()
|
||||
|
@ -6,8 +6,8 @@ defmodule Mobilizon.Federation.ActivityStream.Converter.Event do
|
||||
internal one, and back.
|
||||
"""
|
||||
|
||||
alias Mobilizon.Addresses
|
||||
alias Mobilizon.Actors.Actor
|
||||
alias Mobilizon.Addresses
|
||||
alias Mobilizon.Addresses.Address
|
||||
alias Mobilizon.Events.Event, as: EventModel
|
||||
alias Mobilizon.Media.Picture
|
||||
|
@ -9,11 +9,11 @@ defmodule Mobilizon.GraphQL.Resolvers.Admin do
|
||||
alias Mobilizon.Actors.Actor
|
||||
alias Mobilizon.Admin.ActionLog
|
||||
alias Mobilizon.Events
|
||||
alias Mobilizon.Events.{Event, Comment}
|
||||
alias Mobilizon.Events.{Comment, Event}
|
||||
alias Mobilizon.Reports.{Note, Report}
|
||||
alias Mobilizon.Users.User
|
||||
alias Mobilizon.Service.Statistics
|
||||
alias Mobilizon.Storage.Page
|
||||
alias Mobilizon.Users.User
|
||||
|
||||
alias Mobilizon.Federation.ActivityPub.Relay
|
||||
|
||||
|
@ -5,7 +5,7 @@ defmodule Mobilizon.GraphQL.Resolvers.Event do
|
||||
|
||||
alias Mobilizon.{Actors, Admin, Events}
|
||||
alias Mobilizon.Actors.Actor
|
||||
alias Mobilizon.Events.{Event, Participant, EventParticipantStats}
|
||||
alias Mobilizon.Events.{Event, EventParticipantStats, Participant}
|
||||
alias Mobilizon.Users.User
|
||||
|
||||
alias Mobilizon.GraphQL.API
|
||||
|
@ -5,7 +5,7 @@ defmodule Mobilizon.GraphQL.Resolvers.User do
|
||||
|
||||
import Mobilizon.Users.Guards
|
||||
|
||||
alias Mobilizon.{Actors, Config, Users, Events}
|
||||
alias Mobilizon.{Actors, Config, Events, Users}
|
||||
alias Mobilizon.Actors.Actor
|
||||
alias Mobilizon.Storage.Repo
|
||||
alias Mobilizon.Users.User
|
||||
|
@ -5,7 +5,7 @@ defmodule Mobilizon.GraphQL.Schema.AdminType do
|
||||
|
||||
use Absinthe.Schema.Notation
|
||||
|
||||
alias Mobilizon.Events.{Event, Comment}
|
||||
alias Mobilizon.Events.{Comment, Event}
|
||||
alias Mobilizon.Reports.{Note, Report}
|
||||
|
||||
alias Mobilizon.GraphQL.Resolvers.Admin
|
||||
|
@ -6,8 +6,8 @@ defmodule Mobilizon.GraphQL.Schema.ReportType do
|
||||
|
||||
import Absinthe.Resolution.Helpers, only: [dataloader: 1]
|
||||
|
||||
alias Mobilizon.Reports
|
||||
alias Mobilizon.GraphQL.Resolvers.Report
|
||||
alias Mobilizon.Reports
|
||||
|
||||
@desc "A report object"
|
||||
object :report do
|
||||
|
@ -2,10 +2,12 @@ defmodule Mix.Tasks.Mobilizon.Users.Show do
|
||||
@moduledoc """
|
||||
Task to display an user details
|
||||
"""
|
||||
|
||||
use Mix.Task
|
||||
|
||||
alias Mobilizon.Actors.Actor
|
||||
alias Mobilizon.Users
|
||||
alias Mobilizon.Users.User
|
||||
alias Mobilizon.Actors.Actor
|
||||
|
||||
@shortdoc "Show a Mobilizon user details"
|
||||
|
||||
|
@ -92,7 +92,7 @@ defmodule Mobilizon do
|
||||
defp fallback_options(nil), do: []
|
||||
defp fallback_options(fallback), do: [fallback: fallback(default: fallback)]
|
||||
|
||||
defp internal_actor() do
|
||||
defp internal_actor do
|
||||
%{
|
||||
id: :internal_actor_init,
|
||||
start: {Task, :start_link, [&ActivityPub.Relay.init/0]},
|
||||
|
@ -7,13 +7,12 @@ defmodule Mobilizon.Actors.Actor do
|
||||
|
||||
import Ecto.Changeset
|
||||
|
||||
alias Mobilizon.{Actors, Config, Crypto, Share}
|
||||
alias Mobilizon.{Actors, Config, Crypto, Mention, Share}
|
||||
alias Mobilizon.Actors.{ActorOpenness, ActorType, ActorVisibility, Follower, Member}
|
||||
alias Mobilizon.Events.{Event, FeedToken, Comment}
|
||||
alias Mobilizon.Events.{Comment, Event, FeedToken}
|
||||
alias Mobilizon.Media.File
|
||||
alias Mobilizon.Reports.{Note, Report}
|
||||
alias Mobilizon.Users.User
|
||||
alias Mobilizon.Mention
|
||||
|
||||
alias Mobilizon.Web.Endpoint
|
||||
alias Mobilizon.Web.Router.Helpers, as: Routes
|
||||
|
@ -6,31 +6,27 @@ defmodule Mobilizon.Events.Event do
|
||||
use Ecto.Schema
|
||||
|
||||
import Ecto.Changeset
|
||||
|
||||
alias Ecto.Changeset
|
||||
|
||||
alias Mobilizon.Actors.Actor
|
||||
alias Mobilizon.{Addresses, Events, Media, Mention}
|
||||
alias Mobilizon.Addresses.Address
|
||||
|
||||
alias Mobilizon.Addresses
|
||||
|
||||
alias Mobilizon.Events
|
||||
|
||||
alias Mobilizon.Events.{
|
||||
Comment,
|
||||
EventOptions,
|
||||
EventParticipantStats,
|
||||
EventStatus,
|
||||
EventVisibility,
|
||||
JoinOptions,
|
||||
EventParticipantStats,
|
||||
Participant,
|
||||
Session,
|
||||
Tag,
|
||||
Track
|
||||
}
|
||||
|
||||
alias Mobilizon.Media
|
||||
alias Mobilizon.Media.Picture
|
||||
alias Mobilizon.Mention
|
||||
alias Mobilizon.Storage.Repo
|
||||
|
||||
alias Mobilizon.Web.Endpoint
|
||||
|
@ -10,7 +10,7 @@ defmodule Mobilizon.Events do
|
||||
|
||||
import Mobilizon.Storage.Ecto
|
||||
|
||||
alias Ecto.{Multi, Changeset}
|
||||
alias Ecto.{Changeset, Multi}
|
||||
|
||||
alias Mobilizon.Actors.Actor
|
||||
alias Mobilizon.Addresses.Address
|
||||
@ -1078,7 +1078,7 @@ defmodule Mobilizon.Events do
|
||||
|> Repo.all()
|
||||
end
|
||||
|
||||
def data() do
|
||||
def data do
|
||||
Dataloader.Ecto.new(Repo, query: &query/2)
|
||||
end
|
||||
|
||||
|
@ -6,8 +6,7 @@ defmodule Mobilizon.Mention do
|
||||
use Ecto.Schema
|
||||
import Ecto.Changeset
|
||||
alias Mobilizon.Actors.Actor
|
||||
alias Mobilizon.Events.Event
|
||||
alias Mobilizon.Events.Comment
|
||||
alias Mobilizon.Events.{Comment, Event}
|
||||
alias Mobilizon.Storage.Repo
|
||||
|
||||
@type t :: %__MODULE__{
|
||||
|
@ -4,10 +4,12 @@ defmodule Mobilizon.Share do
|
||||
"""
|
||||
|
||||
use Ecto.Schema
|
||||
|
||||
import Ecto.Changeset
|
||||
import Ecto.Query
|
||||
alias Mobilizon.Storage.Repo
|
||||
|
||||
alias Mobilizon.Actors.Actor
|
||||
alias Mobilizon.Storage.Repo
|
||||
|
||||
@type t :: %__MODULE__{
|
||||
uri: String.t(),
|
||||
|
@ -5,8 +5,8 @@ defmodule Mobilizon.Service.Export.ICalendar do
|
||||
|
||||
alias Mobilizon.{Actors, Events, Users}
|
||||
alias Mobilizon.Actors.Actor
|
||||
alias Mobilizon.Events.{Event, FeedToken}
|
||||
alias Mobilizon.Addresses.Address
|
||||
alias Mobilizon.Events.{Event, FeedToken}
|
||||
alias Mobilizon.Users.User
|
||||
|
||||
@doc """
|
||||
|
@ -4,8 +4,8 @@ defmodule Mobilizon.Service.Geospatial.Addok do
|
||||
"""
|
||||
|
||||
alias Mobilizon.Addresses.Address
|
||||
alias Mobilizon.Service.Geospatial.Provider
|
||||
alias Mobilizon.Config
|
||||
alias Mobilizon.Service.Geospatial.Provider
|
||||
|
||||
require Logger
|
||||
|
||||
|
@ -10,8 +10,8 @@ defmodule Mobilizon.Service.Geospatial.MapQuest do
|
||||
"""
|
||||
|
||||
alias Mobilizon.Addresses.Address
|
||||
alias Mobilizon.Service.Geospatial.Provider
|
||||
alias Mobilizon.Config
|
||||
alias Mobilizon.Service.Geospatial.Provider
|
||||
|
||||
require Logger
|
||||
|
||||
|
@ -8,8 +8,8 @@ defmodule Mobilizon.Service.Geospatial.Mimirsbrunn do
|
||||
"""
|
||||
|
||||
alias Mobilizon.Addresses.Address
|
||||
alias Mobilizon.Service.Geospatial.Provider
|
||||
alias Mobilizon.Config
|
||||
alias Mobilizon.Service.Geospatial.Provider
|
||||
|
||||
require Logger
|
||||
|
||||
|
@ -4,8 +4,8 @@ defmodule Mobilizon.Service.Geospatial.Nominatim do
|
||||
"""
|
||||
|
||||
alias Mobilizon.Addresses.Address
|
||||
alias Mobilizon.Service.Geospatial.Provider
|
||||
alias Mobilizon.Config
|
||||
alias Mobilizon.Service.Geospatial.Provider
|
||||
|
||||
require Logger
|
||||
|
||||
|
@ -6,8 +6,8 @@ defmodule Mobilizon.Service.Geospatial.Pelias do
|
||||
"""
|
||||
|
||||
alias Mobilizon.Addresses.Address
|
||||
alias Mobilizon.Service.Geospatial.Provider
|
||||
alias Mobilizon.Config
|
||||
alias Mobilizon.Service.Geospatial.Provider
|
||||
|
||||
require Logger
|
||||
|
||||
|
@ -4,8 +4,8 @@ defmodule Mobilizon.Service.Geospatial.Photon do
|
||||
"""
|
||||
|
||||
alias Mobilizon.Addresses.Address
|
||||
alias Mobilizon.Service.Geospatial.Provider
|
||||
alias Mobilizon.Config
|
||||
alias Mobilizon.Service.Geospatial.Provider
|
||||
|
||||
require Logger
|
||||
|
||||
|
@ -5,10 +5,11 @@ defmodule Mobilizon.Service.Metadata.Instance do
|
||||
|
||||
alias Phoenix.HTML
|
||||
alias Phoenix.HTML.Tag
|
||||
|
||||
alias Mobilizon.Config
|
||||
alias Mobilizon.Web.Endpoint
|
||||
|
||||
def build_tags() do
|
||||
def build_tags do
|
||||
description = process_description(Config.instance_description())
|
||||
title = "#{Config.instance_name()} - Mobilizon"
|
||||
|
||||
|
@ -3,10 +3,11 @@ defmodule Mobilizon.Service.Workers.BuildSearch do
|
||||
Worker to build search results
|
||||
"""
|
||||
|
||||
alias Ecto.Adapters.SQL
|
||||
|
||||
alias Mobilizon.Events
|
||||
alias Mobilizon.Events.Event
|
||||
alias Mobilizon.Storage.Repo
|
||||
alias Ecto.Adapters.SQL
|
||||
|
||||
use Mobilizon.Service.Workers.Helper, queue: "search"
|
||||
|
||||
|
@ -3,8 +3,7 @@ defmodule Mobilizon.Web.Email.Checker do
|
||||
Provides a function to test emails against a "not so bad" regex.
|
||||
"""
|
||||
|
||||
# TODO: simplify me!
|
||||
@email_regex ~r/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/
|
||||
@email_regex ~r/^[\w.!#$%&’*+\-\/=?\^`{|}~]+@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*$/i
|
||||
|
||||
@doc """
|
||||
Returns whether the email is valid.
|
||||
|
@ -15,7 +15,7 @@ defmodule Mobilizon.Web.Email.Event do
|
||||
alias Mobilizon.Storage.Repo
|
||||
alias Mobilizon.Users.User
|
||||
|
||||
alias Mobilizon.Web.{Gettext, Email}
|
||||
alias Mobilizon.Web.{Email, Gettext}
|
||||
|
||||
@important_changes [:title, :begins_on, :ends_on, :status]
|
||||
|
||||
|
@ -9,9 +9,9 @@ defmodule Mobilizon.Web.Email.Participation do
|
||||
|
||||
import Mobilizon.Web.Gettext
|
||||
|
||||
alias Mobilizon.Users.User
|
||||
alias Mobilizon.Actors.Actor
|
||||
alias Mobilizon.Events.Participant
|
||||
alias Mobilizon.Users.User
|
||||
|
||||
alias Mobilizon.Web.{Email, Gettext}
|
||||
|
||||
|
@ -49,7 +49,7 @@ defmodule Mobilizon.Web.ErrorView do
|
||||
render("500.html", assigns)
|
||||
end
|
||||
|
||||
defp index_file_path() do
|
||||
defp index_file_path do
|
||||
Path.join(Application.app_dir(:mobilizon, "priv/static"), "index.html")
|
||||
end
|
||||
end
|
||||
|
@ -10,8 +10,7 @@ defmodule Mobilizon.GraphQL.Resolvers.AdminTest do
|
||||
|
||||
alias Mobilizon.Federation.ActivityPub.Relay
|
||||
|
||||
alias Mobilizon.GraphQL.API
|
||||
alias Mobilizon.GraphQL.AbsintheHelpers
|
||||
alias Mobilizon.GraphQL.{AbsintheHelpers, API}
|
||||
|
||||
describe "Resolver: List the action logs" do
|
||||
@note_content "This a note on a report"
|
||||
|
@ -5,9 +5,9 @@ defmodule Mobilizon.ActorsTest do
|
||||
|
||||
import Mobilizon.Factory
|
||||
|
||||
alias Mobilizon.{Actors, Config, Users, Events, Tombstone}
|
||||
alias Mobilizon.{Actors, Config, Events, Tombstone, Users}
|
||||
alias Mobilizon.Actors.{Actor, Bot, Follower, Member}
|
||||
alias Mobilizon.Events.{Event, Comment}
|
||||
alias Mobilizon.Events.{Comment, Event}
|
||||
alias Mobilizon.Media.File, as: FileModel
|
||||
alias Mobilizon.Service.Workers
|
||||
alias Mobilizon.Storage.Page
|
||||
|
@ -1,12 +1,14 @@
|
||||
defmodule Mobilizon.Service.ICalendarTest do
|
||||
alias Mobilizon.Service.Export.ICalendar, as: ICalendarService
|
||||
alias Mobilizon.Events.Event
|
||||
alias Mobilizon.Addresses.Address
|
||||
alias ICalendar.Value
|
||||
use Mobilizon.DataCase
|
||||
|
||||
import Mobilizon.Factory
|
||||
|
||||
alias ICalendar.Value
|
||||
|
||||
alias Mobilizon.Addresses.Address
|
||||
alias Mobilizon.Events.Event
|
||||
alias Mobilizon.Service.Export.ICalendar, as: ICalendarService
|
||||
|
||||
describe "export an event to ics" do
|
||||
test "export basic infos" do
|
||||
%Event{} = event = insert(:event)
|
||||
|
@ -6,8 +6,8 @@ defmodule Mobilizon.Service.Geospatial.AddokTest do
|
||||
import Mock
|
||||
|
||||
alias Mobilizon.Addresses.Address
|
||||
alias Mobilizon.Service.Geospatial.Addok
|
||||
alias Mobilizon.Config
|
||||
alias Mobilizon.Service.Geospatial.Addok
|
||||
|
||||
@httpoison_headers [
|
||||
{"User-Agent",
|
||||
|
@ -6,8 +6,8 @@ defmodule Mobilizon.Service.Geospatial.MapQuestTest do
|
||||
import Mock
|
||||
|
||||
alias Mobilizon.Addresses.Address
|
||||
alias Mobilizon.Service.Geospatial.MapQuest
|
||||
alias Mobilizon.Config
|
||||
alias Mobilizon.Service.Geospatial.MapQuest
|
||||
|
||||
@httpoison_headers [
|
||||
{"User-Agent",
|
||||
|
@ -6,8 +6,8 @@ defmodule Mobilizon.Service.Geospatial.NominatimTest do
|
||||
import Mock
|
||||
|
||||
alias Mobilizon.Addresses.Address
|
||||
alias Mobilizon.Service.Geospatial.Nominatim
|
||||
alias Mobilizon.Config
|
||||
alias Mobilizon.Service.Geospatial.Nominatim
|
||||
|
||||
@httpoison_headers [
|
||||
{"User-Agent",
|
||||
|
@ -6,8 +6,8 @@ defmodule Mobilizon.Service.Geospatial.PhotonTest do
|
||||
import Mock
|
||||
|
||||
alias Mobilizon.Addresses.Address
|
||||
alias Mobilizon.Service.Geospatial.Photon
|
||||
alias Mobilizon.Config
|
||||
alias Mobilizon.Service.Geospatial.Photon
|
||||
|
||||
@httpoison_headers [
|
||||
{"User-Agent",
|
||||
|
@ -1,10 +1,12 @@
|
||||
defmodule Mix.Tasks.Mobilizon.ActorsTest do
|
||||
use Mobilizon.DataCase
|
||||
|
||||
alias Mobilizon.Actors.Actor
|
||||
alias Mix.Tasks.Mobilizon.Actors.Show
|
||||
import Mobilizon.Factory
|
||||
|
||||
alias Mix.Tasks.Mobilizon.Actors.Show
|
||||
|
||||
alias Mobilizon.Actors.Actor
|
||||
|
||||
Mix.shell(Mix.Shell.Process)
|
||||
|
||||
@username "someone"
|
||||
|
@ -3,9 +3,10 @@ defmodule Mix.Tasks.Mobilizon.UsersTest do
|
||||
|
||||
import Mobilizon.Factory
|
||||
|
||||
alias Mix.Tasks.Mobilizon.Users.{Delete, Modify, New, Show}
|
||||
|
||||
alias Mobilizon.Users
|
||||
alias Mobilizon.Users.User
|
||||
alias Mix.Tasks.Mobilizon.Users.{New, Delete, Show, Modify}
|
||||
|
||||
Mix.shell(Mix.Shell.Process)
|
||||
|
||||
|
@ -4,16 +4,18 @@ defmodule Mobilizon.Web.ErrorViewTest do
|
||||
# Bring render/3 and render_to_string/3 for testing custom views
|
||||
import Phoenix.View
|
||||
|
||||
alias Mobilizon.Web.ErrorView
|
||||
|
||||
test "renders 404.html" do
|
||||
assert render_to_string(Mobilizon.Web.ErrorView, "404.html", []) =~
|
||||
assert render_to_string(ErrorView, "404.html", []) =~
|
||||
"We're sorry but mobilizon doesn't work properly without JavaScript enabled. Please enable it to continue."
|
||||
end
|
||||
|
||||
test "render 500.html" do
|
||||
assert render_to_string(Mobilizon.Web.ErrorView, "500.html", []) == "Internal server error"
|
||||
assert render_to_string(ErrorView, "500.html", []) == "Internal server error"
|
||||
end
|
||||
|
||||
test "render any other" do
|
||||
assert render_to_string(Mobilizon.Web.ErrorView, "505.html", []) == "Internal server error"
|
||||
assert render_to_string(ErrorView, "505.html", []) == "Internal server error"
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user