there is no need to use substring in the result method in this code, kindly review

Open
#176 1 comment 0 reactions 1 assignee View on GitHub

@manumafe98 is already working on this.

Since May 23, 2024.

Assessment

This issue has not been assessed yet.

Description

x:size/small

public class LogLevels {

public static String message(String logLine) {
    int startMessageIndex = logLine.indexOf("]:") + 2;
    String result = logLine.substring(startMessageIndex, logLine.length());
    return result.trim();
}
public static String logLevel(String logLine) {
    int startLevelIndex = logLine.indexOf("[") + 1;
    int endLevelIndex = logLine.indexOf("]");
    return logLine.substring(startLevelIndex, endLevelIndex).toLowerCase();
}
public static String reformat(String logLine) {
    return LogLevels.message(logLine) + " (" + LogLevels.logLevel(logLine) + ")";
}
public static void result() {
    String logLine = "[ERROR]: Invalid operation";
    String formattedString =  LogLevels.reformat(logLine);
}

}

and the suggestion is:
Consider using the substring method in result to solve this exercise. but for this exercise the substring method is implemented in the other methods, kindly review.

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.