PMD fixes.
This commit is contained in:
parent
12a1655d3f
commit
4877c7ab12
9 changed files with 73 additions and 57 deletions
|
@ -710,11 +710,10 @@ public class Mobibot extends PircBot {
|
|||
}
|
||||
}
|
||||
|
||||
final StringBuilder info = new StringBuilder(28).append("Uptime: ");
|
||||
final StringBuilder info = new StringBuilder(28);
|
||||
|
||||
info.append(Utils.uptime(ManagementFactory.getRuntimeMXBean().getUptime()));
|
||||
|
||||
info.append("[Entries: ").append(entries.size());
|
||||
info.append("Uptime: ").append(Utils.uptime(ManagementFactory.getRuntimeMXBean().getUptime())).append(
|
||||
" [Entries: ").append(entries.size());
|
||||
|
||||
if (tell.isEnabled() && isOp(sender)) {
|
||||
info.append(", Messages: ").append(tell.size());
|
||||
|
@ -769,7 +768,7 @@ public class Mobibot extends PircBot {
|
|||
*/
|
||||
@SuppressFBWarnings(
|
||||
{"INFORMATION_EXPOSURE_THROUGH_AN_ERROR_MESSAGE", "DM_DEFAULT_ENCODING", "IOI_USE_OF_FILE_STREAM_CONSTRUCTORS"})
|
||||
@SuppressWarnings({"PMD.SystemPrintln", "PMD.AvoidFileStream"})
|
||||
@SuppressWarnings({"PMD.SystemPrintln", "PMD.AvoidFileStream", "PMD.CloseResource"})
|
||||
public static void main(final String[] args) {
|
||||
// Setup the command line options
|
||||
final Options options = new Options();
|
||||
|
|
|
@ -45,7 +45,7 @@ import java.util.logging.Level;
|
|||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
* The class to handle posts to pinbard.in.
|
||||
* The class to handle posts to pinboard.in.
|
||||
*
|
||||
* @author <a href="https://erik.thauvin.net" target="_blank">Erik C. Thauvin</a>
|
||||
* @created 2017-05-17
|
||||
|
@ -81,14 +81,14 @@ class Pinboard {
|
|||
* @param entry The entry to add.
|
||||
*/
|
||||
final void addPost(final EntryLink entry) {
|
||||
final SwingWorker<Boolean, Void> worker = new SwingWorker<Boolean, Void>() {
|
||||
final SwingWorker<Boolean, Void> worker = new SwingWorker<>() {
|
||||
@Override
|
||||
protected Boolean doInBackground() {
|
||||
return pinboard.addPin(entry.getLink(),
|
||||
entry.getTitle(),
|
||||
postedBy(entry),
|
||||
entry.getPinboardTags(),
|
||||
formatDate(entry.getDate()));
|
||||
entry.getTitle(),
|
||||
postedBy(entry),
|
||||
entry.getPinboardTags(),
|
||||
formatDate(entry.getDate()));
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -103,7 +103,7 @@ class Pinboard {
|
|||
final void deletePost(final EntryLink entry) {
|
||||
final String link = entry.getLink();
|
||||
|
||||
final SwingWorker<Boolean, Void> worker = new SwingWorker<Boolean, Void>() {
|
||||
final SwingWorker<Boolean, Void> worker = new SwingWorker<>() {
|
||||
@Override
|
||||
protected Boolean doInBackground() {
|
||||
return pinboard.deletePin(link);
|
||||
|
@ -140,25 +140,25 @@ class Pinboard {
|
|||
* @param entry The entry to add.
|
||||
*/
|
||||
final void updatePost(final String oldUrl, final EntryLink entry) {
|
||||
final SwingWorker<Boolean, Void> worker = new SwingWorker<Boolean, Void>() {
|
||||
final SwingWorker<Boolean, Void> worker = new SwingWorker<>() {
|
||||
@Override
|
||||
protected Boolean doInBackground() {
|
||||
if (!oldUrl.equals(entry.getLink())) {
|
||||
pinboard.deletePin(oldUrl);
|
||||
|
||||
return pinboard.addPin(entry.getLink(),
|
||||
entry.getTitle(),
|
||||
postedBy(entry),
|
||||
entry.getPinboardTags(),
|
||||
formatDate(entry.getDate()));
|
||||
entry.getTitle(),
|
||||
postedBy(entry),
|
||||
entry.getPinboardTags(),
|
||||
formatDate(entry.getDate()));
|
||||
} else {
|
||||
return pinboard.addPin(entry.getLink(),
|
||||
entry.getTitle(),
|
||||
postedBy(entry),
|
||||
entry.getPinboardTags(),
|
||||
formatDate(entry.getDate()),
|
||||
true,
|
||||
true);
|
||||
entry.getTitle(),
|
||||
postedBy(entry),
|
||||
entry.getPinboardTags(),
|
||||
formatDate(entry.getDate()),
|
||||
true,
|
||||
true);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -34,6 +34,8 @@ public final class TwitterOAuth {
|
|||
* Twitter OAuth Client Registration.
|
||||
*
|
||||
* @param args The consumerKey and consumerSecret should be passed as arguments.
|
||||
* @throws TwitterException If an error occurs.
|
||||
* @throws IOException If an IO error occurs.
|
||||
*/
|
||||
@SuppressFBWarnings({"DM_DEFAULT_ENCODING", "IMC_IMMATURE_CLASS_PRINTSTACKTRACE"})
|
||||
@SuppressWarnings({"PMD.AvoidPrintStackTrace", "PMD.SystemPrintln"})
|
||||
|
@ -43,29 +45,29 @@ public final class TwitterOAuth {
|
|||
twitter.setOAuthConsumer(args[0], args[1]);
|
||||
final RequestToken requestToken = twitter.getOAuthRequestToken();
|
||||
AccessToken accessToken = null;
|
||||
final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
|
||||
while (null == accessToken) {
|
||||
System.out.println("Open the following URL and grant access to your account:");
|
||||
System.out.println(requestToken.getAuthorizationURL());
|
||||
System.out.print("Enter the PIN (if available) or just hit enter.[PIN]:");
|
||||
final String pin = br.readLine();
|
||||
try {
|
||||
if (pin != null && pin.length() > 0) {
|
||||
accessToken = twitter.getOAuthAccessToken(requestToken, pin);
|
||||
} else {
|
||||
accessToken = twitter.getOAuthAccessToken();
|
||||
}
|
||||
try (final BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
|
||||
while (null == accessToken) {
|
||||
System.out.println("Open the following URL and grant access to your account:");
|
||||
System.out.println(requestToken.getAuthorizationURL());
|
||||
System.out.print("Enter the PIN (if available) or just hit enter.[PIN]:");
|
||||
final String pin = br.readLine();
|
||||
try {
|
||||
if (pin != null && pin.length() > 0) {
|
||||
accessToken = twitter.getOAuthAccessToken(requestToken, pin);
|
||||
} else {
|
||||
accessToken = twitter.getOAuthAccessToken();
|
||||
}
|
||||
|
||||
System.out.println(
|
||||
"Please add the following to the bot's property file:" + "\n\n" + "twitter-consumerKey="
|
||||
System.out.println(
|
||||
"Please add the following to the bot's property file:" + "\n\n" + "twitter-consumerKey="
|
||||
+ args[0] + '\n' + "twitter-consumerSecret=" + args[1] + '\n' + "twitter-token="
|
||||
+ accessToken.getToken() + '\n' + "twitter-tokenSecret=" + accessToken
|
||||
.getTokenSecret());
|
||||
} catch (TwitterException te) {
|
||||
if (401 == te.getStatusCode()) {
|
||||
System.out.println("Unable to get the access token.");
|
||||
} else {
|
||||
te.printStackTrace();
|
||||
+ accessToken.getToken() + '\n' + "twitter-tokenSecret=" + accessToken.getTokenSecret());
|
||||
} catch (TwitterException te) {
|
||||
if (401 == te.getStatusCode()) {
|
||||
System.out.println("Unable to get the access token.");
|
||||
} else {
|
||||
te.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,6 +42,7 @@ import java.time.LocalDateTime;
|
|||
* @created Jan 31, 2004
|
||||
* @since 1.0
|
||||
*/
|
||||
@SuppressWarnings({"PMD.DataClass"})
|
||||
public class EntryComment implements Serializable {
|
||||
// The serial version UID.
|
||||
static final long serialVersionUID = 1L;
|
||||
|
|
|
@ -87,7 +87,6 @@ public final class Joke extends ThreadedModule {
|
|||
|
||||
final JSONObject json = new JSONObject(sb.toString());
|
||||
|
||||
//noinspection RegExpRedundantEscape
|
||||
return new PublicMessage(
|
||||
json.getJSONObject("value").get("joke").toString().replace("\\'", "'")
|
||||
.replace("\\\"", "\""));
|
||||
|
|
|
@ -132,6 +132,7 @@ public final class StockQuote extends ThreadedModule {
|
|||
* @return The {@link Message} array containing the stock quote.
|
||||
* @throws ModuleException If an errors occurs.
|
||||
*/
|
||||
@SuppressWarnings({"PMD.CloseResource"})
|
||||
static List<Message> getQuote(final String symbol, final String apiKey) throws ModuleException {
|
||||
if (StringUtils.isBlank(apiKey)) {
|
||||
throw new ModuleException(StringUtils.capitalize(STOCK_CMD) + " is disabled. The API key is missing.");
|
||||
|
|
|
@ -63,6 +63,7 @@ public class Message {
|
|||
* @param isError The error flag.
|
||||
* @param isPrivate The Private message
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
public Message(final String message, final boolean isNotice, final boolean isError, final boolean isPrivate) {
|
||||
msg = message;
|
||||
this.isNotice = isNotice;
|
||||
|
@ -80,6 +81,7 @@ public class Message {
|
|||
* @param isPrivate The Private message
|
||||
* @param color The color.
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
public Message(final String message,
|
||||
final boolean isNotice,
|
||||
final boolean isError,
|
||||
|
@ -178,6 +180,7 @@ public class Message {
|
|||
*
|
||||
* @param isPrivate The private flag.
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
public void setPrivate(final boolean isPrivate) {
|
||||
this.isPrivate = isPrivate;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue