exercism / exercism/elixir-analyzer

Universal checks for every single solution?

未關閉
#97 21 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
discussion 💬
主要語言
Elixir
星號
33
分支
33
PR 合併指標
30 天內沒有已合併 PR

描述

As I mentor, I keep seeing some reoccurring problems with solutions that are exercise-independent and could, at least partially, be detected automatically.

A code snippet from a real recent solution:
```elixir
@spec reverse(list) :: list
defp reverseHelper([], reversed) do
reversed
end
defp reverseHelper([x|xs], reversed) do
reverseHelper(xs, [x|reversed])
end

def reverse(l) do
reverseHelper(l,[])
end
```

The analyzer could detect and give a suggestion to the user that:
- `@spec` for a function should be placed directly above that function definition, there shouldn't be a different function definition in between
- function (and variable) names should use snake_case

More opinionated, but we could also check if each public function has a `@spec` and `@doc` and nudge students to add them (for practice exercises only).

Without parsing the AST, we could check if the code is intended with spaces or with tabs.

I think in particular the camelCase and indenting are worth doing in the analyzer, because they're hard no-nos in community Elixir code, but they're annoying details that are pretty uncomfortable to point out to a new comer. It would be nicer if a machine did that 🙂.

貢獻指南

開啟貢獻指南

評估

這個 Issue 還沒有評估資料。

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。