Skip to content

Commit 23b162f

Browse files
authored
Fix credo warnings and add credo to CI (#320)
Removes credo checks that are no longer necessary on Elixir >= 1.7 and 1.8 (the current minimum version of Elixir that scenic supports is 1.11)
1 parent d341db1 commit 23b162f

File tree

4 files changed

+19
-18
lines changed

4 files changed

+19
-18
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,5 @@ jobs:
4949
run: mix compile
5050
- name: Run Tests
5151
run: mix test
52+
- name: Run credo
53+
run: mix credo suggest --min-priority=high --ignore-checks Credo.Check.Design.DuplicatedCode

config/.credo.exs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,6 @@
117117
{Credo.Check.Refactor.CyclomaticComplexity},
118118
{Credo.Check.Refactor.FunctionArity},
119119
{Credo.Check.Refactor.LongQuoteBlocks},
120-
{Credo.Check.Refactor.MapInto},
121120
{Credo.Check.Refactor.MatchInCondition},
122121
{Credo.Check.Refactor.NegatedConditionsInUnless},
123122
{Credo.Check.Refactor.NegatedConditionsWithElse},
@@ -132,7 +131,6 @@
132131
{Credo.Check.Warning.ExpensiveEmptyEnumCheck},
133132
{Credo.Check.Warning.IExPry},
134133
{Credo.Check.Warning.IoInspect},
135-
{Credo.Check.Warning.LazyLogging},
136134
{Credo.Check.Warning.OperationOnSameValues},
137135
{Credo.Check.Warning.OperationWithConstantResult},
138136
{Credo.Check.Warning.UnusedEnumOperation},

lib/scenic/graph/bounds.ex

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -279,17 +279,17 @@ defmodule Scenic.Graph.Bounds do
279279

280280
defp pts_arc_to([{x0, y0} | _] = pts, x1, y1, x2, y2, r) do
281281
# recreate as two vectors point out of the 1 point
282-
vAx = x0 - x1
283-
vAy = y0 - y1
284-
vBx = x2 - x1
285-
vBy = y2 - y1
286-
vA = {vAx, vAy}
287-
vB = {vBx, vBy}
282+
v_ax = x0 - x1
283+
v_ay = y0 - y1
284+
v_bx = x2 - x1
285+
v_by = y2 - y1
286+
v_a = {v_ax, v_ay}
287+
v_b = {v_bx, v_by}
288288

289289
# use the dot product to find the angle between them
290-
# angle = Vector2.dot( vA, vB )
290+
# angle = Vector2.dot( v_a, v_b )
291291
# |> :math.acos()
292-
angle = angle(vA, vB)
292+
angle = angle(v_a, v_b)
293293
ha = angle / 2
294294

295295
# calculate the hypotenuse
@@ -301,18 +301,18 @@ defmodule Scenic.Graph.Bounds do
301301

302302
# Find the arc starting point
303303
ratio = dist_tan / Vector2.distance({x0, y0}, {x1, y1})
304-
{vx, vy} = vA2 = Vector2.mul(vA, ratio)
304+
{vx, vy} = v_a2 = Vector2.mul(v_a, ratio)
305305
{sx, sy} = pt_start = {x1 + vx, y1 + vy}
306306

307307
# Find the arc ending point
308308
ratio = dist_tan / Vector2.distance({x2, y2}, {x1, y1})
309-
{vx, vy} = vB2 = Vector2.mul(vB, ratio)
309+
{vx, vy} = v_b2 = Vector2.mul(v_b, ratio)
310310
{ex, ey} = pt_end = {x1 + vx, y1 + vy}
311311

312-
# the center point should be on the vector defined by adding vA2 + vB2
313-
vC = Vector2.add(vA2, vB2)
314-
ratio = hypotenuse / Vector2.length(vC)
315-
{vx, vy} = Vector2.mul(vC, ratio)
312+
# the center point should be on the vector defined by adding v_a2 + v_b2
313+
v_c = Vector2.add(v_a2, v_b2)
314+
ratio = hypotenuse / Vector2.length(v_c)
315+
{vx, vy} = Vector2.mul(v_c, ratio)
316316
{cx, cy} = {x1 + vx, y1 + vy}
317317

318318
# now if re-orient ourselves around the center point, we can create

lib/scenic/scene.ex

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1571,8 +1571,9 @@ defmodule Scenic.Scene do
15711571
try do
15721572
module._has_children?()
15731573
rescue
1574-
UndefinedFunctionError ->
1575-
raise "Attempted to start uncompiled scene: #{inspect(module)}"
1574+
error in [UndefinedFunctionError] ->
1575+
Logger.error("Attempted to start uncompiled scene: #{inspect(module)}")
1576+
reraise error, __STACKTRACE__
15761577
end
15771578
# start a supervisor - or not - depending on if there are children
15781579
|> case do

0 commit comments

Comments
 (0)