Warning: Dangling Javadoc comment

末鹿安然 提交于 2020-07-04 23:31:50

问题


Since I updated my Android Studio (2.3.1) and build tools (2.3.1), I'm getting warning,

Warning: Dangling Javadoc comment

for comments like,

/** set name with format, {@Link FORMAT_NAME} **/
setNameText(getFormattedName(FORMAT_NAME));

As you can see, I use javadoc style comment for linking and others. I'm wondering if there are other comment alternatives that have linking feature.

Thanks.


回答1:


It looks like you are using a Javadoc comment when you call the method setNameText. Javadoc comments are to be inserted above a class declaration, a method declaration, or a field declaration.

If you simply want a comment when calling the method, use the one-line comment: // get formatted name based on {@link FORMAT_NAME}.




回答2:


You are using Javadoc format which starts with /** instead of a block comment format which starts with /* .

To alleviate that warning, always start your comments inside the methods with /* not /**.




回答3:


You may just turn it off in page "File-Settings-Editor-Inspections-Java-Javadoc issues-Dangling Javadoc comment".




回答4:


Just replace "Dangling Javadoc Comment" with block comment.




回答5:


To me it seems like the right place for this comment is alongside method getFormattedName() because your comment explains the functionality of that method not the reason you're calling it.




回答6:


In case it helps someone else, make sure you didn't sneak your JavaDoc between the method/class definition and any annotations you had on that definition.



来源:https://stackoverflow.com/questions/43375177/warning-dangling-javadoc-comment

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!