You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@juneau.apache.org by ja...@apache.org on 2026/09/13 13:17:02 UTC

(juneau) 24/29: TODO-R0005: verify + close cleanup-pass conventions gaps

This is an automated email from the ASF dual-hosted git repository.

jamesbognar pushed a commit to branch juneau-release-manager
in repository https://gitbox.apache.org/repos/asf/juneau.git

commit f40a9bd84651b1c4d89b92936d2b02b93d0c9749
Author: James Bognar <ja...@apache.org>
AuthorDate: Sun Aug 30 12:46:52 2026 -0400

    TODO-R0005: verify + close cleanup-pass conventions gaps
    
    Re-runs CODE-CONVENTIONS.md's own verification greps at current HEAD and
    closes the gaps found, plus adopts the newer idioms from
    @juneau-code-conventions's "Pre-release cleanup pass idioms" subsection:
    
    - @SuppressWarnings normalization: the earlier pass only covered src/main;
      4 more bare single-string sites found in src/test (ReleaseRunRestTest,
      CredentialWriteVectorTest x3) converted to the multiline array form.
    - Null/blank guards: 8 sites (== null || isBlank() / != null && !isBlank())
      collapsed to Shorts.ib(x)/Shorts.inb(x).
    - FQCN leftover: DevDistVerifyStep's inline java.io.IOException replaced
      with an import + simple name.
    - assertSize, Shorts.or(...), injectable Clock, diff-narration comments:
      each verified and recorded as N/A-with-rationale (assertSize needs a new
      juneau-bct/juneau-commons-test dependency this repo intentionally doesn't
      add solely for a convention; the other three have zero candidate sites).
    
    mvn -nsu test green (239/239) before and after.
---
 CODE-CONVENTIONS.md                                | 37 +++++++++++++++++++++-
 .../apache/juneau/releng/email/EmailService.java   |  4 +--
 .../releng/engine/steps/DevDistVerifyStep.java     |  3 +-
 .../releng/engine/steps/NexusStagingCloseStep.java |  3 +-
 .../releng/engine/steps/ReleasePrepareStep.java    |  3 +-
 .../apache/juneau/releng/log/SseLogServlet.java    |  3 +-
 .../juneau/releng/log/VoteDeadlineTimer.java       |  3 +-
 .../apache/juneau/releng/nexus/NexusMockModel.java |  2 +-
 .../juneau/releng/nexus/NexusStagingClient.java    |  2 +-
 .../releng/rest/CredentialWriteVectorTest.java     | 12 +++++--
 .../juneau/releng/rest/ReleaseRunRestTest.java     |  4 ++-
 11 files changed, 62 insertions(+), 14 deletions(-)

diff --git a/CODE-CONVENTIONS.md b/CODE-CONVENTIONS.md
index d98e298638..6b13a6dd60 100644
--- a/CODE-CONVENTIONS.md
+++ b/CODE-CONVENTIONS.md
@@ -47,9 +47,20 @@ Each item: a one-line rule, then **Applied** or **N/A** (with rationale).
   codebase.
 - **`@SuppressWarnings` format** — Always the multiline brace/array form with a `//` rationale on every
   token, even a single token (except the inline catch-parameter `"unused"` case). **Applied.** Converted
-  the four `@SuppressWarnings("unchecked")` (parsed-JSON casts) to the multiline form with rationale.
+  the `@SuppressWarnings("unchecked")` (parsed-JSON casts) in `src/main` to the multiline form with
+  rationale, plus **four more found in `src/test`** on a later verification pass (2026-08-30) — this
+  pass's original sweep only covered `src/main`; `ReleaseRunRestTest.java` (one bare `"unchecked"`) and
+  `CredentialWriteVectorTest.java` (three `"resource"` sites, each already carrying a rationale comment
+  but still in the disallowed single-string form) are now also converted. Verify with
+  `rg -n '@SuppressWarnings\("[^"]+"\)' --type java src` (should be empty).
 - **Delete dead code** — Remove unreachable branches / unused fields & imports rather than leaving them.
   **Applied** (none found).
+- **FQCN inline usage (leftover)** — **Applied.** One leftover found on a later verification pass
+  (2026-08-30): `DevDistVerifyStep.java`'s caught `java.io.IOException` was FQCN'd inline with no
+  `IOException` import elsewhere in the file (not a name-collision case) — added the import and switched
+  to the simple name. Verify with
+  `` rg -n '\bjava\.[a-z][a-zA-Z]+\.[A-Z]' --type java -g '!**/test/**' src `` (filter out
+  `import`/`package` lines).
 - **Indentation: tabs** — **Applied (tabs)** — full Juneau parity; enforced by the checked-in Eclipse
   formatter + save-action profile in `.settings/`. The whole tree (98 Java files) was reformatted with the
   real Eclipse formatter using Juneau's tab profile (`org.eclipse.jdt.core.formatter.tabulation.char=tab`),
@@ -61,6 +72,30 @@ Each item: a one-line rule, then **Applied** or **N/A** (with rationale).
   but here they're inlined into the project `.settings/` so the profile is enforced project-scoped and
   travels with the repo. Only `.classpath` and `.project` remain git-ignored.
 
+## Pre-release cleanup pass idioms
+
+Additional `Shorts`/idiom conventions from `@juneau-code-conventions`'s "Pre-release cleanup pass idioms"
+subsection (added 2026-08-30, upstream `TODO-J0000`), verified against this repo on 2026-08-30:
+
+- **Null/blank guards (`Shorts.ib`/`Shorts.inb`)** — **Applied.** Collapsed `x == null || x.isBlank()` /
+  `x != null && !x.isBlank()` to `ib(x)` / `inb(x)` (`import static
+  org.apache.juneau.commons.utils.Shorts.*;`) at all 8 sites found: `ReleasePrepareStep`,
+  `SseLogServlet`, `NexusStagingClient`, `VoteDeadlineTimer`, `NexusMockModel` (the `ib` guards), and
+  `EmailService` (×2), `NexusStagingCloseStep` (the `inb` guards).
+- **First-non-null coalesce (`Shorts.or(...)`)** — **N/A (none found).** No `x == null ? null : f(x)`
+  ternary candidates in `src/main`.
+- **Injectable wall-clock `Clock`** — **N/A (none found).** No direct `System.currentTimeMillis()` calls
+  in `src/main`.
+- **Size assertions (`assertSize`)** — **N/A**, same reason as `assertBean`/`TestBase` below: neither
+  Juneau-side implementation is reachable from this repo's test classpath. `BctAssertions`
+  (`org.apache.juneau.test.bct`) would require adding `juneau-bct` as a new dependency — confirmed absent
+  from `mvn dependency:tree -Dscope=test` — and `TestAssertions` (`org.apache.juneau.commons`) lives in
+  `juneau-commons`'s **test** sources, not its published main jar, so it isn't on this repo's classpath
+  either. Per this doc's own general rule (below), a new dependency is not added solely to satisfy this
+  idiom; the ~28 `assertEquals(N, x.size())` sites stay as-is.
+- **No diff-narration comments** — **N/A (none found).** No "behaviour-preserving" / "renders
+  pixel-identically" / "appended after X so Y" phrasing in the codebase.
+
 ## Javadoc
 
 - **Javadoc on public types & methods** — Brief description; `@param`/`@return`/`@throws` as applicable.
diff --git a/src/main/java/org/apache/juneau/releng/email/EmailService.java b/src/main/java/org/apache/juneau/releng/email/EmailService.java
index cafcc03fcf..14507a2442 100644
--- a/src/main/java/org/apache/juneau/releng/email/EmailService.java
+++ b/src/main/java/org/apache/juneau/releng/email/EmailService.java
@@ -131,10 +131,10 @@ public class EmailService {
 	 * produces a dangling blank line in the email.
 	 */
 	private static String narrative(String primary, Map<String, String> extra, String key) {
-		if (primary != null && !primary.isBlank())
+		if (inb(primary))
 			return primary.stripTrailing();
 		var e = extra == null ? null : extra.get(key);
-		return (e != null && !e.isBlank()) ? e.stripTrailing() : null;
+		return inb(e) ? e.stripTrailing() : null;
 	}
 
 	private static String nz(String s) {
diff --git a/src/main/java/org/apache/juneau/releng/engine/steps/DevDistVerifyStep.java b/src/main/java/org/apache/juneau/releng/engine/steps/DevDistVerifyStep.java
index 3d27078094..53322c079d 100644
--- a/src/main/java/org/apache/juneau/releng/engine/steps/DevDistVerifyStep.java
+++ b/src/main/java/org/apache/juneau/releng/engine/steps/DevDistVerifyStep.java
@@ -17,6 +17,7 @@
 
 package org.apache.juneau.releng.engine.steps;
 
+import java.io.IOException;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.util.ArrayList;
@@ -98,7 +99,7 @@ public class DevDistVerifyStep implements ReleaseStep {
 	private static long fileSize(Path file) {
 		try {
 			return Files.size(file);
-		} catch (java.io.IOException e) {
+		} catch (IOException e) {
 			return 0;
 		}
 	}
diff --git a/src/main/java/org/apache/juneau/releng/engine/steps/NexusStagingCloseStep.java b/src/main/java/org/apache/juneau/releng/engine/steps/NexusStagingCloseStep.java
index 93af36e006..4911767218 100644
--- a/src/main/java/org/apache/juneau/releng/engine/steps/NexusStagingCloseStep.java
+++ b/src/main/java/org/apache/juneau/releng/engine/steps/NexusStagingCloseStep.java
@@ -17,6 +17,7 @@
 
 package org.apache.juneau.releng.engine.steps;
 
+import static org.apache.juneau.commons.utils.Shorts.*;
 import org.apache.juneau.releng.engine.Preview;
 import org.apache.juneau.releng.engine.ReleaseStep;
 import org.apache.juneau.releng.engine.StepContext;
@@ -41,7 +42,7 @@ public class NexusStagingCloseStep implements ReleaseStep {
 
 	private String resolveRepoId(StepContext ctx) {
 		var override = ctx.formInputs.get("repoIdOverride");
-		if (override != null && !override.isBlank())
+		if (inb(override))
 			return override;
 		return ctx.nexus.findLatestRepo().map(r -> r.id).orElse(null);
 	}
diff --git a/src/main/java/org/apache/juneau/releng/engine/steps/ReleasePrepareStep.java b/src/main/java/org/apache/juneau/releng/engine/steps/ReleasePrepareStep.java
index a3572fba2e..459e9f6eb4 100644
--- a/src/main/java/org/apache/juneau/releng/engine/steps/ReleasePrepareStep.java
+++ b/src/main/java/org/apache/juneau/releng/engine/steps/ReleasePrepareStep.java
@@ -17,6 +17,7 @@
 
 package org.apache.juneau.releng.engine.steps;
 
+import static org.apache.juneau.commons.utils.Shorts.*;
 import java.util.List;
 import org.apache.juneau.releng.engine.Preview;
 import org.apache.juneau.releng.engine.ReleaseStep;
@@ -49,7 +50,7 @@ public class ReleasePrepareStep implements ReleaseStep {
 		var supplied = ctx.formInputs.get("developmentVersion");
 		if (supplied == null && ctx.run.developmentVersion != null)
 			supplied = ctx.run.developmentVersion;
-		return (supplied == null || supplied.isBlank()) ? null : supplied;
+		return ib(supplied) ? null : supplied;
 	}
 
 	@Override
diff --git a/src/main/java/org/apache/juneau/releng/log/SseLogServlet.java b/src/main/java/org/apache/juneau/releng/log/SseLogServlet.java
index 1b2e812940..51a415394c 100644
--- a/src/main/java/org/apache/juneau/releng/log/SseLogServlet.java
+++ b/src/main/java/org/apache/juneau/releng/log/SseLogServlet.java
@@ -17,6 +17,7 @@
 
 package org.apache.juneau.releng.log;
 
+import static org.apache.juneau.commons.utils.Shorts.*;
 import java.io.IOException;
 import java.io.PrintWriter;
 import java.nio.file.Files;
@@ -192,7 +193,7 @@ public class SseLogServlet extends HttpServlet {
 
 	/** Splits {@code /{version}/{stepId}} into {@code [version, stepId]}; either may be empty if absent. */
 	private static String[] trailingTwoSegments(String pathInfo) {
-		if (pathInfo == null || pathInfo.isBlank())
+		if (ib(pathInfo))
 			return new String[] { "", "" };
 		var p = pathInfo.startsWith("/") ? pathInfo.substring(1) : pathInfo;
 		var parts = p.split("/", 2);
diff --git a/src/main/java/org/apache/juneau/releng/log/VoteDeadlineTimer.java b/src/main/java/org/apache/juneau/releng/log/VoteDeadlineTimer.java
index 7cfdfbfa96..a3093dbd79 100644
--- a/src/main/java/org/apache/juneau/releng/log/VoteDeadlineTimer.java
+++ b/src/main/java/org/apache/juneau/releng/log/VoteDeadlineTimer.java
@@ -17,6 +17,7 @@
 
 package org.apache.juneau.releng.log;
 
+import static org.apache.juneau.commons.utils.Shorts.*;
 import java.time.Duration;
 import java.time.Instant;
 import java.util.List;
@@ -44,7 +45,7 @@ public class VoteDeadlineTimer {
 
 	/** Arm (or re-arm) a ping for the given version at {@code deadline}. No-op if webhook empty or deadline past. */
 	public void arm(String version, Instant deadline) {
-		if (slackWebhook == null || slackWebhook.isBlank())
+		if (ib(slackWebhook))
 			return;
 		var delay = Duration.between(Instant.now(), deadline).toMillis();
 		if (delay <= 0)
diff --git a/src/main/java/org/apache/juneau/releng/nexus/NexusMockModel.java b/src/main/java/org/apache/juneau/releng/nexus/NexusMockModel.java
index a016a0a61c..4c031aac52 100644
--- a/src/main/java/org/apache/juneau/releng/nexus/NexusMockModel.java
+++ b/src/main/java/org/apache/juneau/releng/nexus/NexusMockModel.java
@@ -113,7 +113,7 @@ public class NexusMockModel {
 	@SuppressWarnings({ "unchecked" // Parsed JSON is assigned to its known generic shape.
 	})
 	static String repoIdFromBody(String body) {
-		if (body == null || body.isBlank())
+		if (ib(body))
 			return null;
 		Map<String, Object> parsed = Json.DEFAULT.read(body, Map.class);
 		var data = (Map<String, Object>) parsed.get("data");
diff --git a/src/main/java/org/apache/juneau/releng/nexus/NexusStagingClient.java b/src/main/java/org/apache/juneau/releng/nexus/NexusStagingClient.java
index 301ad96082..fe835af057 100644
--- a/src/main/java/org/apache/juneau/releng/nexus/NexusStagingClient.java
+++ b/src/main/java/org/apache/juneau/releng/nexus/NexusStagingClient.java
@@ -141,7 +141,7 @@ public class NexusStagingClient {
 	})
 	public Optional<StagingRepo> findLatestRepo() {
 		var json = transport.send("GET", "/service/local/staging/profile_repositories/" + profileId, null);
-		if (json == null || json.isBlank())
+		if (ib(json))
 			return Optional.empty();
 		List<Map<String, Object>> parsed = Json.DEFAULT.read(json, List.class);
 		return parsed.stream().map(m -> {
diff --git a/src/test/java/org/apache/juneau/releng/rest/CredentialWriteVectorTest.java b/src/test/java/org/apache/juneau/releng/rest/CredentialWriteVectorTest.java
index d3e776d6b8..93dd0ba7dc 100644
--- a/src/test/java/org/apache/juneau/releng/rest/CredentialWriteVectorTest.java
+++ b/src/test/java/org/apache/juneau/releng/rest/CredentialWriteVectorTest.java
@@ -105,17 +105,23 @@ class CredentialWriteVectorTest {
 		service.store("apache", KEYCHAIN_FREE_ACCOUNT, "the-real-password");
 	}
 
-	@SuppressWarnings("resource") // Caller closes via try-with-resources; MockRestClient caches RestContext per class, so opt out with a fresh StackOverlay.
+	@SuppressWarnings({
+		"resource" // Caller closes via try-with-resources; MockRestClient caches RestContext per class, so opt out with a fresh StackOverlay.
+	})
 	private MockRestClient client() {
 		return MockRestClient.builder(new CredentialRest(service)).overridingBeanStore(new StackOverlay()).build();
 	}
 
-	@SuppressWarnings("resource") // As client(): caller closes; fresh StackOverlay opts out of the per-class RestContext cache.
+	@SuppressWarnings({
+		"resource" // As client(): caller closes; fresh StackOverlay opts out of the per-class RestContext cache.
+	})
 	private MockRestClient defaultConfigClient() {
 		return MockRestClient.builder(new DefaultConfigCredentialResource(service)).overridingBeanStore(new StackOverlay()).build();
 	}
 
-	@SuppressWarnings("resource") // As client(): caller closes; fresh StackOverlay opts out of the per-class RestContext cache.
+	@SuppressWarnings({
+		"resource" // As client(): caller closes; fresh StackOverlay opts out of the per-class RestContext cache.
+	})
 	private MockRestClient hardenedConfigClient() {
 		return MockRestClient.builder(new HardenedConfigCredentialResource(service)).overridingBeanStore(new StackOverlay()).build();
 	}
diff --git a/src/test/java/org/apache/juneau/releng/rest/ReleaseRunRestTest.java b/src/test/java/org/apache/juneau/releng/rest/ReleaseRunRestTest.java
index d78394ba5d..d027858104 100644
--- a/src/test/java/org/apache/juneau/releng/rest/ReleaseRunRestTest.java
+++ b/src/test/java/org/apache/juneau/releng/rest/ReleaseRunRestTest.java
@@ -537,7 +537,9 @@ class ReleaseRunRestTest {
 		// Still valid, round-trippable JSON: a JSON parser decodes \u003c back to the original title verbatim
 		// (this is exactly what FreeMarker's HTML entity-encoding would have corrupted).
 		var parsed = org.apache.juneau.marshall.marshaller.Json.to(json, Map.class);
-		@SuppressWarnings("unchecked")
+		@SuppressWarnings({
+			"unchecked" // Assigning a raw Json.to(..., Map.class) result to its known parameterized shape.
+		})
 		var entry = (Map<String,Object>) parsed.get("evil");
 		assertEquals(evilTitle, entry.get("title"));
 		assertEquals(Boolean.TRUE, entry.get("mutating"));