Issue #2551: added deprecated Check for backwards compatibility

This commit is contained in:
rnveach 2016-01-31 00:00:53 -05:00 committed by Roman Ivanov
parent cf96dd9adc
commit ba6781e109
3 changed files with 84 additions and 0 deletions

View File

@ -170,6 +170,12 @@
or @Image='AbstractCheck' or @Image='AbstractJavadocCheck']"/>
</properties>
</rule>
<rule ref="rulesets/java/design.xml/AbstractClassWithoutAnyMethod">
<properties>
<!-- Can not change API -->
<property name="violationSuppressXPath" value="//ClassOrInterfaceDeclaration[@Image='Check']"/>
</properties>
</rule>
<rule ref="rulesets/java/design.xml/AvoidDeeplyNestedIfStmts">
<properties>

View File

@ -0,0 +1,35 @@
////////////////////////////////////////////////////////////////////////////////
// checkstyle: Checks Java source code for adherence to a set of rules.
// Copyright (C) 2001-2016 the original author or authors.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
////////////////////////////////////////////////////////////////////////////////
package com.puppycrawl.tools.checkstyle.api;
/**
* The base class for checks.
*
* @deprecated Class was renamed to support the abstract class naming
* convention. This class remains only to support backwards
* compatibility. Use {@link AbstractCheck} instead.
* @author Oliver Burn
* @see <a href="{@docRoot}/../writingchecks.html" target="_top">Writing your
* own checks</a>
* @noinspection EmptyClass
*/
@Deprecated
public abstract class Check extends AbstractCheck {
}

View File

@ -0,0 +1,43 @@
////////////////////////////////////////////////////////////////////////////////
// checkstyle: Checks Java source code for adherence to a set of rules.
// Copyright (C) 2001-2016 the original author or authors.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
////////////////////////////////////////////////////////////////////////////////
package com.puppycrawl.tools.checkstyle.api;
import org.junit.Assert;
import org.junit.Test;
public class CheckTest {
@SuppressWarnings("deprecation")
@Test
public void testInstanceOfCheck() {
final Object module = new Check() {
@Override
public int[] getDefaultTokens() {
return null;
}
};
Assert.assertTrue("Check must be an instance of AbstractCheck - 1",
module instanceof AbstractCheck);
Assert.assertTrue("Check must be an instance of AbstractCheck - 2",
AbstractCheck.class.isInstance(module));
Assert.assertTrue("Check must be able to be assignable to AbstractCheck",
AbstractCheck.class.isAssignableFrom(Check.class));
}
}