Skip to content

LogLevels solution accused of hardcoding test data #271

@divBad98

Description

@divBad98

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions