【发布时间】:2019-10-13 23:49:07
【问题描述】:
如果您打开一个枚举,并且既不涵盖所有情况也不提供默认值,则获得编译器警告很有用。该站点上的其他答案表明 javac 应该提供这样的警告。
我正在使用 Maven,并已将以下内容添加到 pom.xml 以尝试启用所有警告:
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<compilerArgs>
<arg>-Xlint:all</arg>
</compilerArgs>
<showDeprecation>true</showDeprecation>
<showWarnings>true</showWarnings>
</configuration>
</plugin>
但是编译器仍然对我的代码中的非详尽 switch 语句保持沉默。我可以设置其他标志来启用此类警告吗?
【问题讨论】:
-
为什么不在 maven 中集成 SonarLint/Qube。
-
值得一提的是您正在使用的 Java 和 Maven 版本,当然还有示例代码,如果能够成为重现错误的问题的一部分。
标签: java maven switch-statement compiler-warnings