From 304686431157a44db3e5c1437b9ff340a24d7cea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20F=C3=B6hring?= Date: Sat, 30 Jul 2022 21:40:24 +0200 Subject: [PATCH] Fix error on single-line modules Refs #966 --- lib/credo/priority.ex | 2 +- test/credo/check/readability/module_doc_test.exs | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/credo/priority.ex b/lib/credo/priority.ex index bc1f0f6d6..856112c1a 100644 --- a/lib/credo/priority.ex +++ b/lib/credo/priority.ex @@ -78,7 +78,7 @@ defmodule Credo.Priority do |> Enum.slice(0..(length(names) - 2)) |> Enum.join(".") - mod_prio = lookup[mod_name] + mod_prio = lookup[mod_name] || 0 {scope_name, prio + mod_prio} else diff --git a/test/credo/check/readability/module_doc_test.exs b/test/credo/check/readability/module_doc_test.exs index 24e360067..e3dd548d5 100644 --- a/test/credo/check/readability/module_doc_test.exs +++ b/test/credo/check/readability/module_doc_test.exs @@ -93,4 +93,13 @@ defmodule Credo.Check.Readability.ModuleDocTest do |> run_check(@described_check) |> assert_issue() end + + test "it should report slightly unexpected code" do + """ + defmodule Person, do: def greet(), do: :howdy + """ + |> to_source_file + |> run_check(@described_check) + |> assert_issue() + end end