Allow checkstyle failures fatal, and fix last issues

Failing disabled by default, but setting checkstyle.ignoreFailures=false
in ~/.gradle/gradle.properties enables failing. Travis will always run
with such failing enabled.
This commit is contained in:
Eric Anderson 2015-03-21 10:59:17 -07:00
parent 9175d9d79e
commit 26141b445d
6 changed files with 31 additions and 7 deletions

View File

@ -11,6 +11,8 @@ env:
before_install:
- buildscripts/make_dependencies.sh # build protoc into /tmp/proto3-a2
- mkdir -p $HOME/.gradle
- echo "checkstyle.ignoreFailures=false" >> $HOME/.gradle/gradle.properties
jdk:
- oraclejdk8

View File

@ -91,6 +91,10 @@ subprojects {
checkstyle {
configFile = file("$rootDir/checkstyle.xml")
toolVersion = "6.2"
ignoreFailures = true
if (rootProject.hasProperty("checkstyle.ignoreFailures")) {
ignoreFailures = rootProject.properties["checkstyle.ignoreFailures"].toBoolean()
}
}
checkstyleMain {

View File

@ -24,7 +24,7 @@
<module name = "Checker">
<property name="charset" value="UTF-8"/>
<property name="severity" value="warning"/>
<property name="severity" value="error"/>
<!-- Checks for whitespace -->
<!-- See http://checkstyle.sf.net/config_whitespace.html -->

View File

@ -48,6 +48,7 @@ public class HelloWorldClient {
private final ChannelImpl channel;
private final GreeterGrpc.GreeterBlockingStub blockingStub;
/** Construct client connecting to HelloWorld server at {@code host:port}. */
public HelloWorldClient(String host, int port) {
channel =
NettyChannelBuilder.forAddress(host, port).negotiationType(NegotiationType.PLAINTEXT)
@ -59,6 +60,7 @@ public class HelloWorldClient {
channel.shutdown().awaitTerminated(5, TimeUnit.SECONDS);
}
/** Say hello to server. */
public void greet(String name) {
try {
logger.info("Will try to greet " + name + " ...");
@ -71,6 +73,10 @@ public class HelloWorldClient {
}
}
/**
* Greet server. If provided, the first element of {@code args} is the name to use in the
* greeting.
*/
public static void main(String[] args) throws Exception {
HelloWorldClient client = new HelloWorldClient("localhost", 50051);
try {

View File

@ -57,6 +57,7 @@ public class RouteGuideClient {
private final RouteGuideBlockingStub blockingStub;
private final RouteGuideStub asyncStub;
/** Construct client for accessing RoutGuide server at {@code host:port}. */
public RouteGuideClient(String host, int port) {
channel = NettyChannelBuilder.forAddress(host, port)
.negotiationType(NegotiationType.PLAINTEXT)
@ -70,7 +71,7 @@ public class RouteGuideClient {
}
/**
* This example shows how to make a blocking unary call.
* Blocking unary call example. Calls getFeature and prints the response.
*/
public void getFeature(int lat, int lon) {
try {
@ -95,7 +96,8 @@ public class RouteGuideClient {
}
/**
* This example shows how to make a blocking unary call.
* Blocking server-streaming example. Calls listFeatures with a rectangle of interest. Prints each
* response feature as it arrives.
*/
public void listFeatures(int lowLat, int lowLon, int hiLat, int hiLon) {
try {
@ -120,6 +122,11 @@ public class RouteGuideClient {
}
}
/**
* Async client-streaming example. Sends {@code numPoints} randomly chosen points from {@code
* features} with a variable delay in between. Prints the statistics when they are sent from the
* server.
*/
public void recordRoute(List<Feature> features, int numPoints) throws Exception {
info("*** RecordRoute");
final SettableFuture<Void> finishFuture = SettableFuture.create();
@ -172,7 +179,8 @@ public class RouteGuideClient {
}
/**
* This example shows how to make a bi-directional streaming call, which can only be asynchronous.
* Bi-directional example, which can only be asynchronous. Send some chat messages, and print any
* chat messages that are sent from the server.
*/
public void routeChat() throws Exception {
info("*** RoutChat");
@ -217,6 +225,7 @@ public class RouteGuideClient {
}
}
/** Issues several different requests and then exits. */
public static void main(String[] args) throws Exception {
RouteGuideClient client = new RouteGuideClient("localhost", 8980);
try {

View File

@ -69,6 +69,7 @@ public class RouteGuideServer {
this(port, RouteGuideUtil.getDefaultFeaturesFile());
}
/** Create a RouteGuide server listening on {@code port} using {@code featureFile} database. */
public RouteGuideServer(int port, URL featureFile) {
try {
this.port = port;
@ -78,6 +79,7 @@ public class RouteGuideServer {
}
}
/** Start serving requests. */
public void start() {
grpcServer = NettyServerBuilder.forPort(port)
.addService(RouteGuideGrpc.bindService(new RouteGuideService(features)))
@ -94,6 +96,7 @@ public class RouteGuideServer {
});
}
/** Stop serving requests and shutdown resources. */
public void stop() {
if (grpcServer != null) {
grpcServer.shutdown();
@ -128,7 +131,7 @@ public class RouteGuideServer {
*/
@Override
public void getFeature(Point request, StreamObserver<Feature> responseObserver) {
responseObserver.onValue(getFeature(request));
responseObserver.onValue(checkFeature(request));
responseObserver.onCompleted();
}
@ -178,7 +181,7 @@ public class RouteGuideServer {
@Override
public void onValue(Point point) {
pointCount++;
if (RouteGuideUtil.exists(getFeature(point))) {
if (RouteGuideUtil.exists(checkFeature(point))) {
featureCount++;
}
// For each point after the first, add the incremental distance from the previous point to
@ -255,7 +258,7 @@ public class RouteGuideServer {
* @param location the location to check.
* @return The feature object at the point. Note that an empty name indicates no feature.
*/
private Feature getFeature(Point location) {
private Feature checkFeature(Point location) {
for (Feature feature : features) {
if (feature.getLocation().getLatitude() == location.getLatitude()
&& feature.getLocation().getLongitude() == location.getLongitude()) {