Credo is a static code analysis tool for the Elixir language with a focus on teaching and code consistency.
It can show you refactoring opportunities in your code, complex code fragments, warn you about common mistakes, show inconsistencies in your naming scheme and - if needed - help you enforce a desired coding style.
The easiest way to add Credo to your project is by using Mix.
Add :credo
as a dependency to your project's mix.exs
:
defp deps do
[
{:credo, "~> 1.4", only: [:dev, :test], runtime: false}
]
end
And run:
$ mix deps.get
$ mix credo
Although Credo mostly supports Elixir 1.5, which is compatible with Erlang/OTP 18–20, Credo itself requires Erlang/OTP 20+.
Documentation is available on Hexdocs
Some IDEs and editors are able to run Credo in the background and mark issues inline.
- IntelliJ Elixir - Elixir plugin for JetBrains IDEs (IntelliJ IDEA, Rubymine, PHPStorm, PyCharm, etc)
- linter-elixir-credo - Package for Atom editor (by @smeevil)
- ElixirLinter - VSCode plugin (by @iampeterbanjo)
- flycheck - Emacs syntax checking extension
- Codacy - checks your code from style to security, duplication, complexity, and also integrates with coverage.
- SourceLevel - tracks how your code changes over time and have this information accessible to your whole team.
- Stickler CI - checks your code for style and best practices across your entire stack.
- Fork it!
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request
René Föhring (@rrrene)
Credo is released under the MIT License. See the LICENSE file for further details.