Skip to content

Commit 89bad8e

Browse files
committed
Factorise the regexp
1 parent 84345fe commit 89bad8e

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

buildSrc/src/main/kotlin/datadog/gradle/plugin/naming/InstrumentationNamingPlugin.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ import java.io.File
2121
* ```
2222
*/
2323
class InstrumentationNamingPlugin : Plugin<Project> {
24+
val versionPattern : Regex = Regex("""\d+\.\d+(\.\d+)?$""")
25+
2426
override fun apply(target: Project) {
2527
val extension = target.extensions.create(
2628
"instrumentationNaming",
@@ -131,7 +133,6 @@ class InstrumentationNamingPlugin : Plugin<Project> {
131133
relativePath: String
132134
): NamingViolation? {
133135
// Rule 1: Module name must end with version pattern (X.Y, X.Y.Z, etc.) or "-common"
134-
val versionPattern = Regex("""\d+\.\d+(\.\d+)?$""")
135136
val endsWithCommon = moduleName.endsWith("-common")
136137
val endsWithVersion = versionPattern.containsMatchIn(moduleName)
137138

@@ -163,7 +164,6 @@ class InstrumentationNamingPlugin : Plugin<Project> {
163164
relativePath: String
164165
): NamingViolation? {
165166
// Rule: Module name must end with version pattern (X.Y, X.Y.Z, etc.) or "-common"
166-
val versionPattern = Regex("""\d+\.\d+(\.\d+)?$""")
167167
val endsWithCommon = moduleName.endsWith("-common")
168168
val endsWithVersion = versionPattern.containsMatchIn(moduleName)
169169

0 commit comments

Comments
 (0)