Skip to content

Commit

Permalink
Merge pull request edgehog-device-manager#557 from davidebriani/add-e…
Browse files Browse the repository at this point in the history
…lixir-styler

Add Styler to format the codebase
  • Loading branch information
rbino authored Jul 4, 2024
2 parents ef58d2f + 5a7f6c3 commit 0584b5e
Show file tree
Hide file tree
Showing 298 changed files with 1,748 additions and 1,451 deletions.
7 changes: 3 additions & 4 deletions backend/.credo.exs
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,7 @@
# You can customize the priority of any check
# Priority values are: `low, normal, high, higher`
#
{Credo.Check.Design.AliasUsage,
[priority: :low, if_nested_deeper_than: 2, if_called_more_often_than: 0]},
{Credo.Check.Design.AliasUsage, [priority: :low, if_nested_deeper_than: 2, if_called_more_often_than: 0]},
# You can also customize the exit_status of each check.
# If you don't want TODO comments to cause `mix credo` to fail, just
# set this value to 0 (zero).
Expand Down Expand Up @@ -119,6 +118,7 @@
{Credo.Check.Readability.Semicolons, []},
{Credo.Check.Readability.SeparateAliasRequire, []},
{Credo.Check.Readability.SingleFunctionToBlockPipe, []},
{Credo.Check.Readability.SinglePipe, []},
{Credo.Check.Readability.SpaceAfterCommas, []},
{Credo.Check.Readability.StrictModuleLayout, []},
{Credo.Check.Readability.StringSigils, []},
Expand Down Expand Up @@ -147,6 +147,7 @@
{Credo.Check.Refactor.NegatedConditionsWithElse, []},
{Credo.Check.Refactor.NegatedIsNil, []},
{Credo.Check.Refactor.Nesting, []},
{Credo.Check.Refactor.PipeChainStart, []},
{Credo.Check.Refactor.RejectFilter, []},
{Credo.Check.Refactor.UnlessWithElse, []},
{Credo.Check.Refactor.WithClauses, []},
Expand Down Expand Up @@ -192,12 +193,10 @@
{Credo.Check.Consistency.UnusedVariableNames, []},
{Credo.Check.Design.DuplicatedCode, []},
{Credo.Check.Readability.AliasAs, []},
{Credo.Check.Readability.SinglePipe, []},
{Credo.Check.Readability.Specs, []},
{Credo.Check.Refactor.ABCSize, []},
{Credo.Check.Refactor.AppendSingleItem, []},
{Credo.Check.Refactor.ModuleDependencies, []},
{Credo.Check.Refactor.PipeChainStart, []},
{Credo.Check.Refactor.VariableRebinding, []},
{Credo.Check.Warning.LazyLogging, []}

Expand Down
2 changes: 1 addition & 1 deletion backend/.formatter.exs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
:skogsra,
:nimble_parsec
],
plugins: [Spark.Formatter],
plugins: [Spark.Formatter, Styler],
inputs: ["*.{ex,exs}", "priv/*/seeds.exs", "{config,lib,test}/**/*.{ex,exs}"],
subdirectories: ["priv/*/migrations"]
]
144 changes: 72 additions & 72 deletions backend/config/config.exs
Original file line number Diff line number Diff line change
Expand Up @@ -27,41 +27,6 @@
# General application configuration
import Config

config :edgehog,
ecto_repos: [Edgehog.Repo]

# Configures the endpoint
config :edgehog, EdgehogWeb.Endpoint,
url: [host: "localhost"],
render_errors: [view: EdgehogWeb.ErrorView, accepts: ~w(json), layout: false],
pubsub_server: Edgehog.PubSub,
live_view: [signing_salt: "aiSLZVyY"]

# Configures the mailer
#
# By default it uses the "Local" adapter which stores the emails
# locally. You can see the emails in your browser, at "/dev/mailbox".
#
# For production it's recommended to configure a different adapter
# at the `config/runtime.exs`.
config :edgehog, Edgehog.Mailer, adapter: Swoosh.Adapters.Local

# Swoosh API client is needed for adapters other than SMTP.
config :swoosh, :api_client, false

# Configures Elixir's Logger
config :logger, :console,
format: "$time $metadata[$level] $message\n",
metadata: [:module, :function, :request_id, :tag, :tenant, :realm]

# Use Jason for JSON parsing in Phoenix
config :phoenix, :json_library, Jason

config :tesla, :adapter, {Tesla.Adapter.Finch, name: EdgehogFinch, receive_timeout: 300_000}

config :ex_aws,
json_codec: Jason

allowed_algos = [
"ES256",
"ES384",
Expand All @@ -74,11 +39,36 @@ allowed_algos = [
"RS512"
]

config :edgehog, EdgehogWeb.Auth.Token, allowed_algos: allowed_algos
resource_section_order = [
:resource,
:graphql,
:json_api,
:code_interface,
:actions,
:validations,
:preparations,
:attributes,
:relationships,
:calculations,
:aggregates,
:identities,
:changes,
:pub_sub,
:multitenancy,
:postgres
]

config :edgehog, EdgehogWeb.AdminAPI.Auth.Token,
allowed_algos: allowed_algos,
secret_key: {Edgehog.Config, :admin_jwk!, []}
config :ash, :custom_types, id: Edgehog.Types.Id
config :ash, :default_belongs_to_type, :integer

# Configures the mailer
#
# By default it uses the "Local" adapter which stores the emails
# locally. You can see the emails in your browser, at "/dev/mailbox".
#
# For production it's recommended to configure a different adapter
# at the `config/runtime.exs`.
config :edgehog, Edgehog.Mailer, adapter: Swoosh.Adapters.Local

# Prometheus metrics
config :edgehog, Edgehog.PromEx,
Expand All @@ -88,6 +78,19 @@ config :edgehog, Edgehog.PromEx,
grafana: :disabled,
metrics_server: :disabled

config :edgehog, EdgehogWeb.AdminAPI.Auth.Token,
allowed_algos: allowed_algos,
secret_key: {Edgehog.Config, :admin_jwk!, []}

config :edgehog, EdgehogWeb.Auth.Token, allowed_algos: allowed_algos

# Configures the endpoint
config :edgehog, EdgehogWeb.Endpoint,
url: [host: "localhost"],
render_errors: [view: EdgehogWeb.ErrorView, accepts: ~w(json), layout: false],
pubsub_server: Edgehog.PubSub,
live_view: [signing_salt: "aiSLZVyY"]

config :edgehog, :ash_domains, [
Edgehog.Astarte,
Edgehog.BaseImages,
Expand All @@ -101,27 +104,34 @@ config :edgehog, :ash_domains, [
Edgehog.UpdateCampaigns
]

config :ash, :default_belongs_to_type, :integer
config :ash, :custom_types, id: Edgehog.Types.Id
config :edgehog, :edgehog_forwarder, %{
hostname: "localhost",
port: 4001,
secure_sessions?: false,
enabled?: true
}

resource_section_order = [
:resource,
:graphql,
:json_api,
:code_interface,
:actions,
:validations,
:preparations,
:attributes,
:relationships,
:calculations,
:aggregates,
:identities,
:changes,
:pub_sub,
:multitenancy,
:postgres
]
config :edgehog,
ecto_repos: [Edgehog.Repo]

config :ex_aws,
json_codec: Jason

# Configures Elixir's Logger
config :logger, :console,
format: "$time $metadata[$level] $message\n",
metadata: [:module, :function, :request_id, :tag, :tenant, :realm]

config :mime, :extensions, %{
"json" => "application/vnd.api+json"
}

config :mime, :types, %{
"application/vnd.api+json" => ["json"]
}

# Use Jason for JSON parsing in Phoenix
config :phoenix, :json_library, Jason

config :spark, :formatter,
remove_parens?: true,
Expand All @@ -133,20 +143,10 @@ config :spark, :formatter,
section_order: resource_section_order
]

config :mime, :types, %{
"application/vnd.api+json" => ["json"]
}

config :mime, :extensions, %{
"json" => "application/vnd.api+json"
}
# Swoosh API client is needed for adapters other than SMTP.
config :swoosh, :api_client, false

config :edgehog, :edgehog_forwarder, %{
hostname: "localhost",
port: 4001,
secure_sessions?: false,
enabled?: true
}
config :tesla, :adapter, {Tesla.Adapter.Finch, name: EdgehogFinch, receive_timeout: 300_000}

# Import environment specific config. This must remain at the bottom
# of this file so it overrides the configuration defined above.
Expand Down
40 changes: 20 additions & 20 deletions backend/config/dev.exs
Original file line number Diff line number Diff line change
Expand Up @@ -59,40 +59,40 @@ config :edgehog, EdgehogWeb.Endpoint,
# The `http:` config above can be replaced with:
#
# https: [
config :ex_aws, :s3,
scheme: "http://",
host: "localhost",
port: "9000"

config :ex_aws,
access_key_id: "minioadmin",
secret_access_key: "minioadmin"

config :goth,
disabled: true

# Do not include timestamps in development logs
# port: 4001,
# cipher_suite: :strong,
# keyfile: "priv/cert/selfsigned_key.pem",
# certfile: "priv/cert/selfsigned.pem"
config :logger, :console, format: "[$level] $message $metadata\n"

# Initialize plugs at runtime for faster development compilation
# ],
#
# If desired, both `http:` and `https:` keys can be
# configured to run both http and https servers on
# different ports.

# Do not include timestamps in development logs
config :logger, :console, format: "[$level] $message $metadata\n"
config :phoenix, :plug_init_mode, :runtime

# Set a higher stacktrace during development. Avoid configuring such
# configured to run both http and https servers on
# in production as building large stacktraces may be expensive.
config :phoenix, :stacktrace_depth, 20
# different ports.

# Initialize plugs at runtime for faster development compilation
config :phoenix, :plug_init_mode, :runtime
config :phoenix, :stacktrace_depth, 20

config :waffle,
storage: Waffle.Storage.S3,
bucket: "edgehog",
asset_host: "http://localhost:9000/edgehog",
virtual_host: true

config :ex_aws,
access_key_id: "minioadmin",
secret_access_key: "minioadmin"

config :ex_aws, :s3,
scheme: "http://",
host: "localhost",
port: "9000"

config :goth,
disabled: true
3 changes: 2 additions & 1 deletion backend/config/prod.exs
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,12 @@ import Config
# before starting your production server.
config :edgehog, EdgehogWeb.Endpoint, url: [host: "example.com", port: 80]

config :logger, :console, format: {PrettyLog.LogfmtFormatter, :format}

# Do not print debug messages in production
config :logger, level: :info

# Configure Logfmt
config :logger, :console, format: {PrettyLog.LogfmtFormatter, :format}

# ## SSL Support
#
Expand Down
Loading

0 comments on commit 0584b5e

Please sign in to comment.