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: check files key in track-level config #435

Merged
merged 44 commits into from
Oct 13, 2021

Commits on Oct 5, 2021

  1. Configuration menu
    Copy the full SHA
    9f50c4d View commit details
    Browse the repository at this point in the history

Commits on Oct 6, 2021

  1. Add more tests

    bobtfish committed Oct 6, 2021
    Configuration menu
    Copy the full SHA
    dc240cc View commit details
    Browse the repository at this point in the history
  2. Use a HashSet

    bobtfish committed Oct 6, 2021
    Configuration menu
    Copy the full SHA
    2e82742 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    82ac0da View commit details
    Browse the repository at this point in the history

Commits on Oct 7, 2021

  1. tests(lint): prefer a check block

    This is more consistent with the test layout in the `isFilesPattern`
    suite, and elsewhere in this file.
    ee7 committed Oct 7, 2021
    Configuration menu
    Copy the full SHA
    48e99ce View commit details
    Browse the repository at this point in the history
  2. tests(lint): prefer method call syntax for len

    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.
    ee7 committed Oct 7, 2021
    Configuration menu
    Copy the full SHA
    4085ca0 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    fe82c4f View commit details
    Browse the repository at this point in the history
  4. tests(lint): bikeshed test name

    Before:
      no placeholder
      with placeholder
      multiple placeholders
    
    After:
      no placeholder
      one placeholder
      multiple placeholders
    ee7 committed Oct 7, 2021
    Configuration menu
    Copy the full SHA
    a12bf22 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    8a89d84 View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    c793924 View commit details
    Browse the repository at this point in the history
  7. lint(validators): fix IndexDefect

    Previously, an IndexDefect was raised for an input string that ends with
    the % character.
    ee7 committed Oct 7, 2021
    Configuration menu
    Copy the full SHA
    8432a61 View commit details
    Browse the repository at this point in the history
  8. lint(validators): group the mutable globals

    Let's put both these variables close to the `isString` proc that uses
    them.
    ee7 committed Oct 7, 2021
    Configuration menu
    Copy the full SHA
    94400e2 View commit details
    Browse the repository at this point in the history
  9. Configuration menu
    Copy the full SHA
    fbf5faf View commit details
    Browse the repository at this point in the history
  10. lint(validators): fix long line

    Appease `nimpretty`.
    ee7 committed Oct 7, 2021
    Configuration menu
    Copy the full SHA
    61f6692 View commit details
    Browse the repository at this point in the history
  11. lint(validators): prefer notin

    I think this reads more naturally, and we've tended to use this style
    elsewhere.
    ee7 committed Oct 7, 2021
    Configuration menu
    Copy the full SHA
    e5385eb View commit details
    Browse the repository at this point in the history
  12. lint(validators): move global into proc

    This makes it obvious that `filesPatterns` isn't used elsewhere.
    ee7 committed Oct 7, 2021
    Configuration menu
    Copy the full SHA
    5041aaa View commit details
    Browse the repository at this point in the history
  13. lint(validators): s/placeholder/ph

    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
    ee7 committed Oct 7, 2021
    Configuration menu
    Copy the full SHA
    59317b5 View commit details
    Browse the repository at this point in the history
  14. lint(validators): optimize extractPlaceholders

    The Nim compiler doesn't optimize the previous pattern.
    
    The recommended ways to write it are these:
    
        foo.add bar
        foo &= bar
    ee7 committed Oct 7, 2021
    Configuration menu
    Copy the full SHA
    0273683 View commit details
    Browse the repository at this point in the history
  15. lint(validators): prefer let

    This makes it obvious that we don't mutate `c`.
    ee7 committed Oct 7, 2021
    Configuration menu
    Copy the full SHA
    41d31f2 View commit details
    Browse the repository at this point in the history
  16. lint(validators): rename parameter

    This is more consistent with the name of the parameter in
    `isFilesPattern`, and our code elsewhere.
    ee7 committed Oct 7, 2021
    Configuration menu
    Copy the full SHA
    817f67a View commit details
    Browse the repository at this point in the history
  17. lint(validators): prefer setLen

    ee7 committed Oct 7, 2021
    Configuration menu
    Copy the full SHA
    8a80087 View commit details
    Browse the repository at this point in the history
  18. Configuration menu
    Copy the full SHA
    3ffce9e View commit details
    Browse the repository at this point in the history
  19. tests(lint): add tests

    ee7 committed Oct 7, 2021
    Configuration menu
    Copy the full SHA
    51dcf9b View commit details
    Browse the repository at this point in the history

Commits on Oct 8, 2021

  1. lint(validators): make iterator private

    This was used neither in the configlet codebase, nor the tests.
    ee7 committed Oct 8, 2021
    Configuration menu
    Copy the full SHA
    9975b0f View commit details
    Browse the repository at this point in the history
  2. tests(lint): use seq comparison

    Probably more readable.
    ee7 committed Oct 8, 2021
    Configuration menu
    Copy the full SHA
    0435e44 View commit details
    Browse the repository at this point in the history
  3. lint(track_config): tweak indentation style

    I don't have a strong preference for this indentation style, but it's
    what we've used elsewhere.
    ee7 committed Oct 8, 2021
    Configuration menu
    Copy the full SHA
    e9c1d44 View commit details
    Browse the repository at this point in the history
  4. lint(track_config): tweak hasObject use

    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.
    ee7 committed Oct 8, 2021
    Configuration menu
    Copy the full SHA
    6df6fe6 View commit details
    Browse the repository at this point in the history
  5. lint(validators): prefer func

    ee7 committed Oct 8, 2021
    Configuration menu
    Copy the full SHA
    f3b544c View commit details
    Browse the repository at this point in the history
  6. move testing-only extractPlaceholders procedure

    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.
    ee7 committed Oct 8, 2021
    Configuration menu
    Copy the full SHA
    9ea0422 View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    8ffd252 View commit details
    Browse the repository at this point in the history
  8. tests(lint): move a test case

    This test case used 3 placeholder characters, not 2.
    ee7 committed Oct 8, 2021
    Configuration menu
    Copy the full SHA
    c889846 View commit details
    Browse the repository at this point in the history
  9. tests(lint): improve comments

    ee7 committed Oct 8, 2021
    Configuration menu
    Copy the full SHA
    d7b61d3 View commit details
    Browse the repository at this point in the history

Commits on Oct 12, 2021

  1. Revert "lint(track_config): tweak hasObject use"

    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
    ee7 committed Oct 12, 2021
    Configuration menu
    Copy the full SHA
    8b6e9cc View commit details
    Browse the repository at this point in the history
  2. lint(validators): add warning for possible bad placeholder usage

    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.
    ee7 committed Oct 12, 2021
    Configuration menu
    Copy the full SHA
    60e26ad View commit details
    Browse the repository at this point in the history
  3. tests(lint): check multiple uses of same placeholder

    And the (unlikely) use of 3 placeholders.
    ee7 committed Oct 12, 2021
    Configuration menu
    Copy the full SHA
    b5f8033 View commit details
    Browse the repository at this point in the history
  4. lint(validators): remove final . from error msg

    We omitted these elsewhere.
    ee7 committed Oct 12, 2021
    Configuration menu
    Copy the full SHA
    a1e8efd View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    fe72242 View commit details
    Browse the repository at this point in the history
  6. lint(validators): specify valid placeholders only once

    Note that the string is still set at compile-time.
    
    The func is a bit long - oh well.
    ee7 committed Oct 12, 2021
    Configuration menu
    Copy the full SHA
    24a42ba View commit details
    Browse the repository at this point in the history
  7. lint(validators): return false quicker

    This better communicates that `extractPlaceholders` isn't printing error
    messages, so we don't need to iterate over every placeholder.
    ee7 committed Oct 12, 2021
    Configuration menu
    Copy the full SHA
    60267c4 View commit details
    Browse the repository at this point in the history
  8. Configuration menu
    Copy the full SHA
    99ae34d View commit details
    Browse the repository at this point in the history
  9. Configuration menu
    Copy the full SHA
    7d7cabd View commit details
    Browse the repository at this point in the history

Commits on Oct 13, 2021

  1. lint(validators): use "patterns" and "placeholders" consistently

    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`)
    ee7 committed Oct 13, 2021
    Configuration menu
    Copy the full SHA
    faffd0f View commit details
    Browse the repository at this point in the history
  2. lint(validators): nitpick "files pattern"

    "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.
    ee7 committed Oct 13, 2021
    Configuration menu
    Copy the full SHA
    9febbcd View commit details
    Browse the repository at this point in the history
  3. tests(lint): test multiple placeholders that are different

    This is allowed, but unlikely.
    ee7 committed Oct 13, 2021
    Configuration menu
    Copy the full SHA
    01a0c18 View commit details
    Browse the repository at this point in the history