Skip to content

Commit

Permalink
Fix Credo issues in Script, UploadFile, DefaultTest and Utils
Browse files Browse the repository at this point in the history
  • Loading branch information
lawik authored and fhunleth committed Dec 22, 2024
1 parent 472deba commit 536770d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/nerves_hub_link/script.ex
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
defmodule NervesHubLink.Script do
@moduledoc """
Mechanism for running scripts from NervesHub on device.
"""

use GenServer

@doc """
Run a script from NervesHub and capture its output
"""
@spec capture(String.t(), any()) :: :ok
def capture(text, ref) do
_ = GenServer.start_link(__MODULE__, {self(), text, ref})

Expand Down
3 changes: 3 additions & 0 deletions lib/nerves_hub_link/upload_file.ex
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ defmodule NervesHubLink.UploadFile do
alias NervesHubLink.Socket

defmodule State do
@moduledoc false
@type t() :: %__MODULE__{
file_path: Path.t(),
socket_pid: pid()
Expand Down Expand Up @@ -52,8 +53,10 @@ defmodule NervesHubLink.UploadFile do
end

if Version.match?(System.version(), ">= 1.16.0") do
@spec file_stream!(any()) :: File.Stream.t()
def file_stream!(state), do: File.stream!(state.file_path, 1024, [])
else
@spec file_stream!(any()) :: File.Stream.t()
def file_stream!(state), do: File.stream!(state.file_path, [], 1024)
end
end
3 changes: 3 additions & 0 deletions test/support/utils.ex
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
defmodule NervesHubLink.Support.Utils do
@moduledoc false

@spec unique_port_number() :: integer()
def unique_port_number() do
System.unique_integer([:positive, :monotonic]) + 6000
end
Expand Down

0 comments on commit 536770d

Please sign in to comment.