From 494bc176613e9eb0994a8bf09c3fd015dff3e69a Mon Sep 17 00:00:00 2001 From: Ahmed Ismail Date: Fri, 10 Nov 2023 02:01:02 +0500 Subject: [PATCH] Remove some code-readability issues like: - Module names should be written in PascalCase - Module attribute names should be written in snake_case - Numbers larger than 9999 should be written with underscores: 10_000 etc --- lib/absinthe/middleware/async.ex | 4 ++-- lib/absinthe/middleware/batch.ex | 4 ++-- .../schema/validation/interfaces_must_resolve_types.ex | 2 +- lib/absinthe/resolution/helpers.ex | 4 ++-- .../null/literal_to_element_of_type_list_of_T_test.exs | 2 +- ...literal_to_element_of_type_non_null_list_of_T_test.exs | 2 +- .../literal_to_type_T_overrides_default_value_test.exs | 2 +- .../input_types/null/literal_to_type_list_of_T_test.exs | 2 +- .../input_types/null/literal_to_type_non_null_T_test.exs | 2 +- .../literal_to_type_non_null_list_of_T_element_test.exs | 2 +- .../null/literal_to_type_non_null_list_of_T_test.exs | 2 +- ...l_to_type_non_null_list_of_non_null_T_element_test.exs | 2 +- .../literal_to_type_non_null_list_of_non_null_T_test.exs | 2 +- .../variable_to_type_T_overrides_default_value_test.exs | 2 +- .../input_types/null/variable_to_type_T_test.exs | 2 +- .../null/variable_to_type_list_of_T_element_test.exs | 2 +- .../input_types/null/variable_to_type_list_of_T_test.exs | 2 +- .../input_types/null/variable_to_type_non_null_T_test.exs | 2 +- .../variable_to_type_non_null_list_of_T_element_test.exs | 2 +- .../null/variable_to_type_non_null_list_of_T_test.exs | 2 +- ...e_to_type_non_null_list_of_non_null_T_element_test.exs | 2 +- .../variable_to_type_non_null_list_of_non_null_T_test.exs | 2 +- .../null/variable_to_variable_type_non_null_T_test.exs | 2 +- .../integration/execution/operation_by_name_test.exs | 4 +--- test/absinthe/lexer_test.exs | 2 +- test/absinthe/pipeline_test.exs | 8 ++++---- test/absinthe/subscription/pipeline_serializer_test.exs | 3 +-- 27 files changed, 33 insertions(+), 36 deletions(-) diff --git a/lib/absinthe/middleware/async.ex b/lib/absinthe/middleware/async.ex index 52bdaccdb1..c121af0481 100644 --- a/lib/absinthe/middleware/async.ex +++ b/lib/absinthe/middleware/async.ex @@ -113,10 +113,10 @@ defmodule Absinthe.Middleware.Async do # Optionally use `async/1` function from `opentelemetry_process_propagator` if available if Code.ensure_loaded?(OpentelemetryProcessPropagator.Task) do - @spec async((-> any)) :: Task.t() + @spec async((() -> any)) :: Task.t() defdelegate async(fun), to: OpentelemetryProcessPropagator.Task else - @spec async((-> any)) :: Task.t() + @spec async((() -> any)) :: Task.t() defdelegate async(fun), to: Task end end diff --git a/lib/absinthe/middleware/batch.ex b/lib/absinthe/middleware/batch.ex index 1030fbb098..4ab60719b1 100644 --- a/lib/absinthe/middleware/batch.ex +++ b/lib/absinthe/middleware/batch.ex @@ -209,10 +209,10 @@ defmodule Absinthe.Middleware.Batch do # Optionally use `async/1` function from `opentelemetry_process_propagator` if available if Code.ensure_loaded?(OpentelemetryProcessPropagator.Task) do - @spec async((-> any)) :: Task.t() + @spec async((() -> any)) :: Task.t() defdelegate async(fun), to: OpentelemetryProcessPropagator.Task else - @spec async((-> any)) :: Task.t() + @spec async((() -> any)) :: Task.t() defdelegate async(fun), to: Task end end diff --git a/lib/absinthe/phase/schema/validation/interfaces_must_resolve_types.ex b/lib/absinthe/phase/schema/validation/interfaces_must_resolve_types.ex index 5c774dce44..34819ea74a 100644 --- a/lib/absinthe/phase/schema/validation/interfaces_must_resolve_types.ex +++ b/lib/absinthe/phase/schema/validation/interfaces_must_resolve_types.ex @@ -31,7 +31,7 @@ defmodule Absinthe.Phase.Schema.Validation.InterfacesMustResolveTypes do defp validate_interface(%Blueprint.Schema.InterfaceTypeDefinition{} = iface, implementors) do resolve_type = Absinthe.Type.function(iface, :resolve_type) - if(resolve_type || all_objects_is_type_of?(iface, implementors)) do + if resolve_type || all_objects_is_type_of?(iface, implementors) do iface else iface |> put_error(error(iface)) diff --git a/lib/absinthe/resolution/helpers.ex b/lib/absinthe/resolution/helpers.ex index 70f1e21738..1746b27c94 100644 --- a/lib/absinthe/resolution/helpers.ex +++ b/lib/absinthe/resolution/helpers.ex @@ -34,8 +34,8 @@ defmodule Absinthe.Resolution.Helpers do end ``` """ - @spec async((-> term)) :: {:middleware, Middleware.Async, term} - @spec async((-> term), opts :: [{:timeout, pos_integer}]) :: + @spec async((() -> term)) :: {:middleware, Middleware.Async, term} + @spec async((() -> term), opts :: [{:timeout, pos_integer}]) :: {:middleware, Middleware.Async, term} def async(fun, opts \\ []) do {:middleware, Middleware.Async, {fun, opts}} diff --git a/test/absinthe/integration/execution/input_types/null/literal_to_element_of_type_list_of_T_test.exs b/test/absinthe/integration/execution/input_types/null/literal_to_element_of_type_list_of_T_test.exs index 1416a29404..08c763a2e9 100644 --- a/test/absinthe/integration/execution/input_types/null/literal_to_element_of_type_list_of_T_test.exs +++ b/test/absinthe/integration/execution/input_types/null/literal_to_element_of_type_list_of_T_test.exs @@ -1,4 +1,4 @@ -defmodule Elixir.Absinthe.Integration.Execution.InputTypes.Null.LiteralToElementOfTypeListOf_TTest do +defmodule Elixir.Absinthe.Integration.Execution.InputTypes.Null.LiteralToElementOfTypeListOfTTest do use Absinthe.Case, async: true @query """ diff --git a/test/absinthe/integration/execution/input_types/null/literal_to_element_of_type_non_null_list_of_T_test.exs b/test/absinthe/integration/execution/input_types/null/literal_to_element_of_type_non_null_list_of_T_test.exs index 7d7d3df7ac..a8eb607e4c 100644 --- a/test/absinthe/integration/execution/input_types/null/literal_to_element_of_type_non_null_list_of_T_test.exs +++ b/test/absinthe/integration/execution/input_types/null/literal_to_element_of_type_non_null_list_of_T_test.exs @@ -1,4 +1,4 @@ -defmodule Elixir.Absinthe.Integration.Execution.InputTypes.Null.LiteralToElementOfTypeNonNullListOf_TTest do +defmodule Elixir.Absinthe.Integration.Execution.InputTypes.Null.LiteralToElementOfTypeNonNullListOfTTest do use Absinthe.Case, async: true @query """ diff --git a/test/absinthe/integration/execution/input_types/null/literal_to_type_T_overrides_default_value_test.exs b/test/absinthe/integration/execution/input_types/null/literal_to_type_T_overrides_default_value_test.exs index ad8a1f3cab..3b8c81ede6 100644 --- a/test/absinthe/integration/execution/input_types/null/literal_to_type_T_overrides_default_value_test.exs +++ b/test/absinthe/integration/execution/input_types/null/literal_to_type_T_overrides_default_value_test.exs @@ -1,4 +1,4 @@ -defmodule Elixir.Absinthe.Integration.Execution.InputTypes.Null.LiteralToType_TOverridesDefaultValueTest do +defmodule Elixir.Absinthe.Integration.Execution.InputTypes.Null.LiteralToTypeTOverridesDefaultValueTest do use Absinthe.Case, async: true @query """ diff --git a/test/absinthe/integration/execution/input_types/null/literal_to_type_list_of_T_test.exs b/test/absinthe/integration/execution/input_types/null/literal_to_type_list_of_T_test.exs index ca6f341631..c322a4abdc 100644 --- a/test/absinthe/integration/execution/input_types/null/literal_to_type_list_of_T_test.exs +++ b/test/absinthe/integration/execution/input_types/null/literal_to_type_list_of_T_test.exs @@ -1,4 +1,4 @@ -defmodule Elixir.Absinthe.Integration.Execution.InputTypes.Null.LiteralToTypeListOf_TTest do +defmodule Elixir.Absinthe.Integration.Execution.InputTypes.Null.LiteralToTypeListOfTTest do use Absinthe.Case, async: true @query """ diff --git a/test/absinthe/integration/execution/input_types/null/literal_to_type_non_null_T_test.exs b/test/absinthe/integration/execution/input_types/null/literal_to_type_non_null_T_test.exs index 9c66d551dd..a051eeabfd 100644 --- a/test/absinthe/integration/execution/input_types/null/literal_to_type_non_null_T_test.exs +++ b/test/absinthe/integration/execution/input_types/null/literal_to_type_non_null_T_test.exs @@ -1,4 +1,4 @@ -defmodule Elixir.Absinthe.Integration.Execution.InputTypes.Null.LiteralToTypeNonNull_TTest do +defmodule Elixir.Absinthe.Integration.Execution.InputTypes.Null.LiteralToTypeNonNullTTest do use Absinthe.Case, async: true @query """ diff --git a/test/absinthe/integration/execution/input_types/null/literal_to_type_non_null_list_of_T_element_test.exs b/test/absinthe/integration/execution/input_types/null/literal_to_type_non_null_list_of_T_element_test.exs index c6ab3ed36b..ab3e60c974 100644 --- a/test/absinthe/integration/execution/input_types/null/literal_to_type_non_null_list_of_T_element_test.exs +++ b/test/absinthe/integration/execution/input_types/null/literal_to_type_non_null_list_of_T_element_test.exs @@ -1,4 +1,4 @@ -defmodule Elixir.Absinthe.Integration.Execution.InputTypes.Null.LiteralToTypeNonNullListOf_TElementTest do +defmodule Elixir.Absinthe.Integration.Execution.InputTypes.Null.LiteralToTypeNonNullListOfTElementTest do use Absinthe.Case, async: true @query """ diff --git a/test/absinthe/integration/execution/input_types/null/literal_to_type_non_null_list_of_T_test.exs b/test/absinthe/integration/execution/input_types/null/literal_to_type_non_null_list_of_T_test.exs index f381ba57f7..360d3c57df 100644 --- a/test/absinthe/integration/execution/input_types/null/literal_to_type_non_null_list_of_T_test.exs +++ b/test/absinthe/integration/execution/input_types/null/literal_to_type_non_null_list_of_T_test.exs @@ -1,4 +1,4 @@ -defmodule Elixir.Absinthe.Integration.Execution.InputTypes.Null.LiteralToTypeNonNullListOf_TTest do +defmodule Elixir.Absinthe.Integration.Execution.InputTypes.Null.LiteralToTypeNonNullListOfTTest do use Absinthe.Case, async: true @query """ diff --git a/test/absinthe/integration/execution/input_types/null/literal_to_type_non_null_list_of_non_null_T_element_test.exs b/test/absinthe/integration/execution/input_types/null/literal_to_type_non_null_list_of_non_null_T_element_test.exs index 8f9f8289bf..bee9a66722 100644 --- a/test/absinthe/integration/execution/input_types/null/literal_to_type_non_null_list_of_non_null_T_element_test.exs +++ b/test/absinthe/integration/execution/input_types/null/literal_to_type_non_null_list_of_non_null_T_element_test.exs @@ -1,4 +1,4 @@ -defmodule Elixir.Absinthe.Integration.Execution.InputTypes.Null.LiteralToTypeNonNullListOfNonNull_TElementTest do +defmodule Elixir.Absinthe.Integration.Execution.InputTypes.Null.LiteralToTypeNonNullListOfNonNullTElementTest do use Absinthe.Case, async: true @query """ diff --git a/test/absinthe/integration/execution/input_types/null/literal_to_type_non_null_list_of_non_null_T_test.exs b/test/absinthe/integration/execution/input_types/null/literal_to_type_non_null_list_of_non_null_T_test.exs index 12900cb313..00da92e5e1 100644 --- a/test/absinthe/integration/execution/input_types/null/literal_to_type_non_null_list_of_non_null_T_test.exs +++ b/test/absinthe/integration/execution/input_types/null/literal_to_type_non_null_list_of_non_null_T_test.exs @@ -1,4 +1,4 @@ -defmodule Elixir.Absinthe.Integration.Execution.InputTypes.Null.LiteralToTypeNonNullListOfNonNull_TTest do +defmodule Elixir.Absinthe.Integration.Execution.InputTypes.Null.LiteralToTypeNonNullListOfNonNullTTest do use Absinthe.Case, async: true @query """ diff --git a/test/absinthe/integration/execution/input_types/null/variable_to_type_T_overrides_default_value_test.exs b/test/absinthe/integration/execution/input_types/null/variable_to_type_T_overrides_default_value_test.exs index d836206b85..cf6b5a544c 100644 --- a/test/absinthe/integration/execution/input_types/null/variable_to_type_T_overrides_default_value_test.exs +++ b/test/absinthe/integration/execution/input_types/null/variable_to_type_T_overrides_default_value_test.exs @@ -1,4 +1,4 @@ -defmodule Elixir.Absinthe.Integration.Execution.InputTypes.Null.VariableToType_TOverridesDefaultValueTest do +defmodule Elixir.Absinthe.Integration.Execution.InputTypes.Null.VariableToTypeTOverridesDefaultValueTest do use Absinthe.Case, async: true @query """ diff --git a/test/absinthe/integration/execution/input_types/null/variable_to_type_T_test.exs b/test/absinthe/integration/execution/input_types/null/variable_to_type_T_test.exs index aaf2f88d4f..eb14c905a9 100644 --- a/test/absinthe/integration/execution/input_types/null/variable_to_type_T_test.exs +++ b/test/absinthe/integration/execution/input_types/null/variable_to_type_T_test.exs @@ -1,4 +1,4 @@ -defmodule Elixir.Absinthe.Integration.Execution.InputTypes.Null.VariableToType_TTest do +defmodule Elixir.Absinthe.Integration.Execution.InputTypes.Null.VariableToTypeTTest do use Absinthe.Case, async: true @query """ diff --git a/test/absinthe/integration/execution/input_types/null/variable_to_type_list_of_T_element_test.exs b/test/absinthe/integration/execution/input_types/null/variable_to_type_list_of_T_element_test.exs index 4d529e9f86..f0df2d20db 100644 --- a/test/absinthe/integration/execution/input_types/null/variable_to_type_list_of_T_element_test.exs +++ b/test/absinthe/integration/execution/input_types/null/variable_to_type_list_of_T_element_test.exs @@ -1,4 +1,4 @@ -defmodule Elixir.Absinthe.Integration.Execution.InputTypes.Null.VariableToTypeListOf_TElementTest do +defmodule Elixir.Absinthe.Integration.Execution.InputTypes.Null.VariableToTypeListOfTElementTest do use Absinthe.Case, async: true @query """ diff --git a/test/absinthe/integration/execution/input_types/null/variable_to_type_list_of_T_test.exs b/test/absinthe/integration/execution/input_types/null/variable_to_type_list_of_T_test.exs index 9b63d6558e..c81a8b0866 100644 --- a/test/absinthe/integration/execution/input_types/null/variable_to_type_list_of_T_test.exs +++ b/test/absinthe/integration/execution/input_types/null/variable_to_type_list_of_T_test.exs @@ -1,4 +1,4 @@ -defmodule Elixir.Absinthe.Integration.Execution.InputTypes.Null.VariableToTypeListOf_TTest do +defmodule Elixir.Absinthe.Integration.Execution.InputTypes.Null.VariableToTypeListOfTTest do use Absinthe.Case, async: true @query """ diff --git a/test/absinthe/integration/execution/input_types/null/variable_to_type_non_null_T_test.exs b/test/absinthe/integration/execution/input_types/null/variable_to_type_non_null_T_test.exs index 03c9bf87b0..234b497179 100644 --- a/test/absinthe/integration/execution/input_types/null/variable_to_type_non_null_T_test.exs +++ b/test/absinthe/integration/execution/input_types/null/variable_to_type_non_null_T_test.exs @@ -1,4 +1,4 @@ -defmodule Elixir.Absinthe.Integration.Execution.InputTypes.Null.VariableToTypeNonNull_TTest do +defmodule Elixir.Absinthe.Integration.Execution.InputTypes.Null.VariableToTypeNonNullTTest do use Absinthe.Case, async: true @query """ diff --git a/test/absinthe/integration/execution/input_types/null/variable_to_type_non_null_list_of_T_element_test.exs b/test/absinthe/integration/execution/input_types/null/variable_to_type_non_null_list_of_T_element_test.exs index 22058e908a..4afa1d1050 100644 --- a/test/absinthe/integration/execution/input_types/null/variable_to_type_non_null_list_of_T_element_test.exs +++ b/test/absinthe/integration/execution/input_types/null/variable_to_type_non_null_list_of_T_element_test.exs @@ -1,4 +1,4 @@ -defmodule Elixir.Absinthe.Integration.Execution.InputTypes.Null.VariableToTypeNonNullListOf_TElementTest do +defmodule Elixir.Absinthe.Integration.Execution.InputTypes.Null.VariableToTypeNonNullListOfTElementTest do use Absinthe.Case, async: true @query """ diff --git a/test/absinthe/integration/execution/input_types/null/variable_to_type_non_null_list_of_T_test.exs b/test/absinthe/integration/execution/input_types/null/variable_to_type_non_null_list_of_T_test.exs index a9505ff521..973d5e10b8 100644 --- a/test/absinthe/integration/execution/input_types/null/variable_to_type_non_null_list_of_T_test.exs +++ b/test/absinthe/integration/execution/input_types/null/variable_to_type_non_null_list_of_T_test.exs @@ -1,4 +1,4 @@ -defmodule Elixir.Absinthe.Integration.Execution.InputTypes.Null.VariableToTypeNonNullListOf_TTest do +defmodule Elixir.Absinthe.Integration.Execution.InputTypes.Null.VariableToTypeNonNullListOfTTest do use Absinthe.Case, async: true @query """ diff --git a/test/absinthe/integration/execution/input_types/null/variable_to_type_non_null_list_of_non_null_T_element_test.exs b/test/absinthe/integration/execution/input_types/null/variable_to_type_non_null_list_of_non_null_T_element_test.exs index d637361cf4..b6fd50f366 100644 --- a/test/absinthe/integration/execution/input_types/null/variable_to_type_non_null_list_of_non_null_T_element_test.exs +++ b/test/absinthe/integration/execution/input_types/null/variable_to_type_non_null_list_of_non_null_T_element_test.exs @@ -1,4 +1,4 @@ -defmodule Elixir.Absinthe.Integration.Execution.InputTypes.Null.VariableToTypeNonNullListOfNonNull_TElementTest do +defmodule Elixir.Absinthe.Integration.Execution.InputTypes.Null.VariableToTypeNonNullListOfNonNullTElementTest do use Absinthe.Case, async: true @query """ diff --git a/test/absinthe/integration/execution/input_types/null/variable_to_type_non_null_list_of_non_null_T_test.exs b/test/absinthe/integration/execution/input_types/null/variable_to_type_non_null_list_of_non_null_T_test.exs index 3b7693bbd4..d9dc25689c 100644 --- a/test/absinthe/integration/execution/input_types/null/variable_to_type_non_null_list_of_non_null_T_test.exs +++ b/test/absinthe/integration/execution/input_types/null/variable_to_type_non_null_list_of_non_null_T_test.exs @@ -1,4 +1,4 @@ -defmodule Elixir.Absinthe.Integration.Execution.InputTypes.Null.VariableToTypeNonNullListOfNonNull_TTest do +defmodule Elixir.Absinthe.Integration.Execution.InputTypes.Null.VariableToTypeNonNullListOfNonNullTTest do use Absinthe.Case, async: true @query """ diff --git a/test/absinthe/integration/execution/input_types/null/variable_to_variable_type_non_null_T_test.exs b/test/absinthe/integration/execution/input_types/null/variable_to_variable_type_non_null_T_test.exs index b23092c6fe..7174cd0a76 100644 --- a/test/absinthe/integration/execution/input_types/null/variable_to_variable_type_non_null_T_test.exs +++ b/test/absinthe/integration/execution/input_types/null/variable_to_variable_type_non_null_T_test.exs @@ -1,4 +1,4 @@ -defmodule Elixir.Absinthe.Integration.Execution.InputTypes.Null.VariableToVariableTypeNonNull_TTest do +defmodule Elixir.Absinthe.Integration.Execution.InputTypes.Null.VariableToVariableTypeNonNullTTest do use Absinthe.Case, async: true @query """ diff --git a/test/absinthe/integration/execution/operation_by_name_test.exs b/test/absinthe/integration/execution/operation_by_name_test.exs index fcdc6a8860..a67a17df38 100644 --- a/test/absinthe/integration/execution/operation_by_name_test.exs +++ b/test/absinthe/integration/execution/operation_by_name_test.exs @@ -55,9 +55,7 @@ defmodule Elixir.Absinthe.Integration.Execution.OperationByNameTest do test "scenario #4" do assert {:ok, %{data: %{"thing" => %{"name" => "Bar"}}}} == - Absinthe.run(@query, Absinthe.Fixtures.Things.MacroSchema, - operation_name: "ThingBar" - ) + Absinthe.run(@query, Absinthe.Fixtures.Things.MacroSchema, operation_name: "ThingBar") end @query """ diff --git a/test/absinthe/lexer_test.exs b/test/absinthe/lexer_test.exs index fc90551769..263106e8b6 100644 --- a/test/absinthe/lexer_test.exs +++ b/test/absinthe/lexer_test.exs @@ -116,7 +116,7 @@ defmodule Absinthe.LexerTest do end defp too_long_query do - Enum.to_list(for n <- 1..10000, do: "test#{n}") + Enum.to_list(for n <- 1..10_000, do: "test#{n}") |> deep_query() end diff --git a/test/absinthe/pipeline_test.exs b/test/absinthe/pipeline_test.exs index b4e1aa3c0e..9b11351d71 100644 --- a/test/absinthe/pipeline_test.exs +++ b/test/absinthe/pipeline_test.exs @@ -41,23 +41,23 @@ defmodule Absinthe.PipelineTest do end end - @goodQuery """ + @good_query """ { foo { bar } } """ - @badQuery """ + @bad_query """ { noFoo { bar } } """ test "well-formed query" do {:ok, %{execution: %{validation_errors: validation_errors}}, _} = - validation_only_query(@goodQuery) + validation_only_query(@good_query) assert length(validation_errors) == 0 end test "ill-formed query" do {:ok, %{execution: %{validation_errors: validation_errors}}, _} = - validation_only_query(@badQuery) + validation_only_query(@bad_query) refute length(validation_errors) == 0 end diff --git a/test/absinthe/subscription/pipeline_serializer_test.exs b/test/absinthe/subscription/pipeline_serializer_test.exs index 693bfc08de..b4e71ee2b5 100644 --- a/test/absinthe/subscription/pipeline_serializer_test.exs +++ b/test/absinthe/subscription/pipeline_serializer_test.exs @@ -58,8 +58,7 @@ defmodule Absinthe.Subscription.PipelineSerializerTest do 0 => %{large: 123}, 1 => [context: [:pack | 0]], 2 => [context: [:pack | 0], another: 456] - }} = - PipelineSerializer.pack(pipeline) + }} = PipelineSerializer.pack(pipeline) end end