Skip to content

Commit 2180f4b

Browse files
committed
fix: update type for validation phase
1 parent dda33d7 commit 2180f4b

File tree

2 files changed

+7
-24
lines changed

2 files changed

+7
-24
lines changed

cmd/readmevalidation/errors.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ type validationPhaseError struct {
1414
var _ error = validationPhaseError{}
1515

1616
func (vpe validationPhaseError) Error() string {
17-
msg := fmt.Sprintf("Error during %q phase of README validation:", vpe.phase.String())
17+
msg := fmt.Sprintf("Error during %q phase of README validation:", vpe.phase)
1818
for _, e := range vpe.errors {
1919
msg += fmt.Sprintf("\n- %v", e)
2020
}

cmd/readmevalidation/readmefiles.go

Lines changed: 6 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -151,45 +151,28 @@ func validateReadmeBody(body string) []error {
151151
// validationPhase represents a specific phase during README validation. It is
152152
// expected that each phase is discrete, and errors during one will prevent a
153153
// future phase from starting.
154-
type validationPhase int
154+
type validationPhase string
155155

156156
const (
157157
// validationPhaseFileStructureValidation indicates when the entire Registry
158158
// directory is being verified for having all files be placed in the file
159159
// system as expected.
160-
validationPhaseFileStructureValidation validationPhase = iota
160+
validationPhaseFileStructureValidation validationPhase = "File structure validation"
161161

162162
// validationPhaseFileLoad indicates when README files are being read from
163163
// the file system
164-
validationPhaseFileLoad
164+
validationPhaseFileLoad = "Filesystem reading"
165165

166166
// validationPhaseReadmeParsing indicates when a README's frontmatter is
167167
// being parsed as YAML. This phase does not include YAML validation.
168-
validationPhaseReadmeParsing
168+
validationPhaseReadmeParsing = "README parsing"
169169

170170
// validationPhaseReadmeValidation indicates when a README's frontmatter is
171171
// being validated as proper YAML with expected keys.
172-
validationPhaseReadmeValidation
172+
validationPhaseReadmeValidation = "README validation"
173173

174174
// validationPhaseAssetCrossReference indicates when a README's frontmatter
175175
// is having all its relative URLs be validated for whether they point to
176176
// valid resources.
177-
validationPhaseAssetCrossReference
177+
validationPhaseAssetCrossReference = "Cross-referencing relative asset URLs"
178178
)
179-
180-
func (p validationPhase) String() string {
181-
switch p {
182-
case validationPhaseFileStructureValidation:
183-
return "File structure validation"
184-
case validationPhaseFileLoad:
185-
return "Filesystem reading"
186-
case validationPhaseReadmeParsing:
187-
return "README parsing"
188-
case validationPhaseReadmeValidation:
189-
return "README validation"
190-
case validationPhaseAssetCrossReference:
191-
return "Cross-referencing relative asset URLs"
192-
default:
193-
return fmt.Sprintf("Unknown validation phase: %d", p)
194-
}
195-
}

0 commit comments

Comments
 (0)