Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ jobs:
distribution: temurin
- name: Spotless check (fail fast on format violations)
run: mvn -B --no-transfer-progress spotless:check
- name: SpotBugs check (fail fast on static-analysis findings)
run: mvn -B --no-transfer-progress -DskipTests -Denforcer.skip=true compile spotbugs:check
- name: Print internal package dependency graph (jdeps, informational)
continue-on-error: true
run: |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@
private final AiMdHeaderSupport headerSupport = new AiMdHeaderSupport();
private final AiMdChildEntryLineFormatter childEntryLineFormatter = new AiMdChildEntryLineFormatter();
private final AiMdDocumentCodec documentCodec = new AiMdDocumentCodec();
private final AiMdHeaderCodec headerCodec = new AiMdHeaderCodec();
private final Java8CompatibilityHelper compatibilityHelper = new Java8CompatibilityHelper();

private final AiFieldGenerationSupport fieldGenerationSupport;
Expand Down Expand Up @@ -365,44 +366,16 @@
}

/**
* Appends the package's own deterministic header block (title plus single-letter fields)
* to {@code builder}, mirroring the on-disk {@code .ai.md} header layout.
* Appends the package's own deterministic header block (title plus single-letter fields) to
* {@code builder} by delegating to {@link AiMdHeaderCodec#write(AiMdHeader)} — the single source
* of truth for the {@code .ai.md} header layout, and the same call {@link AiMdDocumentCodec} uses
* to serialise a persisted header.
*
* @param builder target string builder
* @param header the package header to render
*/
private void appendPackageHeaderLines(final StringBuilder builder, final AiMdHeader header) {
builder.append(AiMdHeaderCodec.HEADER_TITLE_PREFIX)
.append(header.title())
.append('\n');
builder.append(AiMdHeaderCodec.HEADER_FIELD_PREFIX)
.append("H: ")
.append(header.h())
.append('\n');
builder.append(AiMdHeaderCodec.HEADER_FIELD_PREFIX)
.append("C: ")
.append(header.c())
.append('\n');
builder.append(AiMdHeaderCodec.HEADER_FIELD_PREFIX)
.append("D: ")
.append(header.d())
.append('\n');
builder.append(AiMdHeaderCodec.HEADER_FIELD_PREFIX)
.append("T: ")
.append(header.t())
.append('\n');
builder.append(AiMdHeaderCodec.HEADER_FIELD_PREFIX)
.append("G: ")
.append(header.g())
.append('\n');
builder.append(AiMdHeaderCodec.HEADER_FIELD_PREFIX)
.append("A: ")
.append(header.a())
.append('\n');
builder.append(AiMdHeaderCodec.HEADER_FIELD_PREFIX)
.append("X: ")
.append(header.x())
.append('\n');
builder.append(headerCodec.write(header));
}

/**
Expand All @@ -418,11 +391,11 @@
* @return the number of children that contributed a non-blank body
* @throws IOException if a child {@code .ai.md} file cannot be read
*/
private int appendChildSummaries(final StringBuilder builder, final Path directory) throws IOException {

Check failure on line 394 in src/main/java/net/ladenthin/maven/llamacpp/aiindex/indexer/PackageIndexer.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Refactor this method to reduce its Cognitive Complexity from 17 to the 15 allowed.

See more on https://sonarcloud.io/project/issues?id=bernardladenthin_llamacpp-ai-index-maven-plugin&issues=AZ8CuNK3dU8WZgScJmiL&open=AZ8CuNK3dU8WZgScJmiL&pullRequest=118
int bodyCount = 0;

try (Stream<Path> stream = Files.list(directory)) {
for (Path path : compatibilityHelper.toList(stream.sorted(BY_FILE_NAME))) {

Check warning on line 398 in src/main/java/net/ladenthin/maven/llamacpp/aiindex/indexer/PackageIndexer.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Reduce the total number of break and continue statements in this loop to use at most one.

See more on https://sonarcloud.io/project/issues?id=bernardladenthin_llamacpp-ai-index-maven-plugin&issues=AZ8CuNK3dU8WZgScJmiK&open=AZ8CuNK3dU8WZgScJmiK&pullRequest=118
final Path fileNamePath = path.getFileName();
if (fileNamePath == null) {
continue;
Expand Down
Loading