Skip to content

Linter tests and improvements#613

Open
niknetniko wants to merge 6 commits intomasterfrom
linter-tests
Open

Linter tests and improvements#613
niknetniko wants to merge 6 commits intomasterfrom
linter-tests

Conversation

@niknetniko
Copy link
Member

Follow-up to #610:

  • Unify handling of line/column numbers for all linters
  • Add a whole bunch of more tests for linters
    • Previously, we just checked that the linter did something
    • Now we test a lot more details, which will also help when we upgrade linters in the future
  • Fixed some uncovered bugs and off-by-one errors in, e.g. HLint

@niknetniko niknetniko self-assigned this Feb 8, 2026
@niknetniko niknetniko marked this pull request as ready for review February 15, 2026 11:28
@niknetniko niknetniko requested a review from chvp February 15, 2026 11:28
Copy link
Member

@chvp chvp left a comment

Choose a reason for hiding this comment

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

👌

Comment on lines +88 to +95
"rows": {
"type": "integer",
"minimum": 1
},
"columns": {
"type": "integer",
"minimum": 1
}
Copy link
Member

Choose a reason for hiding this comment

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

Is this something we should apply in the Dodona codebase as well?

Copy link
Member Author

Choose a reason for hiding this comment

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

  • For rows, not sure. For manual annotations this is enforced, but the client code does seem to handle it, so unsure if there are valid use-cases.
  • For columns this is actually a good point, Dodona does support it, so I changed TESTed to emit those as well (instead of ignoring the column span information in that case), forgot we supported this.
    • The use case is e.g. end-of-line annotations

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 is a follow-up to #610, unifying the handling of line/column numbers across all linters, adding comprehensive tests, and fixing several uncovered bugs and off-by-one errors.

Changes:

  • Introduced centralized get_linter_position and annotation_from_position helper functions for consistent position conversion across all linters
  • Added comprehensive unit tests for linter position conversion logic covering edge cases like zero-width annotations, exclusive vs inclusive ranges, and 0-based vs 1-based indexing
  • Refactored all language-specific linters (Bash/ShellCheck, C/C++/cppcheck, Haskell/HLint, Java/Checkstyle, JavaScript/ESLint, Kotlin/ktlint, Python/Pylint, TypeScript/ESLint) to use the new helper functions
  • Added detailed integration tests for each linter validating specific error messages, positions, and configurations
  • Updated annotation schema to allow columns=0 for zero-width annotations
  • Added TypeScript-specific ESLint rule URL handling
  • Removed language parameter from ShellCheck (always uses bash)
  • Added pytest warning suppression for Testcase class

Reviewed changes

Copilot reviewed 59 out of 59 changed files in this pull request and generated no comments.

Show a summary per file
File Description
tested/judge/linter.py Added core position conversion helpers: get_linter_position and annotation_from_position, plus centralized annotation sorting
tested/languages/bash/linter.py Refactored to use new helpers, removed unused language parameter
tested/languages/c/linter.py Refactored to use new helpers, improved location element handling
tested/languages/haskell/linter.py Refactored to use new helpers for HLint position conversion
tested/languages/java/linter.py Refactored to use new helpers for Checkstyle position conversion
tested/languages/javascript/linter.py Refactored to use new helpers for ESLint position conversion
tested/languages/kotlin/linter.py Refactored to use new helpers for ktlint position conversion
tested/languages/python/linter.py Refactored to use new helpers for Pylint position conversion
tested/languages/typescript/linter.py Refactored to use new helpers, added TypeScript-specific ESLint rule URL handling
tests/test_utils_linter.py Comprehensive unit tests for get_linter_position covering all edge cases
tests/test_linters_*.py Integration tests for each linter validating error detection, positioning, and configurations
tests/partial_output.json Updated schema to allow columns=0 and rows >= 1
tests/exercises/linter/solution/* Test fixture files for each linter
tests/exercises/linter/evaluation/* Configuration files for linter tests
tested/testsuite.py Added pytest warning suppression for Testcase class

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

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