Issue #2792: Include InterfaceTypeParameterName into Config of Google Style
This commit is contained in:
parent
e59effff08
commit
3e4367941c
|
|
@ -0,0 +1,57 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// 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.google.checkstyle.test.chapter5naming.rule528typevariablenames;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import com.google.checkstyle.test.base.BaseCheckTestSupport;
|
||||
import com.puppycrawl.tools.checkstyle.api.Configuration;
|
||||
|
||||
public class InterfaceTypeParameterNameTest extends BaseCheckTestSupport {
|
||||
|
||||
private static final String MSG_KEY = "name.invalidPattern";
|
||||
|
||||
@Override
|
||||
protected String getPath(String fileName) throws IOException {
|
||||
return super.getPath("chapter5naming" + File.separator + "rule528typevariablenames"
|
||||
+ File.separator + fileName);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInterfaceDefault() throws Exception {
|
||||
final Configuration configuration = getCheckConfig("InterfaceTypeParameterName");
|
||||
final String format = configuration.getAttribute("format");
|
||||
|
||||
final String[] expected = {
|
||||
"48:15: " + getCheckMessage(configuration.getMessages(), MSG_KEY, "Input", format),
|
||||
"76:25: " + getCheckMessage(configuration.getMessages(), MSG_KEY, "Request", format),
|
||||
"80:25: " + getCheckMessage(configuration.getMessages(), MSG_KEY, "TRequest", format),
|
||||
};
|
||||
|
||||
final String filePath = getPath("InputInterfaceTypeParameterName.java");
|
||||
|
||||
final Integer[] warnList = getLinesWithWarn(filePath);
|
||||
verify(configuration, filePath, expected, warnList);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,86 @@
|
|||
package com.google.checkstyle.test.chapter5naming.rule528typevariablenames;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class InputInterfaceTypeParameterName <t>
|
||||
{
|
||||
public <TT> void foo() { }
|
||||
|
||||
<e_e> void foo(int i) {
|
||||
}
|
||||
}
|
||||
|
||||
class OtherClass <foo extends Serializable & Cloneable> {
|
||||
|
||||
foo getOne() {
|
||||
return null;//comment
|
||||
}
|
||||
|
||||
<Tfo$o2T extends foo> /*comment*/Tfo$o2T getTwo(Tfo$o2T a) {
|
||||
return null;
|
||||
}
|
||||
|
||||
<foo extends Runnable> foo getShadow() {
|
||||
return null;
|
||||
}
|
||||
|
||||
static class Junk <foo> {
|
||||
<_fo extends foo> void getMoreFoo() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class MoreOtherClass <T extends Cloneable> {
|
||||
|
||||
<E extends T> void getMore() {
|
||||
new Other() {
|
||||
<T> void getMoreFoo() {
|
||||
}
|
||||
};
|
||||
|
||||
// Other o = new Other() {
|
||||
// <EE> void getMoreFoo() {
|
||||
// }
|
||||
// };
|
||||
}
|
||||
}
|
||||
|
||||
interface Boo<Input> { // warn
|
||||
Input boo();
|
||||
}
|
||||
|
||||
interface FooInterface<T> {
|
||||
T foo();
|
||||
}
|
||||
|
||||
interface FooInterface2 {
|
||||
Input foo();
|
||||
}
|
||||
|
||||
interface FooInterface3<T2> {
|
||||
Input foo();
|
||||
}
|
||||
|
||||
interface FooInterface4<E> {
|
||||
Input foo();
|
||||
}
|
||||
|
||||
interface FooInterface5<X> {
|
||||
Input foo();
|
||||
}
|
||||
|
||||
interface FooInterface6<RequestT> {
|
||||
Input foo();
|
||||
}
|
||||
|
||||
interface FooInterface7<Request> { // warn
|
||||
Input foo();
|
||||
}
|
||||
|
||||
interface FooInterface8<TRequest> { // warn
|
||||
Input foo();
|
||||
}
|
||||
|
||||
class Input {
|
||||
|
||||
}
|
||||
|
|
@ -128,6 +128,11 @@
|
|||
<message key="name.invalidPattern"
|
||||
value="Method type name ''{0}'' must match pattern ''{1}''."/>
|
||||
</module>
|
||||
<module name="InterfaceTypeParameterName">
|
||||
<property name="format" value="(^[A-Z][0-9]?)$|([A-Z][a-zA-Z0-9]*[T]$)"/>
|
||||
<message key="name.invalidPattern"
|
||||
value="Interface type name ''{0}'' must match pattern ''{1}''."/>
|
||||
</module>
|
||||
<module name="NoFinalizer"/>
|
||||
<module name="GenericWhitespace">
|
||||
<message key="ws.followed"
|
||||
|
|
|
|||
|
|
@ -1201,6 +1201,11 @@
|
|||
src="images/ok_green.png"
|
||||
alt="" />
|
||||
<a href="config_naming.html#ClassTypeParameterName">ClassTypeParameterName</a>
|
||||
<br/>
|
||||
<img
|
||||
src="images/ok_green.png"
|
||||
alt="" />
|
||||
<a href="config_naming.html#InterfaceTypeParameterName">InterfaceTypeParameterName</a>
|
||||
</td>
|
||||
<td>
|
||||
<a
|
||||
|
|
@ -1214,6 +1219,12 @@
|
|||
<br />
|
||||
<a
|
||||
href="https://github.com/checkstyle/checkstyle/blob/master/src/it/java/com/google/checkstyle/test/chapter5naming/rule528typevariablenames/ClassTypeParameterNameTest.java">test</a>
|
||||
<br />
|
||||
<a
|
||||
href="https://github.com/search?q=path%3Asrc%2Fmain%2Fresources+filename%3Agoogle_checks.xml+repo%3Acheckstyle%2Fcheckstyle+InterfaceTypeParameterName">config</a>
|
||||
<br />
|
||||
<a
|
||||
href="https://github.com/checkstyle/checkstyle/blob/master/src/it/java/com/google/checkstyle/test/chapter5naming/rule528typevariablenames/InterfaceTypeParameterNameTest.java">test</a>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
|
|
|||
Loading…
Reference in New Issue