Skip to content

Fix invalid C lint output#610

Merged
niknetniko merged 2 commits intomasterfrom
fix/invalid-c-lint-output
Feb 8, 2026
Merged

Fix invalid C lint output#610
niknetniko merged 2 commits intomasterfrom
fix/invalid-c-lint-output

Conversation

@chvp
Copy link
Member

@chvp chvp commented Feb 5, 2026

For some bad student code the linter was returning a column 0, which resulted in a negative column in the actual judge output, which is not allowed by Dodona. This created internal errors.

I applied a band-aid fix for this to just set to column to None in this case, since I'd guess that the - 1 actually means that the columns are 1-indexed and 0 means that there isn't really a column to latch on to, but I'm not a 100% sure of that.

@chvp chvp self-assigned this Feb 5, 2026
@chvp chvp added the bug Something isn't working label Feb 5, 2026
@chvp chvp force-pushed the fix/invalid-c-lint-output branch 2 times, most recently from ee28670 to 8cbdc7c Compare February 5, 2026 16:38
@chvp chvp force-pushed the fix/invalid-c-lint-output branch from 8cbdc7c to 2c5f9a6 Compare February 5, 2026 16:42
@chvp chvp requested a review from niknetniko February 5, 2026 16:42
@chvp chvp marked this pull request as ready for review February 5, 2026 16:42
@bmesuere
Copy link
Member

bmesuere commented Feb 6, 2026

In Java and Kotlin, we also do -1 so the same fix should be applied there.

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 fixes an issue where the C linter (cppcheck) could return column 0 for certain syntax errors, which after subtracting 1 would result in a negative column value (-1). This violated Dodona's schema requirements causing internal errors. The fix sets the column to None when the computed value would be negative.

Changes:

  • Added a safety check in the C linter to set column to None when column 0 is received from cppcheck
  • Added a test case with intentionally malformed C code to verify the fix works correctly
  • Created a test fixture file with a missing semicolon to reproduce the column 0 scenario

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
tested/languages/c/linter.py Added check to set column to None when value is negative after 1-based to 0-based conversion
tests/test_linters.py Added new test function to verify linter handles bad column values correctly
tests/exercises/echo-function/solution/bad-column-cppcheck.c Created test fixture with missing semicolon to trigger column 0 from cppcheck

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

Copy link
Member

@niknetniko niknetniko left a comment

Choose a reason for hiding this comment

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

Makes sense to me. In a follow-up I'll create some helpers to add some more tests for our linters, hopefully preventing similar issues in the future.

@niknetniko niknetniko merged commit 22fdaa6 into master Feb 8, 2026
8 of 9 checks passed
@niknetniko niknetniko deleted the fix/invalid-c-lint-output branch February 8, 2026 13:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants