codeql icon indicating copy to clipboard operation
codeql copied to clipboard

Java: `getNumberOfCommentLines` and `getNumberOfLinesOfCode` should only exist for supported classes

Open Marcono1234 opened this issue 3 years ago • 1 comments
trafficstars

The predicates getNumberOfCommentLines() and getNumberOfLinesOfCode() are currently defined for Top, however they only seem to have results for the following CodeQL classes (list might be incomplete):

  • XMLFile
  • CompilationUnit
  • Package
  • Class
  • Callable
  • some weird element which has getPrimaryQlClasses() = "???", getAQlClass() = "Top" and which has no location (they seem to be duplicating some of the elements listed above, at least XMLFile)

This can be quite confusing, for example when you try to use the predicates for Stmt (or specifically for BlockStmt). Maybe it would therefore be good to move the predicate to the classes where they actually work, or at least clearly mention in the documentation that these predicates do not work for most elements.

Marcono1234 avatar Aug 28 '22 18:08 Marcono1234

Thank you for raising this - this definitely sounds like something to improve. We'll try to have a look when time permits.

aschackmull avatar Aug 31 '22 07:08 aschackmull