Skip to content

Commit 2285701

Browse files
authored
Merge branch 'main' into ruby/mad-prototype
2 parents e168da4 + f6681f3 commit 2285701

File tree

1,517 files changed

+99758
-83638
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,517 files changed

+99758
-83638
lines changed

.github/workflows/check-qldoc.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: "Check QLdoc coverage"
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- "*/ql/lib/**"
7+
- .github/workflows/check-qldoc.yml
8+
branches:
9+
- main
10+
- "rc/*"
11+
12+
jobs:
13+
qldoc:
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- name: Install CodeQL
18+
run: |
19+
gh extension install github/gh-codeql
20+
gh codeql set-channel nightly
21+
gh codeql version
22+
env:
23+
GITHUB_TOKEN: ${{ github.token }}
24+
25+
- uses: actions/checkout@v2
26+
with:
27+
fetch-depth: 2
28+
29+
- name: Check QLdoc coverage
30+
shell: bash
31+
run: |
32+
EXIT_CODE=0
33+
changed_lib_packs="$(git diff --name-only --diff-filter=ACMRT HEAD^ HEAD | { grep -o '^[a-z]*/ql/lib' || true; } | sort -u)"
34+
for pack_dir in ${changed_lib_packs}; do
35+
lang="${pack_dir%/ql/lib}"
36+
gh codeql generate library-doc-coverage --output="${RUNNER_TEMP}/${lang}-current.txt" --dir="${pack_dir}"
37+
done
38+
git checkout HEAD^
39+
for pack_dir in ${changed_lib_packs}; do
40+
lang="${pack_dir%/ql/lib}"
41+
gh codeql generate library-doc-coverage --output="${RUNNER_TEMP}/${lang}-baseline.txt" --dir="${pack_dir}"
42+
awk -F, '{gsub(/"/,""); if ($4==0 && $6=="public") print "\""$3"\"" }' "${RUNNER_TEMP}/${lang}-current.txt" | sort -u > "${RUNNER_TEMP}/current-undocumented.txt"
43+
awk -F, '{gsub(/"/,""); if ($4==0 && $6=="public") print "\""$3"\"" }' "${RUNNER_TEMP}/${lang}-baseline.txt" | sort -u > "${RUNNER_TEMP}/baseline-undocumented.txt"
44+
UNDOCUMENTED="$(grep -f <(comm -13 "${RUNNER_TEMP}/baseline-undocumented.txt" "${RUNNER_TEMP}/current-undocumented.txt") "${RUNNER_TEMP}/${lang}-current.txt" || true)"
45+
if [ -n "$UNDOCUMENTED" ]; then
46+
echo "$UNDOCUMENTED" | awk -F, '{gsub(/"/,""); print "::warning file='"${pack_dir}"'/"$1",line="$2"::Missing QLdoc for "$5, $3 }'
47+
EXIT_CODE=1
48+
fi
49+
done
50+
exit "${EXIT_CODE}"

.github/workflows/ruby-qltest.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ jobs:
6363
qltest:
6464
runs-on: ubuntu-latest
6565
strategy:
66+
fail-fast: false
6667
matrix:
6768
slice: ["1/2", "2/2"]
6869
steps:

.pre-commit-config.yaml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# See https://pre-commit.com for more information
2+
# See https://pre-commit.com/hooks.html for more hooks
3+
exclude: /test/.*$(?<!\.ql)(?<!\.qll)(?<!\.qlref)
4+
repos:
5+
- repo: https://github.com/pre-commit/pre-commit-hooks
6+
rev: v3.2.0
7+
hooks:
8+
- id: trailing-whitespace
9+
- id: end-of-file-fixer
10+
11+
- repo: local
12+
hooks:
13+
- id: codeql-format
14+
name: Fix QL file formatting
15+
files: \.qll?$
16+
language: system
17+
entry: codeql query format --in-place
18+
19+
- id: sync-files
20+
name: Fix files required to be identical
21+
language: system
22+
entry: python3 config/sync-files.py --latest
23+
pass_filenames: false
24+
25+
- id: qhelp
26+
name: Check query help generation
27+
files: \.qhelp$
28+
language: system
29+
entry: python3 misc/scripts/check-qhelp.py

CONTRIBUTING.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,11 @@ If you have an idea for a query that you would like to share with other CodeQL u
4242

4343
- The queries and libraries must be autoformatted, for example using the "Format Document" command in [CodeQL for Visual Studio Code](https://help.semmle.com/codeql/codeql-for-vscode/procedures/about-codeql-for-vscode.html).
4444

45-
If you prefer, you can use this [pre-commit hook](misc/scripts/pre-commit) that automatically checks whether your files are correctly formatted. See the [pre-commit hook installation guide](docs/pre-commit-hook-setup.md) for instructions on how to install the hook.
45+
If you prefer, you can either:
46+
1. install the [pre-commit framework](https://pre-commit.com/) and install the configured hooks on this repo via `pre-commit install`, or
47+
2. use this [pre-commit hook](misc/scripts/pre-commit) that automatically checks whether your files are correctly formatted.
48+
49+
See the [pre-commit hook installation guide](docs/pre-commit-hook-setup.md) for instructions on the two approaches.
4650

4751
4. **Compilation**
4852

@@ -63,6 +67,6 @@ After the experimental query is merged, we welcome pull requests to improve it.
6367

6468
## Using your personal data
6569

66-
If you contribute to this project, we will record your name and email address (as provided by you with your contributions) as part of the code repositories, which are public. We might also use this information to contact you in relation to your contributions, as well as in the normal course of software development. We also store records of CLA agreements signed in the past, but no longer require contributors to sign a CLA. Under GDPR legislation, we do this on the basis of our legitimate interest in creating the CodeQL product.
70+
If you contribute to this project, we will record your name and email address (as provided by you with your contributions) as part of the code repositories, which are public. We might also use this information to contact you in relation to your contributions, as well as in the normal course of software development. We also store records of CLA agreements signed in the past, but no longer require contributors to sign a CLA. Under GDPR legislation, we do this on the basis of our legitimate interest in creating the CodeQL product.
6771

6872
Please do get in touch (privacy@github.com) if you have any questions about this or our data protection policies.

config/blame-deprecations.mjs

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
import fs from "fs";
2+
import path from "path";
3+
import cp from "child_process";
4+
function* walk(dir) {
5+
for (const file of fs.readdirSync(dir)) {
6+
const filePath = path.join(dir, file);
7+
if (fs.statSync(filePath).isDirectory()) {
8+
yield* walk(filePath);
9+
} else {
10+
yield filePath;
11+
}
12+
}
13+
}
14+
15+
function* deprecatedFiles(dir) {
16+
for (const file of walk(dir)) {
17+
if (file.endsWith(".ql") || file.endsWith(".qll")) {
18+
const contents = fs.readFileSync(file, "utf8");
19+
if (/\sdeprecated\s/.test(contents)) {
20+
yield file;
21+
}
22+
}
23+
}
24+
}
25+
26+
const blameRegExp =
27+
/^(\^?\w+)\s.+\s+(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2} (?:\+|-)\d{4})\s+(\d+)\).*$/;
28+
29+
function* deprecationMessages(dir) {
30+
for (const file of deprecatedFiles(dir)) {
31+
const blame = cp.execFileSync("git", ["blame", "--", file]);
32+
const lines = blame.toString().split("\n");
33+
for (let i = 0; i < lines.length; i++) {
34+
const line = lines[i];
35+
if (line.includes(" deprecated ")) {
36+
try {
37+
const [_, sha, time, lineNumber] = line.match(blameRegExp);
38+
const date = new Date(time);
39+
// check if it's within the last 14 months (a year, plus 2 months for safety, in case a PR was delayed)
40+
if (date.getTime() >= Date.now() - 14 * 31 * 24 * 60 * 60 * 1000) {
41+
continue;
42+
}
43+
const message = `${file}:${lineNumber} was last updated on ${date.getFullYear()}-${date.getMonth()}-${date.getDate()}`;
44+
yield [message, date];
45+
} catch (e) {
46+
console.log(e);
47+
console.log("----");
48+
console.log(line);
49+
console.log("----");
50+
process.exit(0);
51+
}
52+
}
53+
}
54+
}
55+
}
56+
[...deprecationMessages(".")]
57+
.sort((a, b) => a[1].getTime() - b[1].getTime())
58+
.forEach((msg) => console.log(msg[0]));

config/identical-files.json

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,14 @@
7373
"java/ql/lib/semmle/code/java/dataflow/internal/rangeanalysis/SsaReadPositionCommon.qll",
7474
"csharp/ql/lib/semmle/code/csharp/dataflow/internal/rangeanalysis/SsaReadPositionCommon.qll"
7575
],
76+
"Model as Data Generation Java/C# - Utils": [
77+
"java/ql/src/utils/model-generator/ModelGeneratorUtils.qll",
78+
"csharp/ql/src/utils/model-generator/ModelGeneratorUtils.qll"
79+
],
80+
"Model as Data Generation Java/C# - SummaryModels": [
81+
"java/ql/src/utils/model-generator/CaptureSummaryModels.qll",
82+
"csharp/ql/src/utils/model-generator/CaptureSummaryModels.qll"
83+
],
7684
"Sign Java/C#": [
7785
"java/ql/lib/semmle/code/java/dataflow/internal/rangeanalysis/Sign.qll",
7886
"csharp/ql/lib/semmle/code/csharp/dataflow/internal/rangeanalysis/Sign.qll"
@@ -426,7 +434,6 @@
426434
"python/ql/src/Lexical/CommentedOutCodeMetricOverview.inc.qhelp"
427435
],
428436
"FLinesOfDuplicatedCodeCommon.inc.qhelp": [
429-
"cpp/ql/src/Metrics/Files/FLinesOfDuplicatedCodeCommon.inc.qhelp",
430437
"java/ql/src/Metrics/Files/FLinesOfDuplicatedCodeCommon.inc.qhelp",
431438
"javascript/ql/src/Metrics/FLinesOfDuplicatedCodeCommon.inc.qhelp",
432439
"python/ql/src/Metrics/FLinesOfDuplicatedCodeCommon.inc.qhelp"
@@ -513,4 +520,4 @@
513520
"javascript/ql/lib/semmle/javascript/frameworks/data/internal/ApiGraphModels.qll",
514521
"ruby/ql/lib/codeql/ruby/frameworks/data/internal/ApiGraphModels.qll"
515522
]
516-
}
523+
}

0 commit comments

Comments
 (0)