【问题标题】:Checkstyle not detecting @throws tagCheckstyle 未检测到 @throws 标签
【发布时间】:2015-06-09 17:45:08
【问题描述】:

Checkstyle 一直给我这个错误:

RemoteException 的预期 @throws 标记

这是我的 javadoc cmets 和第一行方法:

   /**
     * Inits the filter
     *
     * @throws RemoteException if there is an issue
     */

    public void init() throws RemoteException {

【问题讨论】:

  • 请分享您用于运行 Checkstyle 的配置。

标签: java javadoc checkstyle


【解决方案1】:

使用
"* @throws IOException - IOException" 而不仅仅是
"* @throws IOException" 为我工作。

希望这会有所帮助。

【讨论】:

    【解决方案2】:

    真的希望这对某人有所帮助:

    /*
    * @throws SomeExceptionPresentOnImports             some text
    * @throws com.myorg.SomeExceptionPresentOnImports1  some text
    */
    

    两者都被报告为错误

    但如果您删除完全限定名称,它不会抱怨。

    /*
    * @throws SomeExceptionPresentOnImports   some text
    * @throws SomeExceptionPresentOnImports1  some text
    */
    

    【讨论】:

      【解决方案3】:

      对我有用的一个较晚的答案是在 javaDoc 注释中的异常之后添加一个额外的空格:

          /**
           * ...... 
           * @throws DummyException (notice the extra space in this line)
           * ......
           */
      

      【讨论】:

        【解决方案4】:

        如果您没有为异常添加描述,请尝试添加它。 这对我有用!

        【讨论】:

          【解决方案5】:

          我遇到了同样的问题。我最终修改了我的 checkstyle 配置文件:

          <module name="JavadocMethod">
            <property name="allowMissingThrowsTags" value="true"/>
          </module>
          

          【讨论】:

            猜你喜欢
            • 1970-01-01
            • 2018-04-13
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 2021-07-20
            • 2019-07-09
            • 1970-01-01
            • 1970-01-01
            相关资源
            最近更新 更多