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

SLCORE-1038 Remove workaround for suppressing noisy analyzer logs #1161

Merged
merged 1 commit into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,12 @@
package org.sonarsource.sonarlint.core.commons.log;

import java.util.Optional;
import java.util.regex.Pattern;
import javax.annotation.CheckForNull;
import javax.annotation.Nullable;
import org.sonarsource.sonarlint.core.commons.log.LogOutput.Level;

class LogOutputDelegator {

/**
* Temporary until the actual log is removed from sonar-analyzer-commons
* See SLCORE-520
*/
private static final Pattern SKIPPED_MESSAGE_PATTERN = Pattern.compile("^Skipping section '.*?' for rule '.*?', content is empty$");

private final InheritableThreadLocal<LogOutput> target = new InheritableThreadLocal<>();

void log(@Nullable String formattedMessage, Level level, @Nullable String stackTrace) {
Expand All @@ -42,9 +35,6 @@ void log(@Nullable String formattedMessage, Level level, @Nullable String stackT
return noLogOutputConfigured;
});
if (output != null) {
if (formattedMessage != null && level == Level.DEBUG && SKIPPED_MESSAGE_PATTERN.matcher(formattedMessage).matches()) {
return;
}
output.log(formattedMessage, level, stackTrace);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
package org.sonarsource.sonarlint.core.commons.log;

import org.junit.jupiter.api.Test;
import org.mockito.ArgumentMatchers;
import org.sonarsource.sonarlint.core.commons.log.LogOutput.Level;

import static org.assertj.core.api.Assertions.assertThat;
Expand Down Expand Up @@ -71,12 +70,4 @@ void handle_nulls() {
delegator.log(null, Level.ERROR, (Throwable) null);
verifyNoInteractions(output);
}

@Test
void should_not_log_skipped_message() {
var messageToSkip = "Skipping section 'introduction' for rule 'S123', content is empty";
delegator.setTarget(output);
delegator.log(messageToSkip, Level.DEBUG, (Throwable) null);
verifyNoInteractions(output);
}
}