I am using mix credo -a to check code readably. But I am getting multiple message as “Modules should have a @moduledoc tag.” I am not sure how to suppress/remove this.
Thanks in advance for any kind of help.
Sometimes when you are not sure about how to solve an issue, you can use mix credo explain
, and it will tell you something about the suggestion and how to resolve it.
The simplest way though to solve your issue at hand is, to simply document the modules that have this issue: @moduledoc
Or you could just document your modules
Yes, that seems to be the actual reason of this warning. Thanks.
That command alone will not solve anything, its just that it might give you some more in depth explanation of an issue.
To solve the actual issue, you need to use @moduledoc
do document your modules, as I already said earlier.
You can add @moduledoc false
and credo will skip the module’s documentation, not showing the warning.
This will also specifically prevent the module from even being listed in generation documentation and some other lookups as well.
For who like me doesn’t want to open all files one by one and type that:
#!/bin/bash
# acting on all files under lib/
IFS=$'\n'
SUBB='Modules should have a @moduledoc tag.'
for line in $(mix credo list --format oneline)
do
if [[ "$line" == *"$SUBB"* ]]; then
path_to_file=$(echo "$line" | grep -P '((lib)+[\/a-z0-9._]+)+(\/?){1}' -o)
sed -i '2 i\ @moduledoc false\n' $path_to_file
fi
done
The separator is 2 whitespaces (others prefer tabs)
it gets all files under lib
Add this to your .credo.exs
file:
{Credo.Check.Readability.ModuleDoc, false}
Put a false near to the Credo.Check.Readability.ModuleDoc
This would disable checks for module docs.