Lab 2: fix code smells and bugs (no behavior change)#19
Open
nik-bykoff wants to merge 2 commits intolenagrin:masterfrom
Open
Lab 2: fix code smells and bugs (no behavior change)#19nik-bykoff wants to merge 2 commits intolenagrin:masterfrom
nik-bykoff wants to merge 2 commits intolenagrin:masterfrom
Conversation
- Move SONAR_PROJECT_KEY/SONAR_ORGANIZATION into workflow env block with explicit setup instructions for fork-based usage. - Update README with student header, fork/upstream links and a table of all eight lab reports. - Replace SonarCloud badges with placeholders for nik-bykoff fork. - Add docs/labs/lab-01.md report describing manual SonarCloud steps, CI workflow layout and verification checklist. - Ignore local .env files to prevent accidental token leaks.
- Rename NetSdrClient.Disconect to Disconnect (typo) and update callers/tests. - Remove stray semicolon in StartIQAsync and unused JSType using-statics. - Make responseTaskSource thread-safe via Interlocked.Exchange + TrySetResult. - Replace Aggregate-on-empty-may-throw log formatting with string.Join in three places. - Rewrite GetSamples from O(n^2) IEnumerable.Count loop to O(n) for-loop with reusable byte[4] buffer. - Replace MD5-based UdpClientWrapper.GetHashCode with HashCode.Combine and add Equals override. - Make TcpClientWrapper._cts nullable, mark _host/_port readonly, drop unused exception variable names. - All eight existing unit tests still pass; compiler warnings dropped from 18 to 15 (rest are EchoTcpServer or NuGet).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Address 5-10 Sonar-style smells/bugs in
NetSdrClientAppwithout changing the public behavior. Compiler warnings inside the production project drop from 5 to 0 (overall solution: 18 -> 15; remaining 15 belong toEchoTcpServerand NuGet vulnerabilities, scheduled for Labs 6/7).Bug-class fixes
NetSdrClient.Disconect->Disconnectand update bothProgram.csand the test suite.;beforevar iqDataMode = (byte)0x80;inStartIQAsync.responseTaskSourcethread-safe by replacing the racy null-check pattern withInterlocked.ExchangeandTrySetResult.Enumerable.Aggregate((l, r) => $\"{l} {r}\")(which throws on empty input) withstring.Join(\" \", ...)in three log statements.NetSdrMessageHelper.GetSamplesfrom an O(n^2)IEnumerable.Count/Skiploop into an O(n)forloop with a reusablebyte[4]buffer.UdpClientWrapper.GetHashCodeMD5 implementation withHashCode.Combineand add a matchingEquals(object?)override.Code-smell fixes
using static System.Runtime.InteropServices.JavaScript.JSType;from two files.TcpClientWrapper._host/_portasreadonly.TcpClientWrapper._ctsnullable to remove CS8625.Intentionally deferred
StopListening/ExitinUdpClientWrapperis left intact for Lab 4 (Duplications).EchoTcpServerwarnings are deferred to Lab 6 (testability refactor).Newtonsoft.Json13.0.0,SharpZipLib1.3.2) are deferred to Lab 7.Test plan
dotnet build NetSdrClient.sln -c Release --no-restoresucceeds.dotnet test NetSdrClient.sln -c Release --no-buildreports 8/8 passing.New Bugs = 0andNew Code Smellssubstantially decrease in this PR.Discipline / Author