exercism / exercism/elixir-analyzer

Universal checks for every single solution?

Đang mở
#97 21 bình luận 0 reaction 0 người được giao Xem trên GitHub
discussion 💬
Ngôn ngữ chính
Elixir
Star
33
Fork
33
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

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 🙂.

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.