parent
fc128c18dd
commit
9bf476ac4f
@ -15,6 +15,8 @@ This is a {{ site.pmd.release_type }} release.
|
||||
### 🚀 New and noteworthy
|
||||
|
||||
### 🐛 Fixed Issues
|
||||
* core
|
||||
* [#5091](https://github.com/pmd/pmd/issues/5091): \[core] PMD CPD v7.3.0 gives deprecation warning for skipLexicalErrors even when not used
|
||||
|
||||
### 🚨 API Changes
|
||||
|
||||
|
@ -111,9 +111,6 @@ public class CPDTask extends Task {
|
||||
+ "Use failOnError=\"false\" to not fail the build.", Project.MSG_WARN);
|
||||
}
|
||||
|
||||
// implicitly enable skipLexicalErrors, so that we can fail the build at the end. A report is created in any case.
|
||||
config.setSkipLexicalErrors(true);
|
||||
|
||||
config.setIgnoreAnnotations(ignoreAnnotations);
|
||||
config.setIgnoreLiterals(ignoreLiterals);
|
||||
config.setIgnoreIdentifiers(ignoreIdentifiers);
|
||||
|
@ -124,7 +124,6 @@ public class CpdCommand extends AbstractAnalysisPmdSubcommand<CPDConfiguration>
|
||||
configuration.setRendererName(rendererName);
|
||||
configuration.setSkipBlocksPattern(skipBlocksPattern);
|
||||
configuration.setSkipDuplicates(skipDuplicates);
|
||||
configuration.setSkipLexicalErrors(skipLexicalErrors);
|
||||
configuration.setSourceEncoding(encoding.getEncoding());
|
||||
configuration.setInputUri(uri);
|
||||
|
||||
@ -133,9 +132,6 @@ public class CpdCommand extends AbstractAnalysisPmdSubcommand<CPDConfiguration>
|
||||
configuration.setFailOnError(false);
|
||||
}
|
||||
|
||||
// implicitly enable skipLexicalErrors, so that we can fail the build at the end. A report is created in any case.
|
||||
configuration.setSkipLexicalErrors(true);
|
||||
|
||||
return configuration;
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
package net.sourceforge.pmd.cli;
|
||||
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.hamcrest.Matchers.emptyString;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
@ -146,7 +146,7 @@ abstract class BaseCliTest {
|
||||
}
|
||||
|
||||
public void checkNoErrorOutput() {
|
||||
checkStdErr(equalTo(""));
|
||||
checkStdErr(emptyString());
|
||||
}
|
||||
|
||||
public void checkStdOut(Matcher<? super String> matcher) {
|
||||
|
@ -239,10 +239,24 @@ class CpdCliTest extends BaseCliTest {
|
||||
"--skip-lexical-errors")
|
||||
.verify(r -> {
|
||||
r.checkStdErr(containsPattern("Skipping file: Lexical error in file .*?BadFile\\.java"));
|
||||
r.checkStdErr(containsString("--skip-lexical-errors is deprecated. Use --no-fail-on-error instead."));
|
||||
r.checkStdOut(containsString("Found a 5 line (13 tokens) duplication"));
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @see <a href="https://github.com/pmd/pmd/issues/5091">[core] PMD CPD v7.3.0 gives deprecation warning for skipLexicalErrors even when not used #5091</a>
|
||||
* @throws Exception
|
||||
*/
|
||||
@Test
|
||||
void noWarningsWithoutSkipLexicalErrors() throws Exception {
|
||||
runCliSuccessfully("--minimum-tokens", "340", "--language", "java", "--dir", SRC_DIR, "--format", "text")
|
||||
.verify(r -> {
|
||||
r.checkNoErrorOutput();
|
||||
r.checkStdOut(emptyString());
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
void testExitCodeWithLexicalErrors() throws Exception {
|
||||
runCli(RECOVERED_ERRORS_OR_VIOLATIONS,
|
||||
|
@ -67,7 +67,8 @@ public class CPDConfiguration extends AbstractConfiguration {
|
||||
private boolean ignoreIdentifierAndLiteralSequences = false;
|
||||
|
||||
@Deprecated
|
||||
private boolean skipLexicalErrors = false;
|
||||
// Note: The default value was false until up to 7.3.0 and is true since 7.4.0
|
||||
private boolean skipLexicalErrors = true;
|
||||
|
||||
private boolean noSkipBlocks = false;
|
||||
|
||||
|
@ -153,10 +153,6 @@ public final class CpdAnalysis implements AutoCloseable {
|
||||
|
||||
@SuppressWarnings("PMD.CloseResource")
|
||||
public void performAnalysis(Consumer<CPDReport> consumer) {
|
||||
if (configuration.isSkipLexicalErrors()) {
|
||||
LOGGER.warn("The option skipLexicalErrors is deprecated. Use failOnError instead.");
|
||||
}
|
||||
|
||||
try (SourceManager sourceManager = new SourceManager(files.getCollectedFiles())) {
|
||||
Map<Language, CpdLexer> tokenizers =
|
||||
sourceManager.getTextFiles().stream()
|
||||
|
@ -223,7 +223,6 @@ class CpdAnalysisTest {
|
||||
PmdReporter reporter = mock(PmdReporter.class);
|
||||
config.setReporter(reporter);
|
||||
|
||||
config.setSkipLexicalErrors(true); // must be true, otherwise CPD is aborted with first processing error
|
||||
try (CpdAnalysis cpd = CpdAnalysis.create(config)) {
|
||||
assertTrue(cpd.files().addSourceFile(FileId.fromPathLikeString("foo.dummy"), DummyLanguageModule.CPD_THROW_LEX_EXCEPTION));
|
||||
assertTrue(cpd.files().addSourceFile(FileId.fromPathLikeString("foo2.dummy"), DummyLanguageModule.CPD_THROW_MALFORMED_SOURCE_EXCEPTION));
|
||||
@ -252,7 +251,6 @@ class CpdAnalysisTest {
|
||||
PmdReporter reporter = mock(PmdReporter.class);
|
||||
config.setReporter(reporter);
|
||||
|
||||
config.setSkipLexicalErrors(true);
|
||||
try (CpdAnalysis cpd = CpdAnalysis.create(config)) {
|
||||
assertTrue(cpd.files().addSourceFile(FileId.fromPathLikeString("foo.dummy"), DummyLanguageModule.CPD_THROW_LEX_EXCEPTION));
|
||||
assertTrue(cpd.files().addSourceFile(FileId.fromPathLikeString("foo2.dummy"), DummyLanguageModule.CPD_THROW_MALFORMED_SOURCE_EXCEPTION));
|
||||
|
Loading…
x
Reference in New Issue
Block a user