Com o novo formatador no Elixir v1.6, não acho que haja mais um uso para dogma. Obrigado por usar este linhador, tem sido divertido :)
O dogma é um princípio ou conjunto de princípios estabelecidos por uma autoridade tão incontestamente verdadeira .
É também um linhador de estilo de código para Elixir, alimentado pela vergonha.
O dogma é uma ferramenta para impor um estilo de código Elixir consistente em seu projeto, a idéia é que, se o seu código for mais fácil de ler, também deve ser mais fácil de entender. É altamente configurável para que você possa ajustá-lo para se ajustar ao seu guia de estilo, mas vem com um conjunto de padrões sãos, para que para a maioria das pessoas deva apenas funcionar fora da caixa. Eu gosto de executar dogma no servidor CI com a suíte de teste e considerar a construção quebrada se o dogma relatar um problema.
Se você estiver interessado em uma ferramenta mais voltada para fazer sugestões de estilo, em vez de aplicar estritamente seu guia de estilo, confira o Credo.
Adicione dogma às suas dependências de mixagem
# mix.exs
def deps do
[
{ :dogma , "~> 0.1" , only: :dev } ,
]
endBuscá -lo:
mix deps.get
Execute a tarefa Mix:
mix dogma
Você terá algo assim:
Inspecting 27 files.
.....X..........X..........
27 files, 2 errors!
== lib/dogma/rules.ex ==
23: TrailingBlankLines: Blank lines detected at end of file
== test/dogma/formatter_test.exs ==
9: TrailingWhitespace: Trailing whitespace detected
Como é útil!
Para executar o dogma de qualquer diretório, construa o ESCRCT:
mix escript.build
Isso criará um executável que você pode colocar no seu caminho e invocar de qualquer lugar.
mix test # Run tests once
mix test.watch # Run tests on file changes
mix dogma # Dogfooding- run the linter!Confira -os em hexdocs ou gerá -los você mesmo:
mix docs Dogma - A code style linter for Elixir, powered by shame.
Copyright © 2015 Louis Pilfold - MIT Licence
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.