Skip to content

Commit

Permalink
Add parentheses to all function calls to fix Elixir 1.17 warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
doughsay committed May 22, 2024
1 parent f63b860 commit 47917fc
Show file tree
Hide file tree
Showing 16 changed files with 30 additions and 30 deletions.
2 changes: 1 addition & 1 deletion lib/absinthe/blueprint/schema.ex
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ defmodule Absinthe.Blueprint.Schema do

def functions(module) do
if function_exported?(module, :functions, 0) do
module.functions
module.functions()
else
[]
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ defmodule Absinthe.Phase.Document.Validation.FieldsOnCorrectType do
[identifier]

%Type.Interface{identifier: identifier} ->
schema.__absinthe_interface_implementors__
schema.__absinthe_interface_implementors__()
|> Map.fetch!(identifier)

%Type.Union{types: types} ->
Expand Down
2 changes: 1 addition & 1 deletion lib/absinthe/phase/schema/directive_imports.ex
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ defmodule Absinthe.Phase.Schema.DirectiveImports do
defp do_imports([{module, opts} | rest], acc, schema) do
case ensure_compiled(module) do
{:module, module} ->
[other_def] = module.__absinthe_blueprint__.schema_definitions
[other_def] = module.__absinthe_blueprint__().schema_definitions

rejections = MapSet.new(Keyword.get(opts, :except, []))

Expand Down
2 changes: 1 addition & 1 deletion lib/absinthe/phase/schema/spec_compliant_int.ex
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ defmodule Absinthe.Phase.Schema.SpecCompliantInt do
defp handle_node(%Blueprint.Schema.ScalarTypeDefinition{identifier: :integer}) do
case ensure_compiled(Absinthe.Type.BuiltIns.SpecCompliantInt) do
{:module, module} ->
[types] = module.__absinthe_blueprint__.schema_definitions
[types] = module.__absinthe_blueprint__().schema_definitions

Enum.find(
types.type_definitions,
Expand Down
2 changes: 1 addition & 1 deletion lib/absinthe/phase/schema/type_extension_imports.ex
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ defmodule Absinthe.Phase.Schema.TypeExtensionImports do
defp do_imports([{module, opts} | rest], type_extensions_acc, schema) do
case ensure_compiled(module) do
{:module, module} ->
[other_def] = module.__absinthe_blueprint__.schema_definitions
[other_def] = module.__absinthe_blueprint__().schema_definitions

rejections = Keyword.get(opts, :except, []) |> MapSet.new()

Expand Down
2 changes: 1 addition & 1 deletion lib/absinthe/phase/schema/type_imports.ex
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ defmodule Absinthe.Phase.Schema.TypeImports do
defp do_imports([{module, opts} | rest], types_acc, schema) do
case ensure_compiled(module) do
{:module, module} ->
[other_def] = module.__absinthe_blueprint__.schema_definitions
[other_def] = module.__absinthe_blueprint__().schema_definitions

rejections =
MapSet.new([:query, :mutation, :subscription] ++ Keyword.get(opts, :except, []))
Expand Down
20 changes: 10 additions & 10 deletions lib/absinthe/schema.ex
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ defmodule Absinthe.Schema do
```
You can see what your schema's blueprint looks like by calling
`__absinthe_blueprint__` on any schema or type definition module.
`__absinthe_blueprint__()` on any schema or type definition module.
```
defmodule MyAppWeb.Schema do
Expand All @@ -38,7 +38,7 @@ defmodule Absinthe.Schema do
end
end
> MyAppWeb.Schema.__absinthe_blueprint__
> MyAppWeb.Schema.__absinthe_blueprint__()
#=> %Absinthe.Blueprint{...}
```
Expand Down Expand Up @@ -88,7 +88,7 @@ defmodule Absinthe.Schema do
end
end
Foo.__absinthe_blueprint__ #=> ...
Foo.__absinthe_blueprint__() #=> ...
```
"""

Expand Down Expand Up @@ -363,7 +363,7 @@ defmodule Absinthe.Schema do

@spec apply_modifiers(Absinthe.Pipeline.t(), t) :: Absinthe.Pipeline.t()
def apply_modifiers(pipeline, schema, opts \\ []) do
Enum.reduce(schema.__absinthe_pipeline_modifiers__, pipeline, fn
Enum.reduce(schema.__absinthe_pipeline_modifiers__(), pipeline, fn
{module, function}, pipeline ->
cond do
function_exported?(module, function, 1) ->
Expand Down Expand Up @@ -400,7 +400,7 @@ defmodule Absinthe.Schema do
|> Absinthe.Pipeline.for_schema(prototype_schema: prototype_schema)
|> apply_modifiers(env.module)

env.module.__absinthe_blueprint__
env.module.__absinthe_blueprint__()
|> Absinthe.Pipeline.run(pipeline)
|> case do
{:ok, _, _} ->
Expand Down Expand Up @@ -639,7 +639,7 @@ defmodule Absinthe.Schema do
"""
@spec directives(t) :: [Type.Directive.t()]
def directives(schema) do
schema.__absinthe_directives__
schema.__absinthe_directives__()
|> Map.keys()
|> Enum.map(&lookup_directive(schema, &1))
end
Expand All @@ -661,13 +661,13 @@ defmodule Absinthe.Schema do
def to_sdl(schema, opts \\ []) do
pipeline =
schema
|> Absinthe.Pipeline.for_schema(prototype_schema: schema.__absinthe_prototype_schema__)
|> Absinthe.Pipeline.for_schema(prototype_schema: schema.__absinthe_prototype_schema__())
|> Absinthe.Pipeline.upto({Absinthe.Phase.Schema.Validation.Result, pass: :final})
|> apply_modifiers(schema, opts)

# we can be assertive here, since this same pipeline was already used to
# successfully compile the schema.
{:ok, bp, _} = Absinthe.Pipeline.run(schema.__absinthe_blueprint__, pipeline)
{:ok, bp, _} = Absinthe.Pipeline.run(schema.__absinthe_blueprint__(), pipeline)

inspect(bp, pretty: true)
end
Expand All @@ -677,7 +677,7 @@ defmodule Absinthe.Schema do
"""
@spec implementors(t, Type.identifier_t() | Type.Interface.t()) :: [Type.Object.t()]
def implementors(schema, ident) when is_atom(ident) do
schema.__absinthe_interface_implementors__
schema.__absinthe_interface_implementors__()
|> Map.get(ident, [])
|> Enum.map(&lookup_type(schema, &1))
end
Expand All @@ -691,7 +691,7 @@ defmodule Absinthe.Schema do
"""
@spec types(t) :: [Type.t()]
def types(schema) do
schema.__absinthe_types__
schema.__absinthe_types__()
|> Map.keys()
|> Enum.map(&lookup_type(schema, &1))
end
Expand Down
8 changes: 4 additions & 4 deletions lib/absinthe/schema/compiled.ex
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,22 @@ defmodule Absinthe.Schema.Compiled do
end

def __absinthe_types__(schema_mod) do
Module.concat([schema_mod, Compiled]).__absinthe_types__
Module.concat([schema_mod, Compiled]).__absinthe_types__()
end

def __absinthe_types__(schema_mod, group) do
Module.concat([schema_mod, Compiled]).__absinthe_types__(group)
end

def __absinthe_directives__(schema_mod) do
Module.concat([schema_mod, Compiled]).__absinthe_directives__
Module.concat([schema_mod, Compiled]).__absinthe_directives__()
end

def __absinthe_interface_implementors__(schema_mod) do
Module.concat([schema_mod, Compiled]).__absinthe_interface_implementors__
Module.concat([schema_mod, Compiled]).__absinthe_interface_implementors__()
end

def __absinthe_schema_declaration__(schema_mod) do
Module.concat([schema_mod, Compiled]).__absinthe_schema_declaration__
Module.concat([schema_mod, Compiled]).__absinthe_schema_declaration__()
end
end
4 changes: 2 additions & 2 deletions lib/absinthe/schema/manager.ex
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ defmodule Absinthe.Schema.Manager do
end

def init(schema_module) do
prototype_schema = schema_module.__absinthe_prototype_schema__
prototype_schema = schema_module.__absinthe_prototype_schema__()

pipeline =
schema_module
|> Absinthe.Pipeline.for_schema(prototype_schema: prototype_schema)
|> Absinthe.Schema.apply_modifiers(schema_module)

schema_module.__absinthe_blueprint__
schema_module.__absinthe_blueprint__()
|> Absinthe.Pipeline.run(pipeline)
|> case do
{:ok, _, _} ->
Expand Down
2 changes: 1 addition & 1 deletion lib/absinthe/type/built_ins/introspection.ex
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ defmodule Absinthe.Type.BuiltIns.Introspection do
field :kind,
type: non_null(:__type_kind),
resolve: fn _, %{source: %{__struct__: type}} ->
{:ok, type.kind}
{:ok, type.kind()}
end

field :name, :string
Expand Down
4 changes: 2 additions & 2 deletions lib/absinthe/utils.ex
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ defmodule Absinthe.Utils do
|> List.last()

types =
module.__absinthe_types__
module.__absinthe_types__()
|> Map.keys()
|> Enum.sort_by(& &1)
|> Enum.map(fn identifier ->
Expand All @@ -131,7 +131,7 @@ defmodule Absinthe.Utils do
end)

directives =
module.__absinthe_directives__
module.__absinthe_directives__()
|> Map.keys()
|> Enum.sort_by(& &1)
|> Enum.map(fn identifier ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,8 @@ defmodule Absinthe.Phase.Document.Validation.KnownDirectivesTest do
)
end

@tag :pending
describe "within schema language" do
@tag :pending
test "with well placed directives" do
assert_passes_validation(
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ defmodule Absinthe.Schema.Notation.Experimental.ImportTypeExtensionsTest do
end

defp imports(module) do
%{schema_definitions: [schema]} = module.__absinthe_blueprint__
%{schema_definitions: [schema]} = module.__absinthe_blueprint__()
schema.type_extension_imports
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ defmodule Absinthe.Schema.Notation.Experimental.ImportTypesTest do
end

defp imports(module) do
%{schema_definitions: [schema]} = module.__absinthe_blueprint__
%{schema_definitions: [schema]} = module.__absinthe_blueprint__()
schema.imports
end
end
2 changes: 1 addition & 1 deletion test/absinthe/schema/notation/import_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ defmodule Absinthe.Schema.Notation.ImportTest do
|> Absinthe.Pipeline.upto(Phase.Schema.FieldImports)
|> Kernel.++([Phase.Schema.Validation.Result])

case Absinthe.Pipeline.run(schema.__absinthe_blueprint__, pipeline) do
case Absinthe.Pipeline.run(schema.__absinthe_blueprint__(), pipeline) do
{ok_or_error, val, _} ->
{ok_or_error, val}
end
Expand Down
2 changes: 1 addition & 1 deletion test/test_helper.exs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ fixtures_schemas = [
]

for schema <- fixtures_schemas,
schema.__absinthe_schema_provider__ == Absinthe.Schema.PersistentTerm do
schema.__absinthe_schema_provider__() == Absinthe.Schema.PersistentTerm do
Absinthe.Schema.Manager.start_link(schema)
end

0 comments on commit 47917fc

Please sign in to comment.