| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,14 +1,22 @@ | |||
| 1 | 1 | name: Fetch CodeQL | |
| 2 | 2 | description: Fetches the latest version of CodeQL | |
| 3 | + | ||
| 4 | + inputs: | ||
| 5 | + channel: | ||
| 6 | + description: 'The CodeQL channel to use' | ||
| 7 | + required: false | ||
| 8 | + default: 'nightly' | ||
| 9 | + | ||
| 3 | 10 | runs: | |
| 4 | 11 | using: composite | |
| 5 | 12 | steps: | |
| 6 | 13 | - name: Fetch CodeQL | |
| 7 | 14 | shell: bash | |
| 15 | + env: | ||
| 16 | + GITHUB_TOKEN: ${{ github.token }} | ||
| 17 | + CHANNEL: ${{ inputs.channel }} | ||
| 8 | 18 | run: | | |
| 9 | 19 | gh extension install github/gh-codeql | |
| 10 | - gh codeql set-channel nightly | ||
| 20 | + gh codeql set-channel "$CHANNEL" | ||
| 11 | 21 | gh codeql version | |
| 12 | 22 | gh codeql version --format=json | jq -r .unpackedLocation >> "${GITHUB_PATH}" | |
| 13 | - env: | ||
| 14 | - GITHUB_TOKEN: ${{ github.token }} | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,51 @@ | |||
| 1 | + name: "Compile all queries using the latest stable CodeQL CLI" | ||
| 2 | + | ||
| 3 | + on: | ||
| 4 | + push: | ||
| 5 | + branches: [main] # makes sure the cache gets populated | ||
| 6 | + pull_request: | ||
| 7 | + branches: | ||
| 8 | + - main | ||
| 9 | + - "rc/*" | ||
| 10 | + | ||
| 11 | + jobs: | ||
| 12 | + compile-queries: | ||
| 13 | + runs-on: ubuntu-latest-xl | ||
| 14 | + | ||
| 15 | + steps: | ||
| 16 | + - uses: actions/checkout@v3 | ||
| 17 | + with: | ||
| 18 | + fetch-depth: 0 | ||
| 19 | + # calculate the merge-base with main, in a way that works both on PRs and pushes to main. | ||
| 20 | + - name: Calculate merge-base | ||
| 21 | + id: merge-base | ||
| 22 | + env: | ||
| 23 | + BASE_BRANCH: ${{ github.base_ref }} | ||
| 24 | + run: | | ||
| 25 | + MERGE_BASE=$(git merge-base --fork-point origin/$BASE_BRANCH) | ||
| 26 | + echo "merge-base=$MERGE_BASE" >> $GITHUB_ENV | ||
| 27 | + - name: Cache CodeQL query compilation | ||
| 28 | + uses: actions/cache@v3 | ||
| 29 | + with: | ||
| 30 | + path: '*/ql/src/.cache' | ||
| 31 | + # current GH HEAD first, merge-base second, generic third | ||
| 32 | + key: codeql-stable-compile-${{ github.sha }} | ||
| 33 | + restore-keys: | | ||
| 34 | + codeql-stable-compile-${{ env.merge-base }} | ||
| 35 | + codeql-stable-compile- | ||
| 36 | + - name: Setup CodeQL | ||
| 37 | + uses: ./.github/actions/fetch-codeql | ||
| 38 | + with: | ||
| 39 | + channel: 'release' | ||
| 40 | + - name: check formatting | ||
| 41 | + run: codeql query format */ql/{src,lib,test}/**/*.{qll,ql} --check-only | ||
| 42 | + - name: compile queries - check-only | ||
| 43 | + # run with --check-only if running in a PR (github.sha != main) | ||
| 44 | + if : ${{ github.sha != steps.merge-base.outputs.merge-base }} | ||
| 45 | + shell: bash | ||
| 46 | + run: codeql query compile -j0 */ql/src --keep-going --warnings=error --check-only | ||
| 47 | + - name: compile queries - full | ||
| 48 | + # do full compile if running on main - this populates the cache | ||
| 49 | + if : ${{ github.sha == steps.merge-base.outputs.merge-base }} | ||
| 50 | + shell: bash | ||
| 51 | + run: codeql query compile -j0 */ql/src --keep-going --warnings=error | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -6,7 +6,6 @@ | |||
| 6 | 6 | * @treemap.warnOn highValues | |
| 7 | 7 | * @metricType file | |
| 8 | 8 | * @metricAggregate avg sum max | |
| 9 | - * @precision very-high | ||
| 10 | 9 | * @id go/lines-of-code-in-files | |
| 11 | 10 | * @tags maintainability | |
| 12 | 11 | */ | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -6,7 +6,6 @@ | |||
| 6 | 6 | * @treemap.warnOn lowValues | |
| 7 | 7 | * @metricType file | |
| 8 | 8 | * @metricAggregate avg sum max | |
| 9 | - * @precision very-high | ||
| 10 | 9 | * @id go/lines-of-comments-in-files | |
| 11 | 10 | * @tags documentation | |
| 12 | 11 | */ | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -66,4 +66,5 @@ query predicate edges(CallGraphNode pred, CallGraphNode succ) { | |||
| 66 | 66 | ||
| 67 | 67 | from LoopStmt loop, DatabaseAccess dbAccess | |
| 68 | 68 | where edges*(loop, dbAccess.asExpr()) | |
| 69 | - select dbAccess, loop, dbAccess, "This calls " + dbAccess.toString() + " in a $@.", loop, "loop" | ||
| 69 | + select dbAccess, loop, dbAccess.asExpr(), "This calls " + dbAccess.toString() + " in a $@.", loop, | ||
| 70 | + "loop" | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -4,6 +4,8 @@ | |||
| 4 | 4 | * This can lead to unintentionally holding resources open like file handles or database transactions. | |
| 5 | 5 | * @id go/examples/deferinloop | |
| 6 | 6 | * @kind problem | |
| 7 | + * @problem.severity warning | ||
| 8 | + * @precision high | ||
| 7 | 9 | * @tags defer | |
| 8 | 10 | * nesting | |
| 9 | 11 | */ | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -70,7 +70,8 @@ abstract class Completion extends TCompletion { | |||
| 70 | 70 | predicate isValidFor(ControlFlowElement n) { | |
| 71 | 71 | this.isValidForSpecific(n) | |
| 72 | 72 | or | |
| 73 | - mayHaveThrowCompletion(n, this) | ||
| 73 | + this instanceof ThrowCompletion and | ||
| 74 | + mayHaveThrowCompletion(n) | ||
| 74 | 75 | or | |
| 75 | 76 | not any(Completion c).isValidForSpecific(n) and | |
| 76 | 77 | this = TSimpleCompletion() | |
@@ -320,7 +321,7 @@ private predicate mustHaveThrowCompletion(ThrowStmt throw, ThrowCompletion c) { | |||
| 320 | 321 | ||
| 321 | 322 | private predicate isThrowingType(AnyFunctionType type) { type.isThrowing() } | |
| 322 | 323 | ||
| 323 | - private predicate mayHaveThrowCompletion(ControlFlowElement n, ThrowCompletion c) { | ||
| 324 | + private predicate mayHaveThrowCompletion(ControlFlowElement n) { | ||
| 324 | 325 | // An AST expression that may throw. | |
| 325 | 326 | isThrowingType(n.asAstNode().(ApplyExpr).getFunction().getType()) | |
| 326 | 327 | or | |
| Back | FazBrowse Home | New Git URL |
0 commit comments