Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
johanjaguardev opened this issue May 22, 2024 · 1 comment · May be fixed by #177
Open

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

johanjaguardev opened this issue May 22, 2024 · 1 comment · May be fixed by #177
Assignees
Labels
x:size/small Small amount of work

Comments

@johanjaguardev
Copy link

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.

@manumafe98 manumafe98 self-assigned this May 23, 2024
@manumafe98 manumafe98 added the x:size/small Small amount of work label May 23, 2024
@manumafe98
Copy link
Contributor

@johanjaguardev Thanks for opening this issue! You caught a bug, you're right, the bug is being caused by the extra result method that you added, because our analyzer function checks that all method excepting reformat contain either substring or split. in this case is detecting that result does not have any of them and triggers the comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
x:size/small Small amount of work
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants