-
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
01161d9
commit daa8d03
Showing
3 changed files
with
48 additions
and
0 deletions.
There are no files selected for viewing
19 changes: 19 additions & 0 deletions
19
src/main/java/analyzer/exercises/loglevels/PreferStringConcatenation.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package analyzer.exercises.loglevels; | ||
|
||
import analyzer.Comment; | ||
|
||
/** | ||
* @see <a href="https://github.com/exercism/website-copy/blob/main/analyzer-comments/java/log-levels/avoid_using_string_format.md">Markdown Template</a> | ||
*/ | ||
class PreferStringConcatenation extends Comment { | ||
|
||
@Override | ||
public String getKey() { | ||
return "java.log-levels.prefer_string_concatenation"; | ||
} | ||
|
||
@Override | ||
public Type getType() { | ||
return Type.INFORMATIVE; | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
...es/analyzer/AnalyzerIntegrationTest.loglevels.NotUsingSubstringOnBothMethods.approved.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"comments": [ | ||
{ | ||
"comment": "java.log-levels.use_substring_method", | ||
"params": {}, | ||
"type": "actionable" | ||
}, | ||
{ | ||
"comment": "java.general.feedback_request", | ||
"params": {}, | ||
"type": "informative" | ||
} | ||
] | ||
} |
15 changes: 15 additions & 0 deletions
15
src/test/resources/scenarios/log-levels/NotUsingSubstringOnBothMethods.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package scenarios.loglevels; | ||
|
||
public class LogLevels { | ||
public static String message(String logLine) { | ||
return logLine.split("]: ")[1].trim(); | ||
} | ||
|
||
public static String logLevel(String logLine) { | ||
return logLine.split("]: ")[0].replace("[", "").toLowerCase(); | ||
} | ||
|
||
public static String reformat(String logLine) { | ||
return message(logLine) + " (" + logLevel(logLine) + ")"; | ||
} | ||
} |