Skip to content

Spark formatter dependency issue #228

@rgraff

Description

@rgraff

Code of Conduct

  • I agree to follow this project's Code of Conduct

AI Policy

  • I agree to follow this project's AI Policy, or I agree that AI was not used while creating this issue.

Versions

using spark 2.3.5 with elixir 1.18.3

Operating system

ubuntu

Current Behavior

In some instances Spark formatter will raise on error when the dependent resource is not already compiled. I can work around this by called mix phx.server or iex -S mix to compile the resource and then call mix format

mix format failed for file: lib/my_app/my_domain/my_resource.ex
** (UndefinedFunctionError) function MyApp.Resource.default_extensions/0 is undefined (module MyApp.Resource is not available)
    MyApp.Resource.default_extensions()
    (spark 2.3.5) lib/spark/formatter.ex:299: Spark.Formatter.parse_extensions/3
    (spark 2.3.5) lib/spark/formatter.ex:261: anonymous fn/2 in Spark.Formatter.get_extensions/2
    (elixir 1.18.3) lib/enum.ex:4432: Enum.find_value_list/3
    (spark 2.3.5) lib/spark/formatter.ex:100: anonymous fn/5 in Spark.Formatter.format_resources/3
    (spark 2.3.5) lib/spark/code_helpers.ex:53: Spark.CodeHelpers.traverse/5
    (spark 2.3.5) lib/spark/formatter.ex:96: Spark.Formatter.format_resources/3
    (spark 2.3.5) lib/spark/formatter.ex:79: Spark.Formatter.format/2

Reproduction

No response

Expected Behavior

Should compile without error

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions