[go: nahoru, domu]

Skip to content

Commit

Permalink
resolve all checkstyle errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Yaniv Inbar committed Jun 23, 2011
1 parent a0336ba commit 300c933
Show file tree
Hide file tree
Showing 12 changed files with 64 additions and 42 deletions.
14 changes: 14 additions & 0 deletions checkstyle-suppressions.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0"?>
<!DOCTYPE suppressions PUBLIC
"-//Puppy Crawl//DTD Suppressions 1.0//EN"
"http://www.puppycrawl.com/dtds/suppressions_1_0.dtd">

<suppressions>

<!-- Don't check Base64.java because it was copied from anther proejct. -->
<suppress checks="." files="Base64.java"/>

<!-- Don't check JavaDoc on tests in com.google.api.testing.json. -->
<suppress checks="JavadocType" files="com/google/api/client/testing/json/.*Test.java"/>

</suppressions>
16 changes: 4 additions & 12 deletions checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -70,16 +70,11 @@ page at http://checkstyle.sourceforge.net/config.html -->
<property name="severity" value="error"/>
</module>

<module name="UnusedImports">
<!-- Checks for unused import statements. -->
<property name="severity" value="error"/>
</module>

<module name="ImportOrder">
<!-- Checks for out of order import statements. -->

<property name="severity" value="warning"/>
<property name="groups" value="com.google,*,java,javax"/>
<property name="groups" value="com.google,android,junit,org,java,javax"/>
<!-- This ensures that static imports go first. -->
<property name="option" value="top"/>
<property name="tokens" value="STATIC_IMPORT, IMPORT"/>
Expand All @@ -96,9 +91,11 @@ page at http://checkstyle.sourceforge.net/config.html -->
<module name="JavadocMethod">
<property name="scope" value="protected"/>
<property name="severity" value="warning"/>
<property name="allowMissingReturnTag" value="true"/>
<property name="allowMissingJavadoc" value="true"/>
<property name="allowMissingParamTags" value="true"/>
<property name="allowMissingReturnTag" value="true"/>
<property name="allowMissingThrowsTags" value="true"/>
<property name="allowThrowsTagsForSubclasses" value="true"/>
<property name="allowUndeclaredRTE" value="true"/>
</module>

Expand All @@ -107,11 +104,6 @@ page at http://checkstyle.sourceforge.net/config.html -->
<property name="severity" value="error"/>
</module>

<module name="JavadocVariable">
<property name="scope" value="protected"/>
<property name="severity" value="error"/>
</module>

<module name="JavadocStyle">
<property name="severity" value="warning"/>
</module>
Expand Down
4 changes: 2 additions & 2 deletions google-http-client/.settings/org.eclipse.jdt.ui.prefs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#Fri Mar 18 23:23:48 EDT 2011
#Thu Jun 23 11:55:32 EDT 2011
cleanup.add_default_serial_version_id=true
cleanup.add_generated_serial_version_id=false
cleanup.add_missing_annotations=true
Expand Down Expand Up @@ -58,7 +58,7 @@ formatter_settings_version=11
org.eclipse.jdt.ui.exception.name=exception
org.eclipse.jdt.ui.gettersetter.use.is=false
org.eclipse.jdt.ui.ignorelowercasenames=true
org.eclipse.jdt.ui.importorder=com;org;;java;javax;
org.eclipse.jdt.ui.importorder=com.google;;java;javax;
org.eclipse.jdt.ui.javadoc=true
org.eclipse.jdt.ui.keywordthis=false
org.eclipse.jdt.ui.ondemandthreshold=999
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
*/
public abstract class AbstractInputStreamContent implements HttpContent {

private final static int BUFFER_SIZE = 2048;
private static final int BUFFER_SIZE = 2048;

/**
* Content type or {@code null} for none.
Expand Down Expand Up @@ -75,7 +75,7 @@ public AbstractInputStreamContent(String type) {
* {@link #retrySupported()} this should be a factory function which will create a new
* {@link InputStream} from the source data whenever invoked.
*/
abstract protected InputStream getInputStream() throws IOException;
protected abstract InputStream getInputStream() throws IOException;

public void writeTo(OutputStream out) throws IOException {
InputStream inputStream = getInputStream();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
/*
* Copyright (c) 2011 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/

package com.google.api.client.http;

import com.google.common.base.Preconditions;
Expand Down Expand Up @@ -94,9 +108,9 @@ public static MultipartRelatedContent forRequest(HttpRequest request, HttpConten
}

public void writeTo(OutputStream out) throws IOException {
byte[] END_OF_PART = boundary.getBytes();
byte[] boundayBytes = boundary.getBytes();
out.write(TWO_DASHES);
out.write(END_OF_PART);
out.write(boundayBytes);
for (HttpContent part : parts) {
String contentType = part.getType();
byte[] typeBytes = contentType.getBytes();
Expand All @@ -112,7 +126,7 @@ public void writeTo(OutputStream out) throws IOException {
part.writeTo(out);
out.write(CR_LF);
out.write(TWO_DASHES);
out.write(END_OF_PART);
out.write(boundayBytes);
}
out.write(TWO_DASHES);
out.flush();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public class ProtocolBuffers {

/**
* Parses protocol buffer content from an input stream (closing the input stream) into a protocol
* buffer message
* buffer message.
*
* @param <T> destination message type
* @param messageClass destination message class that has a {@code parseFrom(InputStream)} public
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@
* {@link ConcurrentMap}.
* </p>
*
* @param <K> the type of keys maintained by this map
* @param <V> the type of mapped values
*
* @since 1.0
* @author Yaniv Inbar
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,22 +82,22 @@ public class Data {
public static final DateTime NULL_DATE_TIME = new DateTime(0);

/** Cache of the magic null object for the given Java class. */
private static final ConcurrentHashMap<Class<?>, Object> nullCache =
private static final ConcurrentHashMap<Class<?>, Object> NULL_CACHE =
new ConcurrentHashMap<Class<?>, Object>();
static {
// special cases for some primitives
nullCache.put(Boolean.class, NULL_BOOLEAN);
nullCache.put(String.class, NULL_STRING);
nullCache.put(Character.class, NULL_CHARACTER);
nullCache.put(Byte.class, NULL_BYTE);
nullCache.put(Short.class, NULL_SHORT);
nullCache.put(Integer.class, NULL_INTEGER);
nullCache.put(Float.class, NULL_FLOAT);
nullCache.put(Long.class, NULL_LONG);
nullCache.put(Double.class, NULL_DOUBLE);
nullCache.put(BigInteger.class, NULL_BIG_INTEGER);
nullCache.put(BigDecimal.class, NULL_BIG_DECIMAL);
nullCache.put(DateTime.class, NULL_DATE_TIME);
NULL_CACHE.put(Boolean.class, NULL_BOOLEAN);
NULL_CACHE.put(String.class, NULL_STRING);
NULL_CACHE.put(Character.class, NULL_CHARACTER);
NULL_CACHE.put(Byte.class, NULL_BYTE);
NULL_CACHE.put(Short.class, NULL_SHORT);
NULL_CACHE.put(Integer.class, NULL_INTEGER);
NULL_CACHE.put(Float.class, NULL_FLOAT);
NULL_CACHE.put(Long.class, NULL_LONG);
NULL_CACHE.put(Double.class, NULL_DOUBLE);
NULL_CACHE.put(BigInteger.class, NULL_BIG_INTEGER);
NULL_CACHE.put(BigDecimal.class, NULL_BIG_DECIMAL);
NULL_CACHE.put(DateTime.class, NULL_DATE_TIME);
}

/**
Expand All @@ -109,10 +109,10 @@ public class Data {
* @throws IllegalArgumentException if unable to create a new instance
*/
public static <T> T nullOf(Class<?> objClass) {
Object result = nullCache.get(objClass);
Object result = NULL_CACHE.get(objClass);
if (result == null) {
synchronized (nullCache) {
result = nullCache.get(objClass);
synchronized (NULL_CACHE) {
result = NULL_CACHE.get(objClass);
if (result == null) {
if (objClass.isArray()) {
// arrays are special because we need to compute both the dimension and component type
Expand All @@ -135,7 +135,7 @@ public static <T> T nullOf(Class<?> objClass) {
// other classes are simpler
result = Types.newInstance(objClass);
}
nullCache.put(objClass, result);
NULL_CACHE.put(objClass, result);
}
}
}
Expand All @@ -153,7 +153,7 @@ public static <T> T nullOf(Class<?> objClass) {
*/
public static boolean isNull(Object object) {
// don't call nullOf because will throw IllegalArgumentException if cannot create instance
return object != null && object == nullCache.get(object.getClass());
return object != null && object == NULL_CACHE.get(object.getClass());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public static ParameterizedType getSuperParameterizedType(Type type, Class<?> su
}

/**
* Returns whether a class is either assignable to or from another class
* Returns whether a class is either assignable to or from another class.
*
* @param classToCheck class to check
* @param anotherClass another class
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public final class CharEscapers {
* <li>All other characters are converted into one or more bytes using UTF-8 encoding and each
* byte is then represented by the 3-character string "%XY", where "XY" is the two-digit,
* uppercase, hexadecimal representation of the byte value.
* <ul>
* </ul>
*
* <p>
* <b>Note</b>: Unlike other escapers, URI escapers produce uppercase hexadecimal sequences. From
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,6 @@
public class PercentEscaper extends UnicodeEscaper {
/**
* A string of safe characters that mimics the behavior of {@link java.net.URLEncoder}.
*
* TODO: Fix escapers to be compliant with RFC 3986
*/
public static final String SAFECHARS_URLENCODER = "-_.*";

Expand Down
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@
<configuration>
<configLocation>checkstyle.xml</configLocation>
<consoleOutput>true</consoleOutput>
<suppressionsLocation>${basedir}/../checkstyle-suppressions.xml</suppressionsLocation>
</configuration>
</plugin>
</plugins>
Expand Down

0 comments on commit 300c933

Please sign in to comment.