github / github/codeql

Java: Deprecate and remove Element::getDoc

未关闭
#5,320 2 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
question
主要语言
CodeQL
星标
10.1k
派生
2.1k
平均合并
2 天 15 小时
30 天内合并 PR
141

描述

`Element::getDoc` only performs an implicit cast of `this`:
https://github.com/github/codeql/blob/f9973d10aea9c550d91f6607b7cfdd2f543d64ee/java/ql/src/semmle/code/java/Element.qll#L42-L43

- This is probably redundant because you can instead write a cast `element.(Document) ...`
- It is irritating because it suggests that every `Element` can be 'converted' to `Document`, which is not the case
- It causes irritating error messages when used on types which cannot be cast to `Document`:
![Error message screenshot](https://user-images.githubusercontent.com/11685886/109879540-fba75f00-7c75-11eb-86cd-b2775019dc81.png)

Therefore it might be good to deprecate and remove the predicate.

Edit: `Package` is not a good example for an `Element` which does not extend `Document` since it should support documentation, see #5288. Though there are other `Element` subclasses such as `Import` or `Modifier` which cannot be documented in Java.

Relates to #3705

贡献指南

打开贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。