Skip to content

Commit

Permalink
Remove some code-readability issues like:
Browse files Browse the repository at this point in the history
 - 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
  • Loading branch information
imahmedismail committed Nov 19, 2023
1 parent 8bcd696 commit 494bc17
Show file tree
Hide file tree
Showing 27 changed files with 33 additions and 36 deletions.
4 changes: 2 additions & 2 deletions lib/absinthe/middleware/async.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions lib/absinthe/middleware/batch.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
4 changes: 2 additions & 2 deletions lib/absinthe/resolution/helpers.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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}}
Expand Down
Original file line number Diff line number Diff line change
@@ -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 """
Expand Down
Original file line number Diff line number Diff line change
@@ -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 """
Expand Down
Original file line number Diff line number Diff line change
@@ -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 """
Expand Down
Original file line number Diff line number Diff line change
@@ -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 """
Expand Down
Original file line number Diff line number Diff line change
@@ -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 """
Expand Down
Original file line number Diff line number Diff line change
@@ -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 """
Expand Down
Original file line number Diff line number Diff line change
@@ -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 """
Expand Down
Original file line number Diff line number Diff line change
@@ -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 """
Expand Down
Original file line number Diff line number Diff line change
@@ -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 """
Expand Down
Original file line number Diff line number Diff line change
@@ -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 """
Expand Down
Original file line number Diff line number Diff line change
@@ -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 """
Expand Down
Original file line number Diff line number Diff line change
@@ -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 """
Expand Down
Original file line number Diff line number Diff line change
@@ -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 """
Expand Down
Original file line number Diff line number Diff line change
@@ -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 """
Expand Down
Original file line number Diff line number Diff line change
@@ -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 """
Expand Down
Original file line number Diff line number Diff line change
@@ -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 """
Expand Down
Original file line number Diff line number Diff line change
@@ -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 """
Expand Down
Original file line number Diff line number Diff line change
@@ -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 """
Expand Down
Original file line number Diff line number Diff line change
@@ -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 """
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 """
Expand Down
2 changes: 1 addition & 1 deletion test/absinthe/lexer_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 4 additions & 4 deletions test/absinthe/pipeline_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions test/absinthe/subscription/pipeline_serializer_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 494bc17

Please sign in to comment.