This commit is contained in:
@@ -53,29 +53,28 @@
|
||||
|
||||
---
|
||||
|
||||
### 2. **Создан `sonar-project.properties`**
|
||||
### 2. **Настроены исключения в `dotnet-sonarscanner begin`**
|
||||
|
||||
```properties
|
||||
# Exclude auto-generated files and migrations from analysis
|
||||
sonar.coverage.exclusions=**/Migrations/**/*.cs,**/Migrations/*.cs,**/*ModelSnapshot.cs
|
||||
sonar.exclusions=**/Migrations/**/*.cs,**/obj/**,**/bin/**
|
||||
⚠️ **Важно**: `SonarScanner for .NET` НЕ использует файл `sonar-project.properties`!
|
||||
Все настройки передаются через параметры командной строки:
|
||||
|
||||
# Exclude test projects from code coverage calculation
|
||||
sonar.test.exclusions=**/*Tests.cs,**/ChatBot.Tests/**
|
||||
|
||||
# Include only C# files
|
||||
sonar.sources=ChatBot/
|
||||
sonar.tests=ChatBot.Tests/
|
||||
|
||||
# Code coverage report paths
|
||||
sonar.cs.vscoveragexml.reportsPaths=coverage.xml
|
||||
sonar.cs.opencover.reportsPaths=**/coverage.opencover.xml
|
||||
```bash
|
||||
~/.sonar/scanner/dotnet-sonarscanner begin \
|
||||
/k:"mrleo1nid_chatbot" \
|
||||
/o:"mrleo1nid" \
|
||||
/d:sonar.token="${{ secrets.SONAR_TOKEN }}" \
|
||||
/d:sonar.cs.opencover.reportsPaths="**/coverage.opencover.xml" \
|
||||
/d:sonar.coverage.exclusions="**/Migrations/**,**/Migrations/*.cs,**/*ModelSnapshot.cs" \
|
||||
/d:sonar.exclusions="**/Migrations/**,**/obj/**,**/bin/**" \
|
||||
/d:sonar.sources="ChatBot/" \
|
||||
/d:sonar.tests="ChatBot.Tests/"
|
||||
```
|
||||
|
||||
**Что это дает**:
|
||||
- 📊 SonarQube знает, что миграции нужно исключить
|
||||
- 📊 SonarQube знает, что миграции нужно исключить из coverage
|
||||
- 📊 Правильно определяет source и test файлы
|
||||
- 📊 Использует правильный формат coverage отчетов
|
||||
- 📊 Использует правильный формат coverage отчетов (OpenCover)
|
||||
- 📊 Исключает build артефакты (obj, bin)
|
||||
|
||||
---
|
||||
|
||||
@@ -169,14 +168,21 @@ Branch Coverage: 76.01%
|
||||
|
||||
## 🎯 Следующие шаги
|
||||
|
||||
1. **Commit и push изменений**:
|
||||
```bash
|
||||
git add .gitea/workflows/build.yml
|
||||
git add sonar-project.properties
|
||||
git add ChatBot.Tests/ChatBot.Tests.csproj
|
||||
git commit -m "Fix SonarQube coverage: exclude migrations, use coverlet"
|
||||
git push origin master
|
||||
```
|
||||
1. **Сделайте commit и push**:
|
||||
|
||||
```bash
|
||||
git add .gitea/workflows/build.yml
|
||||
git add .sonarqube/exclusions.txt
|
||||
git add ChatBot.Tests/ChatBot.Tests.csproj
|
||||
git add run-coverage-detailed.ps1
|
||||
git add SonarQube_Coverage_Fix.md
|
||||
|
||||
git commit -m "Fix SonarQube coverage: exclude migrations, use coverlet with proper exclusions"
|
||||
|
||||
git push origin master
|
||||
```
|
||||
|
||||
⚠️ **Важно**: НЕ создавайте файл `sonar-project.properties` - он не используется SonarScanner for .NET!
|
||||
|
||||
2. **Дождаться выполнения CI/CD**:
|
||||
- Проверить логи GitHub Actions/Gitea
|
||||
|
||||
Reference in New Issue
Block a user