Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump credo from 0.10.2 to 1.1.5 #121

Merged
merged 2 commits into from
Jan 3, 2020
Merged
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
148 changes: 87 additions & 61 deletions .credo.exs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
# You can give explicit globs or simply directories.
# In the latter case `**/*.{ex,exs}` will be used.
#
included: ["lib/", "src/", "web/", "apps/"],
excluded: [~r"/_build/", ~r"/deps/"]
included: ["lib/", "src/", "test/", "web/", "apps/"],
excluded: [~r"/_build/", ~r"/deps/", ~r"/node_modules/"]
},
#
# If you create your own checks, you must specify the source files for
Expand All @@ -48,85 +48,111 @@
# {Credo.Check.Design.DuplicatedCode, false}
#
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},
#
## 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, []},

#
## Design Checks
#
# You can customize the priority of any check
# Priority values are: `low, normal, high, higher`
#
{Credo.Check.Design.AliasUsage, priority: :low},

{Credo.Check.Design.AliasUsage, [priority: :low]},
# 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: []},

{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: 2},
{Credo.Check.Design.TagFIXME},
{Credo.Check.Readability.FunctionNames},
{Credo.Check.Readability.LargeNumbers},
{Credo.Check.Readability.MaxLineLength, priority: :low, max_length: 100},
{Credo.Check.Readability.ModuleAttributeNames},
{Credo.Check.Readability.ModuleDoc},
{Credo.Check.Readability.ModuleNames},
{Credo.Check.Readability.ParenthesesOnZeroArityDefs},
{Credo.Check.Readability.ParenthesesInCondition},
{Credo.Check.Readability.PredicateFunctionNames},
{Credo.Check.Readability.PreferImplicitTry},
{Credo.Check.Readability.RedundantBlankLines},
{Credo.Check.Readability.StringSigils},
{Credo.Check.Readability.TrailingBlankLine, false},
{Credo.Check.Readability.TrailingWhiteSpace},
{Credo.Check.Readability.VariableNames},
{Credo.Check.Readability.Semicolons},
{Credo.Check.Readability.SpaceAfterCommas},
{Credo.Check.Refactor.DoubleBooleanNegation},
{Credo.Check.Refactor.CondStatements},
{Credo.Check.Refactor.CyclomaticComplexity},
{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.PipeChainStart},
{Credo.Check.Refactor.UnlessWithElse},
{Credo.Check.Warning.BoolOperationOnSameValues},
{Credo.Check.Warning.ExpensiveEmptyEnumCheck},
{Credo.Check.Warning.IExPry},
{Credo.Check.Warning.IoInspect},
{Credo.Check.Warning.LazyLogging},
{Credo.Check.Warning.OperationOnSameValues},
{Credo.Check.Warning.OperationWithConstantResult},
{Credo.Check.Warning.UnusedEnumOperation},
{Credo.Check.Warning.UnusedFileOperation},
{Credo.Check.Warning.UnusedKeywordOperation},
{Credo.Check.Warning.UnusedListOperation},
{Credo.Check.Warning.UnusedPathOperation},
{Credo.Check.Warning.UnusedRegexOperation},
{Credo.Check.Warning.UnusedStringOperation},
{Credo.Check.Warning.UnusedTupleOperation},
{Credo.Check.Warning.RaiseInsideRescue},
{Credo.Check.Design.TagTODO, [exit_status: 0]},
{Credo.Check.Design.TagFIXME, []},

#
## Readability Checks
#
{Credo.Check.Readability.AliasOrder, []},
{Credo.Check.Readability.FunctionNames, []},
{Credo.Check.Readability.LargeNumbers, []},
{Credo.Check.Readability.MaxLineLength, [priority: :low, max_length: 120]},
{Credo.Check.Readability.ModuleAttributeNames, []},
{Credo.Check.Readability.ModuleDoc, []},
{Credo.Check.Readability.ModuleNames, []},
{Credo.Check.Readability.ParenthesesOnZeroArityDefs, []},
{Credo.Check.Readability.ParenthesesInCondition, []},
{Credo.Check.Readability.PredicateFunctionNames, []},
{Credo.Check.Readability.PreferImplicitTry, []},
{Credo.Check.Readability.RedundantBlankLines, []},
{Credo.Check.Readability.StringSigils, []},
{Credo.Check.Readability.TrailingBlankLine, []},
{Credo.Check.Readability.TrailingWhiteSpace, []},
{Credo.Check.Readability.VariableNames, []},
{Credo.Check.Readability.Semicolons, []},
{Credo.Check.Readability.SpaceAfterCommas, []},

#
## Refactoring Opportunities
#
{Credo.Check.Refactor.DoubleBooleanNegation, []},
{Credo.Check.Refactor.CondStatements, []},
{Credo.Check.Refactor.CyclomaticComplexity, []},
{Credo.Check.Refactor.FunctionArity, []},
{Credo.Check.Refactor.LongQuoteBlocks, []},
{Credo.Check.Refactor.MapInto, []},
{Credo.Check.Refactor.MatchInCondition, []},
{Credo.Check.Refactor.NegatedConditionsInUnless, []},
{Credo.Check.Refactor.NegatedConditionsWithElse, []},
{Credo.Check.Refactor.Nesting, []},
{Credo.Check.Refactor.PipeChainStart,
[excluded_argument_types: [:atom, :binary, :fn, :keyword], excluded_functions: []]},
{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, []},
{Credo.Check.Warning.OperationOnSameValues, []},
{Credo.Check.Warning.OperationWithConstantResult, []},
{Credo.Check.Warning.UnusedEnumOperation, []},
{Credo.Check.Warning.UnusedFileOperation, []},
{Credo.Check.Warning.UnusedKeywordOperation, []},
{Credo.Check.Warning.UnusedListOperation, []},
{Credo.Check.Warning.UnusedPathOperation, []},
{Credo.Check.Warning.UnusedRegexOperation, []},
{Credo.Check.Warning.UnusedStringOperation, []},
{Credo.Check.Warning.UnusedTupleOperation, []},
{Credo.Check.Warning.RaiseInsideRescue, []},

#
# Controversial and experimental checks (opt-in, just remove `, false`)
#
{Credo.Check.Refactor.ABCSize, false},
{Credo.Check.Refactor.VariableRebinding},
{Credo.Check.Refactor.AppendSingleItem, false},
{Credo.Check.Warning.MapGetUnsafePass},
{Credo.Check.Consistency.MultiAliasImportRequireUse, false}
{Credo.Check.Refactor.VariableRebinding, false},
{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}

#
# Custom checks can be created using `mix credo.gen.check`.
#
]
Expand Down
4 changes: 2 additions & 2 deletions lib/torch/helpers.ex
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ defmodule Torch.Helpers do
end

@doc """
Paginates a given `Ecto.Queryable` using Scrivener.
Paginates a given `Ecto.Queryable` using Scrivener.

This is a very thin wrapper around `Scrivener.paginate/2`, so see [the Scrivener
Ecto documentation](https://github.com/drewolson/scrivener_ecto) for more details.
Expand All @@ -57,4 +57,4 @@ defmodule Torch.Helpers do
def paginate(query, repo, params, settings \\ [page_size: 10]) do
Scrivener.paginate(query, Scrivener.Config.new(repo, settings, params))
end
end
end
2 changes: 1 addition & 1 deletion lib/torch/views/pagination_view.ex
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,4 @@ defmodule Torch.PaginationView do
defp sort_opts(%{sort_field: sort_field, sort_direction: sort_direction}) do
%{sort_field: sort_field, sort_direction: sort_direction}
end
end
end
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ defmodule Torch.MixProject do
{:timex, "~> 3.1"},
{:jason, ">= 0.0.0", only: [:dev, :test]},
{:excoveralls, ">= 0.0.0", only: [:dev, :test]},
{:credo, "~> 0.5", only: [:dev, :test]},
{:credo, "~> 1.1", only: [:dev, :test]},
{:ex_doc, ">= 0.0.0", only: [:dev, :test]}
]
end
Expand Down
2 changes: 1 addition & 1 deletion mix.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"certifi": {:hex, :certifi, "2.5.1", "867ce347f7c7d78563450a18a6a28a8090331e77fa02380b4a21962a65d36ee5", [:rebar3], [{:parse_trans, "~>3.3", [hex: :parse_trans, repo: "hexpm", optional: false]}], "hexpm"},
"combine": {:hex, :combine, "0.10.0", "eff8224eeb56498a2af13011d142c5e7997a80c8f5b97c499f84c841032e429f", [:mix], [], "hexpm"},
"connection": {:hex, :connection, "1.0.4", "a1cae72211f0eef17705aaededacac3eb30e6625b04a6117c1b2db6ace7d5976", [:mix], [], "hexpm"},
"credo": {:hex, :credo, "0.10.2", "03ad3a1eff79a16664ed42fc2975b5e5d0ce243d69318060c626c34720a49512", [:mix], [{:bunt, "~> 0.2.0", [hex: :bunt, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, 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"},
"db_connection": {:hex, :db_connection, "2.0.5", "ddb2ba6761a08b2bb9ca0e7d260e8f4dd39067426d835c24491a321b7f92a4da", [:mix], [{:connection, "~> 1.0.2", [hex: :connection, repo: "hexpm", optional: false]}], "hexpm"},
"decimal": {:hex, :decimal, "1.8.0", "ca462e0d885f09a1c5a342dbd7c1dcf27ea63548c65a65e67334f4b61803822e", [], [], "hexpm"},
"earmark": {:hex, :earmark, "1.4.0", "397e750b879df18198afc66505ca87ecf6a96645545585899f6185178433cc09", [:mix], [], "hexpm"},
Expand Down
2 changes: 1 addition & 1 deletion test/support/apps/example/config/config.exs
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ config :torch,

# Import environment specific config. This must remain at the bottom
# of this file so it overrides the configuration defined above.
import_config "#{Mix.env()}.exs"
import_config "#{Mix.env()}.exs"
2 changes: 1 addition & 1 deletion test/support/apps/example/config/test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ config :example, Example.Repo,
password: System.get_env("DATABASE_POSTGRESQL_PASSWORD") || "",
database: "example_test",
hostname: "localhost",
pool: Ecto.Adapters.SQL.Sandbox
pool: Ecto.Adapters.SQL.Sandbox
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ defmodule ExampleWeb.ErrorView do
# def template_not_found(_template, _assigns) do
# # Phoenix.Controller.status_message_from_template(template)
# end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ defmodule ExampleWeb.ErrorViewTest do
test "renders 500.html" do
assert render_to_string(ExampleWeb.ErrorView, "500.html", []) == "Internal Server Error"
end
end
end
4 changes: 2 additions & 2 deletions test/support/apps/example/test/support/channel_case.ex
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ defmodule ExampleWeb.ChannelCase do
end
end


setup tags do
:ok = Ecto.Adapters.SQL.Sandbox.checkout(Example.Repo)

unless tags[:async] do
Ecto.Adapters.SQL.Sandbox.mode(Example.Repo, {:shared, self()})
end

:ok
end

end
4 changes: 2 additions & 2 deletions test/support/apps/example/test/support/conn_case.ex
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ defmodule ExampleWeb.ConnCase do
end
end


setup tags do
:ok = Ecto.Adapters.SQL.Sandbox.checkout(Example.Repo)

unless tags[:async] do
Ecto.Adapters.SQL.Sandbox.mode(Example.Repo, {:shared, self()})
end

{:ok, conn: Phoenix.ConnTest.build_conn()}
end

end
1 change: 0 additions & 1 deletion test/support/apps/example/test/test_helper.exs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
ExUnit.start()

Ecto.Adapters.SQL.Sandbox.mode(Example.Repo, :manual)

12 changes: 6 additions & 6 deletions test/torch/views/pagination_view_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ defmodule Torch.PaginationViewTest do

test "when current page is more than 1" do
current_page = 2
link = prev_link(%Plug.Conn{params: %{}}, current_page) |> safe_to_string()
link = %Plug.Conn{params: %{}} |> prev_link(current_page) |> safe_to_string()
assert link =~ "?page=#{current_page - 1}"
end

test "internationalization" do
assert prev_link(%Plug.Conn{params: %{}}, 2) |> safe_to_string() =~ "Prev"
assert %Plug.Conn{params: %{}} |> prev_link(2) |> safe_to_string() =~ "Prev"

set_locale("ru")
assert prev_link(%Plug.Conn{params: %{}}, 2) |> safe_to_string() =~ "Предыдущая"
assert %Plug.Conn{params: %{}} |> prev_link(2) |> safe_to_string() =~ "Предыдущая"
end
end

Expand All @@ -33,15 +33,15 @@ defmodule Torch.PaginationViewTest do

test "when current page is more than num pages" do
current_page = 1
link = next_link(%Plug.Conn{params: %{}}, current_page, 2) |> safe_to_string()
link = %Plug.Conn{params: %{}} |> next_link(current_page, 2) |> safe_to_string()
assert link =~ "?page=#{current_page + 1}"
end

test "internationalization" do
assert next_link(%Plug.Conn{params: %{}}, 1, 2) |> safe_to_string() =~ "Next"
assert %Plug.Conn{params: %{}} |> next_link(1, 2) |> safe_to_string() =~ "Next"

set_locale("ru")
assert next_link(%Plug.Conn{params: %{}}, 1, 2) |> safe_to_string() =~ "Следующая"
assert %Plug.Conn{params: %{}} |> next_link(1, 2) |> safe_to_string() =~ "Следующая"
end
end

Expand Down