From de5908615c21193a37d1ca2c416f7cdac75e6c31 Mon Sep 17 00:00:00 2001 From: Kah Goh Date: Fri, 2 Feb 2024 21:24:48 +0800 Subject: [PATCH] Add analyzer feedback for Annalyns Infiltration (#2700) * Add analyzer feedback for Annalyns Infiltration * Update analyzer according to comments * Make if statement comment essential * Remove trailing space * Fix formatting * Fix formatting --- .../annalyns-infiltration/.meta/design.md | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/exercises/concept/annalyns-infiltration/.meta/design.md b/exercises/concept/annalyns-infiltration/.meta/design.md index 4fb590e67..d4084b93b 100644 --- a/exercises/concept/annalyns-infiltration/.meta/design.md +++ b/exercises/concept/annalyns-infiltration/.meta/design.md @@ -17,3 +17,30 @@ Nothing to report ## Prerequisites - `basics`: know how to define methods. + +## Analyzer + +This exercise could benefit from the following rules in the [analyzer]: + +- `essential`: If student returns a boolean literal, tell them it is possible to directly return the result of a expression. For example: + + ```java + // instead of + if (knightIsAwake) { + return true; + } else { + return false; + } + + // ... return the expression directly + return knightIsAwake; + ``` + +- `essential`: If the student compares a boolean variable with a boolean literal (e.g. `knightIsAwake == true` or `archerIsAwake == false`), tell them this can be simplified to just the variables (e.g. `knightIsAwake` or `archerIsAwake`). +- `essential`: If the student uses an `if` statement or the ternary operator, tell them this exercise was to explore booleans and boolean operators and this exercise can be solved without them. +- `informative`: If the student uses an `||` expression to OR two smaller expressions and either expression is surrounded by parentheses and only ANDs some terms together (e.g. `knightIsAwake || (archerIsAwake && !prisonerIsAwake)`), tell them the parentheses is unnecessary because `&&` has the higher precedence over `||`. + +If the solution does not receive any of the above feedback, it must be exemplar. +Leave a `celebratory` comment to celebrate the success! + +[analyzer]: https://github.com/exercism/java-analyzer