Skip to content

Fix Maven Linter incomplete XML insertion (#1)#3

Merged
Emin-ACIKGOZ merged 5 commits into
masterfrom
fix/maven-linter-xml-insertion
Apr 19, 2026
Merged

Fix Maven Linter incomplete XML insertion (#1)#3
Emin-ACIKGOZ merged 5 commits into
masterfrom
fix/maven-linter-xml-insertion

Conversation

@Emin-ACIKGOZ
Copy link
Copy Markdown
Owner

Summary

Fixes issue #1: Maven Linter template was generating a Checkstyle configuration but failing to integrate it into the existing pom.xml file, leaving an orphaned maven-checkstyle-plugin.xml file that users had to manually handle.

Type of Change

  • Bug fix
  • Performance improvement
  • Documentation update
  • Test improvement
  • New feature (backward compatible)
  • Breaking change

Details

This implementation adds a new type that enables safe, transactional modifications to existing XML files. The task:

  1. Validates XML structure before and after insertion
  2. Prevents duplicate insertions (idempotent)
  3. Integrates with transaction manager for automatic rollback on failure
  4. Validates paths to prevent directory traversal attacks
  5. Supports DryRun mode

The Maven Linter handler now uses InsertXMLTask to inject the maven-checkstyle-plugin directly into the project's pom.xml, eliminating the orphaned file issue.

Tests

  • Existing tests pass (go test ./...)
  • New tests added for InsertXMLTask and Maven Linter integration

All tests follow Go best practices with focused test functions, zero linting violations, and comprehensive edge case coverage including:

  • XML parsing and validation
  • Element insertion with attributes and complex structures
  • Path traversal attack prevention
  • Transaction rollback verification
  • Idempotency testing (applying multiple times)
  • Error handling for malformed/missing files

API Impact

  • No public API changes
  • Backward-compatible API change
  • Breaking API change

InsertXMLTask is internal to the scbake execution engine.

Checklist

  • Code follows project standards and idiomatic Go
  • golangci-lint passes
  • Public APIs are documented where applicable
  • Commit history is focused (one logical change per commit)

Related Issues

Closes #1

- Implement InsertXMLTask type with XML parsing and element insertion
- Support simplified XPath for Maven pom.xml and similar structures
- Integrate with transaction manager for safe rollback
- Path validation prevents directory traversal attacks
- DryRun mode support
- Comprehensive test coverage with edge cases
- No linting warnings or test complexity violations
- Use InsertXMLTask to inject maven-checkstyle-plugin into existing pom.xml
- Remove orphaned maven-checkstyle-plugin.xml file generation
- Checkstyle configuration still created separately
- Handler now properly integrates linter with Maven projects
- Comprehensive test coverage verifying idempotency and error handling
- End-to-end test verifying plugin injection into pom.xml
- Test idempotency (applying twice doesn't duplicate)
- Test transaction rollback behavior
- Test error handling for missing plugins section
- All tests follow Go best practices with focused test functions
- No linting warnings or complexity violations
- Document InsertXMLTask in pkg/tasks/doc.go
- Update README with InsertXMLTask explanation and usage example
- Add extension guidelines for file modification handlers
- Update priority band documentation with new task type
- Clarify Maven Linter now provides automatic pom.xml integration
- Update CI workflow to use golangci-lint v2.11 instead of v1.61
- Aligns with local development environment (golangci-lint 2.11.4)
- Resolves configuration schema validation errors
- Enables proper linting of new code
@Emin-ACIKGOZ Emin-ACIKGOZ merged commit df0d815 into master Apr 19, 2026
1 of 2 checks passed
@Emin-ACIKGOZ Emin-ACIKGOZ deleted the fix/maven-linter-xml-insertion branch April 19, 2026 11:25
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.

Maven Linter Implementation is Incomplete

1 participant