Skip to content

Commit 6afc7ad

Browse files
committed
[TT-17507] Refactor Jira issue ID regex to improve efficiency
1 parent 3fd49c4 commit 6afc7ad

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

jira-linter/cmd/linter/main.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,9 +156,10 @@ func (t *basicAuthTransport) RoundTrip(req *http.Request) (*http.Response, error
156156
return http.DefaultTransport.RoundTrip(req)
157157
}
158158

159+
var issueIDRegex = regexp.MustCompile(`(?i)^.*?([A-Z]{1,10}-[0-9]{1,10}).*?$`)
160+
159161
func findIssueID(input string) (string, error) {
160-
re := regexp.MustCompile(`(?i)^.*?([A-Z]{1,10}-[0-9]{1,10}).*?$`)
161-
match := re.FindStringSubmatch(input)
162+
match := issueIDRegex.FindStringSubmatch(input)
162163

163164
if len(match) < 2 {
164165
return "", fmt.Errorf("no valid Jira ticket ID found")

0 commit comments

Comments
 (0)