exercism / exercism/java-analyzer

LogLevels solution accused of hardcoding test data

Open
#271 5 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
13
Forks
27
Avg merge
4d 9h
Merged PRs (30d)
6

Description

I wrote the following code for LogLevels:

`public class LogLevels {

public static String message(String logLine) {
int colonIdx = logLine.indexOf(":");
return logLine.substring(colonIdx + 1).trim();
}

public static String logLevel(String logLine) {
if (logLine.contains("INFO")) {
return "info";
} else if (logLine.contains("WARNING")) {
return "warning";
} else {
return "error";
}
}

public static String reformat(String logLine) {
return message(logLine) + " (" + logLevel(logLine) + ")";
}
}
`

However, the editor keeps saying that I've hardcoded test data. I think it might be because of the specific log level strings that I'm looking for, but what's wrong with that?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.