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

Check that linked issues are open #3277

Merged
merged 35 commits into from
Oct 17, 2023
Merged
Changes from 3 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
3241e6a
add: issue url check open or closed
Aug 29, 2023
e324aae
fix: lint check
Sep 1, 2023
40b39bc
fix: lint check
Sep 1, 2023
628fb00
fix: added comments above methods
Sep 1, 2023
5a82ef4
Merge branch 'main' into checkcomment-issueurl
Sep 25, 2023
891f15d
add: chjeck open issue check initial draft
Sep 25, 2023
46bccfb
remove: env get token
Sep 25, 2023
634bd9c
fix: create a api url
Sep 27, 2023
ba11db9
fix: ran task init fmt
Sep 27, 2023
d8fc961
fix: ran task init fmt
Sep 27, 2023
aef36fe
fix: resolve conflicts
Sep 27, 2023
13098b0
sdd: test for URL check
Sep 29, 2023
7f32530
add: test for URL check
Sep 29, 2023
54c8d48
Merge branch 'main' into pr/KrishnaSindhur/3277
AlekSi Oct 4, 2023
f982de6
Use newer version
AlekSi Oct 4, 2023
368e023
Update tests
AlekSi Oct 4, 2023
bfb897e
add: test case passed
Oct 4, 2023
ba7f89e
remove: redundant code
Oct 4, 2023
210b550
fix: lint issues
Oct 4, 2023
3b2051e
Merge branch 'main' into checkcomment-issueurl
AlekSi Oct 6, 2023
9b0eb8f
Use `GITHUB_TOKEN` only if available
AlekSi Oct 6, 2023
aebcd95
Fix token permissions
AlekSi Oct 6, 2023
3eee57e
removed: redundant code
Oct 6, 2023
240a938
removed: removed continue
Oct 7, 2023
adc6163
Merge branch 'main' into checkcomment-issueurl
AlekSi Oct 9, 2023
d96a6a3
Merge branch 'main' into pr/KrishnaSindhur/3277
AlekSi Oct 17, 2023
06cad22
Use shared package for GH client
AlekSi Oct 17, 2023
093411a
Update docs
AlekSi Oct 17, 2023
dea56c5
Simplify
AlekSi Oct 17, 2023
c13a4ce
Make tests pass
AlekSi Oct 17, 2023
1ff8f67
Merge branch 'main' into checkcomment-issueurl
AlekSi Oct 17, 2023
64ed193
Merge branch 'main' into checkcomment-issueurl
AlekSi Oct 17, 2023
03b9f90
Merge branch 'main' into checkcomment-issueurl
AlekSi Oct 17, 2023
0dc4445
Debug token
AlekSi Oct 17, 2023
f35022e
Simplify
AlekSi Oct 17, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
30 changes: 28 additions & 2 deletions tools/checkcomments/checkcomments.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package main

import (
"net/http"
"regexp"
"strings"

Expand Down Expand Up @@ -49,8 +50,8 @@ func run(pass *analysis.Pass) (any, error) {
continue
}

if !todoRE.MatchString(c.Text) {
pass.Reportf(c.Pos(), "invalid TODO comment")
if !todoRE.MatchString(c.Text) && isIssueOpen(c.Text) {
pass.Reportf(c.Pos(), "invalid TODO comment and issue is still open")
}
}
}
Expand All @@ -59,3 +60,28 @@ func run(pass *analysis.Pass) (any, error) {

return nil, nil
}

func isIssueOpen(todoText string) bool {
issueURL := getURL(todoText)
if issueURL == "" {
return false
}
resp, err := http.Get(issueURL)
if err != nil {
return false
}
defer resp.Body.Close() //nolint:errcheck // we are only reading it

return resp.StatusCode == http.StatusOK
}

func getURL(todoText string) string {
arrText := strings.Split(todoText, " ")
for _, text := range arrText {
if strings.Contains(text, "https://") {
return text
}
}

return ""
}