-
-
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(concepts): implement links.json
checks
#171
Conversation
a6661ea
to
f61a34b
Compare
655ff42
to
67d2eea
Compare
@ErikSchierboom Just to confirm, what should
In the future we could detect empty files and print a better error message.
but it should't complain about this, right? |
67d2eea
to
b9d8f0f
Compare
That is an error.
That's fine. |
b9d8f0f
to
1aa14a7
Compare
Done. This PR now causes the following diff to the Tracks that no longer exit with 0
clojure+File is empty, but must contain at least the empty array, `[]`:
+./concepts/basics/links.json
+ haxeThese files are an object at the top level, see e.g. https://github.com/exercism/haxe/blob/717a4d3cd01ad1c8439501b64b9c3ff46b3f59e7/concepts/abstract-types/links.json +Not an array: root:
+./concepts/abstract-types/links.json
+
+Not an array: root:
+./concepts/array-comprehension/links.json
+
+Not an array: root:
+./concepts/arrays/links.json
+
+Not an array: root:
+./concepts/basics/links.json
+
+Not an array: root:
+./concepts/bit-manipulation/links.json
+
+Not an array: root:
+./concepts/chars/links.json
+
+Not an array: root:
+./concepts/classes/links.json
+
+Not an array: root:
+./concepts/constructors/links.json
+
+Not an array: root:
+./concepts/datetimes/links.json
+
+Not an array: root:
+./concepts/do-while-loops/links.json
+
+Not an array: root:
+./concepts/enums/links.json
+
+Not an array: root:
+./concepts/equality/links.json
+
+Not an array: root:
+./concepts/exceptions/links.json
+
+Not an array: root:
+./concepts/final/links.json
+
+Not an array: root:
+./concepts/flag-enums/links.json
+
+Not an array: root:
+./concepts/floating-point-numbers/links.json
+
+Not an array: root:
+./concepts/for-loops/links.json
+
+Not an array: root:
+./concepts/foreach-loops/links.json
+
+Not an array: root:
+./concepts/generic-types/links.json
+
+Not an array: root:
+./concepts/if-statements/links.json
+
+Not an array: root:
+./concepts/indexers/links.json
+
+Not an array: root:
+./concepts/inheritance/links.json
+
+Not an array: root:
+./concepts/integral-numbers/links.json
+
+Not an array: root:
+./concepts/interfaces/links.json
+
+Not an array: root:
+./concepts/iterators/links.json
+
+Not an array: root:
+./concepts/lambda/links.json
+
+Not an array: root:
+./concepts/lists/links.json
+
+Not an array: root:
+./concepts/maps/links.json
+
+Not an array: root:
+./concepts/nullability/links.json
+
+Not an array: root:
+./concepts/numbers/links.json
+
+Not an array: root:
+./concepts/operator-overloading/links.json
+
+Not an array: root:
+./concepts/option-type/links.json
+
+Not an array: root:
+./concepts/optional-arguments/links.json
+
+Not an array: root:
+./concepts/pattern-matching/links.json
+
+Not an array: root:
+./concepts/properties/links.json
+
+Not an array: root:
+./concepts/randomness/links.json
+
+Not an array: root:
+./concepts/reflection/links.json
+
+Not an array: root:
+./concepts/regular-expressions/links.json
+
+Not an array: root:
+./concepts/rest-args/links.json
+
+Not an array: root:
+./concepts/string-buffer/links.json
+
+Not an array: root:
+./concepts/switch-expressions/links.json
+
+Not an array: root:
+./concepts/templates/links.json
+
+Not an array: root:
+./concepts/ternary-operators/links.json
+
+Not an array: root:
+./concepts/throw-expressions/links.json
+
+Not an array: root:
+./concepts/time/links.json
+
+Not an array: root:
+./concepts/typedefs/links.json
+
+Not an array: root:
+./concepts/using-statements/links.json
+
+Not an array: root:
+./concepts/while-loops/links.json java
+Missing key: 'url':
+./concepts/for-loops/links.json
+
+Missing key: 'url':
+./concepts/foreach-loops/links.json pythonInvalid capitalization of the +Missing key: 'url':
+./concepts/numbers/links.json ruby+
+File is empty, but must contain at least the empty array, `[]`:
+./concepts/enumeration/links.json
+
+File is empty, but must contain at least the empty array, `[]`:
+./concepts/exceptions/links.json
+
+File is empty, but must contain at least the empty array, `[]`:
+./concepts/ostruct/links.json swift+
+Missing file:
+./concepts/characters/links.json
+
+Missing file:
+./concepts/classes/links.json
+
+Missing file:
+./concepts/initializers/links.json
+
+Missing file:
+./concepts/opaque-indices/links.json
+
+Missing key: 'url':
+./concepts/shorthand-arguments/links.json
+
+Missing key: 'description':
+./concepts/shorthand-arguments/links.json
+
+Missing file:
+./concepts/strings/links.json
+
+Missing file:
+./concepts/structs/links.json |
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.
Two minor nits
if not checkString(data, "description", path): | ||
result = false | ||
|
||
if data.hasKey("icon_url"): |
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.
Do you need this call? Doesn't checkString
gracefully handle optional values?
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.
Do you need this call?
With the current checkString
, unfortunately yes.
The full context is:
if data.hasKey("icon_url"):
if checkString(data, "icon_url", path, isRequired = false):
let s = data["icon_url"].getStr()
icon_url
is optional, so we call checkString
with isRequired = false
. That means that checkString
returns true
if icon_url
is missing, which means the data["icon_url"].getStr()
would throw an exception if we don't have the first line.
It is indeed pretty ugly, and we're performing hasKey
twice.
In the future I'm thinking about splitting checkString
into hasString
and isString
(and the same for checkBoolean
, and checkInteger
), similar to the previous split of checkArray
into hasArray
and isArray
.
We can do without this optimization - about 97% of the URLs in `links.json` files so far start with `https://` anyway.
links.json
links.json
checks
`URL` --> `url. Python had a configlet linting error : `Invalid capitalization of the url key:`, as referenced in exercism/configlet#171. This fixes that error.
`URL` --> `url. Python had a configlet linting error : `Invalid capitalization of the url key:`, as referenced in exercism/configlet#171. This fixes that error.
This PR implements the
concept/<slug>/links.json
part of the spec:To-do:
config.json
#169 and rebase this PR on topisEveryConceptLinksFileValid
fromlint.nim
configlet lint
output on every track