-
Notifications
You must be signed in to change notification settings - Fork 89
Feat/sonar analysis #326
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Feat/sonar analysis #326
Changes from all commits
83d39f7
89a9c52
3e827a8
f37e818
443c0f3
56ae62c
5d1be44
30c6e90
0cd7a58
50f8ca2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| # This workflow uses actions that are not certified by GitHub. | ||
| # They are provided by a third-party and are governed by | ||
| # separate terms of service, privacy policy, and support | ||
| # documentation. | ||
|
|
||
| # This workflow helps you trigger a SonarCloud analysis of your code and populates | ||
| # GitHub Code Scanning alerts with the vulnerabilities found. | ||
| # Free for open source project. | ||
|
|
||
| # 1. Login to SonarCloud.io using your GitHub account | ||
|
|
||
| # 2. Import your project on SonarCloud | ||
| # * Add your GitHub organization first, then add your repository as a new project. | ||
| # * Please note that many languages are eligible for automatic analysis, | ||
| # which means that the analysis will start automatically without the need to set up GitHub Actions. | ||
| # * This behavior can be changed in Administration > Analysis Method. | ||
| # | ||
| # 3. Follow the SonarCloud in-product tutorial | ||
| # * a. Copy/paste the Project Key and the Organization Key into the args parameter below | ||
| # (You'll find this information in SonarCloud. Click on "Information" at the bottom left) | ||
| # | ||
| # * b. Generate a new token and add it to your Github repository's secrets using the name SONAR_TOKEN | ||
| # (On SonarCloud, click on your avatar on top-right > My account > Security | ||
| # or go directly to https://sonarcloud.io/account/security/) | ||
|
|
||
| # Feel free to take a look at our documentation (https://docs.sonarcloud.io/getting-started/github/) | ||
| # or reach out to our community forum if you need some help (https://community.sonarsource.com/c/help/sc/9) | ||
|
|
||
| name: SonarCloud analysis | ||
|
|
||
| on: | ||
| push: | ||
| branches: [ "develop" ] | ||
| pull_request: | ||
| branches: [ "develop" ] | ||
| workflow_dispatch: | ||
| inputs: | ||
| scan-type: | ||
| description: '扫描类型' | ||
| required: true | ||
| default: 'full' | ||
| type: choice | ||
| options: | ||
| - incremental | ||
| - full | ||
| branch: | ||
| description: '要扫描的分支' | ||
| required: true | ||
| default: 'develop' | ||
|
|
||
| permissions: | ||
| pull-requests: read # allows SonarCloud to decorate PRs with analysis results | ||
|
|
||
|
Comment on lines
+51
to
+53
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win 🔎 Supported by static analysis🏁 Script executed: printf '%s\n' '--- applicable repository conventions ---'
find /tmp/coderabbit-repo-knowledge/opentiny-tiny-engine-backend-java-1b9e840d -maxdepth 2 -type f -name '*.md' -print
printf '%s\n' '--- workflow ---'
cat -n .github/workflows/sonarcloud.ymlRepository: opentiny/tiny-engine-backend-java Length of output: 4363 🌐 Web query:
💡 Result: When using the actions/checkout action (including version 6) to clone a private repository, you must explicitly grant the GITHUB_TOKEN read access to the repository's contents [1][2][3]. The requirement for Citations:
Grant The workflow-level 🤖 Prompt for AI Agents |
||
| jobs: | ||
| Analysis: | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v6 | ||
| with: | ||
| fetch-depth: 0 # 必须拉取完整历史,才能比较分支差异 | ||
| - name: Analyze with SonarCloud | ||
|
|
||
| # You can pin the exact commit or the version. | ||
| # uses: SonarSource/sonarcloud-github-action@v2.2.0 | ||
| uses: SonarSource/sonarcloud-github-action@v3.0.0 | ||
| env: | ||
| 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: | ||
| # Additional arguments for the SonarScanner CLI | ||
| args: | ||
| # Unique keys of your project and organization. You can find them in SonarCloud > Information (bottom-left menu) | ||
| # mandatory | ||
| -Dsonar.projectKey=msslulu_tiny-engine-backend-java | ||
| -Dsonar.organization=msslulu | ||
| # Comma-separated paths to directories containing main source files. | ||
| #-Dsonar.sources= # optional, default is project base directory | ||
| # 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 | ||
| # When you need the analysis to take place in a directory other than the one from which it was launched, default is . | ||
| projectBaseDir: . | ||
|
Comment on lines
+63
to
+84
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🩺 Stability & Availability | 🟠 Major | ⚡ Quick win 🔎 Supported by static analysis🏁 Script executed: #!/bin/bash
set -euo pipefail
java_sources="$(git ls-files -- '*.java' | wc -l)"
tracked_classes="$(git ls-files -- '*.class' | wc -l)"
printf 'Tracked Java sources: %s\n' "$java_sources"
printf 'Tracked class files: %s\n' "$tracked_classes"
rg -n 'mvn|gradle|setup-java|sonar\.java\.binaries' .github/workflows/sonarcloud.yml || trueRepository: opentiny/tiny-engine-backend-java Length of output: 220 🏁 Script executed: #!/bin/bash
set -euo pipefail
printf '%s\n' '--- workflow ---'
sed -n '1,110p' .github/workflows/sonarcloud.yml
printf '%s\n' '--- root pom modules and Java settings ---'
rg -n -C 3 '<modules>|<module>|maven.compiler|java.version|sonar' pom.xml
printf '%s\n' '--- module poms and Sonar configuration ---'
for f in $(git ls-files -- '*/pom.xml' 'pom.xml'); do
printf '\n--- %s ---\n' "$f"
rg -n -C 2 '<artifactId>|<packaging>|maven.compiler|java.version|sonar' "$f" || true
done
printf '%s\n' '--- repository conventions for workflow scope ---'
find /tmp/coderabbit-repo-knowledge/opentiny-tiny-engine-backend-java-1b9e840d -maxdepth 2 -type f -name '*.md' -printRepository: opentiny/tiny-engine-backend-java Length of output: 14057 🌐 Web query:
💡 Result: The SonarCloud GitHub Action (previously available via the Citations:
🏁 Script executed: #!/bin/bash
set -euo pipefail
printf '%s\n' '--- repository learning for Java reviews ---'
cat /tmp/coderabbit-repo-knowledge/opentiny-tiny-engine-backend-java-1b9e840d/learnings/java.md
printf '%s\n' '--- compiler configuration ---'
sed -n '220,245p' pom.xmlRepository: opentiny/tiny-engine-backend-java Length of output: 2353 Build the Maven modules before Sonar analysis. The workflow sends 343 Java sources to the scanner without compiling the 🧰 Tools🪛 zizmor (1.29.0)[warning] 53-53: action or reusable workflow from archived repository (archived-uses): repository is archived (archived-uses) 🤖 Prompt for AI AgentsSource: Linters/SAST tools |
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
Repository: opentiny/tiny-engine-backend-java
Length of output: 3426
Wire or remove the manual inputs.
No step reads
inputs.branchorinputs['scan-type']. Therefore,branchdoes not affect checkout, andscan-typedoes not affect the SonarCloud command. Wire both inputs into the workflow or remove them.🤖 Prompt for AI Agents