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.