无法同时满足带有参数注释的 Checkstyle ModifierOrder 和 FinalParameters

Cannot satisfy both Checkstyle ModifierOrder and FinalParameters with parameter annotations

我正在使用 Checkstyle 6.12。我想同时使用这两个模块:

<module name="ModifierOrder"/>
<module name="FinalParameters"/>

我有一个看起来像这样的方法

@GET
@Path("{thingId}")
@Produces(MediaType.TEXT_PLAIN)
public String getThing(
    final @PathParam("thingId") String thingId,
) {
  return "halp meh";
}

如果我 运行 Checkstyle 在此我得到这样的输出:

<checkstyle version="6.12">
  <error line="17" column="13" severity="error" 
      message="'@PathParam' annotation modifier does not precede non-annotation modifiers." 
      source="com.puppycrawl.tools.checkstyle.checks.modifier.ModifierOrderCheck"/>
  ...

如果我去掉final修饰符,还是报错:

<checkstyle version="6.12">
  <error line="17" column="7" severity="error" 
      message="Parameter version should be final." source="com.puppycrawl.tools.checkstyle.checks.FinalParametersCheck"/>

这让我陷入了尴尬的境地,因为我想使用这两者来对我正在编写的代码实施某种代码风格。有没有办法配置 Checkstyle 在这种情况下工作?

正如 awks 指出的那样,在 final 起作用之前移动注释。

@PathParam("thingId") final String thingId 

我之所以没有注意到这一点,是因为当我尝试这样做时,我收到了编译器错误。问题是我在那里重复了两次注释:

@PathParam("thingId") final @PathParam("thingId")