From 7ef125db3b4d615102a8083a10316294656f19a9 Mon Sep 17 00:00:00 2001 From: "Erik C. Thauvin" Date: Sat, 30 Jun 2018 23:27:34 -0700 Subject: [PATCH] Added klint checks. --- .idea/codeStyles/codeStyleConfig.xml | 5 +++ build.gradle.kts | 8 +++- .../thauvin/erik/pinboard/PinboardPoster.kt | 42 ++++++++++--------- 3 files changed, 33 insertions(+), 22 deletions(-) create mode 100644 .idea/codeStyles/codeStyleConfig.xml diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml new file mode 100644 index 0000000..d91f848 --- /dev/null +++ b/.idea/codeStyles/codeStyleConfig.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts index 8409712..7023499 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -17,6 +17,7 @@ plugins { id("com.github.ben-manes.versions") version "0.20.0" id("com.jfrog.bintray") version "1.8.3" id("org.jetbrains.dokka") version "0.9.17" + id("org.jlleitschuh.gradle.ktlint") version "4.1.0" } group = "net.thauvin.erik" @@ -26,7 +27,7 @@ description = "Pinboard Poster for Kotlin/Java" val gitHub = "ethauvin/$name" val mavenUrl = "https://github.com/$gitHub" val deployDir = "deploy" -var isRelease = "release" in gradle.startParameter.taskNames +var isRelease = "release" in gradle.startParameter.taskNames // Load local.properties File("local.properties").apply { @@ -127,6 +128,9 @@ tasks { } } + val check by getting { + dependsOn("ktlintCheck") + } val publicationName = "mavenJava" publishing { @@ -212,6 +216,6 @@ tasks { "release" { description = "Publishes version ${project.version} to Bintray." group = PublishingPlugin.PUBLISH_TASK_GROUP - dependsOn(bintrayUpload) + dependsOn("wrapper", bintrayUpload) } } \ No newline at end of file diff --git a/src/main/kotlin/net/thauvin/erik/pinboard/PinboardPoster.kt b/src/main/kotlin/net/thauvin/erik/pinboard/PinboardPoster.kt index 1c02378..17760b3 100644 --- a/src/main/kotlin/net/thauvin/erik/pinboard/PinboardPoster.kt +++ b/src/main/kotlin/net/thauvin/erik/pinboard/PinboardPoster.kt @@ -40,7 +40,7 @@ import java.io.StringReader import java.net.URL import java.nio.file.Files import java.nio.file.Path -import java.util.* +import java.util.Properties import java.util.logging.Level import java.util.logging.Logger import javax.xml.parsers.DocumentBuilderFactory @@ -129,22 +129,24 @@ open class PinboardPoster() { * @param description The title of the bookmark. * @param extended The description of the bookmark. * @param tags A list of up to 100 tags. - * @param dt The creation time of the bookmark. - * @param replace Replace any existing bookmark with the specified URL. Default `true`. - * @param shared Make bookmark public. Default is `true`. + * @param dt The creation time of the bookmark. + * @param replace Replace any existing bookmark with the specified URL. Default `true`. + * @param shared Make bookmark public. Default is `true`. * @param toRead Mark the bookmark as unread. Default is `false`. * * @return `true` if bookmark was successfully added. */ @JvmOverloads - fun addPin(url: String, - description: String, - extended: String = "", - tags: String = "", - dt: String = "", - replace: Boolean = true, - shared: Boolean = true, - toRead: Boolean = false): Boolean { + fun addPin( + url: String, + description: String, + extended: String = "", + tags: String = "", + dt: String = "", + replace: Boolean = true, + shared: Boolean = true, + toRead: Boolean = false + ): Boolean { if (validate()) { if (!validateUrl(url)) { logger.severe("Please specify a valid URL to pin.") @@ -152,14 +154,14 @@ open class PinboardPoster() { logger.severe("Please specify a valid description.") } else { val params = listOf( - Pair("url", url), - Pair("description", description), - Pair("extended", extended), - Pair("tags", tags), - Pair("dt", dt), - Pair("replace", yesNo(replace)), - Pair("shared", yesNo(shared)), - Pair("toread", yesNo(toRead)) + Pair("url", url), + Pair("description", description), + Pair("extended", extended), + Pair("tags", tags), + Pair("dt", dt), + Pair("replace", yesNo(replace)), + Pair("shared", yesNo(shared)), + Pair("toread", yesNo(toRead)) ) return executeMethod("posts/add", params) }