Skip to content

Commit bd6520d

Browse files
author
Taras Tyshko
committed
set TODO and @moduledoc checks to ignore priority
1 parent 78297ea commit bd6520d

File tree

8 files changed

+43
-40
lines changed

8 files changed

+43
-40
lines changed

.credo.exs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@
8383
#
8484
{Credo.Check.Design.AliasUsage,
8585
[priority: :low, if_nested_deeper_than: 2, if_called_more_often_than: 0]},
86-
# TODO comments are acceptable in our codebase, but we want to see them
87-
{Credo.Check.Design.TagTODO, [priority: :low]},
86+
# TODO comments are acceptable in our codebase, but we want to see them locally
87+
{Credo.Check.Design.TagTODO, [priority: :ignore]},
8888
{Credo.Check.Design.TagFIXME, []},
8989
#
9090
## Readability Checks
@@ -96,8 +96,8 @@
9696
{Credo.Check.Readability.MaxLineLength, [priority: :low, max_length: 120]},
9797
{Credo.Check.Readability.ModuleAttributeNames, []},
9898
{Credo.Check.Readability.ModuleNames, []},
99-
# ModuleDoc is not required in our codebase, but we want to see them
100-
{Credo.Check.Readability.ModuleDoc, [priority: :low]},
99+
# ModuleDoc is not required in our codebase, but we want to see them locally
100+
{Credo.Check.Readability.ModuleDoc, [priority: :ignore]},
101101
{Credo.Check.Readability.MultiAlias, []},
102102
{Credo.Check.Readability.ParenthesesInCondition, []},
103103
{Credo.Check.Readability.ParenthesesOnZeroArityDefs, [parens: true]},

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ jobs:
113113
run: mix spellweaver.check
114114

115115
- name: Run Credo
116-
run: mix credo --min-priority normal
116+
run: mix credo --min-priority low
117117

118118
- name: DB Setup
119119
run: mix ecto.migrate.reset

lib/nerves_hub/certificate.ex

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
defmodule NervesHub.Certificate do
2-
alias X509.Certificate.Extension
2+
alias X509.Certificate.Extension, as: X509Extension
33

44
import X509.ASN1,
55
only: [
@@ -19,7 +19,7 @@ defmodule NervesHub.Certificate do
1919
def get_aki(otp_certificate) do
2020
otp_certificate
2121
|> X509.Certificate.extensions()
22-
|> Extension.find(:authority_key_identifier)
22+
|> X509Extension.find(:authority_key_identifier)
2323
|> extension()
2424
|> Keyword.get(:extnValue)
2525
|> authority_key_identifier()
@@ -29,7 +29,7 @@ defmodule NervesHub.Certificate do
2929
def get_ski(otp_certificate) do
3030
otp_certificate
3131
|> X509.Certificate.extensions()
32-
|> Extension.find(:subject_key_identifier)
32+
|> X509Extension.find(:subject_key_identifier)
3333
|> case do
3434
nil ->
3535
nil

lib/nerves_hub/device_ssl_transport.ex

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,20 @@ defmodule NervesHub.DeviceSSLTransport do
1313

1414
@behaviour ThousandIsland.Transport
1515

16-
alias ThousandIsland.Transports.SSL
16+
alias ThousandIsland.Transports.SSL, as: SSLTransport
1717

1818
@impl ThousandIsland.Transport
19-
defdelegate listen(port, user_options), to: SSL
19+
defdelegate listen(port, user_options), to: SSLTransport
2020

2121
@impl ThousandIsland.Transport
22-
defdelegate accept(listener_socket), to: SSL
22+
defdelegate accept(listener_socket), to: SSLTransport
2323

2424
@impl ThousandIsland.Transport
2525
def handshake(socket) do
2626
if NervesHub.RateLimit.increment() do
2727
:telemetry.execute([:nerves_hub, :rate_limit, :accepted], %{count: 1})
2828

29-
SSL.handshake(socket)
29+
SSLTransport.handshake(socket)
3030
else
3131
:telemetry.execute([:nerves_hub, :rate_limit, :rejected], %{count: 1})
3232

@@ -35,50 +35,50 @@ defmodule NervesHub.DeviceSSLTransport do
3535
end
3636

3737
@impl ThousandIsland.Transport
38-
defdelegate upgrade(socket, opts), to: SSL
38+
defdelegate upgrade(socket, opts), to: SSLTransport
3939

4040
@impl ThousandIsland.Transport
41-
defdelegate controlling_process(socket, pid), to: SSL
41+
defdelegate controlling_process(socket, pid), to: SSLTransport
4242

4343
@impl ThousandIsland.Transport
44-
defdelegate recv(socket, length, timeout), to: SSL
44+
defdelegate recv(socket, length, timeout), to: SSLTransport
4545

4646
@impl ThousandIsland.Transport
47-
defdelegate send(socket, data), to: SSL
47+
defdelegate send(socket, data), to: SSLTransport
4848

4949
@impl ThousandIsland.Transport
50-
defdelegate sendfile(socket, filename, offset, length), to: SSL
50+
defdelegate sendfile(socket, filename, offset, length), to: SSLTransport
5151

5252
@impl ThousandIsland.Transport
53-
defdelegate getopts(socket, options), to: SSL
53+
defdelegate getopts(socket, options), to: SSLTransport
5454

5555
@impl ThousandIsland.Transport
56-
defdelegate setopts(socket, options), to: SSL
56+
defdelegate setopts(socket, options), to: SSLTransport
5757

5858
@impl ThousandIsland.Transport
59-
defdelegate shutdown(socket, way), to: SSL
59+
defdelegate shutdown(socket, way), to: SSLTransport
6060

6161
@impl ThousandIsland.Transport
62-
defdelegate close(socket), to: SSL
62+
defdelegate close(socket), to: SSLTransport
6363

6464
@impl ThousandIsland.Transport
65-
defdelegate sockname(socket), to: SSL
65+
defdelegate sockname(socket), to: SSLTransport
6666

6767
@impl ThousandIsland.Transport
68-
defdelegate peername(socket), to: SSL
68+
defdelegate peername(socket), to: SSLTransport
6969

7070
@impl ThousandIsland.Transport
71-
defdelegate peercert(socket), to: SSL
71+
defdelegate peercert(socket), to: SSLTransport
7272

7373
@impl ThousandIsland.Transport
74-
defdelegate secure?(), to: SSL
74+
defdelegate secure?(), to: SSLTransport
7575

7676
@impl ThousandIsland.Transport
77-
defdelegate getstat(socket), to: SSL
77+
defdelegate getstat(socket), to: SSLTransport
7878

7979
@impl ThousandIsland.Transport
80-
defdelegate negotiated_protocol(socket), to: SSL
80+
defdelegate negotiated_protocol(socket), to: SSLTransport
8181

8282
@impl ThousandIsland.Transport
83-
defdelegate connection_information(socket), to: SSL
83+
defdelegate connection_information(socket), to: SSLTransport
8484
end

lib/nerves_hub_web/components/core_components.ex

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ defmodule NervesHubWeb.CoreComponents do
1818

1919
import NervesHubWeb.Components.Icons
2020

21-
alias Phoenix.HTML.Form
21+
alias Phoenix.HTML.Form, as: HTMLForm
2222

2323
alias Phoenix.LiveView.JS
2424

@@ -362,7 +362,9 @@ defmodule NervesHubWeb.CoreComponents do
362362

363363
def input(%{type: "checkbox"} = assigns) do
364364
assigns =
365-
assign_new(assigns, :checked, fn -> Form.normalize_value("checkbox", assigns[:value]) end)
365+
assign_new(assigns, :checked, fn ->
366+
HTMLForm.normalize_value("checkbox", assigns[:value])
367+
end)
366368

367369
~H"""
368370
<div phx-feedback-for={@name}>
@@ -391,7 +393,7 @@ defmodule NervesHubWeb.CoreComponents do
391393
{@rest}
392394
>
393395
<option :if={@prompt} value="">{@prompt}</option>
394-
{Phoenix.HTML.Form.options_for_select(@options, @value)}
396+
{HTMLForm.options_for_select(@options, @value)}
395397
</select>
396398
<div :if={assigns[:hint] || assigns[:rich_hint]} class="text-xs text-zinc-400">
397399
{assigns[:hint] || render_slot(assigns[:rich_hint])}
@@ -415,7 +417,7 @@ defmodule NervesHubWeb.CoreComponents do
415417
@errors != [] && "border-red-500 focus:border-red-500"
416418
]}
417419
{@rest}
418-
><%= Phoenix.HTML.Form.normalize_value("textarea", @value) %></textarea>
420+
><%= HTMLForm.normalize_value("textarea", @value) %></textarea>
419421
<div :if={assigns[:hint] || assigns[:rich_hint]} class="flex flex-col gap-1 text-xs text-zinc-400 pt-1">
420422
{assigns[:hint] || render_slot(assigns[:rich_hint])}
421423
</div>
@@ -434,7 +436,7 @@ defmodule NervesHubWeb.CoreComponents do
434436
type={@type}
435437
name={@name}
436438
id={@id}
437-
value={Phoenix.HTML.Form.normalize_value(@type, @value)}
439+
value={HTMLForm.normalize_value(@type, @value)}
438440
class={[
439441
"mt-2 py-1.5 px-2 block w-full rounded text-zinc-400 bg-zinc-900 focus:ring-0 sm:text-sm",
440442
"phx-no-feedback:border-zinc-600 phx-no-feedback:focus:border-zinc-700",
@@ -463,7 +465,7 @@ defmodule NervesHubWeb.CoreComponents do
463465
type={@type}
464466
name={@name}
465467
id={@id}
466-
value={Phoenix.HTML.Form.normalize_value(@type, @value)}
468+
value={HTMLForm.normalize_value(@type, @value)}
467469
class={[
468470
"mt-2 py-1.5 px-2 block w-full rounded text-zinc-400 bg-zinc-900 focus:ring-0 sm:text-sm",
469471
"phx-no-feedback:border-zinc-600 phx-no-feedback:focus:border-zinc-700",

lib/nerves_hub_web/plugs/configure_uploads.ex

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
defmodule NervesHubWeb.Plugs.ConfigureUploads do
22
use NervesHubWeb, :plug
33

4-
alias NervesHubWeb.Plugs
4+
alias NervesHubWeb.Plugs.FileUpload
5+
alias NervesHubWeb.Plugs.StaticUploads
56

67
def init(_opts), do: []
78

89
def call(conn, _opts) do
910
if local_uploads?() do
1011
conn
11-
|> Plugs.FileUpload.call([])
12-
|> Plugs.StaticUploads.call([])
12+
|> FileUpload.call([])
13+
|> StaticUploads.call([])
1314
else
1415
conn
1516
end

test/nerves_hub/ssl_test.exs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ defmodule NervesHub.SSLTest do
44
alias NervesHub.Certificate
55
alias NervesHub.Devices
66
alias NervesHub.Fixtures
7-
alias X509.Certificate.Validity
7+
alias X509.Certificate.Validity, as: X509Validity
88

99
require X509.ASN1
1010

@@ -389,7 +389,7 @@ defmodule NervesHub.SSLTest do
389389
defp do_corruption(cert, :expired) do
390390
{:ok, not_before, 0} = DateTime.from_iso8601("2018-01-01T00:00:00Z")
391391
{:ok, not_after, 0} = DateTime.from_iso8601("2018-12-31T23:59:59Z")
392-
new_validity = Validity.new(not_before, not_after)
392+
new_validity = X509Validity.new(not_before, not_after)
393393

394394
tbs_cert = X509.ASN1.otp_certificate(cert, :tbsCertificate)
395395
new_tbs_cert = X509.ASN1.tbs_certificate(tbs_cert, validity: new_validity)

test/nerves_hub_web/live/devices/show_test.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -734,7 +734,7 @@ defmodule NervesHubWeb.Live.Devices.ShowTest do
734734

735735
# Test paginate event
736736
view
737-
|> element("button[phx-click=\"paginate\"][phx-value-page=\"2\"]", "2")
737+
|> element(~s{button[phx-click="paginate"][phx-value-page="2"]}, "2")
738738
|> render_click()
739739

740740
# Should redirect to page 2 on same device page

0 commit comments

Comments
 (0)