Enable Checkstyle 7.7.
This commit is contained in:
parent
13fd0b252c
commit
0ea1959b7e
18 changed files with 92 additions and 35 deletions
|
@ -1,9 +1,10 @@
|
|||
<?xml version="1.0"?>
|
||||
<!DOCTYPE module PUBLIC
|
||||
"-//Puppy Crawl//DTD Check Configuration 1.2//EN"
|
||||
"http://www.puppycrawl.com/dtds/configuration_1_2.dtd">
|
||||
"-//Puppy Crawl//DTD Check Configuration 1.3//EN"
|
||||
"http://www.puppycrawl.com/dtds/configuration_1_3.dtd">
|
||||
|
||||
<module name="Checker">
|
||||
<module name="SuppressWarningsFilter"/>
|
||||
<module name="NewlineAtEndOfFile"/>
|
||||
<module name="FileLength"/>
|
||||
<module name="FileTabCharacter"/>
|
||||
|
@ -44,7 +45,7 @@
|
|||
<module name="LocalVariableName"/>
|
||||
<module name="MemberName"/>
|
||||
<module name="MethodName"/>
|
||||
<module name="PackageName"/>
|
||||
<!--<module name="PackageName"/>-->
|
||||
<module name="ParameterName"/>
|
||||
<module name="StaticVariableName"/>
|
||||
<module name="TypeName"/>
|
||||
|
@ -56,7 +57,9 @@
|
|||
<module name="IllegalImport"/>
|
||||
<!-- defaults to sun.* packages -->
|
||||
<module name="RedundantImport"/>
|
||||
<module name="UnusedImports"/>
|
||||
<module name="UnusedImports">
|
||||
<property name="processJavadoc" value="true"/>
|
||||
</module>
|
||||
|
||||
|
||||
<!-- Checks for Size Violations. -->
|
||||
|
@ -64,7 +67,9 @@
|
|||
<module name="LineLength">
|
||||
<property name="max" value="100"/>
|
||||
</module>
|
||||
<module name="MethodLength"/>
|
||||
<module name="MethodLength">
|
||||
<property name="max" value="200"/>
|
||||
</module>
|
||||
|
||||
|
||||
<!-- Checks for whitespace -->
|
||||
|
@ -78,7 +83,15 @@
|
|||
<module name="ParenPad"/>
|
||||
<module name="TypecastParenPad"/>
|
||||
<module name="WhitespaceAfter"/>
|
||||
<module name="WhitespaceAround"/>
|
||||
<module name="WhitespaceAround">
|
||||
<property name="tokens"
|
||||
value="ASSIGN, BAND, BAND_ASSIGN, BOR, BOR_ASSIGN, BSR, BSR_ASSIGN, BXOR, BXOR_ASSIGN,
|
||||
COLON, DIV, DIV_ASSIGN, DO_WHILE, EQUAL, GE, GT, LAND, LCURLY, LE, LITERAL_CATCH,
|
||||
LITERAL_DO, LITERAL_ELSE, LITERAL_FINALLY, LITERAL_FOR, LITERAL_IF, LITERAL_RETURN,
|
||||
LITERAL_SWITCH, LITERAL_SYNCHRONIZED, LITERAL_TRY, LITERAL_WHILE, LOR, LT, MINUS,
|
||||
MINUS_ASSIGN, MOD, MOD_ASSIGN, NOT_EQUAL, PLUS, PLUS_ASSIGN, QUESTION, SL, SLIST,
|
||||
SL_ASSIGN, SR, SR_ASSIGN, STAR, STAR_ASSIGN, LITERAL_ASSERT, TYPE_EXTENSION_AND"/>
|
||||
</module>
|
||||
|
||||
|
||||
<!-- Modifier Checks -->
|
||||
|
@ -108,7 +121,7 @@
|
|||
<!--module name="InnerAssignment"/-->
|
||||
<!--module name="MagicNumber"/-->
|
||||
<!--module name="MissingSwitchDefault"/-->
|
||||
<module name="RedundantThrows"/>
|
||||
<!--<module name="RedundantThrows"/>-->
|
||||
<module name="SimplifyBooleanExpression"/>
|
||||
<module name="SimplifyBooleanReturn"/>
|
||||
|
||||
|
@ -127,5 +140,8 @@
|
|||
<!--module name="FinalParameters"/-->
|
||||
<!--module name="TodoComment"/-->
|
||||
<module name="UpperEll"/>
|
||||
|
||||
<!-- Make the @SuppressWarnings annotations available to Checkstyle -->
|
||||
<module name="SuppressWarningsHolder"/>
|
||||
</module>
|
||||
</module>
|
||||
|
|
|
@ -21,7 +21,7 @@ import com.squareup.moshi.recipes.models.Player;
|
|||
|
||||
public final class CustomFieldName {
|
||||
public void run() throws Exception {
|
||||
String json = ""
|
||||
String json = ""
|
||||
+ "{"
|
||||
+ " \"username\": \"jesse\","
|
||||
+ " \"lucky number\": 32"
|
||||
|
|
|
@ -44,6 +44,7 @@ public final class FromJsonWithoutStrings {
|
|||
new FromJsonWithoutStrings().run();
|
||||
}
|
||||
|
||||
@SuppressWarnings("checkstyle:membername")
|
||||
private static final class EventJson {
|
||||
String title;
|
||||
String begin_date;
|
||||
|
@ -55,10 +56,10 @@ public final class FromJsonWithoutStrings {
|
|||
String beginDateAndTime;
|
||||
|
||||
@Override public String toString() {
|
||||
return "Event{" +
|
||||
"title='" + title + '\'' +
|
||||
", beginDateAndTime='" + beginDateAndTime + '\'' +
|
||||
'}';
|
||||
return "Event{"
|
||||
+ "title='" + title + '\''
|
||||
+ ", beginDateAndTime='" + beginDateAndTime + '\''
|
||||
+ '}';
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ import com.squareup.moshi.recipes.models.BlackjackHand;
|
|||
|
||||
public final class ReadJson {
|
||||
public void run() throws Exception {
|
||||
String json = ""
|
||||
String json = ""
|
||||
+ "{\n"
|
||||
+ " \"hidden_card\": {\n"
|
||||
+ " \"rank\": \"6\",\n"
|
||||
|
|
|
@ -32,6 +32,9 @@ import java.util.Set;
|
|||
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||
|
||||
final class Unwrap {
|
||||
private Unwrap() {
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
String json = ""
|
||||
+ "{\"data\":"
|
||||
|
|
|
@ -17,13 +17,14 @@ package com.squareup.moshi.recipes.models;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
@SuppressWarnings("checkstyle:membername")
|
||||
public final class BlackjackHand {
|
||||
public final Card hidden_card;
|
||||
public final List<Card> visible_cards;
|
||||
|
||||
public BlackjackHand(Card hidden_card, List<Card> visible_cards) {
|
||||
this.hidden_card = hidden_card;
|
||||
this.visible_cards = visible_cards;
|
||||
public BlackjackHand(Card hiddenCard, List<Card> visibleCards) {
|
||||
this.hidden_card = hiddenCard;
|
||||
this.visible_cards = visibleCards;
|
||||
}
|
||||
|
||||
@Override public String toString() {
|
||||
|
|
|
@ -31,7 +31,7 @@ final class AdapterMethodsFactory implements JsonAdapter.Factory {
|
|||
private final List<AdapterMethod> toAdapters;
|
||||
private final List<AdapterMethod> fromAdapters;
|
||||
|
||||
public AdapterMethodsFactory(List<AdapterMethod> toAdapters, List<AdapterMethod> fromAdapters) {
|
||||
AdapterMethodsFactory(List<AdapterMethod> toAdapters, List<AdapterMethod> fromAdapters) {
|
||||
this.toAdapters = toAdapters;
|
||||
this.fromAdapters = fromAdapters;
|
||||
}
|
||||
|
@ -271,7 +271,7 @@ final class AdapterMethodsFactory implements JsonAdapter.Factory {
|
|||
return null;
|
||||
}
|
||||
|
||||
static abstract class AdapterMethod {
|
||||
abstract static class AdapterMethod {
|
||||
final Type type;
|
||||
final Set<? extends Annotation> annotations;
|
||||
final Object adapter;
|
||||
|
@ -280,7 +280,7 @@ final class AdapterMethodsFactory implements JsonAdapter.Factory {
|
|||
final JsonAdapter<?>[] jsonAdapters;
|
||||
final boolean nullable;
|
||||
|
||||
public AdapterMethod(Type type, Set<? extends Annotation> annotations, Object adapter,
|
||||
AdapterMethod(Type type, Set<? extends Annotation> annotations, Object adapter,
|
||||
Method method, int parameterCount, int adaptersOffset, boolean nullable) {
|
||||
this.type = Types.canonicalize(type);
|
||||
this.annotations = annotations;
|
||||
|
|
|
@ -194,7 +194,7 @@ final class ClassJsonAdapter<T> extends JsonAdapter<T> {
|
|||
final Field field;
|
||||
final JsonAdapter<T> adapter;
|
||||
|
||||
public FieldBinding(String name, Field field, JsonAdapter<T> adapter) {
|
||||
FieldBinding(String name, Field field, JsonAdapter<T> adapter) {
|
||||
this.name = name;
|
||||
this.field = field;
|
||||
this.adapter = adapter;
|
||||
|
|
|
@ -58,7 +58,7 @@ public abstract class JsonAdapter<T> {
|
|||
/**
|
||||
* Encodes {@code value} as a Java value object comprised of maps, lists, strings, numbers,
|
||||
* booleans, and nulls.
|
||||
*
|
||||
*
|
||||
* <p>Values encoded using {@code value(double)} or {@code value(long)} are modeled with the
|
||||
* corresponding boxed type. Values encoded using {@code value(Number)} are modeled as a
|
||||
* {@link Long} for boxed integer types ({@link Byte}, {@link Short}, {@link Integer}, and {@link
|
||||
|
|
|
@ -182,7 +182,7 @@ public abstract class JsonReader implements Closeable {
|
|||
final String[] pathNames = new String[32];
|
||||
final int[] pathIndices = new int[32];
|
||||
|
||||
/** True to accept non-spec compliant JSON */
|
||||
/** True to accept non-spec compliant JSON. */
|
||||
boolean lenient;
|
||||
|
||||
/** True to throw a {@link JsonDataException} on any attempt to call {@link #skipValue()}. */
|
||||
|
|
|
@ -17,6 +17,8 @@ package com.squareup.moshi;
|
|||
|
||||
/** Lexical scoping elements within a JSON reader or writer. */
|
||||
final class JsonScope {
|
||||
private JsonScope() {
|
||||
}
|
||||
|
||||
/** An array with no elements requires no separators or newlines before it is closed. */
|
||||
static final int EMPTY_ARRAY = 1;
|
||||
|
|
|
@ -50,7 +50,7 @@ final class JsonValueReader extends JsonReader {
|
|||
|
||||
private final Object[] stack = new Object[32];
|
||||
|
||||
public JsonValueReader(Object root) {
|
||||
JsonValueReader(Object root) {
|
||||
scopes[stackSize] = JsonScope.NONEMPTY_DOCUMENT;
|
||||
stack[stackSize++] = root;
|
||||
}
|
||||
|
|
|
@ -55,7 +55,7 @@ final class LinkedHashTreeMap<K, V> extends AbstractMap<K, V> implements Seriali
|
|||
* Create a natural order, empty tree map whose keys must be mutually
|
||||
* comparable and non-null.
|
||||
*/
|
||||
public LinkedHashTreeMap() {
|
||||
LinkedHashTreeMap() {
|
||||
this(null);
|
||||
}
|
||||
|
||||
|
@ -66,8 +66,10 @@ final class LinkedHashTreeMap<K, V> extends AbstractMap<K, V> implements Seriali
|
|||
* @param comparator the comparator to order elements with, or {@code null} to
|
||||
* use the natural ordering.
|
||||
*/
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" }) // unsafe! if comparator is null, this assumes K is comparable
|
||||
public LinkedHashTreeMap(Comparator<? super K> comparator) {
|
||||
@SuppressWarnings({
|
||||
"unchecked", "rawtypes" // Unsafe! if comparator is null, this assumes K is comparable.
|
||||
})
|
||||
LinkedHashTreeMap(Comparator<? super K> comparator) {
|
||||
this.comparator = comparator != null
|
||||
? comparator
|
||||
: (Comparator) NATURAL_ORDER;
|
||||
|
@ -473,14 +475,14 @@ final class LinkedHashTreeMap<K, V> extends AbstractMap<K, V> implements Seriali
|
|||
V value;
|
||||
int height;
|
||||
|
||||
/** Create the header entry */
|
||||
/** Create the header entry. */
|
||||
Node() {
|
||||
key = null;
|
||||
hash = -1;
|
||||
next = prev = this;
|
||||
}
|
||||
|
||||
/** Create a regular entry */
|
||||
/** Create a regular entry. */
|
||||
Node(Node<K, V> parent, K key, int hash, Node<K, V> next, Node<K, V> prev) {
|
||||
this.parent = parent;
|
||||
this.key = key;
|
||||
|
@ -665,7 +667,7 @@ final class LinkedHashTreeMap<K, V> extends AbstractMap<K, V> implements Seriali
|
|||
* comparisons. Using this class to create a tree of size <i>S</i> is
|
||||
* {@code O(S)}.
|
||||
*/
|
||||
final static class AvlBuilder<K, V> {
|
||||
static final class AvlBuilder<K, V> {
|
||||
/** This stack is a singly linked list, linked by the 'parent' field. */
|
||||
private Node<K, V> stack;
|
||||
private int leavesToSkip;
|
||||
|
|
|
@ -41,7 +41,7 @@ final class MapJsonAdapter<K, V> extends JsonAdapter<Map<K, V>> {
|
|||
private final JsonAdapter<K> keyAdapter;
|
||||
private final JsonAdapter<V> valueAdapter;
|
||||
|
||||
public MapJsonAdapter(Moshi moshi, Type keyType, Type valueType) {
|
||||
MapJsonAdapter(Moshi moshi, Type keyType, Type valueType) {
|
||||
this.keyAdapter = moshi.adapter(keyType);
|
||||
this.valueAdapter = moshi.adapter(valueType);
|
||||
}
|
||||
|
|
|
@ -24,6 +24,9 @@ import java.util.Map;
|
|||
import java.util.Set;
|
||||
|
||||
final class StandardJsonAdapters {
|
||||
private StandardJsonAdapters() {
|
||||
}
|
||||
|
||||
public static final JsonAdapter.Factory FACTORY = new JsonAdapter.Factory() {
|
||||
@Override public JsonAdapter<?> create(
|
||||
Type type, Set<? extends Annotation> annotations, Moshi moshi) {
|
||||
|
@ -216,7 +219,7 @@ final class StandardJsonAdapters {
|
|||
private final T[] constants;
|
||||
private final JsonReader.Options options;
|
||||
|
||||
public EnumJsonAdapter(Class<T> enumType) {
|
||||
EnumJsonAdapter(Class<T> enumType) {
|
||||
this.enumType = enumType;
|
||||
try {
|
||||
constants = enumType.getEnumConstants();
|
||||
|
@ -264,7 +267,7 @@ final class StandardJsonAdapters {
|
|||
static final class ObjectJsonAdapter extends JsonAdapter<Object> {
|
||||
private final Moshi moshi;
|
||||
|
||||
public ObjectJsonAdapter(Moshi moshi) {
|
||||
ObjectJsonAdapter(Moshi moshi) {
|
||||
this.moshi = moshi;
|
||||
}
|
||||
|
||||
|
|
|
@ -149,7 +149,7 @@ public final class Types {
|
|||
return (Class<?>) rawType;
|
||||
|
||||
} else if (type instanceof GenericArrayType) {
|
||||
Type componentType = ((GenericArrayType)type).getGenericComponentType();
|
||||
Type componentType = ((GenericArrayType) type).getGenericComponentType();
|
||||
return Array.newInstance(getRawType(componentType), 0).getClass();
|
||||
|
||||
} else if (type instanceof TypeVariable) {
|
||||
|
@ -560,7 +560,7 @@ public final class Types {
|
|||
private static final class GenericArrayTypeImpl implements GenericArrayType {
|
||||
private final Type componentType;
|
||||
|
||||
public GenericArrayTypeImpl(Type componentType) {
|
||||
GenericArrayTypeImpl(Type componentType) {
|
||||
this.componentType = canonicalize(componentType);
|
||||
}
|
||||
|
||||
|
@ -591,7 +591,7 @@ public final class Types {
|
|||
private final Type upperBound;
|
||||
private final Type lowerBound;
|
||||
|
||||
public WildcardTypeImpl(Type[] upperBounds, Type[] lowerBounds) {
|
||||
WildcardTypeImpl(Type[] upperBounds, Type[] lowerBounds) {
|
||||
if (lowerBounds.length > 1) throw new IllegalArgumentException();
|
||||
if (upperBounds.length != 1) throw new IllegalArgumentException();
|
||||
|
||||
|
|
|
@ -25,6 +25,9 @@ import java.util.Set;
|
|||
final class Util {
|
||||
public static final Set<Annotation> NO_ANNOTATIONS = Collections.emptySet();
|
||||
|
||||
private Util() {
|
||||
}
|
||||
|
||||
public static boolean typesMatch(Type pattern, Type candidate) {
|
||||
// TODO: permit raw types (like Set.class) to match non-raw candidates (like Set<Long>).
|
||||
return pattern.equals(candidate);
|
||||
|
|
26
pom.xml
26
pom.xml
|
@ -127,6 +127,32 @@
|
|||
</pluginManagement>
|
||||
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-checkstyle-plugin</artifactId>
|
||||
<version>2.17</version>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.puppycrawl.tools</groupId>
|
||||
<artifactId>checkstyle</artifactId>
|
||||
<version>7.7</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<configuration>
|
||||
<failsOnError>true</failsOnError>
|
||||
<configLocation>checkstyle.xml</configLocation>
|
||||
<consoleOutput>true</consoleOutput>
|
||||
<excludes>**/Iso8601Utils.java</excludes>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>verify</phase>
|
||||
<goals>
|
||||
<goal>checkstyle</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-release-plugin</artifactId>
|
||||
|
|
Loading…
Reference in a new issue