Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
indent_style = space
indent_size = 4

[*.{md,markdown}]
trim_trailing_whitespace = false

[*.{json,yml,yaml}]
indent_size = 2

[*.{cs,csx}]
indent_size = 4
charset = utf-8-bom

dotnet_sort_system_directives_first = true
dotnet_separate_import_directive_groups = false

dotnet_style_qualification_for_field = false:suggestion
dotnet_style_qualification_for_property = false:suggestion
dotnet_style_qualification_for_method = false:suggestion
dotnet_style_qualification_for_event = false:suggestion

dotnet_style_predefined_type_for_locals_parameters_members = true:suggestion
dotnet_style_predefined_type_for_member_access = true:suggestion

csharp_style_var_for_built_in_types = true:suggestion
csharp_style_var_when_type_is_apparent = true:suggestion
csharp_style_var_elsewhere = true:silent

csharp_new_line_before_open_brace = all
csharp_new_line_before_else = true
csharp_new_line_before_catch = true
csharp_new_line_before_finally = true

csharp_indent_case_contents = true
csharp_indent_switch_labels = true
csharp_space_after_cast = false
csharp_space_after_keywords_in_control_flow_statements = true

dotnet_diagnostic.IDE0005.severity = warning

[*.{csproj,sln,props,targets}]
indent_size = 2
21 changes: 21 additions & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Default owners for everything in the repo. The maintainer is automatically
# requested for review on every pull request that does not match a more
# specific rule below.
* @lenagrin

# Production application code (the focus of refactoring labs).
/NetSdrClientApp/ @lenagrin
/EchoTcpServer/ @lenagrin

# Test suites and architectural rules.
/NetSdrClientAppTests/ @lenagrin
/NetSdrClient.ArchTests/ @lenagrin
/EchoTcpServer.Tests/ @lenagrin

# CI / CD and supply-chain configuration.
/.github/ @lenagrin
/.editorconfig @lenagrin
/NetSdrClient.sln @lenagrin

# Lab reports authored by the student.
/docs/labs/ @nik-bykoff
42 changes: 42 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Dependabot configuration for the NetSdrClient solution.
# - Watches NuGet across the whole solution and creates PRs to bump packages.
# - Watches GitHub Actions used in workflows and bumps them too.
# Reference: https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file

version: 2

updates:
- package-ecosystem: "nuget"
directory: "/"
schedule:
interval: "weekly"
day: "monday"
time: "08:00"
timezone: "Europe/Kyiv"
labels:
- "dependencies"
- "nuget"
open-pull-requests-limit: 5
commit-message:
prefix: "deps(nuget)"
groups:
test-stack:
patterns:
- "NUnit*"
- "Microsoft.NET.Test.Sdk"
- "coverlet.*"
- "Moq"

- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
day: "monday"
time: "08:00"
timezone: "Europe/Kyiv"
labels:
- "dependencies"
- "github-actions"
open-pull-requests-limit: 5
commit-message:
prefix: "deps(actions)"
43 changes: 43 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Pull Request

## Summary

<!--
What does this PR change and why? Reference the lab number, the file(s)
touched and the architectural intent. Two or three sentences are enough.
-->

## Linked lab / report

- Lab: <!-- e.g. Lab 4 - Duplications -->
- Report: <!-- e.g. docs/labs/lab-04.md -->

## Changes

- [ ] Production code (`NetSdrClientApp/` or `EchoTcpServer/`)
- [ ] Tests (`*Tests/`)
- [ ] CI / Sonar / Dependabot (`.github/`)
- [ ] Documentation (`docs/`, `README.md`)

## Test plan

```
# How to verify locally:
dotnet build NetSdrClient.sln -c Release
dotnet test NetSdrClient.sln -c Release --no-build
```

- [ ] All existing tests still pass
- [ ] New tests added or existing tests updated where appropriate
- [ ] No new compiler / NuGet warnings introduced
- [ ] SonarCloud Quality Gate is green (`Sonar Check`, `SonarCloud Code Analysis`, `SonarCloud Quality Gate`)

## Risks and rollback

<!-- Anything reviewers should pay extra attention to (concurrency, IO, public API).
How would we revert this change? -->

## Discipline / Author

- Subject: Реінжиніринг програмного забезпечення
- Student: Биков Нікіта Вячеславович, group ПЗС-1
91 changes: 45 additions & 46 deletions .github/workflows/sonarcloud.yml
Original file line number Diff line number Diff line change
@@ -1,30 +1,12 @@
# 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)
# SonarCloud аналіз для NetSdrClient (.NET 8)
#
# * 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)
# Перед першим запуском обов'язково:
# 1. Створити проект у SonarCloud (Analyze new project) для цього репозиторію.
# 2. У SonarCloud вимкнути Automatic Analysis (Administration -> Analysis Method).
# 3. Згенерувати User Token у SonarCloud та додати його у GitHub Secrets форку
# під іменем SONAR_TOKEN (Repo Settings -> Secrets and variables -> Actions).
# 4. Замінити нижче змінні `SONAR_PROJECT_KEY` і `SONAR_ORGANIZATION` на власні
# значення з SonarCloud (вкладка Information знизу зліва у проєкті Sonar).

name: SonarCloud analysis

Expand All @@ -36,12 +18,16 @@ on:
workflow_dispatch:

permissions:
pull-requests: read # allows SonarCloud to decorate PRs with analysis results
pull-requests: read

env:
SONAR_PROJECT_KEY: nik-bykoff_ReengineeringCourse
SONAR_ORGANIZATION: nik-bykoff

jobs:
sonar-check:
name: Sonar Check
runs-on: windows-latest # безпечно для будь-яких .NET проектів
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
with: { fetch-depth: 0 }
Expand All @@ -50,34 +36,47 @@ jobs:
with:
dotnet-version: '8.0.x'

# 1) BEGIN: SonarScanner for .NET
- name: SonarScanner Begin
run: |
dotnet tool install --global dotnet-sonarscanner
echo "$env:USERPROFILE\.dotnet\tools" >> $env:GITHUB_PATH
dotnet sonarscanner begin `
/k:"ppanchen_NetSdrClient" `
/o:"ppanchen" `
/d:sonar.token="${{ secrets.SONAR_TOKEN }}" `
/d:sonar.cs.opencover.reportsPaths="**/coverage.xml" `
/d:sonar.cpd.cs.minimumTokens=40 `
/d:sonar.cpd.cs.minimumLines=5 `
/d:sonar.exclusions=**/bin/**,**/obj/**,**/sonarcloud.yml `
/d:sonar.qualitygate.wait=true
/k:"${{ env.SONAR_PROJECT_KEY }}" `
/o:"${{ env.SONAR_ORGANIZATION }}" `
/d:sonar.token="${{ secrets.SONAR_TOKEN }}" `
/d:sonar.cs.opencover.reportsPaths="**/coverage.xml,**/*.coverage.xml" `
/d:sonar.cpd.cs.minimumTokens=40 `
/d:sonar.cpd.cs.minimumLines=5 `
/d:sonar.exclusions=**/bin/**,**/obj/**,**/sonarcloud.yml `
/d:sonar.coverage.exclusions=**/Program.cs,**/EchoServer.cs,**/TcpClientWrapper.cs,**/UdpClientWrapper.cs `
/d:sonar.qualitygate.wait=true
shell: pwsh
# 2) BUILD & TEST

- name: Restore
run: dotnet restore NetSdrClient.sln

- name: Format check
run: dotnet format NetSdrClient.sln --verify-no-changes --no-restore --severity warn
continue-on-error: true

- name: Build
run: dotnet build NetSdrClient.sln -c Release --no-restore
#- name: Tests with coverage (OpenCover)
# run: |
# dotnet test NetSdrClientAppTests/NetSdrClientAppTests.csproj -c Release --no-build `
# /p:CollectCoverage=true `
# /p:CoverletOutput=TestResults/coverage.xml `
# /p:CoverletOutputFormat=opencover
# shell: pwsh
# 3) END: SonarScanner

- name: Tests with coverage (OpenCover)
run: |
$exclude = '[NetSdrClientApp]NetSdrClientApp.Program%2c[EchoServer]EchoTcpServer.Program%2c[EchoServer]EchoTcpServer.EchoServer'
dotnet test NetSdrClientAppTests/NetSdrClientAppTests.csproj -c Release --no-build `
/p:CollectCoverage=true `
/p:CoverletOutput=TestResults/netsdr.coverage.xml `
/p:CoverletOutputFormat=opencover `
/p:Exclude="$exclude"
dotnet test EchoTcpServer.Tests/EchoTcpServer.Tests.csproj -c Release --no-build `
/p:CollectCoverage=true `
/p:CoverletOutput=TestResults/echo.coverage.xml `
/p:CoverletOutputFormat=opencover `
/p:Exclude="$exclude"
shell: pwsh

- name: SonarScanner End
run: dotnet sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}"
shell: pwsh
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -360,4 +360,9 @@ MigrationBackup/
.ionide/

# Fody - auto-generated XML schema
FodyWeavers.xsd
FodyWeavers.xsd

# Local environment / secrets
.env
.env.*
!.env.example
Loading