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

Fix static check warning: not calling regexp.Match in a loop #324

Merged
merged 3 commits into from
Apr 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion result_set.go
Original file line number Diff line number Diff line change
Expand Up @@ -1352,6 +1352,10 @@ func (res ResultSet) MakeDotGraphByStruct() string {
// generate profiling data for both Row and TCK formats.
func MakeProfilingData(planNodeDesc *graph.PlanNodeDescription, isTckFmt bool) string {
var profileArr []string
re, err := regexp.Compile(`^[^{(\[]\w+`)
if err != nil {
panic(err)
}
for i, profile := range planNodeDesc.GetProfiles() {
var statArr []string
statArr = append(statArr, fmt.Sprintf("\"version\":%d", i))
Expand All @@ -1363,7 +1367,7 @@ func MakeProfilingData(planNodeDesc *graph.PlanNodeDescription, isTckFmt bool) s
}
for k, v := range profile.GetOtherStats() {
s := string(v)
if matched, err := regexp.Match(`^[^{(\[]\w+`, v); err == nil && matched {
if matched := re.Match(v); matched {
if !strings.HasPrefix(s, "\"") {
s = fmt.Sprintf("\"%s", s)
}
Expand Down
Loading