Skip to content

fix: address chunk decoder review notes#84

Merged
github-actions[bot] merged 1 commit into
mainfrom
feature/devin-20260712-sonar-complexidade-metar-chunks-fix
Jul 12, 2026
Merged

fix: address chunk decoder review notes#84
github-actions[bot] merged 1 commit into
mainfrom
feature/devin-20260712-sonar-complexidade-metar-chunks-fix

Conversation

@devin-ai-integration

@devin-ai-integration devin-ai-integration Bot commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

All Submissions:

  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same update/change?

Changes to Core Features:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
    • Tightened the RunwayVisualRangeChunkDecoder helpers so nullable runway values are handled explicitly instead of via .Value on nullable results.
    • Simplified the WindShearChunkDecoder regex string to remove the redundant verbatim prefix.
  • Have you written new tests for your core changes, as applicable?
    • Existing decoder tests continue to cover the changed paths; behavior remains unchanged.
  • Have you successfully ran tests with your changes locally?
    • dotnet build MetarDecoder.sln --configuration Release
    • dotnet test tests/Metar.Decoder.Tests/Metar.Decoder.Tests.csproj --configuration Release --framework net8.0 --collect:"XPlat Code Coverage"
    • dotnet test tests/Metar.Decoder.Tests/Metar.Decoder.Tests.csproj --configuration Release --framework net10.0 --collect:"XPlat Code Coverage"
    • dotnet test tests/Taf.Decoder.Tests/Taf.Decoder.Tests.csproj --configuration Release --framework net8.0 --collect:"XPlat Code Coverage"
    • dotnet test tests/Taf.Decoder.Tests/Taf.Decoder.Tests.csproj --configuration Release --framework net10.0 --collect:"XPlat Code Coverage"

Link to Devin session: https://app.devin.ai/sessions/a4e91bc6cd1447788a7bec8c00406d09


Open in Devin Review

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

@afonsoft

Copy link
Copy Markdown
Owner

Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@sonarqubecloud

Copy link
Copy Markdown

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 2 potential issues.

Open in Devin Review

Comment on lines +110 to +111
var measuredValue = Value.ToInt(value);
return measuredValue.HasValue ? new Value(measuredValue.Value, unit) : null;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 Info: Silent null return in ToValue changes error-reporting behavior for hypothetical edge cases

The old ToValue would throw InvalidOperationException (accessing .Value on a null Nullable<int>) if Value.ToInt returned null. The new code at src/Metar.Decoder/ChunkDecoder/RunwayVisualRangeChunkDecoder.cs:111 silently returns null instead. This means a RunwayVisualRange object could end up with a null VisualRange or null entries in VisualRangeInterval, which downstream consumers may not expect.

In practice this path is unreachable because the regex group ([0-9]{4}) guarantees a 4-digit numeric string, and Value.ToInt at src/Metar.Decoder/Entity/Value.cs:150-158 will always successfully parse such input. However, if the regex were ever relaxed to accept non-numeric characters in these groups, the silent null would mask a parsing failure rather than surfacing it as an exception.

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Concordo; ajustei ToValue para lançar em falha inesperada de parse, preservando o comportamento fail-fast em vez de retornar null silenciosamente.

{
var qfuAsInt = Value.ToInt(runway);
if (qfuAsInt > 36 || qfuAsInt < 1)
if (!qfuAsInt.HasValue || qfuAsInt.Value > 36 || qfuAsInt.Value < 1)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 Info: Runway number 00 is now rejected by the null check, but was already rejected before

The new !qfuAsInt.HasValue guard at line 81 adds a null check, but for runway designators matched by the regex ([0-9]{2}[LCR]?), Value.ToInt will always return a non-null integer. The existing < 1 check already rejects runway 00 (which is the only invalid low value the regex can produce). The old code relied on C#'s implicit Nullable<int> comparison operators (where null > 36 and null < 1 both return false), meaning a null ToInt result would have passed validation silently. The new explicit null check correctly treats a null parse result as invalid. This is a genuine correctness improvement for the theoretical null case, even though the regex makes it unreachable.

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Intenção é falhar fechado em entrada numérica inesperada; o caso nulo é inalcançável com a regex atual, mas o guard torna a invariável explícita.

@github-actions

Copy link
Copy Markdown

Qodana Community for .NET

4 new problems were found

Inspection name Severity Problems
Possible 'System.NullReferenceException' 🔶 Warning 4

💡 Qodana analysis was run in the pull request mode: only the changed files were checked

View the detailed Qodana report

To be able to view the detailed Qodana report, you can either:

To get *.log files or any other Qodana artifacts, run the action with upload-result option set to true,
so that the action will upload the files as the job artifacts:

      - name: 'Qodana Scan'
        uses: JetBrains/[email protected]
        with:
          upload-result: true
Contact Qodana team

Contact us at [email protected]

@github-actions
github-actions Bot merged commit a895157 into main Jul 12, 2026
26 of 29 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant