From bfa64f50ad45e71bdd2892780f4c0e7f2e1c5119 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20F=C3=B6hring?= Date: Fri, 13 Dec 2024 11:18:52 +0100 Subject: [PATCH] Add test reproducing false negative for ModuleDoc Refs #1168 --- .../check/readability/module_doc_test.exs | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/test/credo/check/readability/module_doc_test.exs b/test/credo/check/readability/module_doc_test.exs index a8c08a1ee..340f69707 100644 --- a/test/credo/check/readability/module_doc_test.exs +++ b/test/credo/check/readability/module_doc_test.exs @@ -53,6 +53,21 @@ defmodule Credo.Check.Readability.ModuleDocTest do |> refute_issues() end + test "it should NOT report modules or submodules when @moduledoc is present" do + """ + defmodule Foo do + @moduledoc false + + defmodule Bar do + @moduledoc false + end + end + """ + |> to_source_file + |> run_check(@described_check, ignore_names: []) + |> refute_issues() + end + # # cases raising issues # @@ -70,6 +85,20 @@ defmodule Credo.Check.Readability.ModuleDocTest do |> assert_issue() end + test "it should report modules when @moduledoc is present in submodules only" do + """ + defmodule Foo do + # distinctly no moduledoc here + defmodule Bar do + @moduledoc false + end + end + """ + |> to_source_file + |> run_check(@described_check, ignore_names: []) + |> assert_issue() + end + test "it should report empty strings" do """ defmodule CredoSampleModule do