Added spotbugs settings & annotations.
This commit is contained in:
parent
2dc748be75
commit
f501e6c073
5 changed files with 54 additions and 50 deletions
74
build.gradle
74
build.gradle
|
@ -1,48 +1,28 @@
|
|||
plugins {
|
||||
id "com.ewerk.gradle.plugins.annotation-processor" version "1.0.4"
|
||||
id 'java'
|
||||
id 'idea'
|
||||
id 'application'
|
||||
id "com.github.ben-manes.versions" version "0.20.0"
|
||||
id "org.owasp.dependencycheck" version "3.2.1"
|
||||
id "org.owasp.dependencycheck" version "3.2.1"
|
||||
id "net.thauvin.erik.gradle.semver" version "0.9.6-beta"
|
||||
id "com.github.spotbugs" version "1.6.2"
|
||||
}
|
||||
|
||||
apply plugin: 'java'
|
||||
apply plugin: 'idea'
|
||||
apply plugin: 'application'
|
||||
|
||||
import com.github.spotbugs.SpotBugsTask
|
||||
|
||||
defaultTasks 'deploy'
|
||||
|
||||
final def packageName = 'net.thauvin.erik.mobibot'
|
||||
final def deployDir = 'deploy'
|
||||
def isRelease = 'release' in gradle.startParameter.taskNames
|
||||
final def semverJar = 'net.thauvin.erik:semver:1.0.1'
|
||||
|
||||
def getVersion(isIncrement = false) {
|
||||
final def propsFile = 'version.properties'
|
||||
final def majorKey = 'version.major'
|
||||
final def minorKey = 'version.minor'
|
||||
final def patchKey = 'version.patch'
|
||||
final def metaKey = 'version.buildmeta'
|
||||
final def preKey = 'version.prerelease'
|
||||
if (isIncrement) {
|
||||
ant.propertyfile(file: propsFile) {
|
||||
entry(key: patchKey,
|
||||
type: 'int',
|
||||
default: '-1',
|
||||
operation: '+')
|
||||
}
|
||||
}
|
||||
def p = new Properties()
|
||||
file(propsFile).withInputStream { final stream -> p.load(stream) }
|
||||
final def metadata = p.getProperty(metaKey, '')
|
||||
final def prerelease = p.getProperty(preKey, '')
|
||||
return (p.getProperty(majorKey, '1') + '.' + p.getProperty(minorKey, '0') + '.' + p.getProperty(patchKey, '0') +
|
||||
(prerelease.length() > 0 ? '-' + prerelease : '') + (metadata.length() > 0 ? '+' + metadata : ''))
|
||||
}
|
||||
|
||||
version = getVersion()
|
||||
final def semverProcessor = "net.thauvin.erik:semver:1.1.0-beta"
|
||||
|
||||
mainClassName = packageName + '.Mobibot'
|
||||
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
|
||||
|
||||
compileJava.options.annotationProcessorGeneratedSourcesDirectory = file("${projectDir}/src/generated")
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
|
@ -50,6 +30,9 @@ repositories {
|
|||
}
|
||||
|
||||
dependencies {
|
||||
annotationProcessor semverProcessor
|
||||
compileOnly semverProcessor
|
||||
|
||||
compile 'pircbot:pircbot:1.5.0'
|
||||
compileOnly 'pircbot:pircbot:1.5.0:sources'
|
||||
|
||||
|
@ -62,7 +45,7 @@ dependencies {
|
|||
compile 'commons-net:commons-net:3.6'
|
||||
compile 'com.squareup.okhttp3:okhttp:3.10.0'
|
||||
|
||||
compile 'com.rometools:rome:1.10.0'
|
||||
compile 'com.rometools:rome:1.11.0'
|
||||
|
||||
compile 'org.json:json:20180130'
|
||||
compile 'org.ostermiller:utils:1.07.00'
|
||||
|
@ -75,24 +58,27 @@ dependencies {
|
|||
// https://bitbucket.org/akapribot/owm-japis
|
||||
compile files('lib/owm-japis-2.5.0.5.jar')
|
||||
|
||||
compileOnly semverJar
|
||||
|
||||
testCompile 'org.testng:testng:6.14.3'
|
||||
testCompile 'org.assertj:assertj-core:3.10.0'
|
||||
|
||||
spotbugsPlugins 'com.h3xstream.findsecbugs:findsecbugs-plugin:1.8.0'
|
||||
compileOnly 'com.github.spotbugs:spotbugs-annotations:3.1.5'
|
||||
}
|
||||
|
||||
test {
|
||||
useTestNG()
|
||||
}
|
||||
|
||||
annotationProcessor {
|
||||
project.version = getVersion(isRelease)
|
||||
library semverJar
|
||||
processor 'net.thauvin.erik.semver.VersionProcessor'
|
||||
tasks.withType(SpotBugsTask) {
|
||||
reports {
|
||||
xml.enabled = false
|
||||
html.enabled = true
|
||||
}
|
||||
excludeFilter = file("$projectDir/config/spotbugs/excludeFilter.xml")
|
||||
}
|
||||
|
||||
compileJava {
|
||||
options.compilerArgs << '-proc:none' << '-Xlint:unchecked' << '-Xlint:deprecation'
|
||||
options.compilerArgs << '-Xlint:unchecked' << '-Xlint:deprecation'
|
||||
}
|
||||
|
||||
javadoc {
|
||||
|
@ -139,11 +125,7 @@ task deploy(dependsOn: ['build']) {
|
|||
mustRunAfter clean
|
||||
}
|
||||
|
||||
|
||||
task release(dependsOn: ['wrapper', 'clean', 'deploy']) {
|
||||
doLast {
|
||||
group = 'Publishing'
|
||||
description = 'Releases new version.'
|
||||
isRelease = true
|
||||
}
|
||||
}
|
||||
group = 'Publishing'
|
||||
description = 'Releases new version.'
|
||||
}
|
||||
|
|
14
config/spotbugs/excludefilter.xml
Normal file
14
config/spotbugs/excludefilter.xml
Normal file
|
@ -0,0 +1,14 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<FindBugsFilter
|
||||
xmlns="https://github.com/spotbugs/filter/3.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="https://github.com/spotbugs/filter/3.0.0 https://raw.githubusercontent.com/spotbugs/spotbugs/3.1.0/spotbugs/etc/findbugsfilter.xsd">
|
||||
<Match>
|
||||
<Package name="net.thauvin.erik.mobibot.*"/>
|
||||
<Or>
|
||||
<Bug pattern="PATH_TRAVERSAL_IN"/>
|
||||
<Bug pattern="PATH_TRAVERSAL_OUT"/>
|
||||
</Or>
|
||||
<Confidence value="2"/>
|
||||
</Match>
|
||||
</FindBugsFilter>
|
|
@ -32,6 +32,7 @@
|
|||
package net.thauvin.erik.mobibot;
|
||||
|
||||
import com.rometools.rome.io.FeedException;
|
||||
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||
import net.thauvin.erik.mobibot.modules.*;
|
||||
import net.thauvin.erik.semver.Version;
|
||||
import org.apache.commons.cli.*;
|
||||
|
@ -294,15 +295,16 @@ public class Mobibot extends PircBot {
|
|||
*
|
||||
* @param args The command line arguments.
|
||||
*/
|
||||
@SuppressFBWarnings(value = {"INFORMATION_EXPOSURE_THROUGH_AN_ERROR_MESSAGE", "DM_DEFAULT_ENCODING"})
|
||||
public static void main(final String[] args) {
|
||||
// Setup the command line options
|
||||
final Options options = new Options();
|
||||
options.addOption(Commands.HELP_ARG.substring(0, 1), Commands.HELP_ARG, false, "print this help message");
|
||||
options.addOption(Commands.DEBUG_ARG.substring(0, 1), Commands.DEBUG_ARG, false,
|
||||
"print debug & logging data directly to the console");
|
||||
"print debug & logging data directly to the console");
|
||||
options.addOption(Option.builder(
|
||||
Commands.PROPS_ARG.substring(0, 1)).hasArg().argName("file").desc("use " + "alternate properties file")
|
||||
.longOpt(Commands.PROPS_ARG).build());
|
||||
Commands.PROPS_ARG.substring(0, 1)).hasArg().argName("file").desc("use " + "alternate properties file")
|
||||
.longOpt(Commands.PROPS_ARG).build());
|
||||
options.addOption(Commands.VERSION_ARG.substring(0, 1), Commands.VERSION_ARG, false, "print version info");
|
||||
|
||||
// Parse the command line
|
||||
|
@ -418,6 +420,7 @@ public class Mobibot extends PircBot {
|
|||
/**
|
||||
* Connects to the server and joins the channel.
|
||||
*/
|
||||
@SuppressFBWarnings(value = {"DM_EXIT", "INFORMATION_EXPOSURE_THROUGH_AN_ERROR_MESSAGE"})
|
||||
public final void connect() {
|
||||
try {
|
||||
connect(ircServer, ircPort);
|
||||
|
@ -1287,6 +1290,7 @@ public class Mobibot extends PircBot {
|
|||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@SuppressFBWarnings(value = "DM_EXIT", justification = "Yes, we want to bail out.")
|
||||
@Override
|
||||
protected final void onPrivateMessage(final String sender,
|
||||
final String login,
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package net.thauvin.erik.mobibot;
|
||||
|
||||
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||
import twitter4j.TwitterException;
|
||||
import twitter4j.TwitterFactory;
|
||||
import twitter4j.auth.AccessToken;
|
||||
|
@ -27,8 +28,9 @@ import java.io.InputStreamReader;
|
|||
* @since 1.0
|
||||
*/
|
||||
public final class TwitterOAuth {
|
||||
@SuppressFBWarnings(value = "DM_DEFAULT_ENCODING")
|
||||
public static void main(final String[] args)
|
||||
throws Exception {
|
||||
throws Exception {
|
||||
if (args.length == 2) {
|
||||
final twitter4j.Twitter twitter = new TwitterFactory().getInstance();
|
||||
twitter.setOAuthConsumer(args[0], args[1]);
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
*/
|
||||
package net.thauvin.erik.mobibot.modules;
|
||||
|
||||
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||
import net.thauvin.erik.mobibot.Mobibot;
|
||||
import net.thauvin.erik.mobibot.Utils;
|
||||
import org.jdom2.Document;
|
||||
|
@ -114,6 +115,7 @@ final public class CurrencyConverter extends AbstractModule {
|
|||
/**
|
||||
* Converts the specified currencies.
|
||||
*/
|
||||
@SuppressFBWarnings(value = "REDOS")
|
||||
private void run(final Mobibot bot, final String sender, final String query) {
|
||||
if (Utils.isValidString(sender)) {
|
||||
if (EXCHANGE_RATES.isEmpty()) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue