diff --git a/.circleci/config.yml b/.circleci/config.yml index a8eea21..be10f4a 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -34,4 +34,4 @@ jobs: path: build/reports/ destination: reports - store_test_results: - path: build/reports/ \ No newline at end of file + path: build/reports/ diff --git a/.idea/modules/httpstatus.iml b/.idea/modules/httpstatus.iml index 3eb958f..24d0b52 100644 --- a/.idea/modules/httpstatus.iml +++ b/.idea/modules/httpstatus.iml @@ -15,12 +15,26 @@ - + + - + + + + - + + + + + + + + + + + \ No newline at end of file diff --git a/HttpStatus.ipr b/HttpStatus.ipr index d9e9d41..7e19236 100644 --- a/HttpStatus.ipr +++ b/HttpStatus.ipr @@ -53,14 +53,14 @@ - + + + + - - - @@ -71,20 +71,23 @@ + + + + @@ -165,6 +170,8 @@ @@ -346,7 +353,7 @@ - + @@ -359,6 +366,28 @@ + + + + + + + + + + @@ -450,6 +479,15 @@ + + + + + + + + + @@ -459,13 +497,13 @@ - + - + - + @@ -477,6 +515,49 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -495,22 +576,94 @@ - + - + - + - + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/LICENSE.txt b/LICENSE.txt index ba192fe..f9918dc 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,4 +1,4 @@ -Copyright (c) 2015-2019, Erik C. Thauvin (erik@thauvin.net) +Copyright (c) 2015-2020, Erik C. Thauvin (erik@thauvin.net) All rights reserved. Redistribution and use in source and binary forms, with or without diff --git a/build.gradle b/build.gradle index 3df0a0b..3a672a3 100644 --- a/build.gradle +++ b/build.gradle @@ -8,13 +8,13 @@ plugins { id 'maven-publish' id 'pmd' id 'com.jfrog.bintray' version '1.8.4' - id 'com.github.ben-manes.versions' version '0.21.0' - id 'net.thauvin.erik.gradle.semver' version '1.0.0' - id 'com.github.spotbugs' version '1.7.1' - id 'org.sonarqube' version '2.7' + id 'com.github.ben-manes.versions' version '0.28.0' + id 'net.thauvin.erik.gradle.semver' version '1.0.4' + id 'com.github.spotbugs' version '4.0.4' + id 'org.sonarqube' version '2.8' } -import com.github.spotbugs.SpotBugsTask +import com.github.spotbugs.snom.SpotBugsTask import org.apache.tools.ant.taskdefs.condition.Os defaultTasks 'deploy' @@ -36,9 +36,12 @@ def pkgLabels = ['jsp', 'tag library', 'http', 'status code', 'java'] group = 'net.thauvin.erik.httpstatus' mainClassName = 'net.thauvin.erik.httpstatus.Reasons' -sourceCompatibility = 1.8 -targetCompatibility = 1.8 -[compileJava, compileTestJava]*.options*.encoding = 'UTF-8' + +ext { + versions = [ + spotbugs: '4.0.1' + ] +} repositories { mavenLocal() @@ -49,13 +52,22 @@ dependencies { implementation 'javax.servlet:javax.servlet-api:4.0.1' implementation 'javax.servlet.jsp:jsp-api:2.2.1-b03' - spotbugsPlugins 'com.h3xstream.findsecbugs:findsecbugs-plugin:1.9.0' - spotbugsPlugins 'com.mebigfatguy.fb-contrib:fb-contrib:7.4.3.sb' + spotbugsPlugins 'com.h3xstream.findsecbugs:findsecbugs-plugin:1.10.1' + spotbugsPlugins 'com.mebigfatguy.sb-contrib:sb-contrib:7.4.7' - compileOnly 'com.github.spotbugs:spotbugs-annotations:3.1.12' - testCompileOnly 'com.github.spotbugs:spotbugs-annotations:3.1.12' + compileOnly "com.github.spotbugs:spotbugs-annotations:$versions.spotbugs" + testCompileOnly "com.github.spotbugs:spotbugs-annotations:$versions.spotbugs" - testImplementation 'org.testng:testng:6.14.3' + testImplementation 'org.testng:testng:7.2.0' +} + +tasks.withType(JavaCompile) { + options.encoding = 'UTF-8' +} + +java { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 } javadoc { @@ -67,11 +79,6 @@ javadoc { options.addStringOption('Xdoclint:none', '-quiet') } -compileJava { - //options.compilerArgs << '-Xlint:unchecked' << '-Xlint:deprecation' -} - - jar { manifest.attributes('Main-Class': mainClassName) } @@ -86,17 +93,16 @@ test { useTestNG() } -pmd { - ruleSetFiles = files("config/pmd.xml") - ruleSets = [] +spotbugs { + toolVersion = versions.spotbugs + excludeFilter = file("$projectDir/config/spotbugs/excludeFilter.xml") } -tasks.withType(SpotBugsTask) { - reports { - xml.enabled = false - html.enabled = true - } - excludeFilter = file("$projectDir/config/spotbugs/excludeFilter.xml") +pmd { + ignoreFailures = true + ruleSets = [] + ruleSetFiles = files("${projectDir}/config/pmd.xml") + consoleOutput = true } tasks.withType(Checkstyle) { @@ -209,7 +215,7 @@ task deploy(dependsOn: ['clean', 'build', 'copyToDeploy']) { mustRunAfter clean } -task release(dependsOn: ['wrapper', 'deploy']) { +task release(dependsOn: ['wrapper', 'deploy', 'publishToMavenLocal']) { group = 'Publishing' description = 'Releases new version.' } diff --git a/config/checkstyle/checkstyle.xml b/config/checkstyle/checkstyle.xml index c426276..c5f6465 100644 --- a/config/checkstyle/checkstyle.xml +++ b/config/checkstyle/checkstyle.xml @@ -32,10 +32,27 @@ + + + + + + + + + + + + + + + + @@ -49,10 +66,6 @@ - - - - @@ -245,11 +258,8 @@ - - - @@ -262,6 +272,6 @@ - + diff --git a/config/pmd.xml b/config/pmd.xml index 6e60806..22f6a03 100644 --- a/config/pmd.xml +++ b/config/pmd.xml @@ -1,26 +1,38 @@ + + Erik's Ruleset - + - + - + + + + + - - + @@ -41,7 +53,7 @@ - + @@ -84,7 +96,7 @@ - + @@ -108,6 +120,8 @@ + + @@ -117,7 +131,11 @@ - + + + + + @@ -150,11 +168,10 @@ - + - @@ -163,7 +180,7 @@ - + @@ -241,7 +258,7 @@ - + diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 5c2d1cf..490fda8 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index f4d7b2b..b43cc6e 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-rc-4-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index b0d6d0a..2fe81a7 100755 --- a/gradlew +++ b/gradlew @@ -7,7 +7,7 @@ # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, @@ -125,8 +125,8 @@ if $darwin; then GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" fi -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; then +# For Cygwin or MSYS, switch paths to Windows format before running java +if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then APP_HOME=`cygpath --path --mixed "$APP_HOME"` CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` JAVACMD=`cygpath --unix "$JAVACMD"` @@ -154,19 +154,19 @@ if $cygwin ; then else eval `echo args$i`="\"$arg\"" fi - i=$((i+1)) + i=`expr $i + 1` done case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + 0) set -- ;; + 1) set -- "$args0" ;; + 2) set -- "$args0" "$args1" ;; + 3) set -- "$args0" "$args1" "$args2" ;; + 4) set -- "$args0" "$args1" "$args2" "$args3" ;; + 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; esac fi @@ -175,14 +175,9 @@ save () { for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done echo " " } -APP_ARGS=$(save "$@") +APP_ARGS=`save "$@"` # Collect all arguments for the java command, following the shell quoting and substitution rules eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" -# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong -if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then - cd "$(dirname "$0")" -fi - exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat index 9991c50..62bd9b9 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -5,7 +5,7 @@ @rem you may not use this file except in compliance with the License. @rem You may obtain a copy of the License at @rem -@rem http://www.apache.org/licenses/LICENSE-2.0 +@rem https://www.apache.org/licenses/LICENSE-2.0 @rem @rem Unless required by applicable law or agreed to in writing, software @rem distributed under the License is distributed on an "AS IS" BASIS, @@ -29,6 +29,9 @@ if "%DIRNAME%" == "" set DIRNAME=. set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" diff --git a/src/main/java/net/thauvin/erik/httpstatus/Utils.java b/src/main/java/net/thauvin/erik/httpstatus/Utils.java index 48fee4e..3ed95bc 100644 --- a/src/main/java/net/thauvin/erik/httpstatus/Utils.java +++ b/src/main/java/net/thauvin/erik/httpstatus/Utils.java @@ -1,7 +1,7 @@ /* * Utils.java * - * Copyright (c) 2015-2016, Erik C. Thauvin (erik@thauvin.net) + * Copyright (c) 2015-2020, Erik C. Thauvin (erik@thauvin.net) * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -100,7 +100,7 @@ public final class Utils { * @throws IOException If an I/O error occurs. */ public static void outWrite(final Writer out, final String value, final String defaultValue, final boolean xml) - throws IOException { + throws IOException { if (xml) { if (value != null) { out.write(escapeXml(value)); diff --git a/src/main/java/net/thauvin/erik/httpstatus/taglibs/CauseTag.java b/src/main/java/net/thauvin/erik/httpstatus/taglibs/CauseTag.java index 1deb166..89a909f 100644 --- a/src/main/java/net/thauvin/erik/httpstatus/taglibs/CauseTag.java +++ b/src/main/java/net/thauvin/erik/httpstatus/taglibs/CauseTag.java @@ -1,7 +1,7 @@ /* * CauseTag.java * - * Copyright (c) 2015-2016, Erik C. Thauvin (erik@thauvin.net) + * Copyright (c) 2015-2020, Erik C. Thauvin (erik@thauvin.net) * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -52,6 +52,7 @@ public class CauseTag extends XmlSupport { @Override public void doTag() throws IOException { final PageContext pageContext = (PageContext) getJspContext(); + @SuppressWarnings("PMD.CloseResource") final JspWriter out = pageContext.getOut(); String cause; @@ -63,5 +64,7 @@ public class CauseTag extends XmlSupport { } Utils.outWrite(out, cause, defaultValue, escapeXml); + + } } \ No newline at end of file diff --git a/src/main/java/net/thauvin/erik/httpstatus/taglibs/CodeTag.java b/src/main/java/net/thauvin/erik/httpstatus/taglibs/CodeTag.java index 5aeea04..8f47289 100644 --- a/src/main/java/net/thauvin/erik/httpstatus/taglibs/CodeTag.java +++ b/src/main/java/net/thauvin/erik/httpstatus/taglibs/CodeTag.java @@ -1,7 +1,7 @@ /* * CodeTag.java * - * Copyright (c) 2015-2016, Erik C. Thauvin (erik@thauvin.net) + * Copyright (c) 2015-2020, Erik C. Thauvin (erik@thauvin.net) * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -51,6 +51,7 @@ public class CodeTag extends SimpleTagSupport { @Override public void doTag() throws IOException { final PageContext pageContext = (PageContext) getJspContext(); + @SuppressWarnings("PMD.CloseResource") final JspWriter out = pageContext.getOut(); out.write(String.valueOf(pageContext.getErrorData().getStatusCode())); diff --git a/src/main/java/net/thauvin/erik/httpstatus/taglibs/ReasonTag.java b/src/main/java/net/thauvin/erik/httpstatus/taglibs/ReasonTag.java index f20c683..20ac422 100644 --- a/src/main/java/net/thauvin/erik/httpstatus/taglibs/ReasonTag.java +++ b/src/main/java/net/thauvin/erik/httpstatus/taglibs/ReasonTag.java @@ -1,7 +1,7 @@ /* * ReasonTag.java * - * Copyright (c) 2015-2016, Erik C. Thauvin (erik@thauvin.net) + * Copyright (c) 2015-2020, Erik C. Thauvin (erik@thauvin.net) * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -56,6 +56,7 @@ public class ReasonTag extends XmlSupport { @Override public void doTag() { final PageContext pageContext = (PageContext) getJspContext(); + @SuppressWarnings("PMD.CloseResource") final JspWriter out = pageContext.getOut(); try { diff --git a/src/main/java/net/thauvin/erik/httpstatus/taglibs/XmlSupport.java b/src/main/java/net/thauvin/erik/httpstatus/taglibs/XmlSupport.java index d38760a..fb8ab3a 100644 --- a/src/main/java/net/thauvin/erik/httpstatus/taglibs/XmlSupport.java +++ b/src/main/java/net/thauvin/erik/httpstatus/taglibs/XmlSupport.java @@ -1,7 +1,7 @@ /* * XmlSupport.java * - * Copyright (c) 2015-2016, Erik C. Thauvin (erik@thauvin.net) + * Copyright (c) 2015-2020, Erik C. Thauvin (erik@thauvin.net) * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/src/main/resources/META-INF/httpstatus.tld b/src/main/resources/META-INF/httpstatus.tld index b037cbc..2b8bb62 100644 --- a/src/main/resources/META-INF/httpstatus.tld +++ b/src/main/resources/META-INF/httpstatus.tld @@ -2,7 +2,7 @@