Permalink
Browse files

Re enable credo

  • Loading branch information...
ConnorRigby committed Apr 18, 2018
1 parent 1f3cf56 commit 4254a9e1d419e36e38f867f5fdb088935b4c9add
@@ -61,6 +61,8 @@ jobs:
key: v5-arduino-cache-{{ checksum ".circleci/setup-arduino.sh" }}
paths:
- ~/arduino-1.8.5
- run:
command: mix credo
- run:
command: mix coveralls.circle --exclude farmbot_firmware

@@ -20,9 +20,9 @@
#
# You can give explicit globs or simply directories.
# In the latter case `**/*.{ex,exs}` will be used.
#
#
included: ["lib/", "src/"],
excluded: [~r"/_build/", ~r"/deps/", ~r"/nerves", ~r"/lib/mix"]
excluded: [~r"/_build/", ~r"/deps/"]
},
#
# If you create your own checks, you must specify the source files for
@@ -48,43 +48,50 @@
# {Credo.Check.Design.DuplicatedCode, false}
#
checks: [
#
## Consistency Checks
#
{Credo.Check.Consistency.ExceptionNames},
{Credo.Check.Consistency.LineEndings},
{Credo.Check.Consistency.ParameterPatternMatching},
{Credo.Check.Consistency.SpaceAroundOperators},
{Credo.Check.Consistency.SpaceInParentheses},
{Credo.Check.Consistency.TabsOrSpaces},

# For some checks, like AliasUsage, you can only customize the priority
#
## Design Checks
#
# You can customize the priority of any check
# Priority values are: `low, normal, high, higher`
#
{Credo.Check.Design.AliasUsage, false},

# For others you can set parameters

# For some checks, you can also set other parameters
#
# If you don't want the `setup` and `test` macro calls in ExUnit tests
# or the `schema` macro in Ecto schemas to trigger DuplicatedCode, just
# set the `excluded_macros` parameter to `[:schema, :setup, :test]`.
#
{Credo.Check.Design.DuplicatedCode, excluded_macros: []},

# You can also customize the exit_status of each check.
# If you don't want TODO comments to cause `mix credo` to fail, just
# set this value to 0 (zero).
#
{Credo.Check.Design.TagTODO, exit_status: 0},
{Credo.Check.Design.TagFIXME, exit_status: 0},
{Credo.Check.Design.TagTODO, false},
{Credo.Check.Design.TagFIXME, false},

#
## Readability Checks
#
{Credo.Check.Readability.FunctionNames},
{Credo.Check.Readability.LargeNumbers},
{Credo.Check.Readability.MaxLineLength, priority: :low, max_length: 80},
{Credo.Check.Readability.ModuleAttributeNames},
{Credo.Check.Readability.ModuleDoc},
{Credo.Check.Readability.ModuleNames},
{Credo.Check.Readability.ParenthesesOnZeroArityDefs, false},
{Credo.Check.Readability.ParenthesesOnZeroArityDefs},
{Credo.Check.Readability.ParenthesesInCondition},
{Credo.Check.Readability.PredicateFunctionNames},
{Credo.Check.Readability.PreferImplicitTry, false},
{Credo.Check.Readability.PreferImplicitTry},
{Credo.Check.Readability.RedundantBlankLines},
{Credo.Check.Readability.StringSigils},
{Credo.Check.Readability.TrailingBlankLine},
@@ -93,19 +100,27 @@
{Credo.Check.Readability.Semicolons},
{Credo.Check.Readability.SpaceAfterCommas},

#
## Refactoring Opportunities
#
{Credo.Check.Refactor.DoubleBooleanNegation},
{Credo.Check.Refactor.CondStatements, false},
{Credo.Check.Refactor.CyclomaticComplexity},
# TODO(Connor) should probably turn this back on..
{Credo.Check.Refactor.CyclomaticComplexity, false},
{Credo.Check.Refactor.FunctionArity},
{Credo.Check.Refactor.LongQuoteBlocks},
{Credo.Check.Refactor.MatchInCondition},
{Credo.Check.Refactor.NegatedConditionsInUnless},
{Credo.Check.Refactor.NegatedConditionsWithElse},
{Credo.Check.Refactor.Nesting},
{Credo.Check.Refactor.Nesting, false},
{Credo.Check.Refactor.PipeChainStart, false},
{Credo.Check.Refactor.UnlessWithElse},

#
## Warnings
#
{Credo.Check.Warning.BoolOperationOnSameValues},
{Credo.Check.Warning.ExpensiveEmptyEnumCheck},
{Credo.Check.Warning.IExPry},
{Credo.Check.Warning.IoInspect},
{Credo.Check.Warning.LazyLogging},
@@ -121,6 +136,7 @@
{Credo.Check.Warning.UnusedTupleOperation},
{Credo.Check.Warning.RaiseInsideRescue},

#
# Controversial and experimental checks (opt-in, just remove `, false`)
#
{Credo.Check.Refactor.ABCSize, false},
@@ -129,14 +145,12 @@
{Credo.Check.Warning.MapGetUnsafePass, false},
{Credo.Check.Consistency.MultiAliasImportRequireUse, false},

#
# Deprecated checks (these will be deleted after a grace period)
#
{Credo.Check.Readability.Specs, false},
{Credo.Check.Warning.NameRedeclarationByAssignment, false},
{Credo.Check.Warning.NameRedeclarationByCase, false},
{Credo.Check.Warning.NameRedeclarationByDef, false},
{Credo.Check.Warning.NameRedeclarationByFn, false},
{Credo.Check.Readability.Specs, false}

#
# Custom checks can be created using `mix credo.gen.check`.
#
]
@@ -1,5 +1,7 @@
defmodule Farmbot.Asset.Device do
@moduledoc """
The current device. Should only ever be _one_ of these. If not there is a huge
problem probably higher up the stack.
"""

use Ecto.Schema
@@ -38,10 +38,10 @@ defmodule Farmbot.CeleryScript.AST.Heap do
# Constants and key names.

@link "🔗"
@body String.to_atom(@link <> "body" )
@next String.to_atom(@link <> "next" )
@body String.to_atom(@link <> "body")
@next String.to_atom(@link <> "next")
@parent String.to_atom(@link <> "parent")
@kind String.to_atom(@link <> "kind" )
@kind String.to_atom(@link <> "kind")

@primary_fields [@parent, @body, @kind, @next]

@@ -7,7 +7,7 @@ defmodule Farmbot.Firmware.EstopTimer do

@msg "Farmbot has been E-Stopped for more than 10 minutes."
# Ten minutes.
@timer_ms 600000
@timer_ms 600_000
# fifteen seconds.
# @timer_ms 15000

@@ -41,10 +41,10 @@ defmodule Farmbot.Firmware.EstopTimer do
end

def handle_call(:start_timer, _from, state) do
if !is_timer_active?(state.timer) do
{:reply, :ok, %{state | timer: do_start_timer(self())}}
else
if is_timer_active?(state.timer) do
{:reply, :ok, state}
else
{:reply, :ok, %{state | timer: do_start_timer(self())}}
end
end

@@ -1,4 +1,9 @@
defmodule Farmbot.Firmware.Supervisor.BlockUntilUp do
@moduledoc """
Quick and dirty task that waits for the :firmware_initialized or :firmware_idle
global events.
"""

@timeout_ms 60_000
use Farmbot.Logger

@@ -1,4 +1,16 @@
defmodule Farmbot.Regimen.NameProvider do
@moduledoc """
Provides global names for running regimens as started by the
RegimenSupervisor.
# Example
```
%Regimen{} = reg = Farmbot.Asset.get_regimen_by_id(123, 100)
via = Farmbot.Regimen.NameProvider.via(reg)
pid = GenServer.whereis(via)
```
"""

alias Farmbot.Asset.Regimen
import Farmbot.System.ConfigStorage, only: [persistent_regimen: 1, delete_persistent_regimen: 1]
use GenServer
@@ -83,14 +83,14 @@ defmodule Farmbot.Repo do
Logger.debug 3, "Starting HTTP requests."
{time, results} = :timer.tc(fn() ->
[
Task.async(fn() -> {Device, HTTP.get!("/api/device.json") |> Map.fetch!(:body) |> Poison.decode!(as: struct(Device)) } end),
Task.async(fn() -> {FarmEvent, HTTP.get!("/api/farm_events.json") |> Map.fetch!(:body) |> Poison.decode!(as: [struct(FarmEvent)]) } end),
Task.async(fn() -> {Peripheral, HTTP.get!("/api/peripherals.json") |> Map.fetch!(:body) |> Poison.decode!(as: [struct(Peripheral)]) } end),
Task.async(fn() -> {Point, HTTP.get!("/api/points.json") |> Map.fetch!(:body) |> Poison.decode!(as: [struct(Point)]) } end),
Task.async(fn() -> {Regimen, HTTP.get!("/api/regimens.json") |> Map.fetch!(:body) |> Poison.decode!(as: [struct(Regimen)]) } end),
Task.async(fn() -> {Sensor, HTTP.get!("/api/sensors.json") |> Map.fetch!(:body) |> Poison.decode!(as: [struct(Sensor)]) } end),
Task.async(fn() -> {Sequence, HTTP.get!("/api/sequences.json") |> Map.fetch!(:body) |> Poison.decode!(as: [struct(Sequence)]) } end),
Task.async(fn() -> {Tool, HTTP.get!("/api/tools.json") |> Map.fetch!(:body) |> Poison.decode!(as: [struct(Tool)]) } end),
Task.async(fn() -> {Device, HTTP.get!("/api/device.json") |> Map.fetch!(:body) |> Poison.decode!(as: struct(Device))} end),
Task.async(fn() -> {FarmEvent, HTTP.get!("/api/farm_events.json") |> Map.fetch!(:body) |> Poison.decode!(as: [struct(FarmEvent)])} end),
Task.async(fn() -> {Peripheral, HTTP.get!("/api/peripherals.json") |> Map.fetch!(:body) |> Poison.decode!(as: [struct(Peripheral)])} end),
Task.async(fn() -> {Point, HTTP.get!("/api/points.json") |> Map.fetch!(:body) |> Poison.decode!(as: [struct(Point)])} end),
Task.async(fn() -> {Regimen, HTTP.get!("/api/regimens.json") |> Map.fetch!(:body) |> Poison.decode!(as: [struct(Regimen)])} end),
Task.async(fn() -> {Sensor, HTTP.get!("/api/sensors.json") |> Map.fetch!(:body) |> Poison.decode!(as: [struct(Sensor)])} end),
Task.async(fn() -> {Sequence, HTTP.get!("/api/sequences.json") |> Map.fetch!(:body) |> Poison.decode!(as: [struct(Sequence)])} end),
Task.async(fn() -> {Tool, HTTP.get!("/api/tools.json") |> Map.fetch!(:body) |> Poison.decode!(as: [struct(Tool)])} end),
]
|> Enum.map(&Task.await(&1))
end)
@@ -99,7 +99,7 @@ defmodule Farmbot.Repo do
end

def enter_into_repo(results) do
Enum.map(results, &do_enter_into_repo(&1))
Enum.each(results, &do_enter_into_repo(&1))
:ok
end

@@ -1,4 +1,9 @@
defmodule Farmbot.System.ConfigStorage.PersistentRegimen do
@moduledoc """
A persistent regimen is a join between a started farm event and the regimen
it is set to operate on. These are stored in the database to persist reboots,
crashes etc.
"""
use Ecto.Schema
import Ecto.Changeset
alias Farmbot.System.ConfigStorage.PersistentRegimen
@@ -1,4 +1,6 @@
defmodule Farmbot.System.Init.KernelMods do
@moduledoc "Loads kernel modules at boot."

use Supervisor
use Farmbot.Logger
@mods Application.get_env(:farmbot, :kernel_modules, [])
@@ -127,7 +127,7 @@ defmodule Farmbot.Mixfile do
{:ex_doc, "~> 0.18.1", only: :dev},
{:excoveralls, "~> 0.7", only: :test},
{:dialyxir, "~> 0.5.1", only: :dev, runtime: false},
{:credo, "~> 0.8", only: [:dev, :test], runtime: false},
{:credo, "~> 0.9.1", only: [:dev, :test], runtime: false},
{:inch_ex, ">= 0.0.0", only: :dev},
{:mock, "~> 0.2.0", only: :test},
{:faker, "~> 0.9", only: :test},
@@ -9,7 +9,7 @@
"cors_plug": {:hex, :cors_plug, "1.5.0", "6311ea6ac9fb78b987df52a7654136626a7a0c3b77f83da265f952a24f2fc1b0", [:mix], [{:plug, "~> 1.4", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm"},
"cowboy": {:hex, :cowboy, "1.0.4", "a324a8df9f2316c833a470d918aaf73ae894278b8aa6226ce7a9bf699388f878", [:make, :rebar], [{:cowlib, "~> 1.0.0", [hex: :cowlib, repo: "hexpm", optional: false]}, {:ranch, "~> 1.0", [hex: :ranch, repo: "hexpm", optional: false]}], "hexpm"},
"cowlib": {:hex, :cowlib, "1.0.2", "9d769a1d062c9c3ac753096f868ca121e2730b9a377de23dec0f7e08b1df84ee", [:make], [], "hexpm"},
"credo": {:hex, :credo, "0.8.10", "261862bb7363247762e1063713bb85df2bbd84af8d8610d1272cd9c1943bba63", [:mix], [{:bunt, "~> 0.2.0", [hex: :bunt, repo: "hexpm", optional: false]}], "hexpm"},
"credo": {:hex, :credo, "0.9.1", "f021affa11b32a94dc2e807a6472ce0914289c9132f99644a97fc84432b202a1", [:mix], [{:bunt, "~> 0.2.0", [hex: :bunt, repo: "hexpm", optional: false]}, {:poison, ">= 0.0.0", [hex: :poison, repo: "hexpm", optional: false]}], "hexpm"},
"db_connection": {:hex, :db_connection, "1.1.3", "89b30ca1ef0a3b469b1c779579590688561d586694a3ce8792985d4d7e575a61", [:mix], [{:connection, "~> 1.0.2", [hex: :connection, repo: "hexpm", optional: false]}, {:poolboy, "~> 1.5", [hex: :poolboy, repo: "hexpm", optional: true]}, {:sbroker, "~> 1.0", [hex: :sbroker, repo: "hexpm", optional: true]}], "hexpm"},
"decimal": {:hex, :decimal, "1.4.1", "ad9e501edf7322f122f7fc151cce7c2a0c9ada96f2b0155b8a09a795c2029770", [:mix], [], "hexpm"},
"dialyxir": {:hex, :dialyxir, "0.5.1", "b331b091720fd93e878137add264bac4f644e1ddae07a70bf7062c7862c4b952", [:mix], [], "hexpm"},

This file was deleted.

Oops, something went wrong.

0 comments on commit 4254a9e

Please sign in to comment.