dogma
1.0.0
有了Elixir v1.6中的新格式化器,我认为教条再也没有使用了。感谢您使用此衬里,这很有趣:)
教条是由当局规定的原则或一组原则,这是无可争议的。
它也是由羞耻推动的长生不老药的代码样式衬里。
Dogma是在项目中执行一致的长精灵代码样式的工具,其想法是,如果您的代码易于阅读,则也应该更容易理解。它是可配置的高度,因此您可以对其进行调整以适合您的样式指南,但是带有一套理智的默认设置,因此对于大多数人来说,它应该仅在开箱即用。我喜欢使用测试套件在CI服务器上运行教条,如果教条报告问题,请考虑构建破裂。
如果您对更倾向于提出风格建议而不是严格执行您的样式指南的工具感兴趣,请查看Credo。
将教条添加到您的混合依赖性
# mix.exs
def deps do
[
{ :dogma , "~> 0.1" , only: :dev } ,
]
end获取它:
mix deps.get
运行混音任务:
mix dogma
您会得到这样的东西:
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
多方面!
为了从任何目录中运行教条,构建escript:
mix escript.build
这将创建可执行的可执行文件,您可以将其放置在路径中并从任何地方调用。
mix test # Run tests once
mix test.watch # Run tests on file changes
mix dogma # Dogfooding- run the linter!在六角洲检查它们,或自己生成它们:
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.