Skip to content

Instantly share code, notes, and snippets.

@0xradical
Created May 22, 2018 12:08
Show Gist options
  • Save 0xradical/c6367a28f08869cfab8f6d4b2d642407 to your computer and use it in GitHub Desktop.
Save 0xradical/c6367a28f08869cfab8f6d4b2d642407 to your computer and use it in GitHub Desktop.
Código exemplo em Elixir
defmodule ProntoCredoExample.Example do
@moduledoc """
This module serves as an example for
cyclomatic complexity
"""
def do_something_complex(a, b, c, d, param) do
g = 0
e = case param
1 — >
if a = = 1 or b = = 2 do
h = 5
end
2 — > do_one_thing(a, b) + 1
_ - > do_another_thing(c,d) — 5
end
f = case param do
1 — >
if c = = 1 or d = = 2 do
g = 7
end
2 — > do_one_thing(a, b) * 8
_ — > do_yet_another_thing(e, f)
end
do_one_last_thing(e, f, g)
end
def do_one_thing(a, b), do: a + b
def do_another_thing(c, d), do:c*d
def do_yet_another_thing(e, f), do: e — f
def do_one_last_thing(e, f, g), do: e + 2 * f + 5 * g
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment