Skip to content

Commit

Permalink
Split "log error or debug" method
Browse files Browse the repository at this point in the history
  • Loading branch information
ericmorand-sonarsource committed Mar 19, 2024
1 parent 2c3830d commit afc77ef
Showing 1 changed file with 12 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -158,19 +158,17 @@ private void saveIssues(
if (ruleKey == null) {
if ("CssSyntaxError".equals(issue.ruleId)) {
String errorMessage = issue.message.replace("(CssSyntaxError)", "").trim();
logErrorOrDebug(
logWarningOrDebug(
inputFile,
"Failed to parse file {}, line {}, {}",
true,
inputFile.uri(),
issue.line,
errorMessage
);
} else {
logErrorOrDebug(
inputFile,
"Unknown stylelint rule or rule not enabled: '" + issue.ruleId + "'",
false
"Unknown stylelint rule or rule not enabled: '" + issue.ruleId + "'"
);
}
} else {
Expand All @@ -186,18 +184,17 @@ private void saveIssues(
}
}

private static void logErrorOrDebug(
InputFile file,
String msg,
boolean logErrorAsWarning,
Object... arguments
) {
private static void logErrorOrDebug(InputFile file, String msg, Object... arguments) {
if (CssLanguage.KEY.equals(file.language())) {
if (logErrorAsWarning) {
LOG.warn(msg, arguments);
} else {
LOG.error(msg, arguments);
}
LOG.error(msg, arguments);
} else {
LOG.debug(msg, arguments);
}
}

private static void logWarningOrDebug(InputFile file, String msg, Object... arguments) {
if (CssLanguage.KEY.equals(file.language())) {
LOG.warn(msg, arguments);
} else {
LOG.debug(msg, arguments);
}
Expand Down

0 comments on commit afc77ef

Please sign in to comment.