This repository has been archived by the owner on Mar 22, 2022. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 23
lint: Check for README presence (and supporting commits) #98
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"slug": "missing-readme", | ||
"language": "Missing Readme", | ||
"repository": "https://github.com/exercism/missing-readme", | ||
"active": true, | ||
"exercises": [ | ||
{ | ||
"uuid": "missingmissing", | ||
"slug": "missing-readme", | ||
"topics": [], | ||
"difficulty": 1 | ||
} | ||
] | ||
} |
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ import ( | |
// Exercise is an implementation of an Exercism exercise. | ||
type Exercise struct { | ||
Slug string | ||
ReadmePath string | ||
SolutionPath string | ||
TestSuitePath string | ||
} | ||
|
@@ -31,6 +32,11 @@ func NewExercise(root string, pg PatternGroup) (Exercise, error) { | |
return ex, err | ||
} | ||
|
||
err = setPath(root, "README\\.md", &ex.ReadmePath) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not seeing a need to let this be configurable, so it is not in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Makes sense to me 👍 |
||
if err != nil { | ||
return ex, err | ||
} | ||
|
||
return ex, err | ||
} | ||
|
||
|
@@ -62,6 +68,11 @@ func setPath(root, pattern string, field *string) error { | |
return filepath.Walk(root, walkFn) | ||
} | ||
|
||
// HasReadme checks that an exercise has a README. | ||
func (ex Exercise) HasReadme() bool { | ||
return ex.ReadmePath != "" | ||
} | ||
|
||
// HasTestSuite checks that an exercise has a test suite. | ||
func (ex Exercise) HasTestSuite() bool { | ||
return ex.TestSuitePath != "" | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Might check and only add if non-exist to make it faster for the second iteration since tracks generally will have readmes. And also for foregone, we can delete added keys. In the end, we can iterate smaller map and make a slice without checking.
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 suggestion. There's a couple of lint checks that could benefit from this refactor.
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.
I really was thinking that missingReadme, missingSolution, missingTestSuite should really all be refactored into one function that parameterises over
HasReadme
,IsValid
(what a name...),HasTestSuite
respectively. They're all the same except for that one line, I think. And then this improvement can be applied to them all.