LogLevels solution accused of hardcoding test data

Open
#271 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Needs clarification
Activity status
Stale
Tech stack
java
Domain
tooling

Research direction

Reproduce the hardcoded-test-data warning using the LogLevels Java solution shown in the issue, then trace the analyzer rule that reports it. Determine whether the required log-level strings are being misclassified and verify that the diagnostic correctly handles this solution without suppressing genuine hardcoded test data.

Written by the indexing model from the issue text.

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?

Dominant language
Java
Stars
13
Forks
27
Avg merge
4d 17h
Merged PRs (30d)
7

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from exercism/java-analyzer

All issues in exercism/java-analyzer

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.