Skip to content

Commit 117e330

Browse files
committed
Merge branch 'main' into models1
2 parents 4281fe7 + 3debd1a commit 117e330

File tree

30 files changed

+314
-76
lines changed

30 files changed

+314
-76
lines changed

cpp/ql/src/CHANGELOG.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
### Minor Analysis Improvements
1313

14-
* Added flow model for the following libraries: `madler/zlib`, `google/brotli`, `libidn/libidn2`, `libssh2/libssh2/`, `nghttp2/nghttp2`, `libuv/libuv/`, and `curl/curl`. This may result in more alerts when running queries on codebases that use these libraries.
14+
* Added flow models for the following libraries: `madler/zlib`, `google/brotli`, `libidn/libidn2`, `libssh2/libssh2`, `nghttp2/nghttp2`, `libuv/libuv`, and `curl/curl`. This may result in more alerts when running queries on codebases that use these libraries.
1515

1616
## 1.4.2
1717

@@ -21,7 +21,7 @@ No user-facing changes.
2121

2222
### Minor Analysis Improvements
2323

24-
* Added flow model for the `SQLite` and `OpenSSL` libraries. This may result in more alerts when running queries on codebases that use these libraries.
24+
* Added flow models for the `SQLite` and `OpenSSL` libraries. This may result in more alerts when running queries on codebases that use these libraries.
2525

2626
## 1.4.0
2727

cpp/ql/src/change-notes/released/1.4.1.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
### Minor Analysis Improvements
44

5-
* Added flow model for the `SQLite` and `OpenSSL` libraries. This may result in more alerts when running queries on codebases that use these libraries.
5+
* Added flow models for the `SQLite` and `OpenSSL` libraries. This may result in more alerts when running queries on codebases that use these libraries.

cpp/ql/src/change-notes/released/1.4.3.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
### Minor Analysis Improvements
44

5-
* Added flow model for the following libraries: `madler/zlib`, `google/brotli`, `libidn/libidn2`, `libssh2/libssh2/`, `nghttp2/nghttp2`, `libuv/libuv/`, and `curl/curl`. This may result in more alerts when running queries on codebases that use these libraries.
5+
* Added flow models for the following libraries: `madler/zlib`, `google/brotli`, `libidn/libidn2`, `libssh2/libssh2`, `nghttp2/nghttp2`, `libuv/libuv`, and `curl/curl`. This may result in more alerts when running queries on codebases that use these libraries.

docs/codeql/reusables/download-github-database.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ GitHub stores CodeQL databases for over 200,000 repos on GitHub.com, which you c
33
You can check if a repository has any CodeQL databases available for download using the ``/repos/<owner>/<repo>/code-scanning/codeql/databases`` endpoint.
44
For example, to check for CodeQL databases using the `GitHub CLI <https://cli.github.com/manual/gh_api>`__ you would run::
55

6-
gh api /repos/<owner>/<repo>/code-scanning/codeql/databases
6+
gh api repos/<owner>/<repo>/code-scanning/codeql/databases
77

88
This command returns information about any CodeQL databases that are available for a repository, including the language the database represents, and when the database was last updated. If no CodeQL databases are available, the response is empty.
99

1010
When you have confirmed that a CodeQL database exists for the language you are interested in, you can download it using the following command::
1111

12-
gh api /repos/<owner>/<repo>/code-scanning/codeql/databases/<language> -H 'Accept: application/zip' > path/to/local/database.zip
12+
gh api repos/<owner>/<repo>/code-scanning/codeql/databases/<language> -H 'Accept: application/zip' > path/to/local/database.zip
1313

1414
For more information, see the documentation for the `Get CodeQL database <https://docs.github.com/en/rest/code-scanning#get-a-codeql-database-for-a-repository>`__ endpoint in the GitHub REST API documentation.

go/extractor/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ toolchain go1.24.0
99
// when adding or removing dependencies, run
1010
// bazel mod tidy
1111
require (
12-
golang.org/x/mod v0.25.0
12+
golang.org/x/mod v0.26.0
1313
golang.org/x/tools v0.34.0
1414
)
1515

go/extractor/go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
22
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
3-
golang.org/x/mod v0.25.0 h1:n7a+ZbQKQA/Ysbyb0/6IbB1H/X41mKgbhfv7AfG/44w=
4-
golang.org/x/mod v0.25.0/go.mod h1:IXM97Txy2VM4PJ3gI61r1YEk/gAj6zAHN3AdZt6S9Ww=
3+
golang.org/x/mod v0.26.0 h1:EGMPT//Ezu+ylkCijjPc+f4Aih7sZvaAr+O3EHBxvZg=
4+
golang.org/x/mod v0.26.0/go.mod h1:/j6NAhSk8iQ723BGAUyoAcn7SlD7s15Dp9Nd/SfeaFQ=
55
golang.org/x/sync v0.15.0 h1:KWH3jNZsfyT6xfAfKiz6MRNmd46ByHDYaZ7KSkCtdW8=
66
golang.org/x/sync v0.15.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=
77
golang.org/x/tools v0.34.0 h1:qIpSLOxeCYGg9TrcJokLBG4KFA6d795g0xkBkiESGlo=

java/ql/integration-tests/java/query-suite/java-code-quality-extended.qls.expected

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ ql/java/ql/src/Compatibility/JDK9/UnderscoreIdentifier.ql
66
ql/java/ql/src/DeadCode/UselessParameter.ql
77
ql/java/ql/src/Language Abuse/EmptyMethod.ql
88
ql/java/ql/src/Language Abuse/IterableIterator.ql
9+
ql/java/ql/src/Language Abuse/LabelInSwitch.ql
910
ql/java/ql/src/Language Abuse/TypeVariableHidesType.ql
1011
ql/java/ql/src/Language Abuse/UselessNullCheck.ql
1112
ql/java/ql/src/Language Abuse/UselessTypeTest.ql

java/ql/integration-tests/java/query-suite/java-code-quality.qls.expected

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ ql/java/ql/src/Compatibility/JDK9/JdkInternalAccess.ql
55
ql/java/ql/src/Compatibility/JDK9/UnderscoreIdentifier.ql
66
ql/java/ql/src/DeadCode/UselessParameter.ql
77
ql/java/ql/src/Language Abuse/IterableIterator.ql
8+
ql/java/ql/src/Language Abuse/LabelInSwitch.ql
89
ql/java/ql/src/Language Abuse/UselessNullCheck.ql
910
ql/java/ql/src/Language Abuse/UselessTypeTest.ql
1011
ql/java/ql/src/Language Abuse/WrappedIterator.ql
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
## Overview
2+
3+
Java allows to freely mix `case` labels and ordinary statement labels in the body of
4+
a `switch` statement. However, this is confusing to read and may be the result of a typo.
5+
6+
## Recommendation
7+
8+
Examine the non-`case` labels to see whether they were meant to be `case` labels. If not, consider placing the non-`case` label headed code into a function, and use a function call inline in the `switch` body instead.
9+
10+
## Example
11+
12+
```java
13+
public class Test {
14+
void test_noncase_label_in_switch(int p) {
15+
switch (p) {
16+
case 1: // Compliant
17+
case2: // Non-compliant, likely a typo
18+
break;
19+
case 3:
20+
notcaselabel: // Non-compliant, confusing to read
21+
for (;;) {
22+
break notcaselabel;
23+
}
24+
}
25+
}
26+
}
27+
```
28+
29+
In the example, `case2` is most likely a typo and should be fixed. For the intentional `notcaselabel`, placing the labelled code into a function and then calling that function is more readable.
30+
31+
## References
32+
33+
CodeQL query help for JavaScript and TypeScript - [Non-case label in switch statement](https://codeql.github.com/codeql-query-help/javascript/js-label-in-switch/).
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/**
2+
* @id java/label-in-switch
3+
* @name Non-case label in switch statement
4+
* @description A non-case label appearing in a switch statement
5+
* is confusing to read or may even indicate a bug.
6+
* @previous-id java/label-in-case
7+
* @kind problem
8+
* @precision very-high
9+
* @problem.severity recommendation
10+
* @tags quality
11+
* maintainability
12+
* readability
13+
*/
14+
15+
import java
16+
17+
from LabeledStmt l, SwitchStmt s, string alert
18+
where
19+
l = s.getAStmt+() and
20+
if exists(JumpStmt jump | jump.getTargetLabel() = l)
21+
then alert = "Confusing non-case label in switch statement."
22+
else
23+
alert =
24+
"Possibly erroneous non-case label in switch statement. The case keyword might be missing."
25+
select l, alert

0 commit comments

Comments
 (0)