exercism / elixir-analyzer

GNU Affero General Public License v3.0
31 stars 32 forks source link

Add common check for removing boilerplate comments #195

Closed angelikatyborska closed 3 years ago

angelikatyborska commented 3 years ago

Most concept exercises have boilerplate code with comments that say "Please implement the xyz/n function". A lot of published solutions still have those comments.

Add a common check for all exercises that will look for this pattern in the string with the solution:

# Please implement

If it finds it, it should return an actionable comment that says something like this:

It looks like you left some "please implement ..." comments in your code. Your code passes the tests, which means those comments are no longer true - you already implemented all of the necessary functions. Make sure to always remove outdated comments from your code.

If you want to be 100% sure that only comments will be found this way and not strings, you can run the check twice - once on the original string, and once on the string turned into the AST and back (see lib/elixir_analyzer/exercise_test/common_checks/indentation.ex that does something similar to find tabs used for indentation).

This check can either be implemented like lib/elixir_analyzer/exercise_test/common_checks/indentation.ex (with a run function) or like lib/elixir_analyzer/exercise_test/common_checks/debug_functions.ex with a __using__ macro, using the check/check_source helpers added in https://github.com/exercism/elixir-analyzer/pull/189

jiegillet commented 3 years ago

This will be such a satisfying check :)

jiegillet commented 3 years ago

To inspect all the comments present in the stub but not in the exemplar, you can use

for D in exercises/concept/*; do comm -23 ./$D/lib/**/*.ex ./$D/.meta/exemplar.ex | grep "#"; done

It kind of works on my Mac with zsh (there is noise and it breaks on one or two exercises, but it's enough to get an idea). Look like a few exercises use # TODO: define the ... function

jlirochon commented 3 years ago

Any "todo" remaining in comments could also return a specific message.

angelikatyborska commented 3 years ago

I'll work on this one