Skip to content
Browse files

Fix warnings found by checkstyle

  • Loading branch information...
1 parent 46b5b66 commit 4b482671f721ecb9d355501d0e69d54eb79558ca @emk committed
Showing with 24 additions and 12 deletions.
  1. +5 −2 conf/checkstyle.xml
  2. +1 −1 src/buglinky/BugLinkyProfileServlet.java
  3. +18 −9 src/buglinky/BugLinkyServlet.java
View
7 conf/checkstyle.xml
@@ -5,7 +5,7 @@
This configuration file was written by the eclipse-cs plugin configuration editor
-->
<!--
- Checkstyle-Configuration: MediaDemo checks
+ Checkstyle-Configuration: BugLinky style rules
Description: none
-->
<module name="Checker">
@@ -38,7 +38,9 @@
<module name="ParameterName"/>
<module name="StaticVariableName"/>
<module name="TypeName"/>
- <module name="AvoidStarImport"/>
+ <module name="AvoidStarImport">
+ <property name="excludes" value="com.google.wave.api"/>
+ </module>
<module name="IllegalImport"/>
<module name="RedundantImport"/>
<module name="UnusedImports"/>
@@ -106,6 +108,7 @@
<property name="severity" value="ignore"/>
</module>
<module name="UpperEll"/>
+ <module name="StringLiteralEquality"/>
</module>
<module name="JavadocPackage"/>
<module name="NewlineAtEndOfFile">
View
2 src/buglinky/BugLinkyProfileServlet.java
@@ -2,6 +2,7 @@
import com.google.wave.api.ProfileServlet;
+/** Provide a name and icon for our robot. */
@SuppressWarnings("serial")
public class BugLinkyProfileServlet extends ProfileServlet {
@@ -14,5 +15,4 @@ public String getRobotAvatarUrl() {
public String getRobotName() {
return "buglinky";
}
-
}
View
27 src/buglinky/BugLinkyServlet.java
@@ -6,12 +6,17 @@
import com.google.wave.api.*;
+/** Called via JSON-RPC whenever an event occurs on one of our waves. */
@SuppressWarnings("serial")
public class BugLinkyServlet extends AbstractRobotServlet {
+ private static final Logger LOG =
+ Logger.getLogger(BugLinkyServlet.class.getName());
+
private static final String ME = "buglinky@appspot.com";
private static final String LINK = "link/manual";
- private static final Logger log =
- Logger.getLogger(BugLinkyServlet.class.getName());
+
+ private static final String INSTRUCTIONS =
+ "buglinky will attempt to link \"bug #NNN\" to a bug tracker.";
private static final String BUG_URL =
"http://code.google.com/p/google-wave-resources/issues/detail?id=";
@@ -36,16 +41,16 @@ public void processEvents(RobotMessageBundle bundle) {
/** Add an instruction blip to this wave if we were just added. */
private void addInstructionsToWave(RobotMessageBundle bundle) {
- log.fine("Adding instructions to wavelet " +
+ LOG.fine("Adding instructions to wavelet " +
bundle.getWavelet().getWaveletId());
Blip blip = bundle.getWavelet().appendBlip();
TextView textView = blip.getDocument();
- textView.append("buglinky will attempt to link \"bug #NNN\" to a bug tracker.");
+ textView.append(INSTRUCTIONS);
}
/** Dispatch events to the appropriate handler method. */
private void dispatchEvents(RobotMessageBundle bundle) {
- for (Event e: bundle.getEvents()) {
+ for (Event e : bundle.getEvents()) {
if (!e.getModifiedBy().equals(ME)) {
switch (e.getType()) {
// One or the other of these should be wired up in
@@ -56,6 +61,9 @@ private void dispatchEvents(RobotMessageBundle bundle) {
case BLIP_VERSION_CHANGED:
addLinksToBlip(e.getBlip());
break;
+
+ default:
+ break;
}
}
}
@@ -63,13 +71,13 @@ private void dispatchEvents(RobotMessageBundle bundle) {
/** Add links to the specified blip. */
private void addLinksToBlip(Blip blip) {
- log.fine("Adding links to blip " + blip.getBlipId());
+ LOG.fine("Adding links to blip " + blip.getBlipId());
// Adapted from http://senikk.com/min-f%C3%B8rste-google-wave-robot,
// a robot which links to @names on Twitter.
TextView doc = blip.getDocument();
Matcher matcher = REGEX.matcher(doc.getText());
while (matcher.find()) {
- log.fine("Found a link: " + matcher.group());
+ LOG.fine("Found a link: " + matcher.group());
Range range = new Range(matcher.start(), matcher.end());
String url = BUG_URL.concat(matcher.group(1));
maybeAnnotate(doc, range, LINK, url);
@@ -77,7 +85,8 @@ private void addLinksToBlip(Blip blip) {
}
/** Add an annotation if it isn't already present. */
- private void maybeAnnotate(TextView doc, Range range, String name, String value) {
+ private void maybeAnnotate(TextView doc, Range range, String name,
+ String value) {
// If this annotation is already present, give up now.
for (Annotation annotation : doc.getAnnotations(range, name)) {
if (annotation.getRange().equals(range) &&
@@ -85,7 +94,7 @@ private void maybeAnnotate(TextView doc, Range range, String name, String value)
return;
}
- log.fine("Making new link to " + value);
+ LOG.fine("Making new link to " + value);
doc.setAnnotation(range, name, value);
}
}

0 comments on commit 4b48267

Please sign in to comment.
Something went wrong with that request. Please try again.