Skip to content

feat: Add --lint support for validating definition files#27

Draft
Copilot wants to merge 4 commits intomainfrom
copilot/add-lint-support
Draft

feat: Add --lint support for validating definition files#27
Copilot wants to merge 4 commits intomainfrom
copilot/add-lint-support

Conversation

Copy link
Contributor

Copilot AI commented Mar 24, 2026

Adds a --lint command that reads the .reviewmark.yaml configuration file and reports structural and semantic issues, with non-zero exit code on failure. Lint errors always identify the problematic file and, for YAML syntax errors, the line and column number.

Description

Context.cs

  • Added Lint boolean property and --lint flag parsing (mirrors --validate pattern)

Program.cs

  • Added --lint to help text
  • Added Priority 4 lint block in Run() (between self-validation and main tool logic)
  • Added RunLintLogic that:
    • Loads the definition file (--definition if specified, else .reviewmark.yaml in working dir)
    • Reports file I/O and YAML parse errors via context.WriteError, always naming the problematic file and line number
    • Detects unknown evidence-source types (must be url or fileshare)
    • Detects duplicate review set IDs with precise location: reviews[1] has duplicate ID 'Core-Logic' (first defined at reviews[0])

ReviewMarkConfiguration.cs

  • Refactored into a new file-local ReviewMarkConfigurationHelpers class containing DeserializeRaw and BuildConfiguration methods, allowing file-local YAML types to appear in method signatures
  • Load now embeds the filename in all exceptions:
    • YAML syntax errors: "Failed to parse 'filename' at line X, column Y: <message>"
    • Semantic validation errors: "Invalid configuration in 'filename': <message>"
    • File-read errors: "Failed to read configuration file 'filename': <message>"
  • Added includes: support: a parent .reviewmark.yaml can list relative paths to child fragment files; their reviews and needs-review patterns are merged into the parent. Errors from included files name the child file and line number.

Validation.cs

  • Added ReviewMark_Lint self-validation test

TestDirectory.cs (new)

  • Added TestDirectory — an IDisposable helper class for the test project that creates and auto-deletes a temporary directory, replacing the repetitive try/finally pattern across tests

Tests

  • ContextTests: Context_Create_LintFlag_SetsLintTrue, Context_Create_NoArguments_LintIsFalse
  • ProgramTests: refactored elaborate and lint tests to use TestDirectory; updated all error tests to capture output via --log and assert specific error message content (filename, "at line", error type); added:
    • Program_Run_WithLintFlag_CorruptedYaml_ReportsError — verifies filename and "at line" appear in the error
    • Program_Run_WithLintFlag_MissingEvidenceSource_ReportsError — verifies filename and "evidence-source" appear in the error
    • Program_Run_WithLintFlag_IncludedFileCorrupted_ReportsChildFilename — valid parent includes a corrupted child; verifies child filename and "at line" appear in the error
  • ReviewMarkConfigurationTests: added five new tests covering Load error message quality and the includes feature:
    • ReviewMarkConfiguration_Load_InvalidYaml_ErrorIncludesFilenameAndLine
    • ReviewMarkConfiguration_Load_MissingEvidenceSource_ErrorIncludesFilename
    • ReviewMarkConfiguration_Load_WithIncludes_MergesReviews
    • ReviewMarkConfiguration_Load_MissingIncludedFile_ErrorNamesIncludedFile
    • ReviewMarkConfiguration_Load_CorruptedIncludedFile_ErrorNamesIncludedFileAndLine

requirements.yaml

  • Added ReviewMark-Cmd-Lint requirement linked to all 13 test cases
  • Added ReviewMark_Lint to all platform requirements (Windows/Linux/macOS, .NET 8/9/10)

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Code quality improvement

Related Issues

Pre-Submission Checklist

Before submitting this pull request, ensure you have completed the following:

Build and Test

  • Code builds successfully: dotnet build --configuration Release
  • All unit tests pass: dotnet test --configuration Release
  • Self-validation tests pass:
    dotnet run --project src/DemaConsulting.ReviewMark --configuration Release --framework net10.0
    --no-build -- --validate
  • Code produces zero warnings

Code Quality

  • Code formatting is correct: dotnet format --verify-no-changes
  • New code has appropriate XML documentation comments
  • Static analyzer warnings have been addressed

Quality Checks

Please run the following checks before submitting:

  • Spell checker passes: cspell "**/*.{md,cs}"
  • Markdown linter passes: markdownlint "**/*.md"
  • YAML linter passes: yamllint .

Testing

  • Added unit tests for new functionality
  • Updated existing tests if behavior changed
  • All tests follow the AAA (Arrange, Act, Assert) pattern
  • Test coverage is maintained or improved

Documentation

  • Updated README.md (if applicable)
  • Updated ARCHITECTURE.md (if applicable)
  • Added code examples for new features (if applicable)
  • Updated requirements.yaml (if applicable)

Additional Notes

The lint check intentionally reports all detectable issues rather than stopping at the first error, so users can fix multiple problems in one pass. All error messages identify the problematic file; YAML syntax errors also include the line and column number. Error tests capture output via --log and assert specific content (filename, "at line", field name) so assertions are reliable regardless of --silent mode.

Original prompt

This section details on the original issue you should resolve

<issue_title>[Feature]: Add --lint support</issue_title>
<issue_description>### Problem Statement

ReviewMark should have a lint option to lint the configuration file and report issues.

Proposed Solution

Add a --lint command which reads the configuration file and checks if it's valid. The result should be written using the Context.WriteLine or Context.WriteError so lint-failures also result in a non-zero exit code.

Alternatives Considered

No response

Usage Examples

Benefits

This provides the ability to check the configuration file is valid.

Priority

Medium - Would improve my workflow

Willingness to Contribute

Yes, I can submit a pull request

Additional Context

Lint errors should be clear about the cause and location so that the issues can be easily fixed.

Checklist

  • I have searched existing issues to ensure this is not a duplicate
  • I have provided a clear description of the feature
  • I have explained why this feature would be useful</issue_description>

Comments on the Issue (you are @copilot in this section)


🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

Copilot AI changed the title [WIP] Add --lint command for configuration validation feat: Add --lint support for validating definition files Mar 24, 2026
Copilot AI requested a review from Malcolmnixon March 24, 2026 21:42
…ge assertions, corrupted YAML tests

Co-authored-by: Malcolmnixon <1863707+Malcolmnixon@users.noreply.github.com>
Agent-Logs-Url: https://github.com/demaconsulting/ReviewMark/sessions/245f177b-039d-4058-a8eb-3fce0818cd47
// Assert — non-zero exit code and log contains an error about invalid content
var logContent = File.ReadAllText(logFile);
Assert.AreEqual(1, context.ExitCode);
Assert.Contains("Error:", logContent);
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm going to need to see more information and more tests than this - does it say WHAT file is bad. Just saying it contains "Error:" doesn't tell me it actually provides useful corrupted-file information.

I'm also going to want a test where a parent requirements.yaml file is valid, but it includes a child file which is corrupt, and I want to see that included file is reported as being the source of the problem.

Ideally I'd like to see that both the file and line number is reported. This is a "--lint" test, and linting is supposed to provide enough information for the user to actually fix the problem.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Addressed in commit 72a7c70:

Error messages now include filename and line number. Load uses a new ReviewMarkConfigurationHelpers.DeserializeRaw(yaml, filePath) helper that formats YAML parse errors as "Failed to parse 'filename' at line X, column Y: ...". Semantic errors (missing evidence-source, etc.) are formatted as "Invalid configuration in 'filename': ...".

Includes support added. The .reviewmark.yaml format now accepts an includes: list of relative paths to child fragment files. Their reviews and needs-review content is merged into the parent. If a child file is missing or corrupted, the error message names the child file (not the parent) with line/column.

Tests strengthened:

  • CorruptedYaml and IncludedFileCorrupted tests now assert "at line" (not just "line") so a numeric position is verified
  • New Program_Run_WithLintFlag_IncludedFileCorrupted_ReportsChildFilename: valid parent, corrupted child; asserts child filename and "at line" in error
  • 5 new ReviewMarkConfigurationTests: filename-in-error for invalid YAML and missing evidence-source; includes merging; missing/corrupted included file errors naming the child file and line

…pport, and stronger test assertions

Co-authored-by: Malcolmnixon <1863707+Malcolmnixon@users.noreply.github.com>
Agent-Logs-Url: https://github.com/demaconsulting/ReviewMark/sessions/7318deb4-3700-47ba-b4b8-b7c3e37c4b4e
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.

[Feature]: Add --lint support

2 participants