-
Notifications
You must be signed in to change notification settings - Fork 7
Feature/dnd validation #738
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #738 +/- ##
==========================================
+ Coverage 36.84% 37.94% +1.09%
==========================================
Files 540 543 +3
Lines 23642 23775 +133
Branches 2825 2836 +11
==========================================
+ Hits 8711 9021 +310
+ Misses 14056 13864 -192
- Partials 875 890 +15 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This reverts commit 558eab8.
This fixes a bug where we didn't return a default explanation when an incorrect answer without an explanation was matched.
| } | ||
|
|
||
| void assertError(final String message, final String status) { | ||
| assertEquals(Integer.parseInt(status), response.getStatus()); |
Check notice
Code scanning / CodeQL
Missing catch of NumberFormatException Note test
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 10 days ago
To fix this problem, we should wrap the call to Integer.parseInt(status) in a try-catch block for NumberFormatException within the assertError(final String message, final String status) method. The catch block should provide meaningful feedback if a bad status string is supplied. In order to not change existing functionality, the recommended approach is to fail the assertion with a clear message indicating that the provided status could not be parsed, optionally including the original exception as the cause. We use the existing JUnit assertion facilities (assertTrue, assertEquals) for this purpose and avoid any changes outside this method.
-
Copy modified lines R167-R171
| @@ -164,7 +164,11 @@ | ||
| } | ||
|
|
||
| void assertError(final String message, final String status) { | ||
| assertEquals(Integer.parseInt(status), response.getStatus()); | ||
| try { | ||
| assertEquals(Integer.parseInt(status), response.getStatus()); | ||
| } catch (NumberFormatException e) { | ||
| throw new AssertionError("Provided status \"" + status + "\" is not a valid integer status code.", e); | ||
| } | ||
| assertTrue(this.readEntityAsJsonUnchecked().getString("errorMessage").contains(message)); | ||
| } | ||
|
|
| .findFirst(); | ||
| } | ||
|
|
||
| private class Rule { |
Check notice
Code scanning / CodeQL
Inner class could be static Note
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 1 day ago
To fix this issue, declare the Rule class as a private static class within BiRuleValidator<T, U>. Since the inner class does not use any instance members of the outer class, and its type parameters <T, U> are available in the enclosing generic class, you can parameterize Rule in the same way (i.e., private static class Rule rather than private class Rule). No other code changes are required, as Rule is only used privately within the methods of BiRuleValidator<T, U>. Add the static modifier to the Rule class declaration on line 301.
All changes are in the shown file and the fix is fully contained within the provided context.
-
Copy modified line R301
| @@ -298,7 +298,7 @@ | ||
| .findFirst(); | ||
| } | ||
|
|
||
| private class Rule { | ||
| private static class Rule { | ||
| public final String message; | ||
| public final BiPredicate<T, U> predicate; | ||
|
|
| private Function<IsaacDndQuestion, String> logMessageOp; | ||
| private Consumer<IsaacDndQuestion> questionOp; | ||
|
|
||
| public T setTitle(final String title) { |
Check notice
Code scanning / CodeQL
Useless parameter Note test
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI about 19 hours ago
The best fix is to remove the unused parameter title from the method setTitle in the TestCase class. This involves:
- Modifying the method signature from
public T setTitle(final String title)topublic T setTitle(). - Updating any invocations of
setTitlethat provide an argument, if present in the shown code (none are visible here, so only the method signature needs editing). - No other changes are needed since the parameter is never used within the method body, and removing it has no side effects on functionality.
Only the code within the snippet for src/test/java/uk/ac/cam/cl/dtg/isaac/quiz/IsaacDndValidatorTest.java—specifically, the setTitle method at line 427—needs editing.
-
Copy modified line R427
| @@ -424,7 +424,7 @@ | ||
| private Function<IsaacDndQuestion, String> logMessageOp; | ||
| private Consumer<IsaacDndQuestion> questionOp; | ||
|
|
||
| public T setTitle(final String title) { | ||
| public T setTitle() { | ||
| return self(); | ||
| } | ||
|
|
Pull Request Check List