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: before_install:
- buildscripts/make_dependencies.sh # build protoc into /tmp/proto3-a2 - buildscripts/make_dependencies.sh # build protoc into /tmp/proto3-a2
- mkdir -p $HOME/.gradle
- echo "checkstyle.ignoreFailures=false" >> $HOME/.gradle/gradle.properties
jdk: jdk:
- oraclejdk8 - oraclejdk8

View File

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

View File

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

View File

@ -48,6 +48,7 @@ public class HelloWorldClient {
private final ChannelImpl channel; private final ChannelImpl channel;
private final GreeterGrpc.GreeterBlockingStub blockingStub; private final GreeterGrpc.GreeterBlockingStub blockingStub;
/** Construct client connecting to HelloWorld server at {@code host:port}. */
public HelloWorldClient(String host, int port) { public HelloWorldClient(String host, int port) {
channel = channel =
NettyChannelBuilder.forAddress(host, port).negotiationType(NegotiationType.PLAINTEXT) NettyChannelBuilder.forAddress(host, port).negotiationType(NegotiationType.PLAINTEXT)
@ -59,6 +60,7 @@ public class HelloWorldClient {
channel.shutdown().awaitTerminated(5, TimeUnit.SECONDS); channel.shutdown().awaitTerminated(5, TimeUnit.SECONDS);
} }
/** Say hello to server. */
public void greet(String name) { public void greet(String name) {
try { try {
logger.info("Will try to greet " + name + " ..."); 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 { public static void main(String[] args) throws Exception {
HelloWorldClient client = new HelloWorldClient("localhost", 50051); HelloWorldClient client = new HelloWorldClient("localhost", 50051);
try { try {

View File

@ -57,6 +57,7 @@ public class RouteGuideClient {
private final RouteGuideBlockingStub blockingStub; private final RouteGuideBlockingStub blockingStub;
private final RouteGuideStub asyncStub; private final RouteGuideStub asyncStub;
/** Construct client for accessing RoutGuide server at {@code host:port}. */
public RouteGuideClient(String host, int port) { public RouteGuideClient(String host, int port) {
channel = NettyChannelBuilder.forAddress(host, port) channel = NettyChannelBuilder.forAddress(host, port)
.negotiationType(NegotiationType.PLAINTEXT) .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) { public void getFeature(int lat, int lon) {
try { 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) { public void listFeatures(int lowLat, int lowLon, int hiLat, int hiLon) {
try { 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 { public void recordRoute(List<Feature> features, int numPoints) throws Exception {
info("*** RecordRoute"); info("*** RecordRoute");
final SettableFuture<Void> finishFuture = SettableFuture.create(); 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 { public void routeChat() throws Exception {
info("*** RoutChat"); info("*** RoutChat");
@ -217,6 +225,7 @@ public class RouteGuideClient {
} }
} }
/** Issues several different requests and then exits. */
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
RouteGuideClient client = new RouteGuideClient("localhost", 8980); RouteGuideClient client = new RouteGuideClient("localhost", 8980);
try { try {

View File

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