Skip to content

Refactor METAR/TAF entrypoints to reduce complexity#80

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

Refactor METAR/TAF entrypoints to reduce complexity#80
github-actions[bot] merged 1 commit into
mainfrom
feature/devin-20260712-sonar-complexidade-entrypoints

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:

  • Added private helpers around the METAR/TAF entrypoints so ParseWithMode stays shallow and Sonar S3776 is reduced.
  • Kept the parsing behavior intact: normalization, chunk decoding, CAVOK tracking, strict-mode handling, and TAF evolutions still flow through the same paths.
  • Ran build and test validation locally.

Validation:

  • dotnet build MetarDecoder.sln --configuration Release
  • dotnet test tests/Metar.Decoder.Tests/Metar.Decoder.Tests.csproj --framework net8.0 --configuration Release --no-build
  • dotnet test tests/Metar.Decoder.Tests/Metar.Decoder.Tests.csproj --framework net10.0 --configuration Release --no-build
  • dotnet test tests/Taf.Decoder.Tests/Taf.Decoder.Tests.csproj --framework net8.0 --configuration Release --no-build
  • dotnet test tests/Taf.Decoder.Tests/Taf.Decoder.Tests.csproj --framework net10.0 --configuration Release --no-build

Note: dotnet test MetarDecoder.sln --configuration Release --collect:"XPlat Code Coverage" aborts on Linux when it reaches the net48 test targets because mono is not installed in this environment; the supported net8.0 and net10.0 test targets passed.

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


Open in Devin Review

@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

@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 b7a03d5 into main Jul 12, 2026
21 of 25 checks passed

@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 +120 to +128
private static string PrepareRemainingTaf(string cleanTaf)
{
if (cleanTaf.Contains("CNL"))
{
remainingTaf = cleanTaf;
return cleanTaf;
}

var decodedTaf = new DecodedTaf(cleanTaf);
var withCavok = false;
return cleanTaf.Trim() + " END";
}

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: Condition inversion in PrepareRemainingTaf is correct but subtle

The old code used if (!cleanTaf.Contains("CNL")) with the "append END" logic in the true branch and the passthrough in the else branch. The new PrepareRemainingTaf at src/Taf.Decoder/TafDecoder.cs:122 inverts this to early-return on Contains("CNL") and fall through to the Trim() + " END" path. This is logically equivalent but worth a second glance since condition inversions are a common source of refactoring bugs. I verified both paths produce identical results.

Open in Devin Review

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

}

// weather evolutions
private static void DecodeEvolutions(DecodedTaf decodedTaf, bool isStrict, bool withCavok, ref string remainingTaf)

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: withCavok passed by value to DecodeEvolutions prevents future propagation

In DecodeEvolutions at src/Taf.Decoder/TafDecoder.cs:158, withCavok is passed by value rather than by ref. This matches the original code's behavior (the old code never modified withCavok after the chunk-decoding loop). However, if a future change needed EvolutionChunkDecoder to update the CAVOK state and have it visible to the caller, this by-value parameter would silently swallow the update. The remainingTaf parameter is correctly passed by ref since it IS modified. This is a minor design consideration for future maintainability.

Open in Devin Review

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

Comment thread src/Metar.Decoder/MetarDecoder.cs Outdated
Comment thread src/Taf.Decoder/TafDecoder.cs Outdated
}
}
}
}
Comment thread src/Metar.Decoder/MetarDecoder.cs Outdated
Comment thread src/Metar.Decoder/MetarDecoder.cs Outdated
Comment on lines 165 to 171
Comment thread src/Taf.Decoder/TafDecoder.cs Outdated
Comment thread src/Taf.Decoder/TafDecoder.cs Outdated
Comment on lines 173 to 179
@afonsoft
afonsoft deleted the feature/devin-20260712-sonar-complexidade-entrypoints branch July 12, 2026 18:26
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.

2 participants