Skip to content

Commit a52eba0

Browse files
committed
more comments lint fixes
Signed-off-by: Callum Styan <[email protected]>
1 parent 0a6746d commit a52eba0

File tree

6 files changed

+28
-25
lines changed

6 files changed

+28
-25
lines changed

.golangci.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ linters:
3535
settings:
3636
dupl:
3737
threshold: 412
38+
godot:
39+
scope: all
40+
capital: true
3841
exhaustruct:
3942
include:
4043
- httpmw\.\w+

cmd/readmevalidation/coderresources.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ func validateCoderResourceIconURL(iconURL string) []error {
7070

7171
// Would normally be skittish about having relative paths like this, but it
7272
// should be safe because we have guarantees about the structure of the
73-
// repo, and where this logic will run
73+
// repo, and where this logic will run.
7474
isPermittedRelativeURL := strings.HasPrefix(iconURL, "./") ||
7575
strings.HasPrefix(iconURL, "/") ||
7676
strings.HasPrefix(iconURL, "../../../../.icons")
@@ -91,7 +91,7 @@ func validateCoderResourceTags(tags []string) error {
9191

9292
// All of these tags are used for the module/template filter controls in the
9393
// Registry site. Need to make sure they can all be placed in the browser
94-
// URL without issue
94+
// URL without issue.
9595
invalidTags := []string{}
9696
for _, t := range tags {
9797
if t != url.QueryEscape(t) {
@@ -132,7 +132,7 @@ func validateCoderResourceReadmeBody(body string) []error {
132132

133133
// Code assumes that invalid headers would've already been handled by
134134
// the base validation function, so we don't need to check deeper if the
135-
// first line isn't an h1
135+
// first line isn't an h1.
136136
if lineNum == 1 {
137137
if !strings.HasPrefix(nextLine, "# ") {
138138
break
@@ -160,14 +160,14 @@ func validateCoderResourceReadmeBody(body string) []error {
160160
}
161161

162162
// Code assumes that we can treat this case as the end of the "h1
163-
// section" and don't need to process any further lines
163+
// section" and don't need to process any further lines.
164164
if lineNum > 1 && strings.HasPrefix(nextLine, "#") {
165165
break
166166
}
167167

168168
// Code assumes that if we've reached this point, the only other options
169169
// are: (1) empty spaces, (2) paragraphs, (3) HTML, and (4) asset
170-
// references made via [] syntax
170+
// references made via [] syntax.
171171
trimmedLine := strings.TrimSpace(nextLine)
172172
isParagraph := trimmedLine != "" && !strings.HasPrefix(trimmedLine, "![") && !strings.HasPrefix(trimmedLine, "<")
173173
foundParagraph = foundParagraph || isParagraph

cmd/readmevalidation/contributors.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ type contributorProfileFrontmatter struct {
1919
Bio string `yaml:"bio"`
2020
ContributorStatus string `yaml:"status"`
2121
// Script assumes that if avatar URL is nil, the Registry site build step
22-
// will backfill the value with the user's GitHub avatar URL
22+
// will backfill the value with the user's GitHub avatar URL.
2323
AvatarURL *string `yaml:"avatar"`
2424
LinkedinURL *string `yaml:"linkedin"`
2525
WebsiteURL *string `yaml:"website"`
@@ -62,7 +62,7 @@ func validateContributorSupportEmail(email *string) []error {
6262
// Can't 100% validate that this is correct without actually sending
6363
// an email, and especially with some contributors being individual
6464
// developers, we don't want to do that on every single run of the CI
65-
// pipeline. Best we can do is verify the general structure
65+
// pipeline. Best we can do is verify the general structure.
6666
username, server, ok := strings.Cut(*email, "@")
6767
if !ok {
6868
errs = append(errs, xerrors.Errorf("email address %q is missing @ symbol", *email))
@@ -126,7 +126,7 @@ func validateContributorAvatarURL(avatarURL *string) []error {
126126
}
127127

128128
// Have to use .Parse instead of .ParseRequestURI because this is the
129-
// one field that's allowed to be a relative URL
129+
// one field that's allowed to be a relative URL.
130130
if _, err := url.Parse(*avatarURL); err != nil {
131131
errs = append(errs, xerrors.Errorf("URL %q is not a valid relative or absolute URL", *avatarURL))
132132
}
@@ -273,12 +273,12 @@ func aggregateContributorReadmeFiles() ([]readme, error) {
273273

274274
func validateContributorRelativeUrls(contributors map[string]contributorProfileReadme) error {
275275
// This function only validates relative avatar URLs for now, but it can be
276-
// beefed up to validate more in the future
276+
// beefed up to validate more in the future.
277277
errs := []error{}
278278

279279
for _, con := range contributors {
280280
// If the avatar URL is missing, we'll just assume that the Registry
281-
// site build step will take care of filling in the data properly
281+
// site build step will take care of filling in the data properly.
282282
if con.frontmatter.AvatarURL == nil {
283283
continue
284284
}

cmd/readmevalidation/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ func main() {
1616

1717
// If there are fundamental problems with how the repo is structured, we
1818
// can't make any guarantees that any further validations will be relevant
19-
// or accurate
19+
// or accurate.
2020
repoErr := validateRepoStructure()
2121
if repoErr != nil {
2222
log.Println(repoErr)

cmd/readmevalidation/readmefiles.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,15 @@ func separateFrontmatter(readmeText string) (readmeFrontmatter string, readmeBod
4141
continue
4242
}
4343
// Break early if the very first line wasn't a fence, because then we
44-
// know for certain that the README has problems
44+
// know for certain that the README has problems.
4545
if fenceCount == 0 {
4646
break
4747
}
4848

4949
// It should be safe to trim each line of the frontmatter on a per-line
5050
// basis, because there shouldn't be any extra meaning attached to the
5151
// indentation. The same does NOT apply to the README; best we can do is
52-
// gather all the lines, and then trim around it
52+
// gather all the lines, and then trim around it.
5353
if inReadmeBody := fenceCount >= 2; inReadmeBody {
5454
body += nextLine + "\n"
5555
} else {
@@ -79,7 +79,7 @@ func validateReadmeBody(body string) []error {
7979

8080
// If the very first line of the README, there's a risk that the rest of the
8181
// validation logic will break, since we don't have many guarantees about
82-
// how the README is actually structured
82+
// how the README is actually structured.
8383
if !strings.HasPrefix(trimmed, "# ") {
8484
return []error{xerrors.New("README body must start with ATX-style h1 header (i.e., \"# \")")}
8585
}
@@ -95,7 +95,7 @@ func validateReadmeBody(body string) []error {
9595

9696
// Have to check this because a lot of programming languages support #
9797
// comments (including Terraform), and without any context, there's no
98-
// way to tell the difference between a markdown header and code comment
98+
// way to tell the difference between a markdown header and code comment.
9999
if strings.HasPrefix(nextLine, "```") {
100100
isInCodeBlock = !isInCodeBlock
101101
continue
@@ -122,7 +122,7 @@ func validateReadmeBody(body string) []error {
122122
}
123123

124124
// If we have obviously invalid headers, it's not really safe to keep
125-
// proceeding with the rest of the content
125+
// proceeding with the rest of the content.
126126
if nextHeaderLevel == 1 {
127127
errs = append(errs, xerrors.New("READMEs cannot contain more than h1 header"))
128128
break
@@ -134,14 +134,14 @@ func validateReadmeBody(body string) []error {
134134

135135
// This is something we need to enforce for accessibility, not just for
136136
// the Registry website, but also when users are viewing the README
137-
// files in the GitHub web view
137+
// files in the GitHub web view.
138138
if nextHeaderLevel > latestHeaderLevel && nextHeaderLevel != (latestHeaderLevel+1) {
139139
errs = append(errs, xerrors.New("headers are not allowed to increase more than 1 level at a time"))
140140
continue
141141
}
142142

143143
// As long as the above condition passes, there's no problems with
144-
// going up a header level or going down 1+ header levels
144+
// going up a header level or going down 1+ header levels.
145145
latestHeaderLevel = nextHeaderLevel
146146
}
147147

@@ -154,20 +154,20 @@ func validateReadmeBody(body string) []error {
154154
type validationPhase string
155155

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

162-
// validationPhaseFileLoad indicates when README files are being read from
162+
// ValidationPhaseFileLoad indicates when README files are being read from
163163
// the file system.
164164
validationPhaseFileLoad = "Filesystem reading"
165165

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

170-
// validationPhaseAssetCrossReference indicates when a README's frontmatter
170+
// ValidationPhaseAssetCrossReference indicates when a README's frontmatter
171171
// is having all its relative URLs be validated for whether they point to
172172
// valid resources.
173173
validationPhaseAssetCrossReference = "Cross-referencing relative asset URLs"

cmd/readmevalidation/repostructure.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ func validateCoderResourceSubdirectory(dirPath string) []error {
1818
subDir, err := os.Stat(dirPath)
1919
if err != nil {
2020
// It's valid for a specific resource directory not to exist. It's just
21-
// that if it does exist, it must follow specific rules
21+
// that if it does exist, it must follow specific rules.
2222
if !errors.Is(err, os.ErrNotExist) {
2323
errs = append(errs, addFilePathToError(dirPath, err))
2424
}
@@ -39,7 +39,7 @@ func validateCoderResourceSubdirectory(dirPath string) []error {
3939
// The .coder subdirectories are sometimes generated as part of Bun
4040
// tests. These subdirectories will never be committed to the repo, but
4141
// in the off chance that they don't get cleaned up properly, we want to
42-
// skip over them
42+
// skip over them.
4343
if !f.IsDir() || f.Name() == ".coder" {
4444
continue
4545
}
@@ -96,7 +96,7 @@ func validateRegistryDirectory() []error {
9696

9797
for _, f := range files {
9898
// Todo: Decide if there's anything more formal that we want to
99-
// ensure about non-directories scoped to user namespaces
99+
// ensure about non-directories scoped to user namespaces.
100100
if !f.IsDir() {
101101
continue
102102
}

0 commit comments

Comments
 (0)