From 82ef399b7356017644cf211e9851308cc06ea439 Mon Sep 17 00:00:00 2001 From: Alexander Weigl Date: Fri, 21 Jun 2024 16:07:00 +0200 Subject: [PATCH] reenable sonarqube, disable the crappy things * also fix some encoding in recorder/src files --- .github/old_workflows/sonarqube.yml | 39 -------- .github/workflows/artiweb.yml | 88 ------------------ .github/workflows/code_quality.yml | 89 +------------------ .github/workflows/codeql.yml | 43 --------- .github/workflows/sonarqube.yml | 49 ++++++++++ build.gradle | 11 +++ gradle.properties | 1 + .../recoder/abstraction/IntersectionType.java | 2 +- .../java5to4/EnhancedFor2For.java | 2 +- 9 files changed, 64 insertions(+), 260 deletions(-) delete mode 100644 .github/old_workflows/sonarqube.yml delete mode 100644 .github/workflows/artiweb.yml delete mode 100644 .github/workflows/codeql.yml create mode 100644 .github/workflows/sonarqube.yml create mode 100644 gradle.properties diff --git a/.github/old_workflows/sonarqube.yml b/.github/old_workflows/sonarqube.yml deleted file mode 100644 index ac751f0d5a8..00000000000 --- a/.github/old_workflows/sonarqube.yml +++ /dev/null @@ -1,39 +0,0 @@ -# This workflow helps you trigger a SonarCloud analysis of your code and populates -# GitHub Code Scanning alerts with the vulnerabilities found. -name: SonarCloud analysis - -on: - push: - branches: [ "main" ] - pull_request: - branches: [ "main" ] - workflow_dispatch: - -permissions: - pull-requests: read # allows SonarCloud to decorate PRs with analysis results - -jobs: - Analysis: - runs-on: ubuntu-latest - steps: - - name: Analyze with SonarCloud - # You can pin the exact commit or the version. - # uses: SonarSource/sonarcloud-github-action@de2e56b42aa84d0b1c5b622644ac17e505c9a049 - uses: SonarSource/sonarcloud-github-action@de2e56b42aa84d0b1c5b622644ac17e505c9a049 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} # Generate a token on Sonarcloud.io, add it to the secrets of this repo with the name SONAR_TOKEN (Settings > Secrets > Actions > add new repository secret) - with: - args: - # Unique keys of your project and organization. You can find them in SonarCloud > Information (bottom-left menu) - # mandatory - -Dsonar.projectKey=key-main - -Dsonar.organization=keyproject - # Comma-separated paths to directories containing main source files. - #-Dsonar.sources= # optional, default is project base directory - # When you need the analysis to take place in a directory other than the one from which it was launched - #-Dsonar.projectBaseDir= # optional, default is . - # Comma-separated paths to directories containing test source files. - #-Dsonar.tests= # optional. For more info about Code Coverage, please refer to https://docs.sonarcloud.io/enriching/test-coverage/overview/ - # Adds more detail to both client and server-side analysis logs, activating DEBUG mode for the scanner, and adding client-side environment variables and system properties to the server-side log of analysis report processing. - #-Dsonar.verbose= # optional, default is false diff --git a/.github/workflows/artiweb.yml b/.github/workflows/artiweb.yml deleted file mode 100644 index ca963363cf0..00000000000 --- a/.github/workflows/artiweb.yml +++ /dev/null @@ -1,88 +0,0 @@ -name: Artiweb Comment - -on: - workflow_run: - workflows: [Tests] - types: - - completed - -# taken from https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#using-data-from-the-triggering-workflow -jobs: - comment: - runs-on: ubuntu-latest - steps: - - name: 'Download artifact' - id: da - uses: actions/github-script@v7 - with: - script: | - if (context.payload.workflow_run === undefined) { - core.setFailed("No workflow run found"); - } - const allArtifacts = await github.rest.actions.listWorkflowRunArtifacts({ - owner: context.repo.owner, - repo: context.repo.repo, - run_id: context.payload.workflow_run.id, - }); - - const testArtifact = allArtifacts.data.artifacts.find((artifact) => { - return artifact.name == "test-results" - }); - if (testArtifact !== undefined) { - core.info("Found test-results artifact id: " + testArtifact.id); - core.setOutput("test-artifact-id", testArtifact.id); - } else { - core.info("Artifact test-results was not found"); - } - - const numberArtifact = allArtifacts.data.artifacts.find((artifact) => { - return artifact.name == "pr-number" - }); - if (numberArtifact !== undefined) { - core.info("Found pr-number artifact id: " + numberArtifact.id); - let download = await github.rest.actions.downloadArtifact({ - owner: context.repo.owner, - repo: context.repo.repo, - artifact_id: numberArtifact.id, - archive_format: 'zip', - }); - let fs = require('fs'); - fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/pr_number.zip`, Buffer.from(download.data)); - } else { - core.setFailed("Artifact pr-number was not found"); - } - - - name: 'Unzip artifact' - run: unzip pr_number.zip - - - name: 'Read pr number' - id: rpn - uses: actions/github-script@v7 - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - script: | - let fs = require('fs'); - let issue_number_text = fs.readFileSync('./pr_number', 'utf8'); - core.info("Found pr number \"" + issue_number_text + "\""); - core.setOutput("pr-number", issue_number_text === "" ? "" : Number(issue_number_text)); - - name: Find Comment - if: ${{ steps.rpn.outputs.pr-number != '' }} - uses: peter-evans/find-comment@v3 - id: fc - with: - issue-number: ${{ steps.rpn.outputs.pr-number }} - comment-author: 'github-actions[bot]' - body-includes: Artiweb - - - name: Create or update comment - if: ${{ steps.rpn.outputs.pr-number != '' }} - uses: peter-evans/create-or-update-comment@v4 - with: - comment-id: ${{ steps.fc.outputs.comment-id }} - issue-number: ${{ steps.rpn.outputs.pr-number }} - body: | - Thank you for your contribution. - - The test artifacts are available on [Artiweb](e8e3f762-a110-4e21-bc41-cacb5f3a3a50.ka.bw-cloud-instance.org/${{steps.rpn.outputs.pr-number}}/). - The newest artifact is [here](e8e3f762-a110-4e21-bc41-cacb5f3a3a50.ka.bw-cloud-instance.org/${{steps.rpn.outputs.pr-number}}/${{steps.da.outputs.test-artifact-id}}/). - edit-mode: replace diff --git a/.github/workflows/code_quality.yml b/.github/workflows/code_quality.yml index 5410a014e96..1365c36e398 100644 --- a/.github/workflows/code_quality.yml +++ b/.github/workflows/code_quality.yml @@ -24,21 +24,6 @@ jobs: with: arguments: -DENABLE_NULLNESS=true compileTest - - qodana: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - name: 'Qodana Scan' - uses: JetBrains/qodana-action@v2024.1.5 - - - uses: github/codeql-action/upload-sarif@v3 - if: success() || failure() - with: - sarif_file: ${{ runner.temp }}/qodana/results/qodana.sarif.json - formatting: runs-on: ubuntu-latest steps: @@ -51,76 +36,4 @@ jobs: - name: Build with Gradle uses: gradle/gradle-build-action@v3.3.2 with: - arguments: --continue spotlessCheck - - # checkstyle: - # runs-on: ubuntu-latest - # steps: - # - uses: actions/checkout@v4 - # with: - # fetch-depth: 0 - # - run: scripts/tools/checkstyle/runIncrementalCheckstyle.sh --xml | tee report.xml - # - run: | - # npx violations-command-line -sarif sarif-report.json \ - # -v "CHECKSTYLE" "." ".*/report.xml$" "Checkstyle" \ - # -diff-to $(git merge-base HEAD origin/main) -pv false - - # - uses: github/codeql-action/upload-sarif@v3 - # if: success() || failure() - # with: - # sarif_file: sarif-report.json - - - checkstyle_new: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-java@v4 - with: - distribution: 'corretto' - java-version: '21' - cache: 'gradle' - - - name: Build with Gradle - uses: gradle/gradle-build-action@v3.3.2 - with: - arguments: --continue checkstyleMainChanged - - run: | - npx violations-command-line -sarif sarif-report.json \ - -v "CHECKSTYLE" "." ".*/build/reports/checkstyle/main_diff.xml$" "Checkstyle" - - #-diff-from $(git merge-base HEAD origin/main) - # - run: python3 ./.github/printcs.py */build/reports/checkstyle/main_diff.xml - - # $(git merge-base HEAD origin/main) - - - uses: github/codeql-action/upload-sarif@v3 - if: success() || failure() - with: - sarif_file: sarif-report.json - - pmd: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-java@v4 - with: - distribution: 'corretto' - java-version: '21' - cache: 'gradle' - - name: Build with Gradle - uses: gradle/gradle-build-action@v3.3.2 - with: - arguments: --continue pmdMainChanged - - # - run: python3 ./.github/printAnnotations.py */build/reports/pmd/main.xml - - - run: | - npx violations-command-line -sarif pmd-report.json \ - -v "PMD" "." ".*/build/reports/pmd/main_diff.xml$" "PMD" - - # -diff-from $(git merge-base HEAD origin/main) - - name: Upload SARIF file - uses: github/codeql-action/upload-sarif@v3 - with: - sarif_file: pmd-report.json + arguments: --continue spotlessCheck \ No newline at end of file diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml deleted file mode 100644 index efdedd8caf2..00000000000 --- a/.github/workflows/codeql.yml +++ /dev/null @@ -1,43 +0,0 @@ -name: "CodeQL" - -on: - push: - branches: [ "main" ] - pull_request: - branches: - - "main" - - "KeY-*" - schedule: - - cron: '21 21 * * 4' - merge_group: - -jobs: - analyze: - name: Analyze - runs-on: ubuntu-latest - permissions: - actions: read - contents: read - security-events: write - - strategy: - fail-fast: false - matrix: - language: [ 'java' ] - - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - - name: Initialize CodeQL - uses: github/codeql-action/init@v3 - with: - languages: ${{ matrix.language }} - - - name: Autobuild - uses: github/codeql-action/autobuild@v3 - - - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v3 - with: - category: "/language:${{matrix.language}}" diff --git a/.github/workflows/sonarqube.yml b/.github/workflows/sonarqube.yml new file mode 100644 index 00000000000..5749981d98f --- /dev/null +++ b/.github/workflows/sonarqube.yml @@ -0,0 +1,49 @@ +## Copied from SonarCloud + +name: SonarCloud +on: + push: + branches: + - main + pull_request: + types: [opened, synchronize, reopened] + +jobs: + build: + name: Build and analyze + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis + - name: Set up JDK 21 + uses: actions/setup-java@v3 + with: + java-version: 21 + distribution: 'zulu' + - name: Cache SonarCloud packages + uses: actions/cache@v3 + with: + path: ~/.sonar/cache + key: ${{ runner.os }}-sonar + restore-keys: ${{ runner.os }}-sonar + - name: Cache Gradle packages + uses: actions/cache@v3 + with: + path: ~/.gradle/caches + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }} + restore-keys: ${{ runner.os }}-gradle + + - name: Generate and submit dependency graph + uses: gradle/actions/dependency-submission@v3 + with: + build-scan-publish: true + build-scan-terms-of-use-url: "https://gradle.com/terms-of-service" + build-scan-terms-of-use-agree: "yes" + + - name: Build and analyze + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + GRADLE_OPTS: "-Xmx6g -XX:MaxMetaspaceSize=512m -Dfile.encoding=UTF-8" + run: ./gradlew --parallel --continue -DjacocoEnabled=true -x :key.core.symbolic_execution:test -x :key.core.proof_references:test classes testClasses :key.util:test jacocoTestReport sonar \ No newline at end of file diff --git a/build.gradle b/build.gradle index 935addaa9a8..487eb193e5c 100644 --- a/build.gradle +++ b/build.gradle @@ -25,8 +25,19 @@ plugins { // EISOP Checker Framework id "org.checkerframework" version "0.6.39" + + id("org.sonarqube") version "5.0.0.4638" +} + +sonar { + properties { + property "sonar.projectKey", "KeYProject_key" + property "sonar.organization", "keyproject" + property "sonar.host.url", "https://sonarcloud.io" + } } + // Configure this project for use inside IntelliJ: idea { module { diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 00000000000..7937f1c737f --- /dev/null +++ b/gradle.properties @@ -0,0 +1 @@ +org.gradle.jvmargs=-Xmx2g -XX:MaxMetaspaceSize=512m -Dfile.encoding=UTF-8 \ No newline at end of file diff --git a/recoder/src/main/java/recoder/abstraction/IntersectionType.java b/recoder/src/main/java/recoder/abstraction/IntersectionType.java index 49186270c8c..c3e5cc0b836 100644 --- a/recoder/src/main/java/recoder/abstraction/IntersectionType.java +++ b/recoder/src/main/java/recoder/abstraction/IntersectionType.java @@ -11,7 +11,7 @@ import recoder.service.ProgramModelInfo; /** - * Represents an intersection type, which was introduced in java 5. See JLS, 3rd edition, �4.9 for + * Represents an intersection type, which was introduced in java 5. See JLS, 3rd edition, §4.9 for * details. * * @author Tobias Gutzmann diff --git a/recoder/src/main/java/recoder/kit/transformation/java5to4/EnhancedFor2For.java b/recoder/src/main/java/recoder/kit/transformation/java5to4/EnhancedFor2For.java index 52e98bccb81..17e4f816382 100644 --- a/recoder/src/main/java/recoder/kit/transformation/java5to4/EnhancedFor2For.java +++ b/recoder/src/main/java/recoder/kit/transformation/java5to4/EnhancedFor2For.java @@ -25,7 +25,7 @@ import recoder.list.generic.ASTList; /** - * converts an enhanced for loop to an "old style" for loop. This follows JLS 3rd edition, �14.14.2. + * converts an enhanced for loop to an "old style" for loop. This follows JLS 3rd edition, §14.14.2. *

* Currently, if given enhanced for iterates over an array, this will replace the enhanced for with * a statement block and not inline it into a possibly given statement block, yielding possibly not