Skip to content

Commit

Permalink
Add credo and fix warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
fhunleth committed Aug 7, 2020
1 parent ebca2e3 commit 2ca8bed
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 8 deletions.
1 change: 1 addition & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ jobs:
- run: mix docs
- run: mix hex.build
- run: mix dialyzer
- run: mix credo -a --strict
- save_cache:
key: v1-mix-cache-{{ checksum "mix.lock" }}
paths:
Expand Down
14 changes: 14 additions & 0 deletions .credo.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# config/.credo.exs
%{
configs: [
%{
name: "default",
checks: [
{Credo.Check.Refactor.MapInto, false},
{Credo.Check.Warning.LazyLogging, false},
{Credo.Check.Readability.LargeNumbers, only_greater_than: 86400},
{Credo.Check.Readability.ParenthesesOnZeroArityDefs, parens: true}
]
}
]
}
6 changes: 4 additions & 2 deletions mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ defmodule SSHSubsystemFwup.MixProject do
preferred_cli_env: %{
docs: :docs,
"hex.publish": :docs,
"hex.build": :docs
"hex.build": :docs,
credo: :test
}
]
end
Expand All @@ -45,7 +46,8 @@ defmodule SSHSubsystemFwup.MixProject do
defp deps do
[
{:ex_doc, "~> 0.22", only: :docs, runtime: false},
{:dialyxir, "~> 1.0.0", only: :dev, runtime: false}
{:dialyxir, "~> 1.0.0", only: :dev, runtime: false},
{:credo, "~> 1.2", only: :test, runtime: false}
]
end

Expand Down
6 changes: 5 additions & 1 deletion mix.lock
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
%{
"bunt": {:hex, :bunt, "0.2.0", "951c6e801e8b1d2cbe58ebbd3e616a869061ddadcc4863d0a2182541acae9a38", [:mix], [], "hexpm", "7af5c7e09fe1d40f76c8e4f9dd2be7cebd83909f31fee7cd0e9eadc567da8353"},
"credo": {:hex, :credo, "1.4.0", "92339d4cbadd1e88b5ee43d427b639b68a11071b6f73854e33638e30a0ea11f5", [:mix], [{:bunt, "~> 0.2.0", [hex: :bunt, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "1fd3b70dce216574ce3c18bdf510b57e7c4c85c2ec9cad4bff854abaf7e58658"},
"dialyxir": {:hex, :dialyxir, "1.0.0", "6a1fa629f7881a9f5aaf3a78f094b2a51a0357c843871b8bc98824e7342d00a5", [:mix], [{:erlex, ">= 0.2.6", [hex: :erlex, repo: "hexpm", optional: false]}], "hexpm", "aeb06588145fac14ca08d8061a142d52753dbc2cf7f0d00fc1013f53f8654654"},
"earmark": {:hex, :earmark, "1.4.5", "62ffd3bd7722fb7a7b1ecd2419ea0b458c356e7168c1f5d65caf09b4fbdd13c8", [:mix], [], "hexpm", "b7d0e6263d83dc27141a523467799a685965bf8b13b6743413f19a7079843f4f"},
"earmark_parser": {:hex, :earmark_parser, "1.4.10", "6603d7a603b9c18d3d20db69921527f82ef09990885ed7525003c7fe7dc86c56", [:mix], [], "hexpm", "8e2d5370b732385db2c9b22215c3f59c84ac7dda7ed7e544d7c459496ae519c0"},
"erlex": {:hex, :erlex, "0.2.6", "c7987d15e899c7a2f34f5420d2a2ea0d659682c06ac607572df55a43753aa12e", [:mix], [], "hexpm", "2ed2e25711feb44d52b17d2780eabf998452f6efda104877a3881c2f8c0c0c75"},
"ex_doc": {:hex, :ex_doc, "0.22.1", "9bb6d51508778193a4ea90fa16eac47f8b67934f33f8271d5e1edec2dc0eee4c", [:mix], [{:earmark, "~> 1.4.0", [hex: :earmark, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}], "hexpm", "d957de1b75cb9f78d3ee17820733dc4460114d8b1e11f7ee4fd6546e69b1db60"},
"ex_doc": {:hex, :ex_doc, "0.22.2", "03a2a58bdd2ba0d83d004507c4ee113b9c521956938298eba16e55cc4aba4a6c", [:mix], [{:earmark_parser, "~> 1.4.0", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}], "hexpm", "cf60e1b3e2efe317095b6bb79651f83a2c1b3edcb4d319c421d7fcda8b3aff26"},
"jason": {:hex, :jason, "1.2.1", "12b22825e22f468c02eb3e4b9985f3d0cb8dc40b9bd704730efa11abd2708c44", [:mix], [{:decimal, "~> 1.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "b659b8571deedf60f79c5a608e15414085fa141344e2716fbd6988a084b5f993"},
"makeup": {:hex, :makeup, "1.0.3", "e339e2f766d12e7260e6672dd4047405963c5ec99661abdc432e6ec67d29ef95", [:mix], [{:nimble_parsec, "~> 0.5", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "2e9b4996d11832947731f7608fed7ad2f9443011b3b479ae288011265cdd3dad"},
"makeup_elixir": {:hex, :makeup_elixir, "0.14.1", "4f0e96847c63c17841d42c08107405a005a2680eb9c7ccadfd757bd31dabccfb", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "f2438b1a80eaec9ede832b5c41cd4f373b38fd7aa33e3b22d9db79e640cbde11"},
"nimble_parsec": {:hex, :nimble_parsec, "0.6.0", "32111b3bf39137144abd7ba1cce0914533b2d16ef35e8abc5ec8be6122944263", [:mix], [], "hexpm", "27eac315a94909d4dc68bc07a4a83e06c8379237c5ea528a9acff4ca1c873c52"},
Expand Down
10 changes: 6 additions & 4 deletions test/ssh_subsystem_fwup_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ defmodule SSHSubsystemFwupTest do
import ExUnit.CaptureLog
# doctest SSHSubsystemFwup

alias SSHSubsystemFwup.Support.Fwup

@port 10123
@tmpdir Path.join(System.tmp_dir!(), "ssh_subsystem_fwup")

Expand Down Expand Up @@ -73,7 +75,7 @@ defmodule SSHSubsystemFwupTest do
File.touch!(options[:devpath])
start_sshd(options)

fw_contents = SSHSubsystemFwup.Support.Fwup.create_firmware()
fw_contents = Fwup.create_firmware()

capture_log(fn ->
{output, exit_status} = do_ssh(fw_contents)
Expand All @@ -94,7 +96,7 @@ defmodule SSHSubsystemFwupTest do
File.touch!(options[:devpath])

start_sshd(options)
fw_contents = SSHSubsystemFwup.Support.Fwup.create_corrupt_firmware()
fw_contents = Fwup.create_corrupt_firmware()

capture_log(fn ->
{_output, exit_status} = do_ssh(fw_contents)
Expand All @@ -110,7 +112,7 @@ defmodule SSHSubsystemFwupTest do
File.touch!(options[:devpath])

start_sshd(options)
fw_contents = SSHSubsystemFwup.Support.Fwup.create_firmware(task: "complete")
fw_contents = Fwup.create_firmware(task: "complete")

capture_log(fn ->
{output, exit_status} = do_ssh(fw_contents)
Expand All @@ -128,7 +130,7 @@ defmodule SSHSubsystemFwupTest do

test "unspecified devpath is an error" do
start_sshd([])
fw_contents = SSHSubsystemFwup.Support.Fwup.create_firmware(task: "complete")
fw_contents = Fwup.create_firmware(task: "complete")

{output, exit_status} = do_ssh(fw_contents)

Expand Down
2 changes: 1 addition & 1 deletion test/support/fwup.ex
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ defmodule SSHSubsystemFwup.Support.Fwup do
"""
end

defp random_string do
defp random_string() do
Integer.to_string(:rand.uniform(0x100000000), 36) |> String.downcase()
end
end

0 comments on commit 2ca8bed

Please sign in to comment.