Skip to content

Commit 097c77b

Browse files
authored
Adding analyzer feedback for Squeaky Clean concept exercise (#2727)
* Adding analyzer feedback for Squeaky Clean concept exercise Updating design.md with the analyzer recommendations Updating hints to not be as specific and tell directly the methods to the student Update reference resolution to use isWhitespace * Applying suggestion
1 parent 27427c3 commit 097c77b

File tree

3 files changed

+20
-10
lines changed

3 files changed

+20
-10
lines changed

exercises/concept/squeaky-clean/.docs/hints.md

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,29 +3,24 @@
33
## 1. Replace any spaces encountered with underscores
44

55
- [This tutorial][chars-tutorial] is useful.
6-
- [Reference documentation][chars-docs] for `char`s is here.
76
- You can retrieve `char`s from a string using the [charAt][char-at] method.
87
- You should use a [`StringBuilder`][string-builder] to build the output string.
9-
- See [this method][iswhitespace] for detecting spaces. Remember it is a static method.
8+
- Check the [Character][chars-docs] documentation for a method to detect whitespaces. Remember it is a static method.
109
- `char` literals are enclosed in single quotes.
1110

1211
## 2. Convert kebab-case to camel-case
1312

14-
- See [this method][toupper] to convert a character to upper case.
13+
- Check the [Character][chars-docs] documentation for a method to convert a character to upper case. Remember it is a static method.
1514

1615
## 3. Convert leetspeak to normal text
1716

18-
- See [this method][isdigit] for detecting numbers.
17+
- Check the [Character][chars-docs] documentation for a method to detect when a character is a digit. Remember it is a static method.
1918

2019
## 4. Omit characters that are not letters
2120

22-
- See [this method][isletter] to check if a character is a letter.
21+
- Check the [Character][chars-docs] documentation for a method to detect when a character is a letter. Remember it is a static method.
2322

2423
[chars-docs]: https://docs.oracle.com/en/java/javase/14/docs/api/java.base/java/lang/Character.html
2524
[chars-tutorial]: https://docs.oracle.com/javase/tutorial/java/data/characters.html
2625
[char-at]: https://docs.oracle.com/en/java/javase/14/docs/api/java.base/java/lang/String.html#charAt(int)
2726
[string-builder]: https://docs.oracle.com/en/java/javase/14/docs/api/java.base/java/lang/StringBuilder.html
28-
[iswhitespace]: https://docs.oracle.com/en/java/javase/14/docs/api/java.base/java/lang/Character.html#isWhitespace(char)
29-
[toupper]: https://docs.oracle.com/en/java/javase/14/docs/api/java.base/java/lang/Character.html#toUpperCase(char)
30-
[isletter]: https://docs.oracle.com/en/java/javase/14/docs/api/java.base/java/lang/Character.html#isLetter(char)
31-
[isdigit]: https://docs.oracle.com/en/java/javase/14/docs/api/java.base/java/lang/Character.html#isDigit(char)

exercises/concept/squeaky-clean/.meta/design.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,18 @@
2727

2828
- `strings`: know of the `string` type that will be iterated over and accessed by index.
2929
- `for-loop` for loops (rather than foreach) are the best means of highlighting the relationship between strings and `char`s
30+
31+
## Analyzer
32+
33+
This exercise could benefit from the following rules in the [analyzer]:
34+
35+
- `actionable`: If the solution did not use `Character.isWhitespace`, instruct the student to do so, because this concept intends to teach the character concept and methods.
36+
- `actionable`: If the solution did not use `Character.isDigit`, instruct the student to do so.
37+
- `actionable`: If the solution did not use `Character.isLetter`, instruct the student to do so.
38+
- `actionable`: If the solution did not use `Character.toUpperCase`, instruct the student to do so.
39+
- `informative`: If the solution uses string concatenation instead of `StringBuilder`, inform the student that this cause a small performance and memory penalty compared to `StringBuilder`.
40+
41+
If the solution does not receive any of the above feedback, it must be exemplar.
42+
Leave a `celebratory` comment to celebrate the success!
43+
44+
[analyzer]: https://github.com/exercism/java-analyzer

exercises/concept/squeaky-clean/.meta/src/reference/java/SqueakyClean.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ static String clean(String identifier) {
2424
boolean kebab = false;
2525
for (int i = 0; i < identifier.length(); i++) {
2626
final char ch = identifier.charAt(i);
27-
if (Character.isSpaceChar(ch)) {
27+
if (Character.isWhitespace(ch)) {
2828
cleanIdentifier.append("_");
2929
} else if (Character.isDigit(ch)) {
3030
cleanIdentifier.append(SqueakyClean.replaceDigit(ch));

0 commit comments

Comments
 (0)