Skip to content

Commit

Permalink
Try to document params in check via tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rrrene committed Feb 6, 2024
1 parent 90ba7b2 commit 390573c
Showing 1 changed file with 77 additions and 2 deletions.
79 changes: 77 additions & 2 deletions test/credo/check/refactor/module_dependencies_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ defmodule Credo.Check.Refactor.ModuleDependenciesTest do
|> refute_issues()
end

test "it should NOT report a violation on non-umbrella test path" do
test "it should NOT report a violation when using param :excluded_paths" do
"""
defmodule CredoSampleModule do
def some_function() do
Expand All @@ -52,7 +52,7 @@ defmodule Credo.Check.Refactor.ModuleDependenciesTest do
end
"""
|> to_source_file("test/foo/my_test.exs")
|> run_check(@described_check)
|> run_check(@described_check, excluded_paths: [~r"test/foo"])
|> refute_issues()
end

Expand Down Expand Up @@ -81,6 +81,81 @@ defmodule Credo.Check.Refactor.ModuleDependenciesTest do
|> refute_issues()
end

test "it should NOT report a violation when using param :max_deps" do
"""
defmodule CredoSampleModule do
def some_function() do
[
DateTime,
Kernel,
GenServer,
GenEvent,
File,
Time,
IO,
Logger,
URI,
Path,
String
]
end
end
"""
|> to_source_file
|> run_check(@described_check, max_deps: 20)
|> refute_issues()
end

test "it should NOT report a violation when using param :excluded_namespaces" do
"""
defmodule CredoSample.Excluded.Module do
def some_function() do
[
Foo.Bar.DateTime,
Foo.Bar.Kernel,
Foo.Bar.GenServer,
Foo.Bar.GenEvent,
Foo.Bar.File,
Foo.Bar.Time,
Foo.Bar.IO,
Foo.Bar.Logger,
URI,
Path,
String
]
end
end
"""
|> to_source_file
|> run_check(@described_check, excluded_namespaces: ["CredoSample.Excluded"])
|> refute_issues()
end

test "it should NOT report a violation when using param :dependency_namespaces" do
"""
defmodule CredoSample.Excluded.Module do
def some_function() do
[
Foo.Bar.DateTime,
Foo.Bar.Kernel,
Foo.Bar.GenServer,
Foo.Bar.GenEvent,
Foo.Bar.File,
Foo.Bar.Time,
Foo.Bar.IO,
Foo.Bar.Logger,
URI,
Path,
String
]
end
end
"""
|> to_source_file
|> run_check(@described_check, dependency_namespaces: ["Foo.Bar"])
|> refute_issues()
end

#
# cases raising issues
#
Expand Down

0 comments on commit 390573c

Please sign in to comment.