Skip to content

Conversation

@felarmouche
Copy link
Collaborator

Summary

This PR introduces Checkstyle report support and refactors the XML report parsing/config layer to be context-aware, easier to extend, and more robust—without changing existing parsing logic.

Key changes

Checkstyle support

  • Add CheckstyleParsingConfig (ToolId = "Checkstyle") and CheckstlyeIndexNodeStrategy
    • Maps Checkstyle <file> paths to Java FQCN nodes (handles Windows/Linux separators, source-root stripping via SourceRootMarker)
    • Emits file-level aggregated metrics + error-level issue strings

XML parsing refactor (extensibility/robustness)

  • Switch XPathMapping to MetricsByContext (context = XML tag name) to avoid applying irrelevant metrics.
  • Update XmlReportParser to:
    • resolve metrics by current.LocalName context
    • use safer XML reader defaults (DtdProcessing = Ignore, XmlResolver = null)
    • parse numeric results using InvariantCulture

Config + indexing improvements

  • Extend ParsingConfig with SourceRootMarker + helper SourceRootRelativePath(fullPath) (path normalization + optional root stripping)
  • Make ParsingConfig.Restore(...) static (instantiates via factory; supports derived configs via hooks)
  • Rename JavaIndexNodeStrategyJaCoCoIndexNodeStrategy (behavior unchanged; adds Windows separator handling)

Findings / metrics application

  • Ensure Finding.Metrics is always non-null (default dictionary)
  • Make MetricApplier static, improve validation, and avoid overwriting duplicate metric keys by storing them as:
    • Key, Key [1], Key [2], ...

Tests + samples

  • Add TestCheckstyleReport integration-style test
  • Update sample configs/assets to include Checkstyle example inputs (checkstyle-result.xml, checkstyle.glx.xz) and Unity meta files

… and robust metric application tests

Implemented a new Checkstyle XML report integration including a dedicated CheckstyleParsingConfig (XPath mapping for <file>/<error> nodes) and parser setup to produce file-level aggregates plus minimal per-error context findings.

Refactored Java node indexing by splitting the former Java index strategy into tool-specific implementations, so each tool (e.g., Checkstyle, JaCoCo) controls its own path → node-id normalization rules.

Added source-root based path normalization for Checkstyle: CheckstyleIndexNodeStrategy now relies on ParsingConfig.SourceRootRelativePath(...) (driven by SourceRootMarker) to make GLX and report paths match even when absolute prefixes differ. JaCoCo remains unchanged since it already normalizes paths; added a note to re-check if extra handling is needed when GLX paths diverge.

Improved metric application behavior: when a node already contains the same metric key, additional values are stored under "<key> [i]" instead of overwriting, enabling multiple findings to coexist safely.

Updated the shared test harness (TestReportGraphProviderBase) for the new behavior: node lookup is no longer context-dependent; it uses SourceRangeIndex when a StartLine is available and falls back to TryGetNode otherwise. Metric assertions now search both base keys and all suffixed variants.

Added a concrete Checkstyle test fixture with representative expected findings and placed example Checkstyle report + matching GLX under StreamingAssets/checkstyle to make the end-to-end tests reproducible.
…sible

- Drop XPathMapping.MapContext and treat the XML tag name as parsing context.
- Refactor JaCoCo/Checkstyle configs to rely on MetricsByContext per context (remove NaN/guard XPath hacks),
  introduce context constants and align PathBuilders/FileName/Location mappings.
- Format numeric XPath results using invariant culture to avoid locale-dependent metric strings.
- Harden XML reader settings (ignore DTDs, disable XmlResolver).
- Make MetricApplier stateless by removing the static prefix cache and passing the prefix explicitly.
- Add SourceRootRelativePath() and persist SourceRootMarker in ParsingConfig serialization; restore configs via ParsingConfigFactory.
- Add SaveAdditional/RestoreAdditional hooks to ParsingConfig to support derived config serialization.
- Clean up Checkstyle index strategy debug output and update tests/fixtures accordingly.

BREAKING:
- Finding.Metrics is now Dictionary<string,string> (no nullable values).
- Checkstyle issue metric key renamed from 'Context-Level.Issue' to 'ContextLevel.Issue'.
- ParsingConfig.Restore is now static and factory-based.
…ogic changes)

Add XML documentation for all declarations (including private/protected) and document namespaces.

Apply naming rules consistently:

private fields/constants start lower-case, remove underscore separators, normalize local names (e.g., ComputeKey, xpathMapping).

mark unused parameters/out values as discards (_, out _).

Enforce style rules:

add braces to all if/loop bodies.

replace var with explicit types (keep explicit KeyValuePair<,> for dictionary iteration).

Improve code hygiene without changing behavior:

remove unused usings and unnecessary temporaries.

fix ArgumentNullException usage to use nameof(...).

add null-guards consistent with documented preconditions.

Fix invalid XML doc markup by escaping <file>/<error> tags.

Normalize formatting/whitespace (regions, XPath string spacing) and mark non-null intent where required.
@felarmouche felarmouche requested a review from koschke December 17, 2025 15:12
@felarmouche felarmouche added the bachelorproject Something applicable to the bachelor project, e.g. its report label Dec 17, 2025
@koschke koschke requested a review from Copilot December 17, 2025 15:30
@koschke koschke removed the bachelorproject Something applicable to the bachelor project, e.g. its report label Dec 17, 2025
…-framework-checkstyle-support

# Conflicts:
#	Assets/StreamingAssets/UserSettings.cfg
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds Checkstyle XML report support to the SEE static analysis framework and refactors the XML parsing infrastructure to be context-aware, making it easier to extend for new tools while improving robustness.

Key Changes

  • Introduces Checkstyle parsing configuration with file-level aggregated metrics and error-level issue tracking
  • Refactors XPath mapping to use context-aware metrics (MetricsByContext) instead of global metrics, avoiding NaN evaluation for irrelevant contexts
  • Adds source root path normalization (SourceRootMarker) to handle absolute paths from different tools and environments

Reviewed changes

Copilot reviewed 23 out of 26 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
CheckstyleParsingConfig.cs New configuration for Checkstyle reports with aggregated file metrics and per-error issue strings
CheckstlyeIndexNodeStrategy.cs New strategy for mapping Checkstyle file paths to Java FQCNs (filename has typo)
XmlReportParser.cs Enhanced with context-aware metric resolution, safer XML defaults, and invariant culture parsing
XPathMapping.cs Refactored to use MetricsByContext dictionary instead of flat Metrics dictionary
ParsingConfig.cs Added SourceRootMarker field and SourceRootRelativePath() helper; made Restore() static
MetricApplier.cs Made static, added key disambiguation for duplicate metrics
JaCoCoParsingConfig.cs Updated to use MetricsByContext structure
JaCoCoIndexNodeStrategy.cs Renamed from JavaIndexNodeStrategy, added Windows path separator handling
TestCheckstyleReport.cs New integration test for Checkstyle parsing
TestReportGraphProviderBase.cs Enhanced documentation and metric validation logic
Unity meta files Standard Unity metadata for new assets
checkstyle-result.xml Sample Checkstyle report for testing
SEE.cfg Updated to reference Checkstyle test data

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Collaborator

@koschke koschke left a comment

Choose a reason for hiding this comment

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

Thanks for the PR. Looks very good overall. I have noted only a few minor issues to be fixed.

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

There are a few bad patterns I found which you should check.

felarmouche and others added 4 commits December 18, 2025 14:48
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

There are a few bad patterns I found which you should check.

felarmouche and others added 2 commits December 18, 2025 15:34
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
No real change beyond formatting.
Copy link
Collaborator

@koschke koschke left a comment

Choose a reason for hiding this comment

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

Looks good. Can be merged.

@koschke koschke merged commit cd9d1c7 into master Dec 18, 2025
4 of 7 checks passed
@koschke koschke deleted the 885-static-analyser-framework-checkstyle-support branch December 18, 2025 16:55
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.

3 participants