Skip to content

Commit 7422281

Browse files
owen-mcmbg
authored andcommitted
Improve Aliases test
Restricting to alias types in the source code stops the results from changing when the standard library changes. Using `pp()` instead of `getName` lets us see the results where the underlying type doesn't have a name.
1 parent c7a5f33 commit 7422281

File tree

2 files changed

+5
-15
lines changed

2 files changed

+5
-15
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,4 @@
11
| github.com/github/codeql-go/ql/test/library-tests/semmle/go/Types.FirstAlias | string | string |
2+
| github.com/github/codeql-go/ql/test/library-tests/semmle/go/Types.GenericSignatureAlias | github.com/github/codeql-go/ql/test/library-tests/semmle/go/Types.GenericSignature | func(T) T |
23
| github.com/github/codeql-go/ql/test/library-tests/semmle/go/Types.SecondAlias | github.com/github/codeql-go/ql/test/library-tests/semmle/go/Types.FirstAlias | string |
3-
| internal/reflectlite.Kind | internal/abi.Kind | uint8 |
4-
| internal/reflectlite.nameOff | internal/abi.NameOff | int32 |
5-
| internal/reflectlite.textOff | internal/abi.TextOff | int32 |
6-
| internal/reflectlite.typeOff | internal/abi.TypeOff | int32 |
7-
| os.FileMode | io/fs.FileMode | uint32 |
8-
| os.syscallErrorType | syscall.Errno | uintptr |
9-
| reflect.aNameOff | internal/abi.NameOff | int32 |
10-
| reflect.aTextOff | internal/abi.TextOff | int32 |
11-
| reflect.aTypeOff | internal/abi.TypeOff | int32 |
12-
| runtime.nameOff | internal/abi.NameOff | int32 |
13-
| runtime.textOff | internal/abi.TextOff | int32 |
14-
| runtime.typeOff | internal/abi.TypeOff | int32 |
4+
| github.com/github/codeql-go/ql/test/library-tests/semmle/go/Types.TypeAlias | github.com/github/codeql-go/ql/test/library-tests/semmle/go/Types.GenericArray | [10]T |
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import go
22

33
string getQualifiedNameIfExists(Type t) {
4-
if exists(t.getQualifiedName()) then result = t.getQualifiedName() else result = t.getName()
4+
if exists(t.getQualifiedName()) then result = t.getQualifiedName() else result = t.pp()
55
}
66

7-
from AliasType at
8-
where at.hasLocationInfo(_, _, _, _, _)
7+
from AliasType at, string filepath
8+
where at.hasLocationInfo(filepath, _, _, _, _) and filepath != ""
99
select getQualifiedNameIfExists(at), getQualifiedNameIfExists(at.getRhs()),
1010
getQualifiedNameIfExists(at.getUnderlyingType())

0 commit comments

Comments
 (0)