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 19, 2020
1 parent 987debd commit 81dc041
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 14 deletions.
1 change: 1 addition & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,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}
]
}
]
}
20 changes: 11 additions & 9 deletions lib/nerves_ssh/exec.ex
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
defmodule NervesSSH.Exec do
@doc """
Run one command coming over ssh
@moduledoc """
This module contains helper methods for running commands over SSH
"""

@doc """
Run one Elixir command coming over ssh
"""
@spec run_elixir(charlist()) :: {:ok, binary()} | {:error, binary()}
def run_elixir(cmd) do
try do
{result, _env} = Code.eval_string(to_string(cmd))
{:ok, inspect(result)}
catch
kind, value ->
{:error, "** (#{kind}) #{inspect(value)}"}
end
{result, _env} = Code.eval_string(to_string(cmd))
{:ok, inspect(result)}
catch
kind, value ->
{:error, "** (#{kind}) #{inspect(value)}"}
end
end
6 changes: 3 additions & 3 deletions lib/nerves_ssh/options.ex
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ defmodule NervesSSH.Options do
* `:daemon_option_overrides` - additional options to pass to `:ssh.daemon/2`. These take precedence and are unchecked.
"""

alias Nerves.Runtime.KV

@default_system_dir "/etc/ssh"

@otp System.otp_release() |> Integer.parse() |> elem(0)
Expand Down Expand Up @@ -243,9 +245,7 @@ defmodule NervesSSH.Options do
defp valid_subsystem?(_), do: false

defp add_fwup_subsystem(opts) do
# TODO: Make it possible to opt out of this

devpath = Nerves.Runtime.KV.get("nerves_fw_devpath")
devpath = KV.get("nerves_fw_devpath")

new_subsystems = [SSHSubsystemFwup.subsystem_spec(devpath: devpath) | opts.subsystems]
%{opts | subsystems: new_subsystems}
Expand Down
6 changes: 4 additions & 2 deletions mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ defmodule NervesSSH.MixProject do
preferred_cli_env: %{
docs: :docs,
"hex.publish": :docs,
"hex.build": :docs
"hex.build": :docs,
credo: :test
}
]
end
Expand All @@ -36,7 +37,8 @@ defmodule NervesSSH.MixProject do
{:ex_doc, "~> 0.22", only: :docs, runtime: false},
{:ssh_subsystem_fwup, "~> 0.5"},
{:nerves_runtime, "~> 0.11"},
{:sshex, "~> 2.2.1", only: [:dev, :test]}
{:sshex, "~> 2.2.1", only: [:dev, :test]},
{:credo, "~> 1.2", only: :test, runtime: false}
]
end

Expand Down
3 changes: 3 additions & 0 deletions mix.lock
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
%{
"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"},
"elixir_make": {:hex, :elixir_make, "0.6.0", "38349f3e29aff4864352084fc736fa7fa0f2995a819a737554f7ebd28b85aaab", [:mix], [], "hexpm", "d522695b93b7f0b4c0fcb2dfe73a6b905b1c301226a5a55cb42e5b14d509e050"},
"erlex": {:hex, :erlex, "0.2.6", "c7987d15e899c7a2f34f5420d2a2ea0d659682c06ac607572df55a43753aa12e", [:mix], [], "hexpm", "2ed2e25711feb44d52b17d2780eabf998452f6efda104877a3881c2f8c0c0c75"},
"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"},
"nerves_runtime": {:hex, :nerves_runtime, "0.11.2", "7606c559d6eb33736af813394d8b4e67e3ede155808c6dc4b2ac0aea2c1b66fb", [:make, :mix], [{:elixir_make, "~> 0.6", [hex: :elixir_make, repo: "hexpm", optional: false]}, {:system_registry, "~> 0.8.0", [hex: :system_registry, repo: "hexpm", optional: false]}, {:uboot_env, "~> 0.1.1 or ~> 0.2.0", [hex: :uboot_env, repo: "hexpm", optional: false]}], "hexpm", "094446be5a1d51d3ec0c26e9f5905ab42731397e8715404a5e5e095b4f3125b6"},
Expand Down

0 comments on commit 81dc041

Please sign in to comment.