-
Notifications
You must be signed in to change notification settings - Fork 2k
Expand file tree
/
Copy pathXmldocMissingException.ql
More file actions
26 lines (24 loc) · 1.13 KB
/
XmldocMissingException.ql
File metadata and controls
26 lines (24 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
/**
* @name Missing documentation for exception
* @description Exceptions thrown by the method should be documented using '<exception cref="..."> </exception>' tags.
* Ensure that the correct type of the exception is given in the 'cref' attribute.
* @kind problem
* @problem.severity recommendation
* @precision low
* @id cs/xmldoc/missing-exception
* @tags maintainability
*/
import Documentation
from SourceMethodOrConstructor m, ThrowElement throw, RefType throwType
where declarationHasXmlComment(m)
and m = throw.getEnclosingCallable()
and throwType = throw.getExpr().getType()
and not exists(ExceptionXmlComment comment, int offset, string exceptionName, RefType throwBaseType |
comment = getADeclarationXmlComment(m)
and exceptionName = comment.getCref(offset)
and throwType.getABaseType*() = throwBaseType
and (throwBaseType.hasName(exceptionName) or throwBaseType.hasQualifiedName(exceptionName))
// and comment.hasBody(offset) // Too slow
)
and not getADeclarationXmlComment(m) instanceof InheritDocXmlComment
select m, "Exception $@ should be documented.", throw, throw.getExpr().getType().getName()