Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/appsignal/check_in/scheduler.ex
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ defmodule Appsignal.CheckIn.Scheduler do
end

@impl true
def terminate(_reason, %{events: events}) when length(events) > 0 do
def terminate(_reason, %{events: [_ | _] = events}) do
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, catching up on this as I was away. Thank you for looking into these warnings!

This is of course subjective, but I find this quite hard to read. Consider when events != [] instead? It should still be O(1), and it's what Enum.empty?/1, the alternative recommended by the Credo warning, does under the hood.

# If any events are stored, attempt to transmit them before the
# process is terminated.
handle_continue({:transmit, events}, initial_state())
Expand Down
10 changes: 5 additions & 5 deletions test/appsignal/error_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ defmodule Appsignal.ErrorTest do
test "format's the error's stack trace", %{metadata: metadata} do
{_name, _message, stack} = metadata
assert is_list(stack)
assert length(stack) > 0
refute Enum.empty?(stack)
assert Enum.all?(stack, &is_binary(&1))
end
end
Expand All @@ -46,7 +46,7 @@ defmodule Appsignal.ErrorTest do
test "format's the error's stack trace", %{metadata: metadata} do
{_name, _message, stack} = metadata
assert is_list(stack)
assert length(stack) > 0
refute Enum.empty?(stack)
assert Enum.all?(stack, &is_binary(&1))
end
end
Expand All @@ -73,7 +73,7 @@ defmodule Appsignal.ErrorTest do
test "format's the error's stack trace", %{metadata: metadata} do
{_name, _message, stack} = metadata
assert is_list(stack)
assert length(stack) > 0
refute Enum.empty?(stack)
assert Enum.all?(stack, &is_binary(&1))
end
end
Expand Down Expand Up @@ -101,7 +101,7 @@ defmodule Appsignal.ErrorTest do
test "format's the error's stack trace", %{metadata: metadata} do
{_name, _message, stack} = metadata
assert is_list(stack)
assert length(stack) > 0
refute Enum.empty?(stack)
assert Enum.all?(stack, &is_binary(&1))
end
end
Expand All @@ -126,7 +126,7 @@ defmodule Appsignal.ErrorTest do
test "format's the error's stack trace", %{metadata: metadata} do
{_name, _message, stack} = metadata
assert is_list(stack)
assert length(stack) > 0
refute Enum.empty?(stack)
assert Enum.all?(stack, &is_binary(&1))
end
end
Expand Down
2 changes: 1 addition & 1 deletion test/appsignal/stacktrace_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ defmodule Appsignal.StacktraceTest do
end

test "does not return an empty list", %{stack: stack} do
assert length(stack) > 0
refute Enum.empty?(stack)
end

test "returns a stacktrace containing the error", %{
Expand Down
Loading