Skip to content

Commit d3cce10

Browse files
committed
Add jqwik, ArchUnit, and SpotBugs to java-llama.cpp
- Add LlamaParameterProperties (jqwik property-based tests for InferenceParameters) - Add LlamaArchitectureTest (ArchUnit rules: no java.util.logging, no test frameworks in prod) - Add spotbugs-maven-plugin with fb-contrib and findsecbugs - Add README badges for jqwik, ArchUnit, SpotBugs https://claude.ai/code/session_01Teo4XcbGFp8LmxeiY8N37h
1 parent 7095c2d commit d3cce10

5 files changed

Lines changed: 116 additions & 0 deletions

File tree

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
**Build:**
22
![Java 11+](https://img.shields.io/badge/Java-11%2B-informational)
33
![JUnit](https://img.shields.io/badge/tested%20with-JUnit4-yellow)
4+
[![jqwik](https://img.shields.io/badge/tested%20with-jqwik-1f6feb)](https://jqwik.net)
5+
[![ArchUnit](https://img.shields.io/badge/tested%20with-ArchUnit-c71a36)](https://www.archunit.org)
6+
[![SpotBugs](https://img.shields.io/badge/analyzed%20with-SpotBugs-3b5998)](https://spotbugs.github.io)
47
[![llama.cpp b9333](https://img.shields.io/badge/llama.cpp-%23b9333-informational)](https://github.com/ggml-org/llama.cpp/releases/tag/b9333)
58
[![Publish](https://github.com/bernardladenthin/java-llama.cpp/actions/workflows/publish.yml/badge.svg)](https://github.com/bernardladenthin/java-llama.cpp/actions/workflows/publish.yml)
69
[![CodeQL](https://github.com/bernardladenthin/java-llama.cpp/actions/workflows/codeql.yml/badge.svg)](https://github.com/bernardladenthin/java-llama.cpp/actions/workflows/codeql.yml)

pom.xml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,18 @@ SPDX-License-Identifier: MIT
6161
<version>6.1.0</version>
6262
<scope>test</scope>
6363
</dependency>
64+
<dependency>
65+
<groupId>net.jqwik</groupId>
66+
<artifactId>jqwik</artifactId>
67+
<version>1.9.2</version>
68+
<scope>test</scope>
69+
</dependency>
70+
<dependency>
71+
<groupId>com.tngtech.archunit</groupId>
72+
<artifactId>archunit-junit5</artifactId>
73+
<version>1.3.0</version>
74+
<scope>test</scope>
75+
</dependency>
6476
<dependency>
6577
<groupId>org.jetbrains</groupId>
6678
<artifactId>annotations</artifactId>
@@ -297,6 +309,39 @@ SPDX-License-Identifier: MIT
297309
<redirectTestOutputToFile>true</redirectTestOutputToFile>
298310
</configuration>
299311
</plugin>
312+
<plugin>
313+
<groupId>com.github.spotbugs</groupId>
314+
<artifactId>spotbugs-maven-plugin</artifactId>
315+
<version>4.8.6.6</version>
316+
<configuration>
317+
<effort>Default</effort>
318+
<threshold>Default</threshold>
319+
<failOnError>false</failOnError>
320+
<includeTests>false</includeTests>
321+
<excludeFilterFile>spotbugs-exclude.xml</excludeFilterFile>
322+
<plugins>
323+
<plugin>
324+
<groupId>com.mebigfatguy.fb-contrib</groupId>
325+
<artifactId>fb-contrib</artifactId>
326+
<version>7.6.4</version>
327+
</plugin>
328+
<plugin>
329+
<groupId>com.h3xstream.findsecbugs</groupId>
330+
<artifactId>findsecbugs-plugin</artifactId>
331+
<version>1.13.0</version>
332+
</plugin>
333+
</plugins>
334+
</configuration>
335+
<executions>
336+
<execution>
337+
<id>spotbugs-check</id>
338+
<phase>verify</phase>
339+
<goals>
340+
<goal>check</goal>
341+
</goals>
342+
</execution>
343+
</executions>
344+
</plugin>
300345
</plugins>
301346
</build>
302347

spotbugs-exclude.xml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
SPDX-FileCopyrightText: 2026 Bernard Ladenthin <bernard.ladenthin@gmail.com>
4+
5+
SPDX-License-Identifier: MIT
6+
-->
7+
<FindBugsFilter
8+
xmlns="https://github.com/spotbugs/filter/3.0.0"
9+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:schemaLocation="https://github.com/spotbugs/filter/3.0.0 https://raw.githubusercontent.com/spotbugs/spotbugs/4.8.6/spotbugs/etc/findbugsfilter.xsd">
11+
12+
</FindBugsFilter>
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// SPDX-FileCopyrightText: 2026 Bernard Ladenthin <bernard.ladenthin@gmail.com>
2+
//
3+
// SPDX-License-Identifier: MIT
4+
package net.ladenthin.llama;
5+
6+
import static com.tngtech.archunit.lang.syntax.ArchRuleDefinition.noClasses;
7+
8+
import com.tngtech.archunit.core.importer.ImportOption;
9+
import com.tngtech.archunit.junit.AnalyzeClasses;
10+
import com.tngtech.archunit.junit.ArchTest;
11+
import com.tngtech.archunit.lang.ArchRule;
12+
13+
@AnalyzeClasses(packages = "net.ladenthin.llama", importOptions = ImportOption.DoNotIncludeTests.class)
14+
public class LlamaArchitectureTest {
15+
16+
/**
17+
* Production code must not use java.util.logging directly; all logging goes through SLF4J.
18+
*/
19+
@ArchTest
20+
static final ArchRule noJavaUtilLogging = noClasses()
21+
.that().resideInAPackage("net.ladenthin.llama..")
22+
.should().dependOnClassesThat()
23+
.resideInAPackage("java.util.logging..");
24+
25+
/**
26+
* Test-framework classes must not appear in production code.
27+
*/
28+
@ArchTest
29+
static final ArchRule noTestFrameworksInProduction = noClasses()
30+
.that().resideInAPackage("net.ladenthin.llama..")
31+
.should().dependOnClassesThat()
32+
.resideInAnyPackage("org.junit..", "net.jqwik..", "com.tngtech.archunit..");
33+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// SPDX-FileCopyrightText: 2026 Bernard Ladenthin <bernard.ladenthin@gmail.com>
2+
//
3+
// SPDX-License-Identifier: MIT
4+
package net.ladenthin.llama;
5+
6+
import net.jqwik.api.ForAll;
7+
import net.jqwik.api.Property;
8+
import net.jqwik.api.constraints.FloatRange;
9+
10+
public class LlamaParameterProperties {
11+
12+
@Property
13+
boolean setTemperatureNeverThrows(@ForAll @FloatRange(min = 0.0f, max = 2.0f) float temperature) {
14+
String json = new InferenceParameters().setTemperature(temperature).toString();
15+
return json.contains("temperature");
16+
}
17+
18+
@Property
19+
boolean setTopPNeverThrows(@ForAll @FloatRange(min = 0.0f, max = 1.0f) float topP) {
20+
String json = new InferenceParameters().setTopP(topP).toString();
21+
return json.contains("top_p");
22+
}
23+
}

0 commit comments

Comments
 (0)