exercism/problem-specifications

canonical-data.json: Compliance with JSON Schema

Closed this issue ยท 38 comments

Now that #602 was merged, it would be great to have all the canonical-data.json files compliant with the JSON Schema, so that we could automatically check them for errors in the future.

At the moment, we have 74 canonical-data.json files, but only 3 are compliant.

When porting the files, I guess it would be nice to follow a few guidelines to make reviewing easier:

  • Distinct commits with the following:
    1. exercise-name: Make canonical-data.json compliant, containing the minimal changes to make the test suite compliant.
    2. exercise-name: Fix canonical-data.json formatting, with the changes needed to make it readable again.
  • pull-request's title: exercise-name: Make exercise schema-compliant
  • pull-request's body: at least a line containing Related to #625.
  • version should start at 1.0.0 and follow the exercise property.

Unless there is already a standard in place that I don't know, I suggest formatting with 2-spaces indentation in the second commit, for consistency, which is already the default when running jq '.' canonical-data.json.

Of course, most of the exercises will demand additional changes to a standard formatting, to make them more compact and readable.

Edit: Just to be clear, this issue is not about style in designing the test suite. Changes that go beyond fixing the test suite to be compliant and fix it to be consistently formatted after that should be avoided here!


canonical-data.json compliance

The final goal here is that we will be able to run every canonical-data.json through a schema check, right?

Then can I propose we do not wait until all canonical-data.json are compliant before starting to do that?

Let's start check them all ASAP, and allow those listed in a file named allowed-schema-failures (or something) to fail.

Because we wouldn't want a file that was compliant to fall out of compliance while this project is underway.

The goal of course will be to drive the number of lines in the file down to zero.

If anyone wants to port and exercise to the new schema, I is a good idea to say here, so that we don't make useless duplicated work.

kotp commented

Working on Hamming

Working on: hello-world, all-your-base

I'll tackle leap and word-count.

Working on: anagram, atbash-cipher and bob.

I've got book-store.

Working on raindrops, rna-transcription and scrabble-score.

Working on change, grains and luhn.

Working on binary and trinary, deprecated exercises.

Working on pig-latin, say and wordy.

Working on sieve, sum-of-multiples and triangle

Working on crypto-square, difference-of-squares and etl.

Working on queen-attack, robot-simulator and secret-handshake.

Working on meetup, minesweeper and nth-prime.

Working on adding schema validation to travis.

kotp commented

Working on nucleotide-count, ocr-numbers and pascals-triangle.

Working on clock, comment and custom-set.

Working on alphametics, binary-search and bowling.

Working on bracket-push, circular-buffer, dominoes, flatten-array and food-chain.


@rbasso I am a little confused with the `property` field. Since it is required in all test cases, is that supposed to be the function/method name in the implementation? The [description here](https://github.com/exercism/x-common/blob/master/canonical-schema.json#L115) is not very useful.

The description here is not very useful.

Sorry for the description!

The property is a string that uniquely identifies a test type.

In test-suite-generation terms, it is a reference to an external test-logic, a way to turn the test data in a real test. Ops, I guess I made the explanation worse. ๐Ÿ˜

I am a little confused with the property field. Since it is required in all test cases, is that supposed to be the function/method name in the implementation?

In most of the situations, yes! It can be the name of a function! Just keep in mind that if the tests use the same function (test logic), they need to have the same property.

Working on forth, grep and largest-series-product. We are almost there...

Edit: grep needs a complete redesign to match the new schema, because it encodes files in the JSON. Not touching it for now.

Working on list-ops, markdown and pov.

Edit: pov also needs a redesign to match the new schema, because it has objects shared by test cases. Not touching it for now.

grep needs a complete redesign to match the new schema, because it encodes files in the JSON. Not touching it for now.

@rbasso Does this mean we need a way to ignore some exercises from the CI? (in #658)

Don't worry about that for now, @tejasbubane. I already have an idea about how to sidestep the grep problem, but I'm waiting to see if I find more incompatible exercises to so that we can rewrite them together in a more consistent way.

Working on prime-factor, rail-fence-cipher, react and rectangles.

Working on rotational-cipher, run-length-encoding and space-age.

I guess I have to do pov.

kotp commented

Make sure to see @rbasso concerns with pov and grep, among others... referenced #699

I see you are already aware, @petertseng

Thanks, @petertseng ! pov is the hardest by far...

Working on sublist and transpose.

Working on two-bucket and variable-length-quantity.

Edit: two-bucket needs descriptions and a good property name. Not touching it today.

People, we are at full compliance with the JSON schema at the moment.

kotp commented

Now we will party like it's 18 years ago!

I'm glad to say that, after something around 150 commits (+75 merges), we are almost done. We just need some eyes in #658 to review enforcing it in Travis-CI, then this chapter of the standardization saga will be over. ๐ŸŽ‰ ๐ŸŽŠ

I know that I'm guilty of rushing the conversion to this new schema a little, but we did all possible to avoid changes in the test contents, so I just hope no one will be mad with me. ๐Ÿ˜

In the few cases where meaningful test-data changes where really needed, we bumped the version to 1.1.0, so it should be easy to identify those exercises.

I'm sorry for adding some completely unhelpful description to tests that where missing them. Some property names I added are also regrettably horrible.

That said, the changes are not forever, and I expect the errors and bad decisions will be fixed someday.

Thanks to everybody who joined this task force! ๐Ÿ‘

Now, if you excuse me, I'll try a JSON-detox for a while. ๐Ÿ˜ท