Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
lint: Check for README presence
Browse files Browse the repository at this point in the history
After exercism/meta#15, READMEs are to be
generated and placed into each track's exercise implementation
directory.

My (unsubstantiated) assumption is that they will be required to be
present after Nextercism, as we don't want to keep generating READMEs on
the fly.

If this assumption is correct, it seems necessary to check that READMEs
are present on all exercises.

With the attached fixture change and attached test changes:

* The example test would fail without the attached code change.
* The unit test in `lint_test.go` testing against `fixtures/numbers`
  actually does not fail, because there are other reasons for the track
  to be invalid, so the attached code change was not necessary. This
  points to the unit test being too coarse, but this is a discussion for
  another day. For now, the example test suffices.

Closes exercism/discussions#200
Closes exercism/configlet#86
Peter Tseng committed Oct 14, 2017

Unverified

This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
1 parent e7c3d0a commit c06ef74
Showing 5 changed files with 30 additions and 0 deletions.
23 changes: 23 additions & 0 deletions cmd/lint.go
Original file line number Diff line number Diff line change
@@ -93,6 +93,10 @@ func lintTrack(path string) bool {
check: missingSolution,
msg: "The implementation for '%v' is missing an example solution.",
},
{
check: missingReadme,
msg: "The implementation for '%v' is missing a README.",
},
{
check: missingTestSuite,
msg: "The implementation for '%v' is missing a test suite.",
@@ -201,6 +205,25 @@ func missingSolution(t track.Track) []string {
return slugs
}

func missingReadme(t track.Track) []string {
readmes := map[string]bool{}
for _, exercise := range t.Exercises {
readmes[exercise.Slug] = exercise.HasReadme()
}
// Don't complain about missing readmes in foregone exercises.
for _, slug := range t.Config.ForegoneSlugs {
readmes[slug] = true
}

slugs := []string{}
for slug, ok := range readmes {
if !ok {
slugs = append(slugs, slug)
}
}
return slugs
}

func missingTestSuite(t track.Track) []string {
tests := map[string]bool{}
for _, exercise := range t.Exercises {
1 change: 1 addition & 0 deletions cmd/lint_example_test.go
Original file line number Diff line number Diff line change
@@ -17,6 +17,7 @@ func ExampleLint() {
// Output:
// -> An exercise with slug 'bajillion' is referenced in config.json, but no implementation was found.
// -> The implementation for 'three' is missing an example solution.
// -> The implementation for 'four' is missing a README.
// -> The implementation for 'two' is missing a test suite.
// -> The exercise 'one' was found in config.json, but does not have a UUID.
// -> An implementation for 'zero' was found, but config.json specifies that it should be foregone (not implemented).
6 changes: 6 additions & 0 deletions fixtures/numbers/config.json
Original file line number Diff line number Diff line change
@@ -23,6 +23,12 @@
"topics": [],
"difficulty": 1
},
{
"uuid": "444",
"slug": "four",
"topics": [],
"difficulty": 1
},
{
"uuid": "ddd",
"slug": "bajillion",
Empty file.
Empty file.

0 comments on commit c06ef74

Please sign in to comment.