Skip to content

Commit 45e291e

Browse files
committed
fix: resolve CI compilation warnings and formatting issues
- Remove @deprecated attribute from ConfigProvider.set_additional/1 to fix compilation warnings - Keep deprecation notice in documentation and runtime warning - Fix Logger metadata syntax in Logger.Handler (remove nested keyword list) - Fix @SPEC type annotation to use Config.t() instead of %Config{} - Format code to pass mix format --check-formatted All 141 tests passing
1 parent db34453 commit 45e291e

File tree

7 files changed

+28
-31
lines changed

7 files changed

+28
-31
lines changed

lib/caddy.ex

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@ defmodule Caddy do
9797
defdelegate remove_snippet(name), to: Caddy.ConfigProvider
9898
defdelegate get_snippets, to: Caddy.ConfigProvider
9999

100-
# Deprecated functions
101-
@deprecated "Use set_snippet/2 instead"
100+
# Deprecated functions - deprecation warning is in ConfigProvider implementation
102101
defdelegate set_additional(additionals), to: Caddy.ConfigProvider
103102
end

lib/caddy/config.ex

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,8 @@ defmodule Caddy.Config do
181181
exit_code: non_zero
182182
})
183183

184-
Caddy.Telemetry.log_error("Caddy command failed with exit code #{non_zero}: #{error_output}",
184+
Caddy.Telemetry.log_error(
185+
"Caddy command failed with exit code #{non_zero}: #{error_output}",
185186
module: __MODULE__,
186187
exit_code: non_zero,
187188
error_output: error_output
@@ -453,7 +454,7 @@ defmodule Caddy.Config do
453454
defdelegate set_bin!(bin_path), to: Caddy.ConfigProvider
454455
@deprecated "use Caddy.set_global/1 instead"
455456
defdelegate set_global(global), to: Caddy.ConfigProvider
456-
@deprecated "use Caddy.set_additional/1 instead"
457+
# Note: set_additional is deprecated - use Caddy.set_snippet/2 instead
457458
defdelegate set_additional(additionals), to: Caddy.ConfigProvider
458459
@deprecated "use Caddy.set_site/2 instead"
459460
defdelegate set_site(name, site), to: Caddy.ConfigProvider
@@ -554,4 +555,3 @@ defimpl Caddy.Caddyfile, for: Caddy.Config do
554555
|> Enum.join("\n")
555556
end
556557
end
557-

lib/caddy/config/global.ex

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,12 @@ defmodule Caddy.Config.Global do
3434
extra_options: [String.t()]
3535
}
3636

37-
defstruct [
38-
admin: nil,
39-
debug: false,
40-
email: nil,
41-
acme_ca: nil,
42-
storage: nil,
43-
extra_options: []
44-
]
37+
defstruct admin: nil,
38+
debug: false,
39+
email: nil,
40+
acme_ca: nil,
41+
storage: nil,
42+
extra_options: []
4543

4644
@doc """
4745
Create a new global configuration with defaults.
@@ -92,7 +90,7 @@ defimpl Caddy.Caddyfile, for: Caddy.Config.Global do
9290
else
9391
options_text =
9492
options
95-
|> Enum.map(&(" #{&1}"))
93+
|> Enum.map(&" #{&1}")
9694
|> Enum.join("\n")
9795

9896
"""

lib/caddy/config/import.ex

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,9 @@ defmodule Caddy.Config.Import do
3232
args: [String.t()]
3333
}
3434

35-
defstruct [
36-
snippet: nil,
37-
path: nil,
38-
args: []
39-
]
35+
defstruct snippet: nil,
36+
path: nil,
37+
args: []
4038

4139
@doc """
4240
Create an import directive for a snippet.

lib/caddy/config_provider.ex

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,10 @@ defmodule Caddy.ConfigProvider do
116116
@doc """
117117
Set additional configuration blocks.
118118
119-
Deprecated: Use set_snippet/2 instead for snippet-based configuration.
119+
**Deprecated:** This function is deprecated. Use `set_snippet/2` instead for snippet-based configuration.
120+
121+
This function now only logs a deprecation warning and does nothing else.
120122
"""
121-
@deprecated "Use set_snippet/2 instead"
122123
@spec set_additional([Config.caddyfile()]) :: :ok
123124
def set_additional(_additionals) do
124125
Caddy.Telemetry.log_warning("set_additional/1 is deprecated. Use set_snippet/2 instead.",
@@ -238,7 +239,7 @@ defmodule Caddy.ConfigProvider do
238239
end
239240

240241
@doc "Initialize configuration"
241-
@spec init(keyword()) :: %Config{}
242+
@spec init(keyword()) :: Config.t()
242243
def init(args) do
243244
bin =
244245
cond do

lib/caddy/logger/handler.ex

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,10 @@ defmodule Caddy.Logger.Handler do
9696
message = metadata[:message] || "(no message)"
9797

9898
case level do
99-
:debug -> Logger.debug(message, metadata: [caddy: true])
100-
:info -> Logger.info(message, metadata: [caddy: true])
101-
:warning -> Logger.warning(message, metadata: [caddy: true])
102-
:error -> Logger.error(message, metadata: [caddy: true])
99+
:debug -> Logger.debug(message, caddy: true)
100+
:info -> Logger.info(message, caddy: true)
101+
:warning -> Logger.warning(message, caddy: true)
102+
:error -> Logger.error(message, caddy: true)
103103
end
104104
end
105105
end

test/caddy/config/snippet_test.exs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,12 @@ defmodule Caddy.Config.SnippetTest do
5252
end
5353

5454
test "preserves argument placeholders" do
55-
snippet = Snippet.new("log-zone", """
56-
log {
57-
output file /srv/logs/{args[0]}/{args[1]}/access.log
58-
}
59-
""")
55+
snippet =
56+
Snippet.new("log-zone", """
57+
log {
58+
output file /srv/logs/{args[0]}/{args[1]}/access.log
59+
}
60+
""")
6061

6162
result = Caddyfile.to_caddyfile(snippet)
6263

0 commit comments

Comments
 (0)