checkstyle 正则表达式不起作用
checkstyle regex is not working
此正则表达式应找到 java 类 没有“@Configuration”字词和多个“@Inject”字词。在 java Matcher 中有效,但在 checkstyle 中无效。
<module name="RegexpMultiline">
<property name="format" value="(?s)((?!@Configuration).)*@Inject.*@Inject.*"/>
</module>
在此示例中,结果为假,但如果您从目标文本中删除 @Configuration
,则结果为真 - 很好。 Checkstyle 始终生成 true。
RegexpMulitiline
检查基于 find()
, see checks/regexp/MultilineDetector.java#L95
.
事实上,您的示例显示有 Find
结果(虽然没有 Match
)。您需要将您的模式调整为 return 也不需要 Find
.
此正则表达式应找到 java 类 没有“@Configuration”字词和多个“@Inject”字词。在 java Matcher 中有效,但在 checkstyle 中无效。
<module name="RegexpMultiline">
<property name="format" value="(?s)((?!@Configuration).)*@Inject.*@Inject.*"/>
</module>
在此示例中,结果为假,但如果您从目标文本中删除 @Configuration
,则结果为真 - 很好。 Checkstyle 始终生成 true。
RegexpMulitiline
检查基于 find()
, see checks/regexp/MultilineDetector.java#L95
.
事实上,您的示例显示有 Find
结果(虽然没有 Match
)。您需要将您的模式调整为 return 也不需要 Find
.