Skip to content

Commit

Permalink
Added detekt extension
Browse files Browse the repository at this point in the history
  • Loading branch information
ethauvin committed Nov 26, 2023
1 parent 1e016de commit cd4d869
Show file tree
Hide file tree
Showing 11 changed files with 65 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .idea/kotlinc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 0 additions & 8 deletions baseline.xml

This file was deleted.

2 changes: 1 addition & 1 deletion examples/gradle/.idea/.name

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion examples/gradle/.idea/kotlinc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions examples/gradle/.idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions examples/gradle/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
## Kotlin Example
To compile & run the Kotlin example:
To run the Kotlin example:

```console
./gradlew run
Expand All @@ -9,7 +9,7 @@ To compile & run the Kotlin example:

## Java Example

To compile & run the Java example:
To run the Java example:

```console
./gradlew runJava
Expand Down
1 change: 1 addition & 0 deletions lib/bld/bld-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ bld.downloadExtensionJavadoc=false
bld.downloadExtensionSources=true
bld.extension.jacoco=com.uwyn.rife2:bld-jacoco-report:0.9.1
bld.extensions=com.uwyn.rife2:bld-kotlin:0.9.0-SNAPSHOT
bld.extension-detekt=com.uwyn.rife2:bld-detekt:0.9.0-SNAPSHOT
bld.repositories=MAVEN_LOCAL,MAVEN_CENTRAL,RIFE2_SNAPSHOTS,RIFE2_RELEASES
bld.downloadLocation=
bld.sourceDirectories=
Expand Down
18 changes: 18 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,24 @@
<version>1.9.21</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib-common</artifactId>
<version>1.9.21</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib-jdk7</artifactId>
<version>1.9.21</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib-jdk8</artifactId>
<version>1.9.21</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
Expand Down
23 changes: 22 additions & 1 deletion src/bld/java/net/thauvin/erik/crypto/CryptoPriceBuild.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import rife.bld.BuildCommand;
import rife.bld.Project;
import rife.bld.extension.CompileKotlinOperation;
import rife.bld.extension.DetektOperation;
import rife.bld.extension.JacocoReportOperation;
import rife.bld.extension.dokka.DokkaOperation;
import rife.bld.extension.dokka.LoggingLevel;
Expand Down Expand Up @@ -35,8 +36,12 @@ public CryptoPriceBuild() {
autoDownloadPurge = true;
repositories = List.of(MAVEN_LOCAL, MAVEN_CENTRAL);

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("org.json", "json", "20231013"))
.include(dependency("com.squareup.okhttp3", "okhttp", version(4, 12, 0)));
scope(test)
Expand Down Expand Up @@ -91,6 +96,22 @@ public void compile() throws IOException {
.execute();
}

@BuildCommand(summary = "Checks source with Detekt")
public void detekt() throws ExitStatusException, IOException, InterruptedException {
new DetektOperation()
.fromProject(this)
.execute();
}

@BuildCommand(value = "detekt-baseline", summary = "Creates the Detekt baseline")
public void detektBaseline() throws ExitStatusException, IOException, InterruptedException {
new DetektOperation()
.fromProject(this)
.baseline("detekt-baseline.xml")
.createBaseline(true)
.execute();
}

@BuildCommand(summary = "Generates JaCoCo Reports")
public void jacoco() throws IOException {
new JacocoReportOperation()
Expand Down
10 changes: 7 additions & 3 deletions src/main/kotlin/net/thauvin/erik/crypto/CryptoPrice.kt
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,16 @@ open class CryptoPrice(val base: String, val currency: String, val amount: BigDe
if (json.has("errors")) {
val data = json.getJSONArray("errors")
throw CryptoException(
response.code, data.getJSONObject(0).getString("id"),
response.code,
data.getJSONObject(0).getString("id"),
data.getJSONObject(0).getString("message")
)
} else {
throw CryptoException(response.code, json.getString("error"),
json.getString("message"))
throw CryptoException(
response.code,
json.getString("error"),
json.getString("message")
)
}
}
} catch (e: JSONException) {
Expand Down

0 comments on commit cd4d869

Please sign in to comment.