Con el nuevo formateador en Elixir v1.6, ya no creo que haya un uso para el dogma. Gracias por usar este Linter, ha sido divertido :)
El dogma es un principio o un conjunto de principios establecidos por una autoridad como incontrovertiblemente cierto .
También es un enlace de estilo de código para Elixir, impulsado por la vergüenza.
Dogma es una herramienta para hacer cumplir un estilo de código de elixir consistente dentro de su proyecto, la idea es que si su código es más fácil de leer, también debería ser más fácil de entender. Es altamente configurable, por lo que puede ajustarlo para que se ajuste a su guía de estilo, pero viene con un conjunto de valores predeterminados sano, por lo que para la mayoría de las personas debería funcionar fuera de la caja. Me gusta ejecutar el dogma en el servidor CI con la suite de prueba, y considerar la compilación rota si el dogma informa un problema.
Si está interesado en una herramienta más orientada a hacer sugerencias de estilo en lugar de hacer cumplir estrictamente su guía de estilo, consulte Credo.
Agregue dogma a sus dependencias de mezcla
# mix.exs
def deps do
[
{ :dogma , "~> 0.1" , only: :dev } ,
]
endBuscarlo:
mix deps.get
Ejecute la tarea de mezcla:
mix dogma
Obtendrás algo como esto:
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
¡Qué práctico!
Para ejecutar el dogma desde cualquier directorio, construya el escript:
mix escript.build
Esto creará un ejecutable que puede colocar en su camino e invocar desde cualquier lugar.
mix test # Run tests once
mix test.watch # Run tests on file changes
mix dogma # Dogfooding- run the linter!Míralos en hexdocs o generarlos tú mismo:
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.