Added detekt extension

This commit is contained in:
Erik C. Thauvin 2023-11-25 21:36:53 -08:00
parent fad1d06b96
commit b5cfb1ddff
11 changed files with 46 additions and 16 deletions

View file

@ -34,7 +34,7 @@ package net.thauvin.erik.bitly;
import rife.bld.BuildCommand;
import rife.bld.Project;
import rife.bld.extension.CompileKotlinOperation;
import rife.bld.extension.CompileKotlinOptions;
import rife.bld.extension.DetektOperation;
import rife.bld.extension.JacocoReportOperation;
import rife.bld.extension.dokka.DokkaOperation;
import rife.bld.extension.dokka.LoggingLevel;
@ -67,8 +67,12 @@ public class BitlyShortenBuild extends Project {
repositories = List.of(MAVEN_LOCAL, MAVEN_CENTRAL);
var okHttp = version(4, 12, 0);
final var kotlin = version(1, 9, 21);
scope(compile)
.include(dependency("org.jetbrains.kotlin", "kotlin-stdlib", version(1, 9, 21)))
.include(dependency("org.jetbrains.kotlin", "kotlin-stdlib", kotlin))
.include(dependency("org.jetbrains.kotlin", "kotlin-stdlib-common", kotlin))
.include(dependency("org.jetbrains.kotlin", "kotlin-stdlib-jdk7", kotlin))
.include(dependency("org.jetbrains.kotlin", "kotlin-stdlib-jdk8", kotlin))
.include(dependency("com.squareup.okhttp3", "okhttp", okHttp))
.include(dependency("com.squareup.okhttp3", "logging-interceptor", okHttp))
.include(dependency("org.json", "json", "20231013"));
@ -124,6 +128,23 @@ public class BitlyShortenBuild extends Project {
.execute();
}
@BuildCommand(summary = "Checks source with Detekt")
public void detekt() throws ExitStatusException, IOException, InterruptedException {
new DetektOperation()
.fromProject(this)
.baseline("config/detekt/baseline.xml")
.execute();
}
@BuildCommand(value = "detekt-baseline", summary = "Creates the Detekt baseline")
public void detektBaseline() throws ExitStatusException, IOException, InterruptedException {
new DetektOperation()
.fromProject(this)
.baseline("config/detekt/baseline.xml")
.createBaseline(true)
.execute();
}
@BuildCommand(summary = "Generates documentation in HTML format")
public void docs() throws ExitStatusException, IOException, InterruptedException {
var kotlin = new File(srcMainDirectory(), "kotlin").getAbsolutePath();

View file

@ -56,7 +56,6 @@ open class Bitly() {
*
* @param accessToken The API access token.
*/
@Suppress("unused")
constructor(accessToken: String) : this() {
this.accessToken = accessToken
}
@ -67,7 +66,6 @@ open class Bitly() {
* @param properties The properties containing the [API Access Token][accessToken].
* @param key The property key containing the [API Access Token][accessToken].
*/
@Suppress("unused")
@JvmOverloads
constructor(properties: Properties, key: String = Constants.ENV_ACCESS_TOKEN) : this() {
accessToken = properties.getProperty(key, accessToken)
@ -96,7 +94,6 @@ open class Bitly() {
* @param propertiesFile The properties file containing the [API Access Token][accessToken].
* @param key The property key containing the [API Access Token][accessToken].
*/
@Suppress("unused")
@JvmOverloads
constructor(propertiesFile: File, key: String = Constants.ENV_ACCESS_TOKEN) : this(propertiesFile.toPath(), key)

View file

@ -39,7 +39,6 @@ package net.thauvin.erik.bitly
* @param description Bitly error description, if any.
* @param statusCode HTTP status code,
*/
@Suppress("unused")
data class CallResponse(
val body: String = Constants.EMPTY_JSON,
val message: String = "",

View file

@ -34,7 +34,6 @@ package net.thauvin.erik.bitly
/**
* Provides units of time definitions.
*/
@Suppress("unused")
enum class Units {
MINUTE, HOUR, DAY, WEEK, MONTH
}

View file

@ -50,7 +50,7 @@ class CreateConfig private constructor(
*
* See the [Bit.ly API](https://dev.bitly.com/api-reference#createFullBitlink) for more information.
**/
@Suppress("unused", "ArrayInDataClass")
@Suppress("ArrayInDataClass")
data class Builder(
private var domain: String = Constants.EMPTY,
private var title: String = Constants.EMPTY,

View file

@ -57,7 +57,7 @@ class UpdateConfig private constructor(
*
* See the [Bit.ly API](https://dev.bitly.com/api-reference#updateBitlink) for more information.
**/
@Suppress("unused", "ArrayInDataClass")
@Suppress("ArrayInDataClass")
data class Builder(
private var bitlink: String = Constants.EMPTY,
private var references: Map<String, String> = emptyMap(),

View file

@ -40,7 +40,6 @@ import net.thauvin.erik.bitly.Utils.toEndPoint
import net.thauvin.erik.bitly.config.CreateConfig
import net.thauvin.erik.bitly.config.UpdateConfig
import org.json.JSONObject
import org.junit.Before
import org.junit.jupiter.api.BeforeAll
import java.io.File
import java.util.logging.Level