Skip to content
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(track_config): check status-dependent exercise rules #415

Merged
merged 15 commits into from
Sep 7, 2021

Conversation

ee7
Copy link
Member

@ee7 ee7 commented Sep 6, 2021

With this commit, configlet lint now checks that a track-level
config.json file follows the below rules for Concept Exercises:

  • The exercises.concept[].concepts value must be a non-empty array of
    strings if exercises.concept[].status is not equal to deprecated
  • The exercises.concept[].concepts value must be an empty array if
    exercises.concept[].status is equal to deprecated
  • The exercises.concept[].prerequisites value must be a non-empty
    array of strings if exercises.concept[].status is not equal to
    deprecated, except for exactly one exercise which is allowed to have
    an empty array as its value
  • The exercises.concept[].prerequisites value must be an empty array
    if exercises.concept[].status is equal to deprecated

and these rules for Practice Exercises:

  • The exercises.practice[].practices value must be an empty array if
    exercises.practice[].status is equal to deprecated
  • The exercises.practice[].prerequisites value must be an empty array
    if exercises.practice[].status is equal to deprecated
  • The exercises.practice[].prerequisites value must be an empty array
    if exercises.practice[].slug is equal to hello-world

This commit also adds support for the below checks of
Practice Exercises. However, because there would currently be too many
linting errors, this commit leaves these checks disabled for now:

  • The exercises.practice[].practices value must be a non-empty array
    of strings if exercises.practice[].status is not equal to
    deprecated
  • The exercises.practice[].prerequisites value must be a non-empty
    array of strings if exercises.practice[].status is not equal to
    deprecated

Closes: #386


This PR currently includes the commit from #414. We will merge that one PR first, then rebase this PR on top. Edit: done.

At the time of writing (2021-09-06T18:27:00Z), this PR causes the below diff to the output of configlet lint, per track:

elixir

https://github.com/exercism/elixir/blob/d5f3834445ca/config.json#L1153-L1338

+The Practice Exercise `binary` has a `status` of `deprecated`, but has a non-empty array of `practices`:
+./config.json
+
+The Practice Exercise `binary` has a `status` of `deprecated`, but has a non-empty array of `prerequisites`:
+./config.json
+
+The Practice Exercise `hexadecimal` has a `status` of `deprecated`, but has a non-empty array of `practices`:
+./config.json
+
+The Practice Exercise `hexadecimal` has a `status` of `deprecated`, but has a non-empty array of `prerequisites`:
+./config.json
+
+Configlet detected at least one problem.
+For more information on resolving the problems, please see the documentation:
+https://github.com/exercism/docs/blob/main/building/configlet/lint.md

python

https://github.com/exercism/python/blob/6afbd74d3bce/config.json#L1971-L2190

+The Practice Exercise `accumulate` has a `status` of `deprecated`, but has a non-empty array of `prerequisites`:
+./config.json
+
+The Practice Exercise `binary` has a `status` of `deprecated`, but has a non-empty array of `prerequisites`:
+./config.json
+
+The Practice Exercise `error-handling` has a `status` of `deprecated`, but has a non-empty array of `prerequisites`:
+./config.json
+
+The Practice Exercise `hexadecimal` has a `status` of `deprecated`, but has a non-empty array of `prerequisites`:
+./config.json
+
+The Practice Exercise `nucleotide-count` has a `status` of `deprecated`, but has a non-empty array of `prerequisites`:
+./config.json
+
+The Practice Exercise `octal` has a `status` of `deprecated`, but has a non-empty array of `prerequisites`:
+./config.json
+
+The Practice Exercise `parallel-letter-frequency` has a `status` of `deprecated`, but has a non-empty array of `prerequisites`:
+./config.json
+
+The Practice Exercise `pascals-triangle` has a `status` of `deprecated`, but has a non-empty array of `prerequisites`:
+./config.json
+
+The Practice Exercise `point-mutations` has a `status` of `deprecated`, but has a non-empty array of `prerequisites`:
+./config.json
+
+The Practice Exercise `proverb` has a `status` of `deprecated`, but has a non-empty array of `prerequisites`:
+./config.json
+
+The Practice Exercise `strain` has a `status` of `deprecated`, but has a non-empty array of `prerequisites`:
+./config.json
+
+The Practice Exercise `trinary` has a `status` of `deprecated`, but has a non-empty array of `prerequisites`:
+./config.json
+
+Configlet detected at least one problem.
+For more information on resolving the problems, please see the documentation:
+https://github.com/exercism/docs/blob/main/building/configlet/lint.md

zig

https://github.com/exercism/zig/blob/3d166c4e2a7a/config.json#L21-L36

+The Practice Exercise `hello-world` is user-facing (because a missing `status` key implies `active`), but has a non-empty array of `prerequisites`:
+./config.json
+

@ee7 ee7 requested a review from ErikSchierboom as a code owner September 6, 2021 18:22
@ee7 ee7 force-pushed the lint-track-config-prereqs-concepts-practices branch from 0e11380 to fe5df29 Compare September 6, 2021 18:24
@BethanyG
Copy link
Member

BethanyG commented Sep 6, 2021

@ee7 -- Since I am here and in cleanup mode anyways, I'll PR a fix for the ones you found for Python. 😄 And..many thanks for adding these checks into configlet!

@ee7
Copy link
Member Author

ee7 commented Sep 6, 2021

I'll PR a fix for the ones you found for Python

Great, thanks.

I've created the PRs for elixir and zig. So here are the relevant PRs:

@ee7 ee7 changed the title lint(track_config): add more checks of prereqs, concepts, practices lint(track_config): add more checks of prerequisites, concepts, practices Sep 6, 2021
Copy link
Member

@ErikSchierboom ErikSchierboom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working on this. I've left a minor nit.

src/lint/track_config.nim Show resolved Hide resolved
src/lint/track_config.nim Outdated Show resolved Hide resolved
result = &"The {exerciseKind} {q exercise.slug} {statusStr}" &
&", but has {problem}"

proc checkExercisePCP(exercises: seq[ConceptExercise] | seq[PracticeExercise];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is PCP? To me this is a non-intuitive abbreviation so I'd prefer it being spelled out a bit more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is PCP?

Indeed. I'll try to improve it.

("practices, concepts, prerequisites")

@ee7
Copy link
Member Author

ee7 commented Sep 7, 2021

I don't think I've found a great factoring here yet - in particular I don't like the proc names.

For the first pass we have a proc called hasValidExercises, and for the second pass:

  • checkExerciseConcepts ("why do we need this when hasValidExercises returned true?")
  • checkExercisePrerequisites
  • checkExercisePCP (the non-obvious "practices, concepts, prerequisites")

Where we will extend/add procs for the second pass to add the remaining exercises.concept[] and exercises.practice[] rules, like:

  • The "exercises.concept[].slug" value must be unique in "exercises.concept[].slug" and may not exist in "exercises.practice[].slug"
  • The "exercises.practice[].slug" value must be unique in "exercises.practice[].slug" and may not exist in "exercises.concept[].slug"
  • There must be exactly one "exercises.practice[].slug" value that is the string hello-world
  • The "exercises.practice[].practices" values must match the "concepts[].slug" property of one of the concepts
  • The "exercises.practice[].practices" values must refer to an individual concept's slug at most 10 times (across all exercises)
  • The "exercises.practice[].prerequisites" values must match any concept exercise's "exercises.concept[].concepts" values
  • The "exercises.practice[].prerequisites" values must match the "concepts[].slug" property of one of the concepts
  • The "concepts" value must have a entry with a matching "slug" property for each concept listed in a concept exercise's "concepts" property

So the names might need to change later too. But I'll try to improve the current situation a little.

@ErikSchierboom
Copy link
Member

👍 I'm fine with renaming later BTW.

ee7 added 10 commits September 7, 2021 10:28
With this commit, `configlet lint` now checks that a track-level
`config.json` file follows the below rules:

- The `exercises.concept[].concepts` value must be a non-empty array of
  strings if `exercises.concept[].status` is not equal to "deprecated"
- The `exercises.concept[].concepts` value must be an empty array if
  `exercises.concept[].status` is equal to "deprecated"
- The `exercises.concept[].prerequisites` value must be an empty array
  if `exercises.concept[].status` is equal to "deprecated"
With this commit, `configlet lint` now checks that a track-level
`config.json` file follows the below rules:

- The `exercises.practice[].practices` value must be a non-empty array
  of strings if `exercises.practice[].status` is not equal to
  "deprecated"
- The `exercises.practice[].practices` value must be an empty array if
  `exercises.practice[].status` is equal to "deprecated"
- The `exercises.practice[].prerequisites` value must be a non-empty
  array of strings if `exercises.practice[].status` is not equal to
  "deprecated"
- The `exercises.practice[].prerequisites` value must be an empty array
  if `exercises.practice[].status` is equal to "deprecated"
With this commit, `configlet lint` now checks that a track-level
`config.json` file follows the below rule:

- The `exercises.practice[].prerequisites` value must be an empty array
  if `exercises.practice[].slug` is equal to "hello-world"
With this commit, `configlet lint` now checks that a track-level
`config.json` file follows the below rule:

- The `exercises.concept[].prerequisites` value must be a non-empty
  array of strings if `exercises.concept[].status` is not equal to
  "deprecated", except for exactly one exercise which is allowed to have
  an empty array as its value
@ee7 ee7 force-pushed the lint-track-config-prereqs-concepts-practices branch from fe5df29 to 92d1906 Compare September 7, 2021 08:28
@ee7 ee7 merged commit 0d139e2 into exercism:main Sep 7, 2021
@ee7 ee7 deleted the lint-track-config-prereqs-concepts-practices branch September 7, 2021 12:15
@ee7 ee7 changed the title lint(track_config): add more checks of prerequisites, concepts, practices lint(track_config): check status-dependent exercise rules Sep 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

lint: check that concept exercise has correct concepts array
3 participants