-
-
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: check files
key in track-level config
#435
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.
Great! I'll leave the Nim code review to @ee7 .
@bobtfish Great! |
This is more consistent with the test layout in the `isFilesPattern` suite, and elsewhere in this file.
Personal taste, but this makes it easier to see that the pattern is identical in each pair of lines, and we've tended to use `.len` elsewhere.
Before: no placeholder with placeholder multiple placeholders After: no placeholder one placeholder multiple placeholders
Previously, an IndexDefect was raised for an input string that ends with the % character.
Let's put both these variables close to the `isString` proc that uses them.
Appease `nimpretty`.
I think this reads more naturally, and we've tended to use this style elsewhere.
This makes it obvious that `filesPatterns` isn't used elsewhere.
This makes the name of this variable more consistent with the code in `isFilesPattern`: for ph in extractPlaceholders(s): if ph notin filesPatterns: result = false
The Nim compiler doesn't optimize the previous pattern. The recommended ways to write it are these: foo.add bar foo &= bar
This makes it obvious that we don't mutate `c`.
This is more consistent with the name of the parameter in `isFilesPattern`, and our code elsewhere.
Again, thanks for working on this. I've done a first pass review - looking good. I again took the liberty of just pushing the commits - please yell at me if you hate anything, or have any questions. Most notably, a string that ended in There's a few more things I want to have before merging (in particular: a few more test cases, and a warning for bad placeholder usage would indeed be nice) but I think it's pretty close. |
files
key in track-level config
This was used neither in the configlet codebase, nor the tests.
Probably more readable.
I don't have a strong preference for this indentation style, but it's what we've used elsewhere.
It was a little confusing that passing `isRequired = false` to `hasObject` did nothing, because we checked `hasKey` twice. But the problem is that the existing `hasX` design is a bit of a mess, or at least the proc names. I don't love that a proc named `hasObject` returns true when `isRequired = false` is passed. Let's just do it this way for now - I found it little clearer. Eventually, all this `hasX` code might be refactored.
This makes it more obvious that this func was only used during the tests. After the Nim 1.6 release we'll be able to test procs in other modules without exporting them.
This test case used 3 placeholder characters, not 2.
hey @ee7 thanks for brushing up my code. Are you going to take this over the line, or would you like me to add the warning? (I think you added the extra tests already, right?) |
This reverts commit 6df6fe6. Oops. It does need to be like this. Otherwise, when the optional `files` key is missing, `configlet lint` incorrectly prints this: The `files` key is missing: ./config.json
This is a very basic check, but at least it catches something like %{snake_slug.foo Currently, there is only one track with multiple placeholders.
And the (unlikely) use of 3 placeholders.
No problem.
@bobtfish Yes - thanks. I'll just add a very basic warning and then I'll merge. I've also like to add more rules about file patterns to the spec, but we should handle that later. |
We omitted these elsewhere.
Note that the string is still set at compile-time. The func is a bit long - oh well.
This better communicates that `extractPlaceholders` isn't printing error messages, so we don't need to iterate over every placeholder.
At the time of writing, this PR produces the following diff to the output of ballerina+A `files.exemplar` value is `.meta/reference/%{snake_slug}.bal`, which is not a unique `files` entry:
+./config.json
+
d+A `files.test` value is `source/%{snake_slug}.d`, which is not a unique `files` entry:
+./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
fortran+A `files.exemplar` value is `%{snake_slug}.f90`, which is not a unique `files` entry:
+./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
groovy+A `files.exemplar` value is `.meta/src/reference/groovy/%{pascal_slug}.groovy`, which is not a unique `files` entry:
+./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
java+A `files.exemplar` value is `.meta/src/reference/java/%{pascal_slug}.java`, which is not a unique `files` entry:
+./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
pharo-smalltalk+A `files.exemplar` value is `.meta/solution/%{pascal_slug}.class.st`, which is not a unique `files` entry:
+./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
plsql+A `files.test` value is `ut_%{snake_slug}#.plsql`, which is not a unique `files` entry:
+./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
vimscript+A `files.exemplar` value is `example.vim`, which is not a unique `files` entry:
+./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
|
This makes the code use the terminology from the docs: 4. Valid `files` pattern: A non-blank string¹ that specifies a location of a file used in an exercise, relative to the exercise's directory. A pattern may use one of the following placeholders: - `%{kebab_slug}`: the `kebab-case` exercise slug (e.g. `bit-manipulation`) - `%{snake_slug}`: the `snake_case` exercise slug (e.g. `bit_manipulation`) - `%{camel_slug}`: the `camelCase` exercise slug (e.g. `bitManipulation`) - `%{pascal_slug}`: the `PascalCase` exercise slug (e.g. `BitManipulation`)
"valid files pattern" sounds like it could be missing a possessive apostrophe. Let's refer to a single string as either a `files` pattern or a file pattern The latter reads better here, since the key name is already mentioned.
This is allowed, but unlikely.
Addresses some of #249
Implements the following rules: