add deprecations

This commit is contained in:
Clément Fournier
2022-07-22 14:33:32 +02:00
parent 8065929879
commit db430e64c5
2 changed files with 24 additions and 2 deletions

View File

@@ -30,6 +30,7 @@ import net.sourceforge.pmd.RuleSets;
import net.sourceforge.pmd.RuleViolation;
import net.sourceforge.pmd.RulesetsFactoryUtils;
import net.sourceforge.pmd.SourceCodeProcessor;
import net.sourceforge.pmd.annotation.InternalApi;
import net.sourceforge.pmd.lang.LanguageVersion;
import net.sourceforge.pmd.properties.PropertyDescriptor;
import net.sourceforge.pmd.renderers.TextRenderer;
@@ -51,6 +52,8 @@ public abstract class RuleTst {
/**
* Find a rule in a certain ruleset by name
*
* todo make this static
*/
public Rule findRule(String ruleSet, String ruleName) {
try {
@@ -73,6 +76,8 @@ public abstract class RuleTst {
* violations.
*/
@SuppressWarnings("unchecked")
@InternalApi
@Deprecated
public void runTest(TestDescriptor test) {
Rule rule = test.getRule();
@@ -218,10 +223,14 @@ public abstract class RuleTst {
/**
* Run the rule on the given code and put the violations in the report.
*/
@InternalApi
@Deprecated
public void runTestFromString(String code, Rule rule, Report report, LanguageVersion languageVersion) {
runTestFromString(code, rule, report, languageVersion, true);
}
@InternalApi
@Deprecated
public void runTestFromString(String code, Rule rule, Report report, LanguageVersion languageVersion,
boolean isUseAuxClasspath) {
try {
@@ -259,6 +268,8 @@ public abstract class RuleTst {
}
}
@InternalApi
@Deprecated
public void runTestFromString(TestDescriptor test, Rule rule, Report report) {
runTestFromString(test.getCode(), rule, report, test.getLanguageVersion(), test.isUseAuxClasspath());
}
@@ -267,6 +278,8 @@ public abstract class RuleTst {
* getResourceAsStream tries to find the XML file in weird locations if the
* ruleName includes the package, so we strip it here.
*/
@InternalApi
@Deprecated
protected String getCleanRuleName(Rule rule) {
String fullClassName = rule.getClass().getName();
if (fullClassName.equals(rule.getName())) {
@@ -284,6 +297,8 @@ public abstract class RuleTst {
* ./xml/RuleName.xml relative to the test class. The format is defined in
* test-data.xsd.
*/
@InternalApi
@Deprecated
public TestDescriptor[] extractTestsFromXml(Rule rule) {
String testsFileName = getCleanRuleName(rule);
@@ -300,6 +315,8 @@ public abstract class RuleTst {
return parseTestXml(rule, testsFileName, "xml/");
}
@InternalApi
@Deprecated
public TestDescriptor[] extractTestsFromXml(Rule rule, String testsFileName) {
return extractTestsFromXml(rule, testsFileName, "xml/");
}
@@ -309,6 +326,8 @@ public abstract class RuleTst {
* should be ./xml/[testsFileName].xml relative to the test class. The
* format is defined in test-data.xsd.
*/
@InternalApi
@Deprecated
public TestDescriptor[] extractTestsFromXml(Rule rule, String testsFileName, String baseDirectory) {
RuleTestCollection collection = parseTestXml(rule, testsFileName, baseDirectory);
return toLegacyArray(collection);
@@ -365,6 +384,8 @@ public abstract class RuleTst {
/**
* Run a set of tests of a certain sourceType.
*/
@InternalApi
@Deprecated
public void runTests(TestDescriptor[] tests) {
for (int i = 0; i < tests.length; i++) {
runTest(tests[i]);

View File

@@ -16,8 +16,11 @@ import net.sourceforge.pmd.test.schema.RuleTestDescriptor;
/**
* Stores the information required to run a complete test.
*
* @deprecated Use {@link RuleTestDescriptor} instead
*/
@Ignore("this is not a unit test")
@Deprecated
public class TestDescriptor {
private Rule rule;
private Properties properties;
@@ -32,7 +35,6 @@ public class TestDescriptor {
private boolean isRegressionTest = true;
private boolean useAuxClasspath = true;
private int numberInDocument = -1;
private boolean isFocused = false;
public TestDescriptor() {
// Empty default descriptor added to please mvn surefire plugin
@@ -63,7 +65,6 @@ public class TestDescriptor {
this.numberInDocument = td.getIndex();
this.properties = td.getProperties();
this.languageVersion = td.getLanguageVersion();
this.isFocused = td.isFocused();
}
public int getNumberInDocument() {