Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@ language: elixir
elixir: '1.9'
env:
- MIX_ENV=test
script: mix coveralls.travis
script:
- mix credo --strict
- mix coveralls.travis
33 changes: 33 additions & 0 deletions config/.credo.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
%{
configs: [
%{
name: "default",
files: %{
included: ["lib/", "src/", "web/", "apps/"],
excluded: []
},
checks: [
{Credo.Check.Refactor.MapInto, false},
{Credo.Check.Warning.LazyLogging, false},
{Credo.Check.Readability.ModuleDoc, false},
{Credo.Check.Consistency.TabsOrSpaces},

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

# For others you can also set parameters
{Credo.Check.Readability.MaxLineLength, priority: :low, max_length: 100},

# 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: 2},

# To deactivate a check:
# Put `false` as second element:
{Credo.Check.Design.TagFIXME, false}
]
}
]
}
1 change: 1 addition & 0 deletions lib/redex/command/set.ex
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ defmodule Redex.Command.SET do

@default_args %{expiry: nil, nx: false, xx: false}

# credo:disable-for-next-line Credo.Check.Refactor.CyclomaticComplexity
def exec([key, value | args], state = %State{quorum: quorum, db: db}) do
case args(args, @default_args) do
{:ok, args} ->
Expand Down
7 changes: 2 additions & 5 deletions lib/redex/manager.ex
Original file line number Diff line number Diff line change
Expand Up @@ -127,12 +127,9 @@ defmodule Redex.Manager do
true ->
Logger.info("sync readonly partition with active partition: #{inspect(parts)}")

if length(local_nodes) > length(remote_nodes) do
remote_nodes
else
(length(local_nodes) > length(remote_nodes) && remote_nodes) ||

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change degrades readability. Short-circuiting is considered an anti-pattern.

local_nodes
end
|> restart_nodes(state)
|> restart_nodes(state)
end
end,
[node() | Node.list()]
Expand Down
1 change: 1 addition & 0 deletions lib/redex/protocol/parser.ex
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ defmodule Redex.Protocol.Parser do
|> parse_cont(len)
end

# credo:disable-for-next-line Credo.Check.Refactor.CyclomaticComplexity
defp parse_cont(state = %State{acc: acc, buffer: buffer}, len) when len < hd(acc) do
case parse_string(buffer) do
{:ok, [size], buffer, _, _, _} when is_integer(size) and byte_size(buffer) >= size + 2 ->
Expand Down
3 changes: 2 additions & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ defmodule Redex.MixProject do
{:mox, "~> 0.5", only: :test},
{:excoveralls, "~> 0.11.1", only: :test},
{:dialyxir, "~> 1.0.0-rc.6", only: :dev, runtime: false},
{:stream_data, "~> 0.4", only: [:dev, :test]}
{:stream_data, "~> 0.4", only: [:dev, :test]},
{:credo, "~> 1.1.0", only: [:dev, :test], runtime: false}
]
end
end
2 changes: 2 additions & 0 deletions mix.lock
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
%{
"bunt": {:hex, :bunt, "0.2.0", "951c6e801e8b1d2cbe58ebbd3e616a869061ddadcc4863d0a2182541acae9a38", [:mix], [], "hexpm"},
"certifi": {:hex, :certifi, "2.5.1", "867ce347f7c7d78563450a18a6a28a8090331e77fa02380b4a21962a65d36ee5", [:rebar3], [{:parse_trans, "~>3.3", [hex: :parse_trans, repo: "hexpm", optional: false]}], "hexpm"},
"credo": {:hex, :credo, "1.1.5", "caec7a3cadd2e58609d7ee25b3931b129e739e070539ad1a0cd7efeeb47014f4", [:mix], [{:bunt, "~> 0.2.0", [hex: :bunt, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm"},
"dialyxir": {:hex, :dialyxir, "1.0.0-rc.6", "78e97d9c0ff1b5521dd68041193891aebebce52fc3b93463c0a6806874557d7d", [:mix], [{:erlex, "~> 0.2.1", [hex: :erlex, repo: "hexpm", optional: false]}], "hexpm"},
"erlex": {:hex, :erlex, "0.2.4", "23791959df45fe8f01f388c6f7eb733cc361668cbeedd801bf491c55a029917b", [:mix], [], "hexpm"},
"excoveralls": {:hex, :excoveralls, "0.11.1", "dd677fbdd49114fdbdbf445540ec735808250d56b011077798316505064edb2c", [:mix], [{:hackney, "~> 1.0", [hex: :hackney, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm"},
Expand Down