Skip to content

Commit 3a296e9

Browse files
committed
improvement: add setting for skipping diagnostic warnings
1 parent 7bedcd2 commit 3a296e9

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

lib/spark/dsl/extension.ex

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -683,7 +683,7 @@ defmodule Spark.Dsl.Extension do
683683
rescue
684684
e in Spark.Error.DslError ->
685685
if e.location do
686-
Spark.Warning.warn(e.message, e.location)
686+
Spark.Dsl.Extension.diagnostic_warning(e)
687687

688688
reraise %{e | module: __MODULE__}, []
689689
else
@@ -696,6 +696,18 @@ defmodule Spark.Dsl.Extension do
696696
end
697697
end
698698

699+
if Application.compile_env(:spark, :skip_diagnostic_warnings, false) do
700+
@doc false
701+
def diagnostic_warning(_e) do
702+
:ok
703+
end
704+
else
705+
@doc false
706+
def diagnostic_warning(e) do
707+
Spark.Warning.warn(e.message, e.location)
708+
end
709+
end
710+
699711
@doc false
700712
def await_tasks(dsl) do
701713
Task.await_many(dsl[:persist][:spark_compile_tasks] || [], :infinity)
@@ -1257,7 +1269,8 @@ defmodule Spark.Dsl.Extension do
12571269
nested_key: nested_key,
12581270
mod: mod
12591271
] do
1260-
if !Map.has_key?(entity.target.__struct__(), :__spark_metadata__) do
1272+
if !Map.has_key?(entity.target.__struct__(), :__spark_metadata__) &&
1273+
!Application.compile_env(:spark, :skip_diagnostic_warnings, false) do
12611274
Spark.Warning.warn_deprecated(
12621275
"Entity without __spark_metadata__ field",
12631276
"Entity #{inspect(entity.target)} does not define a `__spark_metadata__` field. " <>

0 commit comments

Comments
 (0)