Checkbook is a set of checks to help keep your Elixir project code clean and well-factored.

Installation

Add the :checkbook package to your mix.exs dependencies:

def deps do
  [
    {:checkbook, "~> 0.1", only: [:dev, :test], runtime: false}
  ]
end

Usage

You just need to add the checks you want in your .credo.exs configuration file.

Check for public function in your modules that are unused

This check will raise an issue if a public function is defined and not used in the rest of the project.

{Checkbook.Check.Refactor.UnusedPublicFunctions, ignore_exposed_for_testing: true}

Suppose you have a MyApp.ErrorHelpers module:

$ mix credo

┃  Refactoring opportunities
┃
┃ [F] → Unused public function: five_hours/0
┃       lib/my_app_web/views/view_helpers.ex #()
┃ [F] → Unused public function: year_list/0
┃       lib/my_app_web/views/view_helpers.ex #()

With this check configuration for example, a module named MyApp.UserManager or MyApp.FormHelpers would not be allowed.

Setting ignore_exposed_for_testing

ignore_exposed_for_testing is a boolean that will ignore public functions that are exposed for testing. For example, if you have a module attribute that you want to expose for testing, you can set this to true to prevent the check from flagging it as unused.

License

Checkbook is © 2024 Ken Barker and may be freely distributed under the MIT license.