exercism / pharo-smalltalk

Exercism exercises in Pharo.
https://exercism.org/tracks/pharo-smalltalk
MIT License
34 stars 28 forks source link

Configure tokei for pharo #597

Closed glennj closed 1 year ago

glennj commented 1 year ago

Tokei is the "lines of code counter" tool.

Add Pharo configuration

https://github.com/exercism/tokei/blob/master/CONTRIBUTING.md#language-addition https://discord.com/channels/854117591135027261/1169215168484479006

glennj commented 1 year ago

@Bajger feel free to assign this to me.

Bajger commented 1 year ago

@glennj Hi! Here you are :) Just a side note: Pharo has own way to compute lines of code, that respects different formatting (removes whitespaces, etc.). You can send #linesOfCode to method, class or package: image

glennj commented 1 year ago

The Exercism lines-of-code counter uses tokei: you configure the single line comment leader and multi-line comment markers. It will remove comments and empty lines to report LOC. There's no way to invoke a language-aware parser

For example https://exercism.org/tracks/pharo-smalltalk/exercises/two-fer/solutions/glennj

Bajger commented 1 year ago

Pharo probably counts just a methods - its body (including defined name), but ignores enclosing brackets and protocol names (since counting considers this as syntactic sugar). It also doesn't count class definition itself. So probably to be consistent with rest of language tracks, we should keep with tokei? There should be a way to omit text files - maybe I can put in current implementation some markers for omitting this (like \" )?

glennj commented 1 year ago

we should keep with tokei

Yes. We don't want to radically overhaul https://github.com/exercism/lines-of-code-counter/tree/main

glennj commented 1 year ago

I just discovered there's a .tokeignore file that's like a .gitignore. We could add TestResults.txt to that file for each exercise.

Otherwise, we'd have to give the TestResults file a different extension, one for a language with multi-line comments. TestResults.st seems wrong.

glennj commented 1 year ago

Will it upset test generation if I add a .tokeignore file into each exercises/practice/$exercise ?

Bajger commented 1 year ago

I think it is ok to put it there, tests shouldn't harmed, since Pharo generates TestResults.txt file and then is part of submission. Only problem/impediment I see in new exercise generation prom problem spec, if this .tokeignore should be common for all exercises. E.g. one would call configlet sync --metadata -uy -e slug-name and part of sync result should be .tokeignore file I suppose. Otherwise it needs to be added manually each time. Anyway: You probably should test whole user exercise life-cycle with this new file:

Bajger commented 1 year ago

@glennj Please feel free to submit PR with .tokeignore on one exercise and I can try out loading baselne with you PR into the image.

glennj commented 1 year ago

Thinking a little more about this. The TestResults.txt file can be configured away in the exercism/lines-of-code-counter repo: Add an ignore file in https://github.com/exercism/lines-of-code-counter/tree/main/tracks

I'm testing that hypothesis

glennj commented 1 year ago

This is now completed: http://forum.exercism.org/t/question-about-the-lines-of-code-counter/8172