-
-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
lint: add initial linting of practice exercises #219
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is quite a bit of overlap between the practice exercises and concept exercises code. I'm usually hesitant to deduplicate code that is not entirely the same though, which is why I've not yet extracted any common functionality.
import ".."/helpers | ||
import "."/validators | ||
|
||
proc isValidAuthorOrContributor(data: JsonNode, context: string, path: string): bool = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code is currently duplicated between the practice_exercises and concept_exercises modules. We could extract it to some shared module.
if not checkString(data, "exercism_username", path, isRequired = false): | ||
result = false | ||
|
||
proc checkFiles(data: JsonNode, context, path: string): bool = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code is virtually identical to the corresponding concept exercise code, except for exemplar
being named example
here. We could extract this functionality into a shared helper.
else: | ||
result = false | ||
|
||
proc isValidPracticeExerciseConfig(data: JsonNode, path: string): bool = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Once again, this logic is almost identical to the concept exercises' logic. For now, the only difference is that there is no forked_from
property for practice exercises. There will be more difference later when more practice exercise checks are implemented. We could consider extracting the shared logic to a helper.
if not checkString(data, "language_versions", path, isRequired = false): | ||
result = false | ||
|
||
proc isEveryPracticeExerciseConfigValid*(trackDir: string): bool = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And again, this logic is very similar to the concept exercises logic. We could extract it to a helper method.
Looks good. My main observation: I notice that this PR will fill the
These 12 lines multiplied by the number of practice exercises is typically a pretty large amount of output. And even on the tracks that have merged the
Questions:
I'm fine with "no" for both. But if "no" for question 2, do we want to tell users not to add See below for the comparison before and after this PR. Before this PRTracks that exit with 0
Tracks that exit with 1click to expand05ab1e
ada
arm64-assembly
babashka
ballerina
ceylon
cfml
clojure
clojurescript
coffeescript
coq
cpp
crystal
d
dart
emacs-lisp
factor
forth
fortran
gleam
gnu-apl
groovy
haskell
idris
io
j
julia
kotlin
lfe
mips
nix
objective-c
ocaml
perl5
plsql
pony
powershell
prolog
purescript
racket
raku
reasonml
research_experiment_1
ruby
scala
scheme
shen
sml
solidity
swift
system-verilog
typescript
vbnet
vimscript
x86-64-assembly
With this PRThe output across every track is too long (30,000 lines) to post here. See https://gist.github.com/ee7/100ce3fa79310ca7ec7845eb21c13b4f |
I'm in doubt. Few tracks have updated the file pattern: exercism/v3-launch#19 That would indeed mean lots of linting errors. This is both good and bad. Good in that tracks will be confronted with the fact that they have to do this, bad in that we'll "break" a lot of tracks. I've just posted a message on the v3 Slack channel requesting people to update their file patterns. Let's temporarily disable this rule and enable it later on.
This is probably good. I am still (intermittently) working on my script to bulk PR the authors, but we can disable those checks for now. |
5c32ecd
to
81df2d5
Compare
@ee7 I've added a commit to temporarily disable the authors and files checks. |
OK, sounds good. The change that this PR now makes to the Tracks that no longer exit with 0:
Diff (it's messy because it has the output for every track in one file, but it should give the idea): @@ -85,6 +81,30 @@ Array is empty: 'tags':
Array is empty: 'tags':
./config.json
+
+Missing file:
+./exercises/practice/calculator-service/.docs/instructions.md
+
+Missing file:
+./exercises/practice/echo-service/.docs/instructions.md
+
+Missing file:
+./exercises/practice/greeting-service/.docs/instructions.md
+
+Missing file:
+./exercises/practice/hello-world-service/.docs/instructions.md
+
+Missing file:
+./exercises/practice/legacy-service-client/.docs/instructions.md
+
+Missing file:
+./exercises/practice/order-management/.docs/instructions.md
+
+Missing file:
+./exercises/practice/service-composition/.docs/instructions.md
+
+Missing file:
+./exercises/practice/service-invocation/.docs/instructions.md
@@ -223,6 +243,9 @@ Array is empty: 'tags':
Array is empty: 'tags':
./config.json
+
+Missing file:
+./exercises/practice/tautology/.docs/instructions.md
@@ -300,6 +323,16 @@ Array is empty: 'tags':
+#### erlang
+Missing file:
+./exercises/practice/bracket-push/.docs/instructions.md
@@ -577,6 +610,9 @@ String is zero-length: 'blurb':
Array is empty: 'tags':
./config.json
+
+Missing file:
+./exercises/practice/bracket-push/.docs/instructions.md
@@ -603,6 +639,16 @@ Array is empty: 'tags':
+#### pharo-smalltalk
+Missing file:
+./exercises/practice/die/.docs/instructions.md
@@ -654,6 +700,9 @@ Array is empty: 'tags':
Array is empty: 'tags':
./config.json
+Missing file:
+./exercises/practice/bracket-push/.docs/instructions.md
+
Array is empty: 'files.solution':
./exercises/concept/booleans/.meta/config.json
@@ -665,6 +714,16 @@ Array is empty: 'files.test':
+#### r
+Missing file:
+./exercises/practice/fizz-buzz/.docs/instructions.md
@@ -718,6 +777,37 @@ Missing key: 'tags':
Array is empty: 'tags':
./config.json
+
+Missing file:
+./exercises/practice/microwave/.docs/instructions.md
+
+
+
+#### rust
+Missing file:
+./exercises/practice/decimal/.docs/instructions.md
+
+Missing file:
+./exercises/practice/doubly-linked-list/.docs/instructions.md
+
+Missing file:
+./exercises/practice/fizzy/.docs/instructions.md
+
+Missing file:
+./exercises/practice/luhn-from/.docs/instructions.md
+
+Missing file:
+./exercises/practice/luhn-trait/.docs/instructions.md
+
+Missing file:
+./exercises/practice/macros/.docs/instructions.md
+
+Missing file:
+./exercises/practice/xorcism/.docs/instructions.md
@@ -780,6 +870,9 @@ String is zero-length: 'blurb':
Array is empty: 'tags':
./config.json
+
+Missing file:
+./exercises/practice/token-transfer/.docs/instructions.md
@@ -791,6 +884,9 @@ Array is empty: 'tags':
Array is empty: 'tags':
./config.json
+Missing file:
+./exercises/practice/bracket-push/.docs/instructions.md
+
Missing file:
./concepts/capturing/introduction.md |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It turns out that ./exercises/practice
does not exist for exactly these tracks:
- 05ab1e
- ada
- forth
- io
- nix
- research_experiment_1
- system-verilog
But the current state of the PR doesn't print an error message for a missing practice exercise directory, even though it would make configlet lint
exit with a non-zero exit code.
d6b4863
to
1069101
Compare
Each practice exercise's directory should contain at least the following two files: - .docs/instructions.md - .meta/config.json
Co-authored-by: ee7 <45465154+ee7@users.noreply.github.com>
To prevent `configlet lint` from producing a lot of output for nearly every track, we temporarily disable two checks. With this commit, `configlet lint` will not check: - The `files` property in the .meta/config.json file of each practice exercise. - The `authors` property in the .meta/config.json file of each practice exercise.
1069101
to
699710a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved for "rebase and merge".
This PR adds basic validation checks for practice exercises:
The PR also applies a minor refactoring, where required file checking is moved to the corresponding module instead of the lint module.
The helper proc to check whether required files exist in a directory has been moved to the validators module to allow being called from the different modules.