Skip to content

Commit

Permalink
Merge pull request #78 from coreruleset/fix-test-title-formatting
Browse files Browse the repository at this point in the history
fix: better matching of test title
  • Loading branch information
fzipi authored Feb 8, 2023
2 parents 7ac3592 + 01c543e commit 20956b9
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion regex/definitions.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ var RuleIdTestFileNameRegex = regexp.MustCompile(`^(\d{6})(?:\.ya?ml)?$`)

// TestTitleRegex matches any test_title line in test YAML files (test_title: "<title>").
// Everything up to the value of the test title is captured in group 1.
var TestTitleRegex = regexp.MustCompile(`(.*test_title:\s*)"?[^"]+"?\s*$`)
var TestTitleRegex = regexp.MustCompile(`(.*test_title:).*$`)

// DefinitionReferenceRegex matches any reference to a definition.
// The matched reference name will be captured in group 1.
Expand Down
2 changes: 1 addition & 1 deletion util/renumber_tests.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ func (t *TestRenumberer) processYaml(ruleId string, contents []byte) ([]byte, er
matches := regex.TestTitleRegex.FindStringSubmatch(line)
if matches != nil {
index++
line = fmt.Sprint(matches[1], ruleId, "-", index)
line = fmt.Sprint(matches[1], " ", ruleId, "-", index)
}

if _, err := writer.WriteString(line); err != nil {
Expand Down

0 comments on commit 20956b9

Please sign in to comment.