mirror of
https://github.com/github/codeql.git
synced 2026-04-25 08:45:14 +02:00
C#: Extend TestFile instead of separate class
This commit is contained in:
@@ -7,11 +7,7 @@ private import ModelEditor
|
||||
* A class of effectively public callables from source code.
|
||||
*/
|
||||
class PublicEndpointFromSource extends Endpoint {
|
||||
PublicEndpointFromSource() {
|
||||
this.fromSource() and
|
||||
not this.getFile() instanceof TestFile and
|
||||
not this.getFile() instanceof TestSupportFile
|
||||
}
|
||||
PublicEndpointFromSource() { this.fromSource() and not this.getFile() instanceof TestFile }
|
||||
|
||||
override predicate isSource() { this instanceof SourceCallable }
|
||||
|
||||
|
||||
@@ -110,11 +110,9 @@ string supportedType(Endpoint endpoint) {
|
||||
}
|
||||
|
||||
string methodClassification(Call method) {
|
||||
(method.getFile() instanceof TestFile or method.getFile() instanceof TestSupportFile) and
|
||||
result = "test"
|
||||
method.getFile() instanceof TestFile and result = "test"
|
||||
or
|
||||
not method.getFile() instanceof TestFile and
|
||||
not method.getFile() instanceof TestSupportFile and
|
||||
result = "source"
|
||||
}
|
||||
|
||||
@@ -133,9 +131,8 @@ private string qualifiedCallableName(string namespace, string type, Callable c)
|
||||
}
|
||||
|
||||
/** A file that doesn't contain tests itself, but is only used in tests. */
|
||||
class TestSupportFile extends File {
|
||||
class TestSupportFile extends TestFile {
|
||||
TestSupportFile() {
|
||||
not this instanceof TestFile and
|
||||
this.getAbsolutePath().matches(["%/test/%", "%/tests/%"]) and
|
||||
not this.getAbsolutePath().matches("%/ql/test/%") // allows our test cases to work
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user