Public report of apache/kafka, published 23 October 2026. It has the same score, grades and number of findings as the full report. The details of security findings (where they are in the code, which known vulnerabilities and which passwords or keys were found) are left out, so nobody can use them against the project.
Public
Executive report Measured under the Code Assurance Index, an open standard for code quality, using its published scoring rules (rubric version 2026.10.5). Watchdog signed this survey and filed it in the standard's public register, where anyone can look it up by its survey ID. Check this survey → Signed and filed in the standard's public register, 23 October 2026, 05:08 UTC · Survey ID cd_efbece17562f415b91042ac73235a8b1

apache/kafka

Measured 23 October 2026, 04:25 UTC, at code version da22240

First survey, so nothing to compare with yet
CAI score 56out of 100 Adequate
CriticalWeakAdequateStrongExemplary

The score is built from these lenses. Each lens grades one area of the code, such as how easy it is to change or how well it is protected. The weakest lens counts most, so one weak area pulls the score down instead of being averaged away.

A very large codebase: 633,107 lines of product code in 8 projects, tests not counted · Estimated rebuild effort: about 12.9 person-years · Weakest lens: Production Readiness, 49

Findings by how serious they are

143 critical 3175 serious 1284 minor

18 dimensions are left out of the score. For each one, Watchdog either couldn't measure it in this code, or found no evidence of the safeguard it looks for, such as a tested backup restore. They count neither for nor against the score, and Limitations lists each one with its reason.

This survey was produced by

Watchdog
Producer
Canine Development
Analyzer
Watchdog engine 1.0.0
Measured
23 October 2026, 04:25 UTC

A measurement, not a certificate. The Code Assurance Index records a number together with the evidence it was worked out from, so anyone can recalculate it, but it doesn't certify or guarantee the code. The standard was written by Canine Development, which also builds Watchdog. It is open to any tool that implements it, and today Watchdog is the only one that does.

The score is deterministic, which means the same code always gets the same score. Watchdog works it out with tools that follow published rules, and an AI model never decides it, so anyone who applies the same rules to the same code gets the same number. How it is done is explained under Methodology ▸

64of 67 dimensions measured by tools. The other 3 are advisory notes from an AI model, which explain the code but don't count towards the score.
4579of 4602 findings point to an exact file and line, so you can open each one in the code. The other 23 concern the repository as a whole, such as missing documentation.
67dimensions across 6 lenses, read from 633,107 lines of product code in 8 projects.
Chapters

Executive summary

apache/kafka scores 56 out of 100 and is rated Adequate, while four of its six lenses score higher still: Architecture at 87, Performance at 81 and Maturity at 73, all rated Strong, and Code Health at 65, rated Adequate.

The score is lower than those four because the weakest lens counts most, and here that is Production Readiness, which scores 49 and is rated Weak. Its Outbound HTTP resilience dimension scores 3 out of 10, and until that reaches 4, Production Readiness can't be rated higher than Adequate. The first actions are to resolve the 1 Leaked secret finding(s) in Secret Scanning and to resolve the 4 No assertions (empty test) finding(s) in Test Quality, and if Production Readiness rose to 70, the score would rise from 56 to about 62.

143 findings are critical: 71 in Static Analysis (SAST), 50 in Knowledge Freshness, eight in Secrets (history), seven in IaC & Container Security, four in Test Quality, one in Change Coupling, one in Secret Scanning and one in Supply-chain Provenance & Signing.

Watchdog couldn't measure 18 dimensions in this code, among them Code Coverage, Test Reliability and Dependency Hygiene, so they are left out of the score. The product code is 633,107 lines, which would take an estimated 12.9 person-years, around €1,900,000, to rebuild.

A lens is capped at Adequate while one of its dimensions scores below 4 out of 10, however well the rest of the lens does. That way a serious problem in one place always shows in the lens's rating.

How the score is built: what each lens counts for The lenses don't count equally. The weakest lens counts most, the next weakest a little less, and so on, so a weak area pulls the score down instead of being averaged away. In the bar below, each part's width shows how much that lens counts and its colour shows its rating. Improving the widest part moves the score most, and as that lens improves, it counts for less, because another lens becomes the weakest.
Production Readiness 49 · counts for 46%Security and Compliance 53 · counts for 25%Code Health 65 · counts for 14%Maturity 73 · counts for 8%Performance 81 · counts for 4%Architecture 87 · counts for 2%

If Production Readiness rose from 49 to 70, the lowest score rated Strong, the score would rise from 56 to about 62.

Code composition: what the lines of code are
Product code 41%Tests 59%
Rebuild cost: about €1,900,000 · Estimate
Cost to rebuild€620,000 to €3,100,000, for 10,404 to 33,006 hours of work, about 12.9 person-years for 7 to 25 engineers
Difficulty of the problemStandard, judged from the kind of software and how it is built. Code that solves a harder problem, such as payments or medical bookings, costs more per line to write.
Quality factor×0.8 at a score of 56. Better code takes more work to write, so the factor is ×1.0 at a score of 70, lower below it and higher above it.
SizeVery large: 633,107 lines of product code

How the estimate is made: Watchdog prices the hours a team would need to write this code again, at €60 to €95 an hour. Declarations and boilerplate are priced at a fast rate and logic at a slower one, and the logic is then multiplied by the difficulty of the problem and by the quality factor. The estimate can be about 30% off either way, and it moves most with the hourly rate and the difficulty. For this code, every line is priced as straight logic, which keeps the estimate on the low side.

Top priorities

The three actions that raise the score most for the work they take. The full ranked list is in the Roadmap.

1
Resolve the 1 Leaked secret finding(s) in Secret Scanning — start with REDACTED.
Raises the score by about 7 points · Low effort · Secret Scanning
2
Resolve the 4 No assertions (empty test) finding(s) in Test Quality — start with ValuesTest.java, DistributedHerderTest.java, CustomStickyTaskAssignorTest.java.
Raises the score by about 3 points · Low effort · Test Quality
3
Resolve the 8 High secret finding(s) in Secrets (history) — start with REDACTED (8).
Raises the score by about 3 points · Low effort · Secrets (history)

Diagnosis: what the measurements show together

Each conclusion below combines several dimensions into one point that no single dimension shows, and lists the measurements it rests on.

Where the investment is most exposed · Value at risk
This code would cost about €1,900,000 to build again, about 12.9 person-years of work. Its weakest lens is Production Readiness, at 49 (Weak). Production Readiness is about whether the product is ready to run in production and to change without breaking. Because the weakest lens counts most in the score, work on Production Readiness also moves the score most.
Based on: the rebuild estimate · the Production Readiness grade · how much each lens counts
What to do: Start with the Production Readiness actions in Top priorities.
If you do one thing first · First action
Resolve the 1 Leaked secret finding(s) in Secret Scanning. Of all the actions in this report, it raises the score most for the work it takes: about 7 points for low effort, because it clears the 1 Secret Scanning findings. The next survey will show the change in the score.
Based on: the ranked actions in Top priorities, by score gain and effort

Architecture — module dependency graph

Project dependencies, layered top-to-bottom; arrows show direction. Any dashed red edge points upward or sideways — a layering smell or cycle. A clean layered graph has none.

arch ${artifactId} ${artifactId} kafka kafka kafka-api-checker kafka-api-checker kafka-api-checker:core kafka-api-checker:core kafka-api-checker:gradle-plugins kafka-api-checker:gradle-plugins kafka-api-checker:gradle-plugins->kafka-api-checker:core kafka-api-checker:maven-plugin kafka-api-checker:maven-plugin kafka-api-checker:maven-plugin->kafka-api-checker:core kafkatest kafkatest streams-quickstart-java streams-quickstart-java

Architecture: which parts of the code depend on which

The code is divided into modules, groups of code that each handle one part of the product, and a module depends on another when it uses code from it. The table lists the modules both down the side and across the top, in an order where each module should only use modules listed above it. A number in a cell means the module on that row uses the module in that column, and it counts the pairs of building blocks (types) that connect them. The one thing to look for is a mark above the diagonal line. It means two or more modules use each other in a loop (a dependency cycle), so none of them can be changed, tested or released on its own.

385 modules, with 1801 dependencies between them. 6 loops run through 146 of the modules, marked above the diagonal.

The table shows the 40 modules with the most connections; 345 more are left out to keep it readable.

Which modules use which. The module on each row uses the module in each column, and the number counts the pairs of types that connect them. A cell above the diagonal is part of a loop.
uses →1 org.apache.kafka.common.header2 org.apache.kafka.common.config3 org.apache.kafka.common.errors4 org.apache.kafka.common.security.auth5 org.apache.kafka.common.utils.internals6 org.apache.kafka.common.record.internal7 org.apache.kafka.common.protocol8 org.apache.kafka.common.requests9 org.apache.kafka.common.network10 org.apache.kafka.server.common11 org.apache.kafka.common.utils12 org.apache.kafka.image13 org.apache.kafka.common.metrics14 org.apache.kafka.common.serialization15 org.apache.kafka.metadata16 org.apache.kafka.common.internals17 org.apache.kafka.server.util18 org.apache.kafka.clients.producer19 org.apache.kafka.raft20 org.apache.kafka.storage.internals.log21 org.apache.kafka.controller22 org.apache.kafka.server23 org.apache.kafka.common.test24 org.apache.kafka.common25 org.apache.kafka.clients.consumer.internals26 org.apache.kafka.coordinator.common.runtime27 org.apache.kafka.clients.consumer28 org.apache.kafka.coordinator.group29 org.apache.kafka.clients.admin30 org.apache.kafka.streams.state.internals31 org.apache.kafka.clients32 org.apache.kafka.connect.runtime33 org.apache.kafka.streams.processor.internals34 kafka.server35 org.apache.kafka.connect.mirror36 org.apache.kafka.streams.processor37 org.apache.kafka.tools38 kafka.server.share39 org.apache.kafka.streams40 org.apache.kafka.streams.integration
1 org.apache.kafka.common.header
2 org.apache.kafka.common.config1
3 org.apache.kafka.common.errors17
4 org.apache.kafka.common.security.auth2
5 org.apache.kafka.common.utils.internals11111
6 org.apache.kafka.common.record.internal832710
7 org.apache.kafka.common.protocol3212
8 org.apache.kafka.common.requests5344302526431
9 org.apache.kafka.common.network131632434
10 org.apache.kafka.server.common11442
11 org.apache.kafka.common.utils111
12 org.apache.kafka.image311416102
13 org.apache.kafka.common.metrics310
14 org.apache.kafka.common.serialization143
15 org.apache.kafka.metadata6212104184
16 org.apache.kafka.common.internals117
17 org.apache.kafka.server.util111415177
18 org.apache.kafka.clients.producer6311115315278521
19 org.apache.kafka.raft79615610131914173
20 org.apache.kafka.storage.internals.log92438252121925
21 org.apache.kafka.controller721548258317129
22 org.apache.kafka.server11375512219245121335118
23 org.apache.kafka.common.test111121131426346
24 org.apache.kafka.common1111
25 org.apache.kafka.clients.consumer.internals2186841237643061316011464
26 org.apache.kafka.coordinator.common.runtime943616451626
27 org.apache.kafka.clients.consumer3213381121248520321
28 org.apache.kafka.coordinator.group661551552213134
29 org.apache.kafka.clients.admin16132358711693120159571
30 org.apache.kafka.streams.state.internals294201206690115011588
31 org.apache.kafka.clients3117437444222743102
32 org.apache.kafka.connect.runtime301315121111112
33 org.apache.kafka.streams.processor.internals14125271716710851657151812760
34 kafka.server11112221
35 org.apache.kafka.connect.mirror2221152516132
36 org.apache.kafka.streams.processor533626
37 org.apache.kafka.tools2102954110312115471127563
38 kafka.server.share2211311215114
39 org.apache.kafka.streams22244862313281932
40 org.apache.kafka.streams.integration92158245314151587327166
Uses a module listed above itPart of a loopThe module itself
1 org.apache.kafka.common.header2 org.apache.kafka.common.config3 org.apache.kafka.common.errors4 org.apache.kafka.common.security.auth5 org.apache.kafka.common.utils.internals6 org.apache.kafka.common.record.internal7 org.apache.kafka.common.protocol8 org.apache.kafka.common.requests9 org.apache.kafka.common.network10 org.apache.kafka.server.common11 org.apache.kafka.common.utils12 org.apache.kafka.image13 org.apache.kafka.common.metrics14 org.apache.kafka.common.serialization15 org.apache.kafka.metadata16 org.apache.kafka.common.internals17 org.apache.kafka.server.util18 org.apache.kafka.clients.producer19 org.apache.kafka.raft20 org.apache.kafka.storage.internals.log21 org.apache.kafka.controller22 org.apache.kafka.server23 org.apache.kafka.common.test24 org.apache.kafka.common25 org.apache.kafka.clients.consumer.internals26 org.apache.kafka.coordinator.common.runtime27 org.apache.kafka.clients.consumer28 org.apache.kafka.coordinator.group29 org.apache.kafka.clients.admin30 org.apache.kafka.streams.state.internals31 org.apache.kafka.clients32 org.apache.kafka.connect.runtime33 org.apache.kafka.streams.processor.internals34 kafka.server35 org.apache.kafka.connect.mirror36 org.apache.kafka.streams.processor37 org.apache.kafka.tools38 kafka.server.share39 org.apache.kafka.streams40 org.apache.kafka.streams.integrationorg.apache.kafka.common.header1org.apache.kafka.common.config2org.apache.kafka.common.errors3org.apache.kafka.common.security.auth4org.apache.kafka.common.utils.internals5org.apache.kafka.common.record.internal6org.apache.kafka.common.protocol7org.apache.kafka.common.requests8org.apache.kafka.common.network9org.apache.kafka.server.common10org.apache.kafka.common.utils11org.apache.kafka.image12org.apache.kafka.common.metrics13org.apache.kafka.common.serialization14org.apache.kafka.metadata15org.apache.kafka.common.internals16org.apache.kafka.server.util17org.apache.kafka.clients.producer18org.apache.kafka.raft19org.apache.kafka.storage.internals.log20org.apache.kafka.controller21org.apache.kafka.server22org.apache.kafka.common.test23org.apache.kafka.common24org.apache.kafka.clients.consumer.internals25org.apache.kafka.coordinator.common.runtime26org.apache.kafka.clients.consumer27org.apache.kafka.coordinator.group28org.apache.kafka.clients.admin29org.apache.kafka.streams.state.internals30org.apache.kafka.clients31org.apache.kafka.connect.runtime32org.apache.kafka.streams.processor.internals33kafka.server34org.apache.kafka.connect.mirror35org.apache.kafka.streams.processor36org.apache.kafka.tools37kafka.server.share38org.apache.kafka.streams39org.apache.kafka.streams.integration4011721111183271032125344302526431131632434114421113114161023101436212104184117111415177631111531527852179615610131914173924382521219257215482583171291137551221924512133511811112113142634611112186841237643061316011464943616451626321338112124852032166155155221313416132358711693120159571294201206690115011588311743744422274310230131512111111214125271716710851657151812760111122212221152516132533626210295411031211547112756322113112151142224486231328193292158245314151587327166+345 more modules (most-connected shown)

At a glance — Code Health · 65% · Adequate · gated by X5 ·

At a glance — Architecture · 87% · Strong ·

At a glance — Maturity · 73% · Strong ·

At a glance — Readiness · 49% · Weak · gated by P7 ·

At a glance — Security · 53% · Adequate · gated by D28, D29, D36 ·

At a glance — Performance · 81% · Strong ·

Security & Compliance — OWASP Top-10 mapping

Findings mapped to OWASP categories; the specific CVEs/secrets are in the Security dimension cards below and findings.md (redacted only on the public version of this report).

OWASP categoryFindingsSeverity
A05:2025 — Injection73High / Critical
A03:2025 — Software Supply Chain Failures19High / Critical
A02:2025 — Security Misconfiguration16High / Critical
A07:2025 — Authentication Failures10High / Critical

Roadmap

Immediately address security risks by resolving the leaked secret in REDACTED and the eight historical high-severity secrets in REDACTED. Strengthen test reliability by fixing empty assertions in ValuesTest, DistributedHerderTest, and CustomStickyTaskAssignorTest. Enhance system resilience by enforcing timeouts and retry logic on all outbound HTTP calls, and finalize disaster recovery by documenting RTO/RPO targets and a tested restore procedure.

Ranked by impact ÷ effort. "Helps" is the estimated gain on the 0–100 health score.

Do thisHelpsEffortDimension
Resolve the 1 Leaked secret finding(s) in Secret Scanning — start with REDACTED.+7.0 ptsLowSecret Scanning
Resolve the 4 No assertions (empty test) finding(s) in Test Quality — start with ValuesTest.java, DistributedHerderTest.java, CustomStickyTaskAssignorTest.java.+3.3 ptsLowTest Quality
Resolve the 8 High secret finding(s) in Secrets (history) — start with REDACTED (8).+3.0 ptsLowSecrets (history)
Resolve the 8 REDACTED finding(s) in Static Analysis (SAST) — start with REDACTED (5), REDACTED (3).+1.4 ptsLowStatic Analysis (SAST)
Pass `timeout=` on every `requests`/`httpx` call (requests has no default and will wait forever), mount an `HTTPAdapter(max_retries=Retry(...))` on shared sessions, and wrap calls to flaky dependencies in `tenacity` retries or a `pybreaker` circuit breaker.+2.7 ptsMediumOutbound HTTP resilience
Resolve the 1 No ADRs found finding(s) in ADR Quality.+1.2 ptsLowADR Quality
Document RTO/RPO and a tested restore procedure (a backup config alone isn't disaster recovery).+2.1 ptsMediumDR & Backup
Declare the default where Java declares it: `@NullMarked` (org.jspecify.annotations) in each package's `package-info.java`, or once in `module-info.java`, and run NullAway (Error Prone) or the Checker Framework so the declaration is enforced. Then annotate the real exceptions `@Nullable` and resolve the suppressions rather than adding to them: a `@SuppressWarnings("NullAway")` or `castToNonNull(x)` on a value the checker could show to be null is a `NullPointerException` waiting for the path that makes it true — where the value genuinely cannot be null, say something the checker can see instead (a null check, `Objects.requireNonNull`, a non-null field initialised in the constructor).+1.9 ptsMediumNullable reference types

File quality

Per-file score 0–10 — a quality signature. Of 983 files carrying findings, judged against the Production bar: 1% slop · 53% mixed · 46% near-clean.

FileScoreBandWorst signal
REDACTED1.3SlopIaC & Container Security: High IaC: REDACTED
REDACTED1.3SlopStatic Analysis (SAST): High: REDACTED
REDACTED2.0SlopIaC & Container Security: High IaC: REDACTED
REDACTED2.0SlopIaC & Container Security: High IaC: REDACTED
REDACTED2.3SlopStatic Analysis (SAST): High: REDACTED
REDACTED2.4SlopStatic Analysis (SAST): High: REDACTED
REDACTED2.7SlopStatic Analysis (SAST): High: REDACTED
REDACTED2.7SlopStatic Analysis (SAST): High: REDACTED
REDACTED3.0SlopStatic Analysis (SAST): High: REDACTED
REDACTED3.0SlopStatic Analysis (SAST): High: REDACTED
REDACTED3.0SlopStatic Analysis (SAST): High: REDACTED
connect/runtime/src/test/java/org/apache/kafka/connect/runtime/distributed/DistributedHerderTest.java3.3SlopTest Quality: No assertions (empty test): testInconsistentConfigs
REDACTED3.7SlopStatic Analysis (SAST): High: REDACTED
REDACTED4.4MixedSecrets (history): High secret: REDACTED
REDACTED4.6MixedSecret Scanning: Leaked secret: REDACTED
REDACTED4.6MixedStatic Analysis (SAST): High: REDACTED
REDACTED5.1MixedStatic Analysis (SAST): High: REDACTED
REDACTED5.1MixedStatic Analysis (SAST): High: REDACTED
REDACTED5.1MixedStatic Analysis (SAST): High: REDACTED
REDACTED5.1MixedStatic Analysis (SAST): High: REDACTED

How the grades work

Every finding carries one of four grades. Three say how serious it is. The fourth says this survey could not settle it — and it is a grade, not a gap.

Critical — 143

A definite problem that already costs you something and drags the score down: a missing authorisation check, a dependency with a known exploit, a build that does not reproduce. Failure here tends to cause failures elsewhere.

Serious — 3175

Likely wrong, but not failing yet. It degrades the codebase over a longer horizon and can cause failures elsewhere — not urgent this week, not something to carry for two years either.

Minor — 1284

Recorded, with no effect on how the codebase functions. Present so the survey is complete, not because it needs doing.

Could not be resolved — 18

Something this survey could not settle from the outside, and which could be critical or serious. Either a control was required and no positive evidence of it exists in the repository — a backup job that nothing shows was ever restored from proves nothing about restores — or our own analysis could not run over that part of the tree. This is not a clean result. These are excluded from the score rather than awarded a pass, so the number on the cover neither rewards nor penalises them: if you act on this survey without resolving them, you carry that risk yourself. Each one is named under Limitations.

Methodology & how to trust this report

Watchdog is a deep, periodic assessment — run each sprint, monthly, or quarterly, taking the time to go wider and deeper than a quick check and surfacing in one coherent report what you'd otherwise piece together from a dozen separate tools. It scores deterministically: the same commit yields the same score, every run. 64 of 67 evaluated dimensions are computed purely by tools and static analysis (confidence 1.0); 3 documentation/naming judgement(s) are LLM-assisted and labelled advisory. Overall confidence is 0.9 — the weighted average across measured dimensions; it falls as more of the score leans on LLM-assisted judgement and rises when it's fully tool-backed.

Every figure here is one of three kinds, and we label which: ✓ Measured — a deterministic fact (LoC, complexity, coverage); ~ Modeled — an estimate from a stated model (cost, effort, value-at-risk), always a range with its assumptions, never a precise fact; ◐ Advisory — an LLM prose judgement. We never present a modelled estimate as if it were measured. Perfect or absent scores carry their provenance too (ADR-0011): ✓ Tool-verified means the property itself was measured across the surface; ○ Nothing flagged means the probes came back clean — a claim bounded by what a repository can show; ⊘ Not evidenced means a working control (a tested restore, an automated rollback) showed no positive evidence — absence of evidence is not evidence of a control, so it's excluded from the score rather than awarded a spurious 10; ◐ Sampled · advisory marks an LLM verdict over a bounded sample — advisory, never a deterministic measurement.

What we checked — 67 dimensions across the health lenses
D1D2D3D4D5D6D9D10D13D15D16D17D19D20D21D26D28D29D31D34D35D36D37D44AX10AX3AX5AX6AX9IC1M1M2M3M4P1P10P2P3P4P5P6P7PF1PF2X1X12X13X14X15X16X17X18X19X20X21X22X23X24X25X26X27X28X29X3X30X4X5

Each chip is a dimension scored from real signals across architecture, testing, dependencies, security & compliance, documentation, git-history and code quality — in one coherent pass. A surface report typically covers a handful.

How to trust any code-health report — three questions
  1. Can you open the finding? Real findings cite a repo-relative file and line you can open at the cited line — never an absolute scratch path. Here, 4579 of 4602 do; the remainder are repo-wide signals — a dimension-level measurement, not a single line. (Every path in this report is repo-relative by construction: paths are normalized at the producer and the report is rejected if any rooted path leaks through.)
  2. Is there a tool behind the number? Every score below names the method that produced it — Roslyn, git, a scanner, or (for a handful of documentation/naming dimensions) an LLM labelled sampled · advisory — not a narrative.
  3. Does re-running give the same result? Run it again on the same commit and the score — and this report, byte for byte — is identical. A report whose numbers move between runs is describing the run, not the code.

This report answers yes to all three. That's the bar to hold any assessment to.

Tools & methods

The actual versions used this run (captured at analysis time) — re-run on the same commit for the identical score.

MethodBacksVersionEvaluator
Roslyn static analysisComplexity, cohesion, coupling, dead code, API surface, layering5.3.0✓ deterministic
Native secret scannerHardcoded secrets / credentials1.0.0✓ deterministic
Watchdog duplication detector (in-process)Code duplication1.0.0✓ deterministic
Coverage (coverlet / dotnet-coverage)Line & branch coverage10.0.400✓ deterministic
NuGet / dotnetOutdated, vulnerable & deprecated dependencies10.0.400✓ deterministic
git / LibGit2SharpChurn hotspots, knowledge concentration, history2.43.0 · 0.31.0✓ deterministic
gitleaks · semgrep · trivy · checkovSecrets in history, SAST, CVEs, IaC & container, PII / GDPR1.86.0 · 0.69.3 · 3.2.533✓ deterministic
LLM (sampled · advisory)Documentation quality, ADR conformance, naming — sampled over a bounded sample; advisory, never a deterministic measurementLocal LLM◐ LLM · sampled · advisory

Every finding is locatable in findings.md. Run 01a16701-55a9-7469-9071-ef4b6e87ba1f.

The exact command behind every deep-scan dimension — tool, version, invocation and retained raw output — is in Appendix B — Reproduction & audit trail.

Run transparency — what happened this run

What ran differently this time — a tool absent, degraded, or that fell back to an estimate. Named openly, not folded silently into the scores. A degraded run also records its exact cause in diagnostics.md.

  • D8 Code Coverage — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. Coverage NOT MEASURED: test source is present (.java, .py, .scala) but the built-in coverage collector has no runner for this repository's ecosystem — so this suite was never executed by it. Not scored — this is a gap in the analyzer's language coverage, not a defect in the repo. To have real coverage read, produce a coverage report in a standard format (JaCoCo XML — the Gradle `jacocoTestReport` task, or `coverage run -m pytest` then `coverage xml`, or `addSbtPlugin("org.scoverage" % "sbt-scoverage" % "<version>")` in `project/plugins.sbt`, then `sbt clean coverage test coverageReport`) and commit it — a hosted scan measures a clone of the repository, so a report that exists only in a working tree, a CI runner's or your own, never reaches it; the artefact is commonly gitignored, so `git add -f` that one file (or un-ignore its path) and commit it alongside the code it measures. You can widen what we reach: optional: produce a coverage report in a standard format (JaCoCo XML — the Gradle `jacocoTestReport` task, or `coverage run -m pytest` then `coverage xml`, or `addSbtPlugin("org.scoverage" % "sbt-scoverage" % "<version>")` in `project/plugins.sbt`, then `sbt clean coverage test coverageReport`) and commit it — a hosted scan measures a clone of the repository, so a report that exists only in a working tree, a CI runner's or your own, never reaches it; the artefact is commonly gitignored, so `git add -f` that one file (or un-ignore its path) and commit it alongside the code it measures — then the real number is read on the next scan.
  • D10 Test Quality — measured, with a gap in what it reached — Watchdog measured this, but not all of it. What it did not reach is a gap on our side — a collector, parser or image we have not built yet — so the numbers on that dimension cover less than the repository, and the part left out is not evidence that it would have passed. The 20,997 test(s) behind this row are the ones the code-model census could read, and this repository also carries at least 338 test source file(s) (.py, .scala) that it cannot: it reads the test types the .java frontend declared, so a suite in any other language is invisible to it. Skipped tests, zero-assertion tests and the other quality signals on this row are UNMEASURED in that suite — their absence from the counts above is a gap in this analyzer's language coverage, not a finding that those tests are sound.
  • D11 Test Reliability — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. Test source is present (.java, .py, .scala) and this repository declares a JVM test suite (repository root, Gradle), but it was not re-run: no test result was produced. Not scored — this is a gap in the analyzer's language coverage, not a finding about this repository.
  • D12 Dependency Hygiene — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. Not scored — 8 Maven/Gradle manifest(s) were read, stating a version for 2 dependency(ies) and leaving 16 to a parent or an imported BOM, but no build resolved the dependency graph, so the outdated signal was not established. NOT a finding that these dependencies are current or healthy.
  • D22 Internal API Consistency — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. D22 identifies the intentionally-exposed surface from `IsPackable` and `.Contracts` project names, MSBuild conventions read off the loaded project set. This target exposed no such projects, so the probe never ran; this says nothing about whether the repository has a public API. This repository commits no C#/VB source at all, so there was never an MSBuild project set to read these conventions off. That is OUR side and it is an ADMISSION gap, not an environment fault: it declares a published package (api-checker/build.gradle), but no published-package marker D22 reads admitted any project here. D22 DOES collect the public API of every language in this tree, and admits a project only when its manifest makes that ecosystem's publication act in a form the marker recognises — so what is missing is not a collector but an admission rule for the publication act this repository makes, if it makes one. The remedy is a better discriminator for that marker — not a collector, and no change to the scan image can close it. The marker's rules are measured to refuse applications, so one refused repository is the rule working as calibrated; several are the evidence that it is too strict.
  • D27 Navigability — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. Navigability is taken over call sites whose callee resolved. For C# that population includes calls into referenced assemblies; for this language only calls declared inside the repository count, so the abstention threshold reads the repository's use of its standard library as a resolution failure. That is a limit of this analyzer, not a build problem in this repository.
  • D28 Secrets (history) — measured, with a gap in what it reached — Watchdog measured this, but not all of it. What it did not reach is a gap on our side — a collector, parser or image we have not built yet — so the numbers on that dimension cover less than the repository, and the part left out is not evidence that it would have passed. D28's config-credential rule (WD-SECRET-0002) parses each committed `.json` config as a document and reads credential-named values; `gradle/LICENSE.json` did not parse (JSON5, a template, several concatenated documents), so a credential bound there is UNMEASURED by that rule. gitleaks still scanned the same files as text.
  • D30 Dependency Vulnerabilities — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. Osv: osv-scanner exited 127 with no findings — dependency CVEs were not measured. 'osv-scanner' exited 127 and produced no findings, and that exit code has no documented repo-side meaning — so this run measured nothing, and nothing here is a statement about the repository.
  • D32 Data Compliance (PII/GDPR) — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. `streams/quickstart/java/src/main/resources/archetype-resources/src/main/java/LineSplit.java`, `streams/quickstart/java/src/main/resources/archetype-resources/src/main/java/Pipe.java`, `streams/quickstart/java/src/main/resources/archetype-resources/src/main/java/WordCount.java` produced a parse error, so every rule in this engine's `gdpr.yml` was absent there. That absence is NOT a clean result: these rules detect personal data crossing a boundary into a log sink, a URL or browser storage, and a file that was never parsed cannot report any of the three. The rest of the tree analysed normally and its rows above stand; only these files are unaccounted for. You can widen what we reach: fix the syntax error (or exclude the file deliberately) and re-scan to cover it.
  • D43 Malicious Dependencies — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. Osv: osv-scanner exited 127 with no findings — dependency CVEs were not measured. 'osv-scanner' exited 127 and produced no findings, and that exit code has no documented repo-side meaning — so this run measured nothing, and nothing here is a statement about the repository.
  • AX1 Captive dependencies — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. This check reads Microsoft.Extensions.DependencyInjection registrations in C# and Spring beans in Java/Kotlin only, and this repository's container is HK2, whose lifetimes are not modelled yet, so it had nothing of this repository's product to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
  • AXR1 Runtime accessibility — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. Render strategy: boot via DockerCompose (docker/examples/docker-compose-files/cluster/combined/sasl_plaintext/docker-compose.yml). compose up failed (exit 15 — the compose project is invalid) — time="2026-10-23T04:25:58Z" level=warning msg="The \"IMAGE\" variable is not set. Defaulting to a blank string." time="2026-10-23T04:25:58Z" level=warning msg="The \"IMAGE\" variable is not set. Defaulting to a blank string." service "kafka-3" has neither an image nor a build context specified: invalid compose project; runtime evidence skipped.
  • C1 Data Protection — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. These personal data controls are read from declarative annotations, request middleware, entity/column names and guard methods in a C# source model, and none was loaded on this run, so there was nothing to gather. That is a gap in this analyzer's language reach — not a finding that the repository lacks personal data controls.
  • C2 Access Controls — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. These authorization controls are read from declarative annotations, request middleware, entity/column names and guard methods in a C# source model, and none was loaded on this run, so there was nothing to gather. That is a gap in this analyzer's language reach — not a finding that the repository lacks authorization controls.
  • C3 Audit Trail — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. These audit controls are read from declarative annotations, request middleware, entity/column names and guard methods in a C# source model, and none was loaded on this run, so there was nothing to gather. That is a gap in this analyzer's language reach — not a finding that the repository lacks audit controls.
  • C4 Data Retention — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. These retention controls are read from declarative annotations, request middleware, entity/column names and guard methods in a C# source model, and none was loaded on this run, so there was nothing to gather. That is a gap in this analyzer's language reach — not a finding that the repository lacks retention controls.
  • C5 Data-Subject Rights — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. These data-subject rights controls are read from declarative annotations, request middleware, entity/column names and guard methods in a C# source model, and none was loaded on this run, so there was nothing to gather. That is a gap in this analyzer's language reach — not a finding that the repository lacks data-subject rights controls.
  • ED5 Idempotency — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. This check decides whether a handler's mutation is safe to re-run by recognising its persistence writes (a database save, a repository write, an event publish) and its guards. Those markers are .NET member names, so in this repository's language a write such as `repository.save(order)` is not recognised and a same-named call on an unrelated library type could be. The handlers were found; their idempotency was neither confirmed nor ruled out.
  • GD1 Unfinished & placeholder code — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. This check reads C# syntax, F#, JavaScript/TypeScript, Dart, Ruby and Scala source only, and this repository's Java, Python is most of its product and is not read yet, so it had nothing of this repository's product to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
  • M4 Documentation accuracy — measured, with a gap in what it reached — Watchdog measured this, but not all of it. What it did not reach is a gap on our side — a collector, parser or image we have not built yet — so the numbers on that dimension cover less than the repository, and the part left out is not evidence that it would have passed. 68 further occurrence(s) are not listed individually; the score already reflects all 108.
  • S1 Web-Security Posture — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. These web-security controls are read from declarative annotations, request middleware, entity/column names and guard methods in a C# source model, and none was loaded on this run, so there was nothing to gather. That is a gap in this analyzer's language reach — not a finding that the repository lacks web-security controls.
  • X4 Structured logging — measured, with a gap in what it reached — Watchdog measured this, but not all of it. What it did not reach is a gap on our side — a collector, parser or image we have not built yet — so the numbers on that dimension cover less than the repository, and the part left out is not evidence that it would have passed. 31 further occurrence(s) are not listed individually; the score already reflects all 71.

Repo exclusion declarations (.gitattributes linguist-generated/vendored, .editorconfig generated_code): none declared — every source file was scored.

Limitations & what we did not check

Watchdog assesses the repository exactly as committed, and only the repository. By design it does not reach outside the source tree: the live cloud account, the running CI/CD pipeline, the host's branch-protection and approval rules, the production configuration, or a restore actually exercised against a backup are all out of scope. That boundary is a feature, not a gap — a repo-relative, deterministic scan re-runs identically on any commit and every finding opens at a real file and line, where a live audit can neither be reproduced nor traced. The visible consequence is that controls which leave no in-repo evidence are reported as "not evidenced" and excluded from the score rather than awarded a number a static scan cannot justify.

Per-dimension blind spots

For each dimension that was measured, what a static, repo-only scan structurally cannot see — the honest edge of the measurement, not a failure of it.

  • D1 Cyclomatic Complexity: Cyclomatic complexity counts branches statically — it cannot tell an essential decision tree from accidental tangle, nor see complexity that lives in data or configuration (large switch-case token tables, DSL lexers/parsers, data-as-code rule tables) rather than control flow: a tokenizer's many single-character cases read as high complexity though each branch is trivial.
  • D2 Cognitive Complexity: Cognitive-complexity heuristics approximate how hard code is to follow; genuine domain difficulty and well-named intent that eases reading are not captured.
  • D3 God Classes: "God class" is sized by members and responsibilities visible in the type — a deliberately broad facade over a coherent subsystem can read the same as an accidental grab-bag. For front-end JS the file-length check is cohesion-aware (a single-responsibility module — one class/IIFE — earns a 3× threshold), but cohesion is approximated from top-level declarations, not true dependency structure.
  • D4 Code Duplication: Duplication is token-similarity — an in-process token-stream comparison over sliding windows, with type-aware normalization — so it finds copy-paste, not semantic duplication expressed differently. Committed machine-written code (scaffolded migrations, designer/codegen output, protobuf/OpenAPI stubs, model snapshots) is EXCLUDED — its repetition is the tool's, not the team's — so the score reflects hand-written duplication only.
  • D5 Coupling: Coupling is measured between projects/assemblies — runtime coupling through DI, reflection, messaging or shared databases is invisible to a static reference graph.
  • D6 Cohesion (LCOM4): LCOM4 cohesion is syntactic — it infers connectivity from which methods touch which fields/methods by name, not from real runtime behaviour or intent.
  • D9 Test Distribution: The test-pyramid shape is inferred from project/folder naming and references, with a single test host bucketed per-file by its path tier and content signals — a suite that names tiers unconventionally and gives no per-file signal can still be mis-bucketed.
  • D10 Test Quality: Assertion density is structural — it cannot tell a meaningful behavioural assertion from a trivial one, only that an assertion is present.
  • D13 Secret Scanning: Secret detection is signature- and entropy-based on the current tree — a secret that does not match a known pattern, or one already rotated, will not be flagged (a clean scan is "nothing matched", not "no secrets exist").
  • D15 Churn × Complexity Hotspots: Churn hotspots come from git history — a freshly imported or squashed repository has no churn signal, and recent rewrites can mask a historically risky file.
  • D16 Bus Factor: Bus-factor is a time-decayed model of commit attribution (who has recently, repeatedly worked a file), not comprehension — pairing, review and reading-without-committing spread knowledge it can't see; bot commits and shared accounts still distort it.
  • D17 Explicit Debt: Acknowledged-debt signals (TODO/FIXME, suppressions, dead code) are textual — undocumented debt that nobody marked, and debt that lives in design rather than annotations, is invisible. Committed machine-written code (scaffolded migrations, designer/codegen output, generated stubs) is excluded — it is never the team's dead code to delete.
  • D19 Documentation Quality: Documentation quality is judged by an LLM over a bounded sample of docs — it reads what is written, not whether the docs match the running system, and it is advisory, not a measurement. Its critique rows are drawn from a closed category vocabulary and each row means the same thing in every run, so two scans can be compared row by row; the SET that fires is still a sample, and does not repeat exactly. Measured on one frozen input, six scans at one engine SHA: 2-5 critique rows per scan, 8 distinct rows across the six, 3 of those 8 seen in only one scan. So a D19 row is evidence about the documentation, but a COUNT of D19 rows is not a quantity — never read a change in it as an improvement or a regression.
  • D20 ADR Quality: ADR quality is an LLM read of the decision records present — it cannot know about decisions made and never recorded, and its verdict is sampled and advisory.
  • D21 Naming Consistency: Naming quality is an LLM judgement over a bounded sample — it assesses clarity/consistency of the names it sees, not domain-correctness, and is advisory.
  • D26 Project Cohesion: Project focus is sized from members/namespaces per project — a project that is broad by deliberate design reads the same as one that has sprawled.
  • D28 Secrets (history): Secret-history scanning sweeps the git log for known patterns — a secret that predates the available history, or never matched a signature, is not found (clean means "nothing matched in the history we can see").
  • D29 Static Analysis (SAST): SAST findings are pattern-based (semgrep) — it finds classes of bug it has rules for; logic flaws, auth/authorization gaps and issues needing runtime context are out of reach (and clean means "no rule matched").
  • D31 IaC & Container Security: IaC scanning checks Dockerfiles/Terraform/Kubernetes against best-practice rules — it cannot see the live cloud account, runtime configuration, or drift between the committed config and what is actually deployed.
  • D34 Knowledge Freshness: Freshness is decayed commit RECENCY, not comprehension — code read often but rarely committed reads as orphaned, and stable code that genuinely needs no changes is penalised the same as forgotten code; bot/squash commits distort it like the bus factor.
  • D35 Change Coupling: Change coupling is co-change in COMMITS — files split across separate commits, or coupled only through a shared config/build step, read as uncoupled, and a sweeping commit (rename/format) is excluded so it doesn't couple everything. It shows that files change together, not WHY: a high coupling can be a healthy cohesive pair as readily as a hidden leak.
  • D44 Platform End-of-Life: The support table is FROZEN, so it goes out of date by losing RECALL: a release that ended support after the table was written is missed until the table is refreshed, and this dimension reading 10 is not evidence that a platform is current. Only platforms the repository DECLARES in a place this pass reads are seen — a runtime named only in a REDACTED (D31's subject), in a CI workflow (D29's), or in a file this pass does not parse (go.mod, a Gemfile ruby directive) is invisible here, which is why a repository declaring none of them abstains rather than scoring. Only frameworks with a PUBLISHED support policy are tracked: React, Flask and Express publish none, so their age cannot be judged and their absence from a report is not a statement that they are supported.
  • AX10 Code composition: Role is inferred from namespace/folder convention, not semantics — a domain concept living in a folder named "Services" reads as application, and the split is lines-of-code, not business value. The business-logic-share score is a SOFT, FLOORED signal: it contributes to the Architecture lens but is floored at the Critical gate, so an infrastructure-heavy design (a gateway, an ETL, a driver) is legitimately low without being nuked to zero.
  • AX9 CQS / query purity: Handlers are found by interface/name convention — a query handler using neither is not seen. Mutation is a resolved write/publish invocation (SaveChanges/repository/bus), so a write hidden behind a hand-rolled wrapper, reflection, or a string-keyed service locator resolves to a non-persistence type and isn't flagged; it detects that a query writes state, not whether the write is a legitimate read-side cache update. Clean means "no resolved write/publish in a query body", not a proof of CQS purity.
  • M4 Documentation accuracy: Onboarding quality is an LLM read of the docs/setup present — it cannot run the onboarding or measure how long a real new joiner takes; the verdict is sampled and advisory.
  • P4 Deployment & Rollback: Approval/branch-protection rules live in repository settings the scan cannot see — only their in-repo evidence (config files, workflows) is checked, so a control enforced purely in the host's settings reads as "not evidenced".
  • P5 DR & Backup: Backup/restore and disaster-recovery readiness is judged from in-repo evidence — a config that exists is not a tested restore, so the absence of positive evidence is reported as "not evidenced", never scored as present.
  • P6 Release Hygiene: Rollback/observability controls are inferred from repo artefacts (pipelines, dashboards-as-code) — controls configured in external tooling, with no in-repo trace, cannot be credited.

The LLM boundary

LLM-set scores this run (3): D19, D21, M4 (model: Local LLM). For these, a model reads a bounded sample and sets the numeric score; each names its own sample and method on its card. They are sampled and advisory by design: they vary at the margins between runs and are never a deterministic measurement. Every other score in this report is tool-computed at confidence 1.0.

Dimensions

D1 · Cyclomatic Complexity6.5 / 10Adequate✓ Tool-verified

What it measures: How tangled the control flow is — methods with many branches are hard to test and change.

Method: Cyclomatic complexity per method (1 + decision points), computed exhaustively across production source; test projects separated by convention. Deterministic.

Maturity: Documented → Verified → Prevented · effective 6.5 / 10 · rule-coverage 100% · ceiling Prevented

134 method(s) exceeded the cyclomatic complexity threshold of 15; the worst was TransactionCoordinator.endTransaction at 65. A further 14 method(s) were over the threshold but excluded as flat dispatchers (a long switch/match over independent cases: many branches, almost no nesting), the largest being AbstractRequest.doParseRequest at 92 — they are counted neither in the figure above nor in this dimension's score. 10 files carry no cyclomatic complexity row at all for this reason — every one of their over-threshold methods was excluded, so the exclusion is disclosed nowhere in the file itself: clients/src/main/java/org/apache/kafka/common/requests/AbstractRequest.java (AbstractRequest.doParseRequest at 92), clients/src/main/java/org/apache/kafka/common/requests/AbstractResponse.java (AbstractResponse.parseResponse at 92), server/src/main/java/org/apache/kafka/network/RequestConvertToJson.java (RequestConvertToJson.request at 92), clients/src/main/java/org/apache/kafka/clients/consumer/internals/events/ApplicationEventProcessor.java (ApplicationEventProcessor.process at 37), metadata/src/main/java/org/apache/kafka/controller/QuorumController.java (QuorumController.replay at 30), and 5 more not listed here. They are named here because the per-file figures other dimensions report are taken BEFORE this exclusion, so such a file can show a high maximum complexity elsewhere in this report and nothing here, with nothing to reconcile the two.

TransactionCoordinator.endTransaction (cyclomatic 65)core/src/main/scala/kafka/coordinator/transaction/TransactionCoordinator.scala:773
TransactionCoordinator.endTransactionWithTV1 (cyclomatic 46)core/src/main/scala/kafka/coordinator/transaction/TransactionCoordinator.scala:544
GroupMetadataManager.streamsGroupHeartbeat (cyclomatic 43)group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java:2113
JsonConverter.convertToJson (cyclomatic 40)connect/json/src/main/java/org/apache/kafka/connect/json/JsonConverter.java:586
ConnectHeaders.checkSchemaMatches (cyclomatic 39)connect/api/src/main/java/org/apache/kafka/connect/header/ConnectHeaders.java:399

+ 129 more group(s) — more in Appendix A; the complete list is findings.md.

What to do

  1. Bring the 1 body over 60 down to 60 or less in Cyclomatic Complexity — start with TransactionCoordinator.endTransaction (cyclomatic 65). — Refactoring it lifts Cyclomatic Complexity from 6.5 to about 6.5/10.
  2. Enforce Cyclomatic Complexity in CI to reach Verified (currently Documented). — Hardens enforcement from Documented toward Prevented — provenance only; does not change the score.

Detailed fixes: d1_recommendation.md · top locations in Appendix A, every location in findings.md.

D2 · Cognitive Complexity5.4 / 10Adequate✓ Tool-verified

What it measures: How hard the code is for a person to follow, beyond raw branching.

Method: Cognitive complexity per method (Sonar-style nesting-penalized score), computed exhaustively over production code, excluding test projects. Deterministic.

Maturity: Documented → Verified → Prevented · effective 5.4 / 10 · rule-coverage 100% · ceiling Prevented

516 method(s) exceeded the cognitive complexity threshold of 15; the worst was TransactionCoordinator.endTransaction at 182.

ByteUtils.readUnsignedVarint (cognitive 19) · ×2clients/src/main/java/org/apache/kafka/common/utils/internals/ByteUtils.java:266
TransactionCoordinator.endTransaction (cognitive 182)core/src/main/scala/kafka/coordinator/transaction/TransactionCoordinator.scala:773
TransactionCoordinator.endTransactionWithTV1 (cognitive 123)core/src/main/scala/kafka/coordinator/transaction/TransactionCoordinator.scala:544
ConnectHeaders.checkSchemaMatches (cognitive 83)connect/api/src/main/java/org/apache/kafka/connect/header/ConnectHeaders.java:399
Selector.pollSelectionKeys (cognitive 82)clients/src/main/java/org/apache/kafka/common/network/Selector.java:514

+ 510 more group(s) — more in Appendix A; the complete list is findings.md.

What to do

  1. Bring the 2 bodies over 120 down to 120 or less in Cognitive Complexity — start with TransactionCoordinator.endTransaction (cognitive 182), TransactionCoordinator.endTransactionWithTV1 (cognitive 123). — This score is capped by its worst body, so a finding fixed alone moves it by almost nothing — the next one down takes its place. Refactoring these 2 together lifts Cognitive Complexity from 5.4 to about 5.8/10, projected with the scoring formula itself and assuming each lands exactly at 120; a cleaner split scores higher.
  2. Enforce Cognitive Complexity in CI to reach Verified (currently Documented). — Hardens enforcement from Documented toward Prevented — provenance only; does not change the score.

Detailed fixes: d2_recommendation.md · top locations in Appendix A, every location in findings.md.

D3 · God Classes8.3 / 10Strong✓ Tool-verified

What it measures: Over-large classes that try to do too much ("god classes").

Method: God-class detection by line and method-count thresholds per logical type (partial classes unified), filtered for generated code and registration/contract false positives. Deterministic.

Maturity: Documented → Verified → Prevented · effective 8.3 / 10 · rule-coverage 100% · ceiling Prevented

465 god class(es) detected.

TooManyMethods: RocksDBGenericOptionsToDbOptionsColumnFamilyOptionsAdapter · ×153streams/src/main/java/org/apache/kafka/streams/state/internals/RocksDBGenericOptionsToDbOptionsColumnFamilyOptionsAdapter.java:65
ClassTooLong: GroupMetadataManager · ×133group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java:278
FileTooLong: group/GroupMetadataManager.java · ×122group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java
MethodTooLong: GroupCoordinatorMetrics.<init> · ×57group-coordinator/src/main/java/org/apache/kafka/coordinator/group/metrics/GroupCoordinatorMetrics.java:173

What to do

  1. Resolve the 153 TooManyMethods finding(s) in God Classes — start with ConsumerSubscriptionState.java (2), QuorumController.java (2), LogContext.java (2). — One of this dimension's main actionable groups (153 warning-level).
  2. Resolve the 133 ClassTooLong finding(s) in God Classes — start with GroupMetadataManager.java, KafkaAdminClient.java, KafkaRaftClient.java. — One of this dimension's main actionable groups (133 warning-level).
  3. Resolve the 122 FileTooLong finding(s) in God Classes — start with GroupMetadataManager.java, KafkaAdminClient.java, KafkaApis.scala. — One of this dimension's main actionable groups (122 warning-level).
  4. Enforce God Classes in CI to reach Verified (currently Documented). — Hardens enforcement from Documented toward Prevented — provenance only; does not change the score.

Detailed fixes: d3_recommendation.md · top locations in Appendix A, every location in findings.md.

D4 · Code Duplication9.4 / 10Stronggated by 844 serious findings✓ Tool-verified

What it measures: Copy-pasted code that should be shared instead.

Method: Code duplication via token-stream sliding windows with type-aware normalization (locals masked, type names preserved), density-scored per KLoC of production code. Deterministic.

Maturity: Documented → Verified → Prevented · effective 9.4 / 10 · rule-coverage 100% · ceiling Verified

796 duplicated block group(s) detected. A further 48 rows report members as variants of one another; they aggregate block groups already counted above and are not themselves counted. 11 of the 844 are in trees this repository does not ship — vendored, example/demo, fixture and benchmark code — and are ranked below the shipped groups rather than excluded from them: the duplication there is real and is still counted in this dimension's score. The dimensions that publish a production-file census leave those trees out of theirs, so this count is deliberately drawn over the wider population.

Duplicated block (5 lines × 2) · ×66clients/src/main/java/org/apache/kafka/clients/FetchSessionHandler.java:451
Duplicated block (7 lines × 2) · ×57clients/src/main/java/org/apache/kafka/clients/admin/internals/DescribeClassicGroupsHandler.java:91
Duplicated block (6 lines × 2) · ×57clients/src/main/java/org/apache/kafka/clients/producer/internals/TransactionManager.java:1832
Duplicated block (8 lines × 2) · ×55clients/src/main/java/org/apache/kafka/clients/admin/internals/DeleteConsumerGroupOffsetsHandler.java:115
Duplicated block (9 lines × 2) · ×53clients/src/main/java/org/apache/kafka/clients/admin/AlterConsumerGroupOffsetsResult.java:45

+ 174 more group(s) — more in Appendix A; the complete list is findings.md.

What to do

  1. Resolve the 66 Duplicated block (5 lines × 2) finding(s) in Code Duplication — start with KafkaAdminClient.java (2), AsyncKafkaConsumer.java (2), ConsumerPerformance.java (2). — One of this dimension's main actionable groups (66 warning-level).
  2. Resolve the 57 Duplicated block (7 lines × 2) finding(s) in Code Duplication — start with KafkaApis.scala (3), InMemorySessionStore.java (2), Murmur3.java (2). — One of this dimension's main actionable groups (57 warning-level).
  3. Resolve the 57 Duplicated block (6 lines × 2) finding(s) in Code Duplication — start with RemoteLogSegmentMetadataSnapshotTransform.java (2), KTableFilter.java (2), KafkaConsumerMetrics.java (2). — One of this dimension's main actionable groups (57 warning-level).
  4. Enforce Code Duplication in CI to reach Verified (currently Documented). — Hardens enforcement from Documented toward Verified — provenance only; does not change the score.

Detailed fixes: d4_recommendation.md · top locations in Appendix A, every location in findings.md.

D5 · Coupling9.0 / 10Stronggated by 1 serious finding✓ Tool-verified

What it measures: Whether volatile projects sit underneath others that depend on them (so their churn ripples upward), and whether project dependencies form cycles. A widely-depended-on but stable shared/kernel project is healthy, not penalised.

Method: Dependency cycles via elementary-DFS over real .csproj references, plus Martin instability (afferent/efferent) per project. Exhaustive over the reference graph, deterministic.

Coverage: Exhaustive · type-level: afferent/efferent coupling + cycles computed over every production type — the population is all types, not a name convention.

Maturity: Documented → Verified → Prevented · effective 9.0 / 10 · rule-coverage 100% · ceiling Prevented

8 production modules (Gradle+Maven+Python), 0 dependency cycle(s), 0 unstable depended-on module(s). Read from the build's own module declarations; edges a convention plugin adds from buildSrc or build-logic are not visible there; 1 module(s) off the main sequence, with abstractness counted on 5 of the 8 (the rest declare no modelled class or interface, export only macros, declare types in source no model reads, or have no source directory of their own).

Off the main sequence: kafka-api-checker:core

What to do

  1. Resolve the 1 Off the main sequence finding(s) in Coupling. — One of this dimension's main actionable groups (1 warning-level).
  2. Enforce Coupling in CI to reach Verified (currently Documented). — Hardens enforcement from Documented toward Prevented — provenance only; does not change the score.

Detailed fixes: d5_recommendation.md · top locations in Appendix A, every location in findings.md.

D6 · Cohesion (LCOM4)9.9 / 10Stronggated by 16 serious findings✓ Tool-verified

What it measures: Whether a class's methods are focused on a single responsibility.

Method: LCOM4 cohesion per production class with at least two methods: connected components of methods sharing state or calls, computed syntactically. Deterministic, not a proxy.

Coverage: Exhaustive · type-level: LCOM4 cohesion computed over every production class — the population is all types, not a name convention.

Maturity: Documented → Verified → Prevented · effective 9.9 / 10 · rule-coverage 100% · ceiling Verified

16 of 1873 classes have LCOM4 above 3.

Low cohesion: ShareConsumerTestBase (LCOM4 9) · ×16clients/clients-integration-tests/src/test/java/org/apache/kafka/clients/consumer/ShareConsumerTestBase.java:89

What to do

  1. Resolve the 16 Low cohesion finding(s) in Cohesion (LCOM4) — start with ShareConsumerTestBase.java, PapiDslIntegrationTest.java, BaseRepartitionNode.java. — One of this dimension's main actionable groups (16 warning-level).
  2. Enforce Cohesion (LCOM4) in CI to reach Verified (currently Documented). — Hardens enforcement from Documented toward Verified — provenance only; does not change the score.

Detailed fixes: d6_recommendation.md · top locations in Appendix A, every location in findings.md.

D9 · Test Distribution10.0 / 10Exemplary✓ Tool-verified

What it measures: Whether the test suite has a healthy mix of unit / integration / end-to-end tests.

Method: Test projects classified (Unit/Integration/BDD/E2E) from compiled metadata; test methods counted exhaustively across projects with placement-agnostic disk fallback. Deterministic.

Maturity: Documented → Verified → Prevented · effective 10.0 / 10 · rule-coverage 100% · ceiling Documented

22775 test methods: 22530 unit, 240 integration, 0 BDD, 5 e2e. The Python suite contributes 193 test function(s) across 69 file(s) declaring at least one — every `def test…` in a file pytest or unittest would collect, which is those frameworks' own definition of a case; a parametrize table counts once, so this is a floor. Its tier split is read from file names and paths only. The Scala suite contributes 1585 test case(s) across 99 file(s) in a test source set declaring at least one — every `test("…")`, `it("…")`, `property("…")` and `"…" in {…}` registration and every JUnit `@Test`, which is how munit, ScalaTest, utest, ZIO Test and specs2 declare a case; a case registered under a computed name is not counted, so this is a floor. Its tier split is INFERRED from paths and file names, except sbt's src/it source set, which the build declares.

✓ On the Gold path — maintain.

Detailed fixes: d9_recommendation.md.

D10 · Test Quality9.3 / 10Adequategated by 4 critical findings✓ Tool-verified

What it measures: Whether the tests truly assert behaviour rather than just running the code.

Method: Per-test assertions, skips, and mock references analyzed via Roslyn; structured skip-reason tags (BUG:/ENV:) separate documented deferrals from debt. Deterministic.

Maturity: Documented → Verified → Prevented · effective 9.3 / 10 · rule-coverage 100% · ceiling Prevented

9 skipped (9 with a documented reason), 997 zero-assertion, no mocking-framework packages referenced (hand-written doubles or no mocking) across 20997 tests. Measured on the .java suite only — at least 338 test source file(s) (.py, .scala) went unread, so its test quality is unmeasured and is not in these counts.

No assertions (empty test): canConsume · ×4connect/api/src/test/java/org/apache/kafka/connect/data/ValuesTest.java:1043
No assertions: testCoalescedFulfillment · ×993clients/src/test/java/org/apache/kafka/clients/admin/internals/AdminApiDriverTest.java:89
Skipped (documented): testDsaKeyPair · ×9clients/src/test/java/org/apache/kafka/common/network/SslTransportLayerTest.java:486

What to do

  1. Resolve the 4 No assertions (empty test) finding(s) in Test Quality — start with ValuesTest.java, DistributedHerderTest.java, CustomStickyTaskAssignorTest.java. — One of this dimension's main actionable groups (4 issue-level).
  2. Resolve the 993 No assertions finding(s) in Test Quality — start with PCollectionsImmutableNavigableSetTest.java (38), SaslAuthenticatorTest.java (35), SslTransportLayerTest.java (33). — One of this dimension's main actionable groups (993 warning-level).
  3. Enforce Test Quality in CI to reach Verified (currently Documented). — Hardens enforcement from Documented toward Prevented — provenance only; does not change the score.

Detailed fixes: d10_recommendation.md · top locations in Appendix A, every location in findings.md.

D13 · Secret Scanning5.0 / 10Adequate✓ Tool-verified

What it measures: Whether any secrets (keys, tokens, passwords) have leaked into the code.

Method: In-process native secret scanner (entropy plus signature patterns) across all tracked files; no external tool. A clean result is a measured 10, not no-data zero. Deterministic.

Maturity: Documented → Verified → Prevented · effective 5.0 / 10 · rule-coverage 100% · ceiling Prevented

1 secret(s) detected.

REDACTED

What to do

  1. Resolve the 1 Leaked secret finding(s) in Secret Scanning — start with REDACTED. — One of this dimension's main actionable groups (1 issue-level).
  2. Enforce Secret Scanning in CI to reach Verified (currently Documented). — Hardens enforcement from Documented toward Prevented — provenance only; does not change the score.

Detailed fixes: d13_recommendation.md · top locations in Appendix A, every location in findings.md.

D15 · Churn × Complexity Hotspots9.9 / 10Stronggated by 8 serious findings✓ Tool-verified

What it measures: Files that change often and are also complex — the riskiest hotspots.

Method: Per production file churn times cyclomatic complexity over a rolling window, computed from git and Roslyn/JS/Razor analysis. Exhaustive, deterministic per commit date.

Maturity: Documented → Verified → Prevented · effective 9.9 / 10 · rule-coverage 100% · ceiling Documented

Top hotspots: group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java (21×43=903); core/src/main/scala/kafka/server/KafkaConfig.scala (8×22=176); streams/src/main/java/org/apache/kafka/streams/processor/internals/StoreChangelogReader.java (9×16=144)

Hotspot: group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java · ×8group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java:2113

What to do

  1. Resolve the 8 Hotspot finding(s) in Churn × Complexity Hotspots — start with GroupMetadataManager.java, KafkaConfig.scala, StoreChangelogReader.java. — One of this dimension's main actionable groups (8 warning-level).

Detailed fixes: d15_recommendation.md · top locations in Appendix A, every location in findings.md.

D16 · Bus Factor9.6 / 10Exemplary✓ Tool-verified

What it measures: Whether knowledge is concentrated in too few people (the "bus factor").

Method: Living knowledge per author via time-decayed commit attribution (6-month half-life, focus weighting) across largest source files. Deterministic, avoids blame's mechanical-refactor false positives.

Maturity: Documented → Verified → Prevented · effective 9.6 / 10 · rule-coverage 100% · ceiling Documented

99 source file(s) have their living knowledge concentrated in one author (≥90% of recent, decayed contribution). The largest is server/src/main/java/org/apache/kafka/server/share/dlq/ShareGroupDLQStateManager.java. Counted over 2463 of the 3884 production source files in this repository: 1383 are under the ~2,400-byte size floor this dimension measures over, and the remaining 38 have no attributable history left to measure.

Off-boarding risk: anonymized user #1 · ×9
Further sole-owners (lower concentration)

✓ On the Gold path — maintain.

Detailed fixes: d16_recommendation.md · top locations in Appendix A, every location in findings.md.

D17 · Explicit Debt9.9 / 10Stronggated by 143 serious findings✓ Tool-verified

What it measures: Acknowledged debt left in the code — TODOs, dead code, suppressed warnings.

Method: Roslyn syntactic debt markers (suppressions/TODO/FIXME/HACK/empty-catch/commented-code/Obsolete) plus SymbolFinder dead-code analysis; weighted-debt-per-KLoC density deducted 2.0x per unit. Deterministic, exhaustive.

Maturity: Documented → Verified → Prevented · effective 9.9 / 10 · rule-coverage 100% · ceiling Prevented

164 deducted task-comment markers across 633107 LoC (0.0/KLoC) → score 9.9. Task comments only: this repository's language is read without a compiler, so D17's suppression, dead-code and commented-out-code arms did not run and this score counts fewer marker kinds than a .NET repository's would.

TodoComment · ×135clients/clients-integration-tests/src/test/java/org/apache/kafka/clients/consumer/PlaintextConsumerCommitTest.java:583
FixmeComment · ×5connect/runtime/src/main/java/org/apache/kafka/connect/runtime/WorkerSinkTask.java:181
HackComment · ×2connect/runtime/src/test/java/org/apache/kafka/connect/integration/StandaloneWorkerIntegrationTest.java:330
TodoComment repeated across 22 filesstreams/src/testFixtures/java/org/apache/kafka/streams/tests/SmokeTestDriver.java:112

What to do

  1. Resolve the 135 TodoComment finding(s) in Explicit Debt — start with KafkaConsumerTest.java (11), StreamsBuilderTest.java (6), RestServer.java (4). — One of this dimension's main actionable groups (135 warning-level).
  2. Resolve the 5 FixmeComment finding(s) in Explicit Debt — start with WorkerSinkTask.java, DistributedHerder.java, DistributedHerderTest.java. — One of this dimension's main actionable groups (5 warning-level).
  3. Resolve the 2 HackComment finding(s) in Explicit Debt — start with StandaloneWorkerIntegrationTest.java, ExactlyOnceSourceIntegrationTest.java. — One of this dimension's main actionable groups (2 warning-level).
  4. Enforce Explicit Debt in CI to reach Verified (currently Documented). — Hardens enforcement from Documented toward Prevented — provenance only; does not change the score.

Detailed fixes: d17_recommendation.md · top locations in Appendix A, every location in findings.md.

D19 · Documentation QualityStrong◐ Sampled · advisory

What it measures: Whether the project's documentation is clear, complete, and useful.

Method: Judged by language model at low temperature (0.0-0.1) on a deterministic doc sample (READMEs plus first 25 architecture docs), with two-pass stability filtering. Advisory, sampled.

Maturity: Documented → Verified → Prevented · effective Strong / 10 · rule-coverage 100% · ceiling Documented

The repository's root README and its subdirectories are all well written: the top-level README gives an overview of Apache Kafka (its purpose, Java requirements, build/test commands), while each directory README documents itself rather than the repository. The architecture/design docs (112) cover topics like API-checker plugins, committer tools, Docker builds, and JMH benchmarks in detail; none are clipped. All visible documents are clear and complete. The repository's READMEs are well written: trogdor/README.md documents a test framework with a clear quickstart (Kafka cluster setup, Trogdor agent and coordinator commands), vagrant/README.md explains Vagrant steps for setting up a Kafka build, .github/workflows/README.md covers GitHub Actions workflow configuration, docker/examples/README.md provides Docker compose usage examples, and the native image README walks through GraalVM-native-image metadata. The internal-focused jargon is absent from all visible documents (no ticket ids or metrics), so no internal-focused finding applies. All visible documents are complete per their outlines. This is a comprehensive reference documentation set for Kafka covering configuration (admin, broker, and provider references), the core API list, an internal-api-checker tool, and architecture topics. The READMEs are well-structured with titles, descriptions, licensing, and weight metadata; each document in the set has a visible outline (e.g., 'Producer API', 'Admin API') and is clipped only at the scanner boundary, so unshown sections cannot be flagged as missing.

What to do

  1. Improve Documentation Quality — currently 8.8/10. — The repository's root README and its subdirectories are all well written: the top-level README gives an overview of Apache Kafka (its purpose, Java requirements, build/test commands), while each directory README documents itself rather than the repository. The architecture/design docs (112) cover topics like API-checker plugins, committer tools, Docker builds, and JMH benchmarks in detail; none are clipped. All visible documents are clear and complete. The repository's READMEs are well written: trogdor/README.md documents a test framework with a clear quickstart (Kafka cluster setup, Trogdor agent and coordinator commands), vagrant/README.md explains Vagrant steps for setting up a Kafka build, .github/workflows/README.md covers GitHub Actions workflow configuration, docker/examples/README.md provides Docker compose usage examples, and the native image README walks through GraalVM-native-image metadata. The internal-focused jargon is absent from all visible documents (no ticket ids or metrics), so no internal-focused finding applies. All visible documents are complete per their outlines. This is a comprehensive reference documentation set for Kafka covering configuration (admin, broker, and provider references), the core API list, an internal-api-checker tool, and architecture topics. The READMEs are well-structured with titles, descriptions, licensing, and weight metadata; each document in the set has a visible outline (e.g., 'Producer API', 'Admin API') and is clipped only at the scanner boundary, so unshown sections cannot be flagged as missing.

Detailed fixes: d19_recommendation.md.

D20 · ADR Quality0.0 / 10Critical✓ Tool-verified

What it measures: Whether architecture decisions are recorded well (context, decision, consequences).

Method: Per-ADR judgment by language model at low temperature with two-pass stability; confidence is share of ADRs evaluated; enforcement-field presence detected deterministically. Advisory.

Maturity: Documented → Verified → Prevented · effective 0.0 / 10 · rule-coverage 100% · ceiling Documented

No architecture decision records were found.

No ADRs found

What to do

  1. Resolve the 1 No ADRs found finding(s) in ADR Quality. — One of this dimension's main actionable groups (1 recommendation-level).

Detailed fixes: d20_recommendation.md · top locations in Appendix A, every location in findings.md.

D21 · Naming ConsistencyExemplary◐ Sampled · advisory

What it measures: Whether names — types, methods, variables — are clear and consistent.

Method: Judged by language model at low temperature (0.0-0.1) on a deterministic random symbol sample (fixed size, not exhaustive), with disclosed confidence band. Advisory, sampled.

Maturity: Documented → Verified → Prevented · effective Exemplary / 10 · rule-coverage 100% · ceiling Verified

0 naming inconsistencies across 0 sampled symbols.

✓ On the Gold path — maintain.

Detailed fixes: d21_recommendation.md.

D26 · Project Cohesion7.5 / 10Strong✓ Tool-verified

What it measures: Whether each project is a focused, coherent unit rather than an oversized grab-bag.

Method: Project size overshoot penalties (LoC / public-type count / namespace count, 2-of-3 flag) weighted by log magnitude. Exhaustive across projects, deterministic, LLM-independent.

Maturity: Documented → Verified → Prevented · effective 7.5 / 10 · rule-coverage 100% · ceiling Documented

1 of 8 build units (Gradle, Maven, Python) flagged as possibly oversized/incoherent.

Projects may be oversized for their cohesion

What to do

  1. Resolve the 1 Projects may be oversized for their cohesion finding(s) in Project Cohesion. — One of this dimension's main actionable groups (1 recommendation-level).

Detailed fixes: d26_recommendation.md · top locations in Appendix A, every location in findings.md.

D28 · Secrets (history)2.0 / 10Critical✓ Tool-verified

What it measures: Whether any secrets were ever committed — scanned across the full git history, not just now.

Method: Secret scan via TWO gitleaks detect passes in an isolated checkout — the full git history, then a second --no-git pass over the working tree as it stands — merged and de-duplicated by (rule, file, line); each match flagged High. Both invocations are recorded in the audit trail. Exhaustive; when the tool is absent, or when its output cannot be parsed into the expected shape, the dimension is WITHHELD as an explicit measurement gap on our side — unscored and excluded from the lens, never a hedged middling score.

Maturity: Documented → Verified → Prevented · effective 2.0 / 10 · rule-coverage 100% · ceiling Documented

8 finding(s): 0 critical, 8 high, 0 medium, 0 low. Remediation for historically-committed secrets is credential rotation — they remain in history regardless of later deletion.

REDACTED
REDACTED

What to do

  1. Resolve the 8 High secret finding(s) in Secrets (history) — start with REDACTED (8). — One of this dimension's main actionable groups (8 issue-level).
  2. Resolve the 1 Rotate the exposed credentials finding(s) in Secrets (history). — One of this dimension's main actionable groups (1 recommendation-level).

Detailed fixes: d28_recommendation.md · top locations in Appendix A, every location in findings.md.

D29 · Static Analysis (SAST)0.2 / 10Critical✓ Tool-verified

What it measures: Real static-analysis (SAST) findings — likely security bugs in the code, any language.

Method: Polyglot static analysis via semgrep across the repo using the pinned, image-baked p/security-audit + p/owasp-top-ten rulesets (no scan-time registry fetch); severity rules (ERROR/WARNING/INFO) map to a full-band severity-weighted score. Exhaustive, deterministic; degrades on parse failure.

Coverage: semgrep pattern rules over all files — exhaustive for the rule set, blind to classes of bug without a rule (clean = no rule matched).

Maturity: Documented → Verified → Prevented · effective 0.2 / 10 · rule-coverage 100% · ceiling Documented

73 finding(s): 0 critical, 71 high, 1 medium, 1 low. 49 unpinned-GitHub-Actions row(s) are reported here but scored by D36 (supply-chain provenance), which measures that posture as `pinned_actions` — one pinning decision is charged once, not once per lens. semgrep hit a parse error in 6 file(s) — `bin/kafka-run-class.sh` (line 112), `gradle/LICENSE.json`, `gradlew` (line 74, line 178), `streams/quickstart/java/src/main/resources/archetype-resources/src/main/java/LineSplit.java` (line 17), `streams/quickstart/java/src/main/resources/archetype-resources/src/main/java/Pipe.java` (line 17), … (+1 more) — so no absence of findings in the named regions is evidence of anything; rows reported elsewhere in those files are real. Fix the syntax error (or exclude the file deliberately) and re-scan to cover them. Separately, one or more rules could not re-parse an embedded snippet in 2 file(s) (e.g. a workflow `run:` block read as shell). Those files WERE scanned and their other rows are unaffected; only those rules' view of those snippets is missing.

REDACTED
REDACTED
REDACTED
REDACTED
REDACTED

+ 4 more group(s) — more in Appendix A; the complete list is findings.md.

What to do

  1. Resolve the 8 REDACTED finding(s) in Static Analysis (SAST) — start with REDACTED (5), REDACTED (3). — One of this dimension's main actionable groups (8 issue-level).
  2. Resolve the 3 REDACTED finding(s) charged to Static Analysis (SAST) — the other 49 are reported here at file:line but scored by D36 (supply-chain provenance), which charges them once. — One of this dimension's main actionable groups (52 issue-level, 3 of them charged here).
  3. Resolve the 4 REDACTED finding(s) in Static Analysis (SAST) — start with REDACTED, REDACTED, REDACTED. — One of this dimension's main actionable groups (4 issue-level).

Detailed fixes: d29_recommendation.md · top locations in Appendix A, every location in findings.md.

D31 · IaC & Container Security7.0 / 10Adequate✓ Tool-verified

What it measures: Whether Dockerfiles / Terraform / Kubernetes config follow security best practices.

Method: IaC/container misconfiguration scan via trivy config (REDACTED/Terraform/K8s/Helm/CloudFormation); severity rules to 0-10 moderate normalizer. NotApplicable without manifests. Exhaustive, deterministic.

Maturity: Documented → Verified → Prevented · effective 7.0 / 10 · rule-coverage 100% · ceiling Documented

16 finding(s): 0 critical, 7 high, 6 medium, 3 low.

REDACTED
REDACTED
REDACTED

What to do

  1. Resolve the 7 High IaC finding(s) in IaC & Container Security — start with REDACTED (7). — One of this dimension's main actionable groups (7 issue-level).
  2. Resolve the 6 Medium IaC finding(s) in IaC & Container Security — start with REDACTED (6). — One of this dimension's main actionable groups (6 warning-level).
  3. Resolve the 3 Low IaC finding(s) in IaC & Container Security — start with REDACTED (3). — One of this dimension's main actionable groups (3 recommendation-level).

Detailed fixes: d31_recommendation.md · top locations in Appendix A, every location in findings.md.

D34 · Knowledge Freshness5.6 / 10Adequate✓ Tool-verified

What it measures: Whether anyone still has living knowledge of each file, or it has been orphaned — last understood long ago by someone now gone quiet. The sibling of the bus factor: D16 asks who owns it, D34 asks whether anyone still knows it.

Method: File orphaning as total living-knowledge decay below one focused-commit's worth within a year, computed per-file from the D16 decay model. Exhaustive, deterministic over fixed history.

Maturity: Documented → Verified → Prevented · effective 5.6 / 10 · rule-coverage 100% · ceiling Documented

1137 of 2501 significant source file(s) are orphaned — their living knowledge has decayed to nothing, so no one currently understands them. The largest is clients/src/main/java/org/apache/kafka/clients/consumer/internals/AbstractStickyAssignor.java. Counted over 2501 of the 3884 production source files in this repository: the rest are under the ~2,400-byte size floor this dimension measures over.

Orphaned knowledge · ×50clients/src/main/java/org/apache/kafka/clients/consumer/internals/AbstractStickyAssignor.java:1
Orphaned file · ×1087metadata/src/main/java/org/apache/kafka/controller/BrokerHeartbeatManager.java:1
Further orphaned files (smaller)

What to do

  1. Resolve the 1087 Orphaned file finding(s) in Knowledge Freshness — start with ProcessingContext.java (2), Headers.java (2), Struct.java (2). — One of this dimension's main actionable groups (1087 recommendation-level).
  2. Resolve the 50 Orphaned knowledge finding(s) in Knowledge Freshness — start with MockProcessorContext.java (2), AbstractStickyAssignor.java, Values.java. — One of this dimension's main actionable groups (50 issue-level).
  3. Resolve the 1 Further orphaned files (smaller) finding(s) in Knowledge Freshness. — One of this dimension's main actionable groups (1 recommendation-level).

Detailed fixes: d34_recommendation.md · top locations in Appendix A, every location in findings.md.

D35 · Change Coupling9.9 / 10Adequategated by 1 critical finding✓ Tool-verified

What it measures: Whether files that change together actually belong together — pairs that repeatedly co-change in git history despite having no explicit code dependency, surfacing the hidden/logical coupling (and boundaries in the wrong place) a static scan can't see.

Method: Pairwise co-occurrence over the per-commit file sets in git history (production source only — tests and generated dropped): Degree-of-Coupling = shared ÷ min individual revisions, reported above noise floors (each file ≥10 revisions, ≥5 shared commits, ≥50% strength); sweeping commits excluded. Deterministic over fixed history.

Coverage: Population: PRODUCTION source files only — test and generated files are dropped before pairing, so a class co-changing with its own test (trivially ~100%) can't drown the real production↔production coupling. Pairs ranked by Degree-of-Coupling. A non-source file is never a coupling PARTICIPANT either: documentation, schemas, config and data files are dropped with the rest, so a code↔docs pair — a command and the reference page that restates it — is not reported however strongly the two co-change; nor is coupling that runs THROUGH a build step or config file.

Maturity: Documented → Verified → Prevented · effective 9.9 / 10 · rule-coverage 100% · ceiling Documented

Strongest change-coupling: ActiveTaskCreator.java↔StandbyTaskCreator.java 94%; ReplicaFetcherThreadBenchmark.java↔PartitionMakeFollowerBenchmark.java 87%; PartitionMakeFollowerBenchmark.java↔UpdateFollowerFetchStateBenchmark.java 83%

Boundary-crossing change coupling: ApiKeys.java ↔ RequestConvertToJson.javaclients/src/main/java/org/apache/kafka/common/protocol/ApiKeys.java:1
Change coupling: ActiveTaskCreator.java ↔ StandbyTaskCreator.java · ×12streams/src/main/java/org/apache/kafka/streams/processor/internals/ActiveTaskCreator.java:1
Change-coupling hub: ReplicaFetcherThreadBenchmark.java → PartitionMakeFollowerBenchmark.java, UpdateFollowerFetchStateBenchmark.java, PartitionCreationBench.javajmh-benchmarks/src/main/java/org/apache/kafka/jmh/fetcher/ReplicaFetcherThreadBenchmark.java

What to do

  1. Resolve the 1 Boundary-crossing change coupling finding(s) in Change Coupling — start with ApiKeys.java. — One of this dimension's main actionable groups (1 issue-level).
  2. Resolve the 12 Change coupling finding(s) in Change Coupling — start with PartitionMakeFollowerBenchmark.java (2), KafkaApis.scala (2), ActiveTaskCreator.java. — One of this dimension's main actionable groups (12 warning-level).
  3. Resolve the 1 Change-coupling hub finding(s) in Change Coupling — start with ReplicaFetcherThreadBenchmark.java. — One of this dimension's main actionable groups (1 warning-level).

Detailed fixes: d35_recommendation.md · top locations in Appendix A, every location in findings.md.

D36 · Supply-chain Provenance & Signing2.5 / 10Weak✓ Tool-verified

What it measures: Whether the build pipeline provides supply-chain integrity — generated provenance/attestation, signed artifacts (cosign/sigstore), an SBOM, and pinned build actions. Presence of the configuration, not a runtime guarantee.

Method: Supply-chain provenance/signing read deterministically from CI/build config (.github/workflows, .gitlab-ci.yml, azure-pipelines, Jenkinsfile, .circleci) + the release surface: four signals — generated provenance/attestation (SLSA/in-toto/actions-attest), artifact signing (cosign/sigstore/gitsign), an SBOM (syft/sbom-action/*.spdx.json/*.cdx.json), and SHA-pinned build actions — scored 10·present/denom. NotApplicable without a build pipeline. Detects configuration presence, not runtime enforcement.

Maturity: Documented → Verified → Prevented · effective 2.5 / 10 · rule-coverage 100% · ceiling Documented

1/4 supply-chain integrity signals present (provenance, signing, SBOM, pinned actions).

REDACTED
REDACTED
REDACTED
REDACTED
REDACTED

+ 4 more group(s) — more in Appendix A; the complete list is findings.md.

What to do

  1. Resolve the 1 REDACTED finding(s) in Supply-chain Provenance & Signing — start with REDACTED. — One of this dimension's main actionable groups (1 issue-level).
  2. Resolve the 5 REDACTED finding(s) in Supply-chain Provenance & Signing — start with REDACTED, REDACTED, REDACTED. — One of this dimension's main actionable groups (5 warning-level).
  3. Resolve the 4 REDACTED finding(s) in Supply-chain Provenance & Signing — start with REDACTED, REDACTED, REDACTED. — One of this dimension's main actionable groups (4 warning-level).

Detailed fixes: d36_recommendation.md · top locations in Appendix A, every location in findings.md.

D37 · Vulnerability-disclosure Policy10.0 / 10Exemplary✓ Tool-verified

What it measures: Whether the repository publishes a coordinated-vulnerability-disclosure policy (SECURITY.md or security.txt) with a reporting contact, so finders know how to report a vulnerability. Presence of a policy file with a contact, not whether the policy is adequate or honoured.

Method: Vulnerability-disclosure policy read deterministically from the repo: a SECURITY.md (root/.github/docs) or .well-known/security.txt / security.txt, regex-checked for a reporting contact (email / URL / mailto). Present + contact → 10; present without a contact → 4; NotApplicable when no policy file exists (it may live off-repo). Detects the policy file's presence + contact, not its adequacy.

Maturity: Documented → Verified → Prevented · effective 10.0 / 10 · rule-coverage 100% · ceiling Documented

A vulnerability-disclosure policy (SECURITY.md) is published with a reporting contact.

✓ On the Gold path — maintain.

Detailed fixes: d37_recommendation.md.

D44 · Platform End-of-Life10.0 / 10Exemplary✓ Tool-verified

What it measures: Whether anyone still ships security patches for the platform this repository RUNS ON — the runtime it pins and the framework majors its own constraints hold it to. Separate from D12 because the question differs: a current Django on an end-of-life Python is perfectly up to date and completely unsupported, and the fix is a migration rather than a version bump. What the repository says it merely SUPPORTS is never charged.

Method: End-of-life PLATFORM read from the repository's own declarations and graded against a FROZEN, dated table of vendor support dates — no network, no feed, no API, so this dimension answers identically inside a closed scan fence. Two subjects: a RUNTIME the project pins (a single or all-end-of-life TargetFramework, a .nvmrc or .python-version, a requires-python CAP) and a FRAMEWORK major a dependency constraint cannot move off (a caret, tilde or exact version; `vue@^2.7.16` pins Vue 2). A FLOOR is deliberately never charged — `requires-python = ">=3.8"` states what a package SUPPORTS, not what it runs on — and a multi-target project is charged only when EVERY target is out of support. Runtime 4.0/product capped 8.0, framework 1.5 capped 4.5. The table is safe to freeze because a statement about support that ended in the past cannot become false: it loses recall as it ages, never precision, and a test asserts every entry predates the freeze date. Disjoint from D31 (a container image's OS layer) and D29 (the toolchain a CI workflow installs). Abstains when the repository declares no platform this pass reads — never scores it clean.

Maturity: Documented → Verified → Prevented · effective 10.0 / 10 · rule-coverage 100% · ceiling Documented

0 end-of-life runtime(s) and 0 end-of-life framework(s), read from 1 platform declaration(s) and 15 dependency declaration(s). This dimension reads what the repository says about ITSELF — a pinned target framework, a version file, a capped requires-python, a Rust toolchain pin, a framework major a constraint cannot move off. A FLOOR is deliberately never charged: `requires-python = ">=3.8"` states what the package SUPPORTS, not what it runs on, and a well-maintained library declares exactly that while running its own CI on a current release. The end-of-life facts are FROZEN and dated, so this dimension needs no network and answers identically inside a closed scan fence; as the table ages it loses recall and never precision, because a statement about support that ended in the past cannot become false. The OS layer of a container image is D31's question and the toolchain a CI workflow installs is D29's; this row is neither.

✓ On the Gold path — maintain.

Detailed fixes: d44_recommendation.md.

Frontend & cross-cutting dimensions

R = React/JS · M = Maturity · P = Readiness.

AX10 · Code composition7.0 / 10Adequate✓ Tool-verified

Other · Architecture — How the codebase splits by code ROLE — domain, application, infrastructure, test, generated. The significance map behind the knowledge/coupling weighting, and a DDD signal in its own right: a thin domain core under fat infrastructure is the anemic-domain smell, quantified. How each file's role is decided, because the split is only as good as that: a generated name or a build-output tree makes it Generated, a test project makes it Test, and otherwise the file's NAMESPACE and PATH words are matched against fixed vocabularies in a fixed ORDER — domain, then infrastructure, then application — so a file whose words hit two layers is counted under the earlier one. A production file matching none of them counts as application, so that share reads 'application or unclassified' rather than a measured application layer. Roles come from naming convention, never from what the code does. On this repository the split was taken from the source tree on disk rather than from a loaded .NET workspace, so a file's role is decided by its PATH segments alone — no declared namespace was available to add to the evidence — and generated output is excluded from the census entirely rather than counted as a generated share.

Method: Roslyn line-count by code ROLE: every source file classified Domain/Application/Infrastructure/Test/Generated by namespace + path convention (the shared CodeRoleClassifier), then significant lines summed per role. Deterministic; the advisory score is the business-logic (domain+application) share of production code.

Coverage: Population: ALL source files, each bucketed into ONE of five roles (Domain/Application/Infrastructure/Test/Generated) by namespace + path convention — a file whose layer isn't named in the convention falls to Application (the neutral default), and the split is line-count, not semantic depth or business value.

What to do

  • The domain core is a small share of production code, but most of the rest matched no layer vocabulary at all — so this is not yet an anemic-domain finding. The namespace/path convention could not place that code, which makes the composition above a statement about the naming, not about the design. Name the layers (or check that the repository's conventions differ from the ones this check knows) before reading a thin domain into it.
AX3 · Project dependency cycles10.0 / 10Exemplary✓ Tool-verified

Other · Architecture — Whether the project-reference graph is acyclic (cycles block independent build/deploy and signal eroding boundaries).

Method: Project reference cycles via elementary-DFS over real .csproj references, using the engine shared with D5/D7; cyclic versus acyclic. Exhaustive, deterministic.

AX5 · Architecture & structure10.0 / 10Exemplary✓ Tool-verified

Other · Architecture — Whether the codebase has a recognisable, scale-appropriate structure (a named architectural style, or modular enough for its size) rather than being an ad-hoc ball of mud.

Method: Roslyn plus csproj analysis: architecture style detection (DDD, clean, vertical-slice, CQRS) and structure fitness for repo size. Deterministic.

AX6 · Interface segregation9.8 / 10Exemplary✓ Tool-verified

Other · Architecture — Whether interfaces stay focused rather than fat — the Interface-Segregation principle (SOLID 'I').

Method: Roslyn scan: public interface declared-member counts (accessors fold into their property/event); fat-interface threshold (over 15 declared members) flagged per type. Each finding also reports the distinct-OPERATION count — members counted by name, so an overload group counts once — which decides whether it states the caller-side ISP harm or the implementer-side burden of an overload set. TypeScript: exported interfaces that declare behaviour, counted over their REQUIRED operations (method signatures and function-typed properties with no `?`, once per signature) — data-shape interfaces and ambient .d.ts declarations are outside the population; JavaScript declares no interfaces and is not applicable. Deterministic, type-level.

  • `Admin` declares 66 abstract methods: `abortTransaction`, `addRaftVoter`, `alterClientQuotas`, `alterConsumerGroupOffsets`, `alterPartitionReassignments`, `alterReplicaLogDirs`, `alterShareGroupOffsets`, `alterStreamsGroupOffsets`, `alterUserScramCredentials`, `clientInstanceId`, `close`, `createAcls`, `createDelegationToken`, `createPartitions`, `createTopics`, `deleteAcls`, `deleteConsumerGroupOffsets`, `deleteConsumerGroups`, `deleteRecords`, `deleteShareGroupOffsets`, `deleteShareGroups`, `deleteStreamsGroupOffsets`, `deleteStreamsGroups`, `deleteTopics`, `describeAcls`, `describeClassicGroups`, `describeClientQuotas`, `describeCluster`, `describeConfigs`, `describeConsumerGroups`, `describeDelegationToken`, `describeFeatures`, `describeLogDirs`, `describeMetadataQuorum`, `describeProducers`, `describeReplicaLogDirs`, `describeShareGroups`, `describeStreamsGroups`, `describeTopics`, `describeTransactions`, and 26 more. Counted over its ABSTRACT methods, once per signature; `default`, `static` and `private` methods and constants are not counted, because no implementer is forced to write them. A wide interface forces every implementer and caller to depend on methods they don't use (the Interface-Segregation 'I' in SOLID). Split it into focused role-interfaces. — clients/src/main/java/org/apache/kafka/clients/admin/Admin.java:127
  • `Consumer<K, V>` declares 52 abstract methods: `assign`, `assignment`, `beginningOffsets`, `beginningOffsets`, `clientInstanceId`, `close`, `close`, `close`, `commitAsync`, `commitAsync`, `commitAsync`, `commitSync`, `commitSync`, `commitSync`, `commitSync`, `committed`, `committed`, `currentLag`, `endOffsets`, `endOffsets`, `enforceRebalance`, `enforceRebalance`, `groupMetadata`, `listTopics`, `listTopics`, `metrics`, `offsetsForTimes`, `offsetsForTimes`, `partitionsFor`, `partitionsFor`, `pause`, `paused`, `poll`, `position`, `position`, `registerMetricForSubscription`, `resume`, `seek`, `seek`, `seekToBeginning`, and 12 more. Counted over its ABSTRACT methods, once per signature; `default`, `static` and `private` methods and constants are not counted, because no implementer is forced to write them. Those 52 declarations carry 31 distinct name(s), so part of the width is overloading rather than separate responsibilities — but 31 operations clears the >15 bar on its own, so the row is about responsibilities, not signatures. A wide interface forces every implementer and caller to depend on methods they don't use (the Interface-Segregation 'I' in SOLID). Split it into focused role-interfaces. — clients/src/main/java/org/apache/kafka/clients/consumer/Consumer.java:41
  • `RebalanceConsumer` declares 32 abstract methods: `assignment`, `beginningOffsets`, `beginningOffsets`, `clientInstanceId`, `commitAsync`, `commitAsync`, `commitAsync`, `commitSync`, `commitSync`, `commitSync`, `commitSync`, `committed`, `committed`, `currentLag`, `endOffsets`, `endOffsets`, `groupMetadata`, `listTopics`, `listTopics`, `offsetsForTimes`, `offsetsForTimes`, `partitionsFor`, `partitionsFor`, `pause`, `paused`, `position`, `position`, `resume`, `seek`, `seek`, `seekToBeginning`, `seekToEnd`. Counted over its ABSTRACT methods, once per signature; `default`, `static` and `private` methods and constants are not counted, because no implementer is forced to write them. Those 32 declarations carry 19 distinct name(s), so part of the width is overloading rather than separate responsibilities — but 19 operations clears the >15 bar on its own, so the row is about responsibilities, not signatures. A wide interface forces every implementer and caller to depend on methods they don't use (the Interface-Segregation 'I' in SOLID). Split it into focused role-interfaces. — clients/src/main/java/org/apache/kafka/clients/consumer/RebalanceConsumer.java:84
  • `ShareConsumer<K, V>` declares 19 abstract methods under just 15 distinct name(s): `acknowledge`, `acknowledge`, `acknowledge`, `acquisitionLockTimeoutMs`, `clientInstanceId`, `close`, `close`, `commitAsync`, `commitSync`, `commitSync`, `metrics`, `poll`, `registerMetricForSubscription`, `setAcknowledgementCommitCallback`, `subscribe`, `subscription`, `unregisterMetricFromSubscription`, `unsubscribe`, `wakeup`. Counted over its ABSTRACT methods, once per signature; `default`, `static` and `private` methods and constants are not counted, because no implementer is forced to write them. That is an OVERLOAD SET, not 19 separate responsibilities: a caller binds to 15 operation(s) and uses the overload it selected, so the Interface-Segregation harm does NOT apply on the caller's side and splitting this into role-interfaces would scatter one operation without relieving anything. The burden that does remain is the IMPLEMENTER's — all 19 signatures must be written and kept in step. Reduce it by collapsing overloads (optional or default parameters, or an options object) rather than by segregating the interface. — clients/src/main/java/org/apache/kafka/clients/consumer/ShareConsumer.java:41
  • `Producer<K, V>` declares 17 abstract methods under just 15 distinct name(s): `abortTransaction`, `beginTransaction`, `clientInstanceId`, `close`, `close`, `commitTransaction`, `completeTransaction`, `flush`, `initTransactions`, `metrics`, `partitionsFor`, `prepareTransaction`, `registerMetricForSubscription`, `send`, `send`, `sendOffsetsToTransaction`, `unregisterMetricFromSubscription`. Counted over its ABSTRACT methods, once per signature; `default`, `static` and `private` methods and constants are not counted, because no implementer is forced to write them. That is an OVERLOAD SET, not 17 separate responsibilities: a caller binds to 15 operation(s) and uses the overload it selected, so the Interface-Segregation harm does NOT apply on the caller's side and splitting this into role-interfaces would scatter one operation without relieving anything. The burden that does remain is the IMPLEMENTER's — all 17 signatures must be written and kept in step. Reduce it by collapsing overloads (optional or default parameters, or an options object) rather than by segregating the interface. — clients/src/main/java/org/apache/kafka/clients/producer/Producer.java:42
  • `KafkaClient` declares 21 abstract methods: `active`, `authenticationException`, `close`, `connectionDelay`, `connectionFailed`, `disconnect`, `hasInFlightRequests`, `hasInFlightRequests`, `hasReadyNodes`, `inFlightRequestCount`, `inFlightRequestCount`, `initiateClose`, `isReady`, `leastLoadedNode`, `newClientRequest`, `newClientRequest`, `poll`, `pollDelayMs`, `ready`, `send`, `wakeup`. Counted over its ABSTRACT methods, once per signature; `default`, `static` and `private` methods and constants are not counted, because no implementer is forced to write them. Those 21 declarations carry 18 distinct name(s), so part of the width is overloading rather than separate responsibilities — but 18 operations clears the >15 bar on its own, so the row is about responsibilities, not signatures. A wide interface forces every implementer and caller to depend on methods they don't use (the Interface-Segregation 'I' in SOLID). Split it into focused role-interfaces. — clients/src/main/java/org/apache/kafka/clients/KafkaClient.java:29
  • `ClusterInstance` declares 22 abstract methods: `bootstrapControllers`, `bootstrapServers`, `brokers`, `clientListener`, `clusterId`, `config`, `controllerIds`, `controllerListenerName`, `controllers`, `firstFatalException`, `firstNonFatalException`, `restartBroker`, `restartBrokersWithSwappedClientListenerPorts`, `setClientSslConfig`, `shutdownBroker`, `start`, `startBroker`, `started`, `stop`, `stopped`, `type`, `waitForReadyBrokers`. Counted over its ABSTRACT methods, once per signature; `default`, `static` and `private` methods and constants are not counted, because no implementer is forced to write them. A wide interface forces every implementer and caller to depend on methods they don't use (the Interface-Segregation 'I' in SOLID). Split it into focused role-interfaces. — test-common/test-common-runtime/src/main/java/org/apache/kafka/common/test/ClusterInstance.java:72
  • `Headers` declares 30 abstract methods: `add`, `add`, `add`, `addBoolean`, `addByte`, `addBytes`, `addDate`, `addDecimal`, `addDouble`, `addFloat`, `addInt`, `addList`, `addLong`, `addMap`, `addShort`, `addString`, `addStruct`, `addTime`, `addTimestamp`, `allWithName`, `apply`, `apply`, `clear`, `duplicate`, `isEmpty`, `lastWithName`, `remove`, `retainLatest`, `retainLatest`, `size`. Counted over its ABSTRACT methods, once per signature; `default`, `static` and `private` methods and constants are not counted, because no implementer is forced to write them. Those 30 declarations carry 26 distinct name(s), so part of the width is overloading rather than separate responsibilities — but 26 operations clears the >15 bar on its own, so the row is about responsibilities, not signatures. A wide interface forces every implementer and caller to depend on methods they don't use (the Interface-Segregation 'I' in SOLID). Split it into focused role-interfaces. — connect/api/src/main/java/org/apache/kafka/connect/header/Headers.java:34
  • `StatusBackingStore` declares 16 abstract methods under just 12 distinct name(s): `configure`, `connectors`, `deleteTopic`, `flush`, `get`, `get`, `getAll`, `getAllTopics`, `getTopic`, `put`, `put`, `put`, `putSafe`, `putSafe`, `start`, `stop`. Counted over its ABSTRACT methods, once per signature; `default`, `static` and `private` methods and constants are not counted, because no implementer is forced to write them. That is an OVERLOAD SET, not 16 separate responsibilities: a caller binds to 12 operation(s) and uses the overload it selected, so the Interface-Segregation harm does NOT apply on the caller's side and splitting this into role-interfaces would scatter one operation without relieving anything. The burden that does remain is the IMPLEMENTER's — all 16 signatures must be written and kept in step. Reduce it by collapsing overloads (optional or default parameters, or an options object) rather than by segregating the interface. — connect/runtime/src/main/java/org/apache/kafka/connect/storage/StatusBackingStore.java:31
  • `Herder` declares 42 abstract methods: `allLoggerLevels`, `alterConnectorOffsets`, `connectMetrics`, `connectorActiveTopics`, `connectorConfig`, `connectorInfo`, `connectorInfo`, `connectorOffsets`, `connectorPluginConfig`, `connectorPluginConfig`, `connectorStatus`, `connectors`, `connectors`, `deleteConnectorConfig`, `fenceZombieSourceTasks`, `healthCheck`, `isReady`, `kafkaClusterId`, `loggerLevel`, `patchConnectorConfig`, `pauseConnector`, `plugins`, `putConnectorConfig`, `putConnectorConfig`, `putTaskConfigs`, `requestTaskReconfiguration`, `resetConnectorActiveTopics`, `resetConnectorOffsets`, `restartConnector`, `restartConnector`, `restartConnectorAndTasks`, `restartTask`, `resumeConnector`, `setClusterLoggerLevel`, `setWorkerLoggerLevel`, `start`, `statusBackingStore`, `stop`, `stopConnector`, `taskConfigs`, and 2 more. Counted over its ABSTRACT methods, once per signature; `default`, `static` and `private` methods and constants are not counted, because no implementer is forced to write them. Those 42 declarations carry 37 distinct name(s), so part of the width is overloading rather than separate responsibilities — but 37 operations clears the >15 bar on its own, so the row is about responsibilities, not signatures. A wide interface forces every implementer and caller to depend on methods they don't use (the Interface-Segregation 'I' in SOLID). Split it into focused role-interfaces. — connect/runtime/src/main/java/org/apache/kafka/connect/runtime/Herder.java:62
  • `Group` declares 17 abstract methods: `asListedGroup`, `createGroupTombstoneRecords`, `groupId`, `hasMember`, `isEmpty`, `isInStates`, `isSubscribedToTopic`, `numMembers`, `offsetExpirationCondition`, `requestMetadataRefresh`, `stateAsString`, `stateAsString`, `type`, `validateDeleteGroup`, `validateOffsetCommit`, `validateOffsetDelete`, `validateOffsetFetch`. Counted over its ABSTRACT methods, once per signature; `default`, `static` and `private` methods and constants are not counted, because no implementer is forced to write them. Those 17 declarations carry 16 distinct name(s), so part of the width is overloading rather than separate responsibilities — but 16 operations clears the >15 bar on its own, so the row is about responsibilities, not signatures. A wide interface forces every implementer and caller to depend on methods they don't use (the Interface-Segregation 'I' in SOLID). Split it into focused role-interfaces. — group-coordinator/src/main/java/org/apache/kafka/coordinator/group/Group.java:36
  • `GroupCoordinator` declares 32 abstract methods: `alterShareGroupOffsets`, `commitOffsets`, `commitTransactionalOffsets`, `completeTransaction`, `consumerGroupDescribe`, `consumerGroupHeartbeat`, `deleteGroups`, `deleteOffsets`, `deleteShareGroupOffsets`, `describeGroups`, `describeShareGroupAllOffsets`, `describeShareGroupOffsets`, `fetchOffsets`, `groupConfig`, `groupMetadataTopicConfigs`, `heartbeat`, `joinGroup`, `leaveGroup`, `listGroups`, `onElection`, `onMetadataUpdate`, `onResignation`, `partitionFor`, `shareGroupDescribe`, `shareGroupHeartbeat`, `shutdown`, `startup`, `streamsGroupDescribe`, `streamsGroupHeartbeat`, `streamsGroupTopologyDescriptionUpdate`, `syncGroup`, `updateGroupConfig`. Counted over its ABSTRACT methods, once per signature; `default`, `static` and `private` methods and constants are not counted, because no implementer is forced to write them. A wide interface forces every implementer and caller to depend on methods they don't use (the Interface-Segregation 'I' in SOLID). Split it into focused role-interfaces. — group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupCoordinator.java:74
  • `Controller` declares 31 abstract methods: `allocateProducerIds`, `alterClientQuotas`, `alterPartition`, `alterPartitionReassignments`, `alterUserScramCredentials`, `assignReplicasToDirs`, `beginShutdown`, `close`, `createDelegationToken`, `createPartitions`, `createTopics`, `curClaimEpoch`, `deleteTopics`, `describeConfigs`, `electLeaders`, `expireDelegationToken`, `finalizedFeatures`, `findAllTopicIds`, `findTopicIds`, `findTopicNames`, `incrementalAlterConfigs`, `legacyAlterConfigs`, `listPartitionReassignments`, `processBrokerHeartbeat`, `registerBroker`, `registerController`, `renewDelegationToken`, `unregisterBroker`, `unregisterController`, `updateFeatures`, `waitForReadyBrokers`. Counted over its ABSTRACT methods, once per signature; `default`, `static` and `private` methods and constants are not counted, because no implementer is forced to write them. A wide interface forces every implementer and caller to depend on methods they don't use (the Interface-Segregation 'I' in SOLID). Split it into focused role-interfaces. — metadata/src/main/java/org/apache/kafka/controller/Controller.java:67
  • `MetadataCache` declares 25 abstract methods: `contains`, `contains`, `describeClientQuotas`, `describeScramCredentials`, `describeTopicResponse`, `features`, `getAliveBrokerEpoch`, `getAliveBrokerNode`, `getAliveBrokerNodes`, `getAllTopics`, `getBrokerNodes`, `getLeaderAndIsr`, `getPartitionLeaderEndpoint`, `getPartitionReplicaEndpoints`, `getRandomAliveBrokerId`, `getTopicId`, `getTopicMetadata`, `getTopicName`, `hasAliveBroker`, `isBrokerFenced`, `isBrokerShuttingDown`, `metadataVersion`, `numPartitions`, `topicIdsToNames`, `topicNamesToIds`. Counted over its ABSTRACT methods, once per signature; `default`, `static` and `private` methods and constants are not counted, because no implementer is forced to write them. Those 25 declarations carry 24 distinct name(s), so part of the width is overloading rather than separate responsibilities — but 24 operations clears the >15 bar on its own, so the row is about responsibilities, not signatures. A wide interface forces every implementer and caller to depend on methods they don't use (the Interface-Segregation 'I' in SOLID). Split it into focused role-interfaces. — metadata/src/main/java/org/apache/kafka/metadata/MetadataCache.java:50
  • `RaftClient<T>` declares 16 abstract methods: `createSnapshot`, `highWatermark`, `kraftVersion`, `latestSnapshotId`, `latestVoterSet`, `leaderAndEpoch`, `logEndOffset`, `nodeId`, `prepareAppend`, `register`, `resign`, `schedulePreparedAppend`, `shutdown`, `unregister`, `upgradeKRaftVersion`, `voterNode`. Counted over its ABSTRACT methods, once per signature; `default`, `static` and `private` methods and constants are not counted, because no implementer is forced to write them. A wide interface forces every implementer and caller to depend on methods they don't use (the Interface-Segregation 'I' in SOLID). Split it into focused role-interfaces. — raft/src/main/java/org/apache/kafka/raft/RaftClient.java:35
  • `RaftLog` declares 24 abstract methods: `appendAsFollower`, `appendAsLeader`, `createNewSnapshot`, `createNewSnapshotUnchecked`, `deleteBeforeSnapshot`, `earliestSnapshotId`, `endOffset`, `endOffsetForEpoch`, `flush`, `highWatermark`, `initializeLeaderEpoch`, `lastFetchedEpoch`, `latestSnapshot`, `latestSnapshotId`, `maybeClean`, `onSnapshotFrozen`, `read`, `readSnapshot`, `startOffset`, `topicId`, `topicPartition`, `truncateTo`, `truncateToLatestSnapshot`, `updateHighWatermark`. Counted over its ABSTRACT methods, once per signature; `default`, `static` and `private` methods and constants are not counted, because no implementer is forced to write them. A wide interface forces every implementer and caller to depend on methods they don't use (the Interface-Segregation 'I' in SOLID). Split it into focused role-interfaces. — raft/src/main/java/org/apache/kafka/raft/RaftLog.java:28
  • `TaskManager` declares 16 abstract methods: `add`, `assignNextTask`, `awaitProcessableTasks`, `drainUncaughtExceptions`, `getTasks`, `hasUncaughtException`, `lockAllTasks`, `lockTasks`, `remove`, `setUncaughtException`, `shutdown`, `signalTaskExecutors`, `startTaskExecutors`, `unassignTask`, `unlockAllTasks`, `unlockTasks`. Counted over its ABSTRACT methods, once per signature; `default`, `static` and `private` methods and constants are not counted, because no implementer is forced to write them. A wide interface forces every implementer and caller to depend on methods they don't use (the Interface-Segregation 'I' in SOLID). Split it into focused role-interfaces. — streams/src/main/java/org/apache/kafka/streams/processor/internals/tasks/TaskManager.java:30
  • `InternalProcessorContext<KOut, VOut>` declares 19 abstract methods: `addProcessorMetadataKeyValue`, `cache`, `changelogFor`, `currentNode`, `initialize`, `logChange`, `metrics`, `processorMetadata`, `processorMetadataForKey`, `recordContext`, `registerCacheFlushListener`, `setCurrentNode`, `setProcessorMetadata`, `setRecordContext`, `setSystemTimeMs`, `taskType`, `transitionToActive`, `transitionToStandby`, `uninitialize`. Counted over its ABSTRACT methods, once per signature; `default`, `static` and `private` methods and constants are not counted, because no implementer is forced to write them. A wide interface forces every implementer and caller to depend on methods they don't use (the Interface-Segregation 'I' in SOLID). Split it into focused role-interfaces. — streams/src/main/java/org/apache/kafka/streams/processor/internals/InternalProcessorContext.java:39
  • `StateUpdater` declares 16 abstract methods: `add`, `drainExceptionsAndFailedTasks`, `drainQueuedTasks`, `drainRestoredActiveTasks`, `fatalException`, `hasExceptionsAndFailedTasks`, `remove`, `restoreConsumerInstanceId`, `restoresActiveTasks`, `shutdown`, `signalResume`, `standbyTasks`, `start`, `taskEndOffsetSumSnapshot`, `tasks`, `updatingTasks`. Counted over its ABSTRACT methods, once per signature; `default`, `static` and `private` methods and constants are not counted, because no implementer is forced to write them. A wide interface forces every implementer and caller to depend on methods they don't use (the Interface-Segregation 'I' in SOLID). Split it into focused role-interfaces. — streams/src/main/java/org/apache/kafka/streams/processor/internals/StateUpdater.java:33
  • `Task` declares 31 abstract methods: `addRecords`, `changelogOffsets`, `changelogPartitions`, `clearTaskTimeout`, `closeClean`, `closeDirty`, `commitNeeded`, `committedOffsets`, `completeRestoration`, `highWaterMark`, `id`, `initializeIfNeeded`, `inputPartitions`, `isActive`, `markChangelogAsCorrupted`, `maybeCheckpoint`, `maybeInitTaskTimeoutOrThrow`, `postCommit`, `prepareCommit`, `prepareRecycle`, `recordRestoration`, `resume`, `resumePollingForPartitionsWithAvailableSpace`, `revive`, `state`, `stateManager`, `store`, `suspend`, `timeCurrentIdlingStarted`, `updateInputPartitions`, `updateLags`. Counted over its ABSTRACT methods, once per signature; `default`, `static` and `private` methods and constants are not counted, because no implementer is forced to write them. A wide interface forces every implementer and caller to depend on methods they don't use (the Interface-Segregation 'I' in SOLID). Split it into focused role-interfaces. — streams/src/main/java/org/apache/kafka/streams/processor/internals/Task.java:37
  • `TasksRegistry` declares 35 abstract methods: `activeInitializedTaskIds`, `activeInitializedTasks`, `activeInitializedTasksForInputPartition`, `addActiveTask`, `addActiveTasks`, `addFailedTask`, `addPendingActiveTasksToCreate`, `addPendingStandbyTasksToCreate`, `addPendingTasksToClose`, `addPendingTasksToInit`, `addStandbyTask`, `addStandbyTasks`, `addTask`, `allInitializedTaskIds`, `allInitializedTasks`, `allInitializedTasksPerId`, `allNonFailedInitializedTasks`, `clear`, `clearPendingTasksToCreate`, `containsInitialized`, `drainPendingActiveTasksForTopologies`, `drainPendingActiveTasksToInit`, `drainPendingStandbyTasksForTopologies`, `drainPendingStandbyTasksToInit`, `drainPendingTasksToInit`, `hasPendingTasksToClose`, `hasPendingTasksToInit`, `initializedTask`, `initializedTasks`, `pendingTasksToClose`, `pendingTasksToInit`, `removeTask`, `replaceStandbyWithActive`, `standbyInitializedTasks`, `updateActiveTaskInputPartitions`. Counted over its ABSTRACT methods, once per signature; `default`, `static` and `private` methods and constants are not counted, because no implementer is forced to write them. A wide interface forces every implementer and caller to depend on methods they don't use (the Interface-Segregation 'I' in SOLID). Split it into focused role-interfaces. — streams/src/main/java/org/apache/kafka/streams/processor/internals/TasksRegistry.java:26
  • `ProcessorContext` declares 22 abstract methods: `appConfigs`, `appConfigsWithPrefix`, `applicationId`, `commit`, `currentStreamTimeMs`, `currentSystemTimeMs`, `forward`, `forward`, `getStateStore`, `headers`, `keySerde`, `metrics`, `offset`, `partition`, `register`, `schedule`, `schedule`, `stateDir`, `taskId`, `timestamp`, `topic`, `valueSerde`. Counted over its ABSTRACT methods, once per signature; `default`, `static` and `private` methods and constants are not counted, because no implementer is forced to write them. Those 22 declarations carry 20 distinct name(s), so part of the width is overloading rather than separate responsibilities — but 20 operations clears the >15 bar on its own, so the row is about responsibilities, not signatures. A wide interface forces every implementer and caller to depend on methods they don't use (the Interface-Segregation 'I' in SOLID). Split it into focused role-interfaces. — streams/src/main/java/org/apache/kafka/streams/processor/ProcessorContext.java:52
  • `KStream<K, V>` declares 77 abstract methods: `filter`, `filter`, `filterNot`, `filterNot`, `flatMap`, `flatMap`, `flatMapValues`, `flatMapValues`, `flatMapValues`, `flatMapValues`, `foreach`, `foreach`, `groupBy`, `groupBy`, `groupByKey`, `groupByKey`, `join`, `join`, `join`, `join`, `join`, `join`, `join`, `join`, `join`, `join`, `join`, `join`, `join`, `join`, `leftJoin`, `leftJoin`, `leftJoin`, `leftJoin`, `leftJoin`, `leftJoin`, `leftJoin`, `leftJoin`, `leftJoin`, `leftJoin`, and 37 more. Counted over its ABSTRACT methods, once per signature; `default`, `static` and `private` methods and constants are not counted, because no implementer is forced to write them. Those 77 declarations carry 22 distinct name(s), so part of the width is overloading rather than separate responsibilities — but 22 operations clears the >15 bar on its own, so the row is about responsibilities, not signatures. A wide interface forces every implementer and caller to depend on methods they don't use (the Interface-Segregation 'I' in SOLID). Split it into focused role-interfaces. — streams/src/main/java/org/apache/kafka/streams/kstream/KStream.java:63
  • `KTable<K, V>` declares 56 abstract methods under just 11 distinct name(s): `filter`, `filter`, `filter`, `filter`, `filterNot`, `filterNot`, `filterNot`, `filterNot`, `groupBy`, `groupBy`, `join`, `join`, `join`, `join`, `join`, `join`, `join`, `join`, `join`, `join`, `join`, `join`, `leftJoin`, `leftJoin`, `leftJoin`, `leftJoin`, `leftJoin`, `leftJoin`, `leftJoin`, `leftJoin`, `leftJoin`, `leftJoin`, `leftJoin`, `leftJoin`, `mapValues`, `mapValues`, `mapValues`, `mapValues`, `mapValues`, `mapValues`, and 16 more. Counted over its ABSTRACT methods, once per signature; `default`, `static` and `private` methods and constants are not counted, because no implementer is forced to write them. That is an OVERLOAD SET, not 56 separate responsibilities: a caller binds to 11 operation(s) and uses the overload it selected, so the Interface-Segregation harm does NOT apply on the caller's side and splitting this into role-interfaces would scatter one operation without relieving anything. The burden that does remain is the IMPLEMENTER's — all 56 signatures must be written and kept in step. Reduce it by collapsing overloads (optional or default parameters, or an options object) rather than by segregating the interface. — streams/src/main/java/org/apache/kafka/streams/kstream/KTable.java:91
  • `RecordBatch` declares 25 abstract methods: `baseOffset`, `baseSequence`, `checksum`, `compressionType`, `countOrNull`, `deleteHorizonMs`, `ensureValid`, `hasProducerId`, `isCompressed`, `isControlBatch`, `isTransactional`, `isValid`, `lastOffset`, `lastSequence`, `magic`, `maxTimestamp`, `nextOffset`, `partitionLeaderEpoch`, `producerEpoch`, `producerId`, `sizeInBytes`, `streamingIterator`, `streamingIterator`, `timestampType`, `writeTo`. Counted over its ABSTRACT methods, once per signature; `default`, `static` and `private` methods and constants are not counted, because no implementer is forced to write them. Those 25 declarations carry 24 distinct name(s), so part of the width is overloading rather than separate responsibilities — but 24 operations clears the >15 bar on its own, so the row is about responsibilities, not signatures. A wide interface forces every implementer and caller to depend on methods they don't use (the Interface-Segregation 'I' in SOLID). Split it into focused role-interfaces. — clients/src/main/java/org/apache/kafka/common/record/internal/RecordBatch.java:34
  • `KafkaBroker` declares 27 abstract members: `authorizerPlugin`, `brokerState`, `clusterId`, `config`, `dataPlaneRequestHandlerPool`, `dataPlaneRequestProcessor`, `kafkaScheduler`, `kafkaYammerMetrics`, `logDirFailureChannel`, `logManager`, `remoteLogManagerOpt`, `metrics`, `quotaManagers`, `replicaManager`, `socketServer`, `metadataCache`, `groupCoordinator`, `boundPort`, `startup`, `awaitShutdown`, `shutdown`, `isShutdown`, `brokerTopicStats`, `credentialProvider`, `clientToControllerChannelManager`, `tokenCache`, `lifecycleManager`. Counted over its ABSTRACT members — a `def` with no body or a `val`/`var` with no initializer, once per signature; concrete members, private and protected members, and members of a companion `object` are not counted, because no implementer is forced to write them. A wide interface forces every implementer and caller to depend on methods they don't use (the Interface-Segregation 'I' in SOLID). Split it into focused role-interfaces. — core/src/main/scala/kafka/server/KafkaBroker.scala:77

What to do

  • Split fat interfaces into focused role-interfaces so clients depend only on what they use.
  • Where the width is an overload set rather than separate responsibilities, collapse the overloads instead — segregating those relieves no caller.
AX9 · CQS / query purity10.0 / 10Exemplary✓ Tool-verified

Other · Architecture — Whether read (query) handlers stay side-effect-free — a query that writes persistent state or raises events breaks CQS and makes reads unsafe to retry, cache, or route to a read replica.

Method: Roslyn scan: CQRS handlers classified query-vs-command by interface (IQueryHandler/ICommandHandler/IRequestHandler<TQuery,TResult>) and name convention (*Query/Get*/Find* vs *Command); each query handler's body checked for persistent-state writes (SaveChanges/repository Add-Update) or event publishes by resolved invocation. Deterministic, type-level, exhaustive over the detected handlers.

Coverage: Population: CQRS handlers identified by IQueryHandler/ICommandHandler/IRequestHandler interface + *Query/Get*/Find*/*Command NAME convention; query purity then checked exhaustively within that set — a query handler using neither convention is invisible, and mutation is a resolved persistence/publish CALL, not full dataflow.

IC1 · Incompleteness & stubs10.0 / 10Exemplary○ Nothing flagged

Other · Code Health — Unfinished work detected by code SHAPE, not keywords, in this repository's Java: methods that only throw a "not implemented" exception, methods that take inputs and return a constant or do nothing, dead `if (false)` branches, and skeleton classes most of whose methods are holes.

Method: Roslyn syntax scan: incompleteness by code shape (constant-returning methods, async-never-await, #if false branches, guards that return what the code already falls through to, tests an earlier guard already decided, comparisons against NaN, skeleton types), not keyword-gated. Deterministic, code-shape heuristic.

  • `defaultLevel`'s body only throws NotSupportedException — sometimes a deliberate contract, often an unfinished stub. Confirm it's intentional. — clients/src/main/java/org/apache/kafka/common/record/internal/CompressionType.java:176
  • `maxLevel`'s body only throws NotSupportedException — sometimes a deliberate contract, often an unfinished stub. Confirm it's intentional. — clients/src/main/java/org/apache/kafka/common/record/internal/CompressionType.java:180
  • `minLevel`'s body only throws NotSupportedException — sometimes a deliberate contract, often an unfinished stub. Confirm it's intentional. — clients/src/main/java/org/apache/kafka/common/record/internal/CompressionType.java:184
  • `levelValidator`'s body only throws NotSupportedException — sometimes a deliberate contract, often an unfinished stub. Confirm it's intentional. — clients/src/main/java/org/apache/kafka/common/record/internal/CompressionType.java:188
  • A test is skipped/ignored — coverage that looks present but never runs. Re-enable it or delete it so the green run means something. (×9) — clients/src/test/java/org/apache/kafka/common/utils/internals/ByteUtilsTest.java:346, clients/src/test/java/org/apache/kafka/common/utils/internals/ByteUtilsTest.java:430, group-coordinator/src/test/java/org/apache/kafka/coordinator/group/GroupCoordinatorShardCompactionReplayTest.java:333, …

What to do

  • Clear the softer debt: re-enable or delete @Disabled/@Ignore tests, decide whether each empty method or UnsupportedOperationException is deliberate (and say so in a comment), and replace @SuppressWarnings("all") with targeted, justified suppressions.
M1 · Documentation (README)7.6 / 10Strong✓ Tool-verified

Maturity · Maturity — Whether the repo and its projects have a README, and whether it's substantive and current.

Method: Filesystem scan: README presence, word count, and headings for depth; git history for staleness. Exhaustive across root and project dirs, deterministic.

What to do

  • Add an 'Architecture' / 'How it works' section to the root README — the high-level shape.
  • Add a README to the 6 of 7 project(s) that lack one — worth up to 1.7 pts.
M2 · Architecture documentation5.0 / 10Adequate✓ Tool-verified

Maturity · Maturity — Whether key decisions (ADRs) and the high-level shape (C4/diagrams) are written down.

Method: Filesystem scan: ADR folder/naming conventions or content, plus Mermaid/PlantUML/C4/architecture.md discovery. Exhaustive, deterministic.

  • No Architecture Decision Records found — no conventional ADR directory, no numbered `NNNN-title` documents in any markup this check reads, and nothing ADR-shaped by content. Design rationale recorded elsewhere (a design-notes tree, a mailing list, pull-request discussion) is not visible to this check and is not re-findable per decision, so a future maintainer cannot ask why one choice was made and get an answer.

What to do

  • Record your significant design decisions. Write one short document per decision, giving its date, the situation, the decision and its consequences, and keep them together with your other design documents. A docs/adr folder with each file named by number and title is the easiest place to find them.
M3 · Folder & project structure10.0 / 10Exemplary✓ Tool-verified

Maturity · Maturity — Whether the repo is organised deliberately — src/test separation and consistent project naming.

Method: Filesystem scan: src/test folder separation and namespace-prefix consistency (majority RootNamespace agreement). Exhaustive across projects, deterministic.

M4 · Documentation accuracy8.5 / 10Strong◐ Sampled · advisory

Maturity · Maturity — Whether the README actually describes the code that exists (LLM-judged, advisory).

Method: Judged by language model at low temperature: README accuracy versus actual projects, within a disclosed tolerance. Advisory, not a measured number.

  • tests/README.md changes into `kafka/tests`, but no such folder exists. Checked without a model against the repository: its files and folders, the scripts and dependencies of every package.json, the projects, namespaces, package references and target frameworks of the .NET build, the SDK and Node pins, and the identifiers of every file that is not a document; the documents' own text never counts. A footprint generated at build time, read only by a platform, or living outside this repository is not seen, and this row is then wrong. — tests/README.md:318
  • docs/configuration/system-properties.md links to `/community/cve-list/#[CVE redacted]`, but `community/cve-list` does not exist. Checked without a model against the repository: its files and folders, the scripts and dependencies of every package.json, the projects, namespaces, package references and target frameworks of the .NET build, the SDK and Node pins, and the identifiers of every file that is not a document; the documents' own text never counts. A footprint generated at build time, read only by a platform, or living outside this repository is not seen, and this row is then wrong. — docs/configuration/system-properties.md:95
  • docs/design/design.md links to `/documentation.html#topicconfigs`, but `documentation.html` does not exist. Checked without a model against the repository: its files and folders, the scripts and dependencies of every package.json, the projects, namespaces, package references and target frameworks of the .NET build, the SDK and Node pins, and the identifiers of every file that is not a document; the documents' own text never counts. A footprint generated at build time, read only by a platform, or living outside this repository is not seen, and this row is then wrong. — docs/design/design.md:445
  • docs/design/protocol.md links to `/documentation/#recordbatch`, but `documentation` does not exist. Checked without a model against the repository: its files and folders, the scripts and dependencies of every package.json, the projects, namespaces, package references and target frameworks of the .NET build, the SDK and Node pins, and the identifiers of every file that is not a document; the documents' own text never counts. A footprint generated at build time, read only by a platform, or living outside this repository is not seen, and this row is then wrong. — docs/design/protocol.md:183
  • docs/getting-started/compatibility.md links to `/40/documentation.html#upgrade_400_notable_consumer`, but `40/documentation.html` does not exist. Checked without a model against the repository: its files and folders, the scripts and dependencies of every package.json, the projects, namespaces, package references and target frameworks of the .NET build, the SDK and Node pins, and the identifiers of every file that is not a document; the documents' own text never counts. A footprint generated at build time, read only by a platform, or living outside this repository is not seen, and this row is then wrong. — docs/getting-started/compatibility.md:316
  • docs/getting-started/introduction.md links to `/powered-by`, but `powered-by` does not exist. Checked without a model against the repository: its files and folders, the scripts and dependencies of every package.json, the projects, namespaces, package references and target frameworks of the .NET build, the SDK and Node pins, and the identifiers of every file that is not a document; the documents' own text never counts. A footprint generated at build time, read only by a platform, or living outside this repository is not seen, and this row is then wrong. — docs/getting-started/introduction.md:51
  • docs/getting-started/introduction.md links to `/protocol.html`, but `protocol.html` does not exist. Checked without a model against the repository: its files and folders, the scripts and dependencies of every package.json, the projects, namespaces, package references and target frameworks of the .NET build, the SDK and Node pins, and the identifiers of every file that is not a document; the documents' own text never counts. A footprint generated at build time, read only by a platform, or living outside this repository is not seen, and this row is then wrong. — docs/getting-started/introduction.md:63
  • docs/getting-started/introduction.md links to `/documentation/streams/`, but `documentation/streams` does not exist. Checked without a model against the repository: its files and folders, the scripts and dependencies of every package.json, the projects, namespaces, package references and target frameworks of the .NET build, the SDK and Node pins, and the identifiers of every file that is not a document; the documents' own text never counts. A footprint generated at build time, read only by a platform, or living outside this repository is not seen, and this row is then wrong. — docs/getting-started/introduction.md:67
  • docs/getting-started/introduction.md links to `/documentation/#design`, but `documentation` does not exist. Checked without a model against the repository: its files and folders, the scripts and dependencies of every package.json, the projects, namespaces, package references and target frameworks of the .NET build, the SDK and Node pins, and the identifiers of every file that is not a document; the documents' own text never counts. A footprint generated at build time, read only by a platform, or living outside this repository is not seen, and this row is then wrong. — docs/getting-started/introduction.md:89
  • docs/getting-started/introduction.md links to `/documentation.html#adminapi`, but `documentation.html` does not exist. Checked without a model against the repository: its files and folders, the scripts and dependencies of every package.json, the projects, namespaces, package references and target frameworks of the .NET build, the SDK and Node pins, and the identifiers of every file that is not a document; the documents' own text never counts. A footprint generated at build time, read only by a platform, or living outside this repository is not seen, and this row is then wrong. — docs/getting-started/introduction.md:95
  • docs/getting-started/introduction.md links to `/quickstart`, but `quickstart` does not exist. Checked without a model against the repository: its files and folders, the scripts and dependencies of every package.json, the projects, namespaces, package references and target frameworks of the .NET build, the SDK and Node pins, and the identifiers of every file that is not a document; the documents' own text never counts. A footprint generated at build time, read only by a platform, or living outside this repository is not seen, and this row is then wrong. — docs/getting-started/introduction.md:105
  • docs/getting-started/introduction.md links to `/books-and-papers`, but `books-and-papers` does not exist. Checked without a model against the repository: its files and folders, the scripts and dependencies of every package.json, the projects, namespaces, package references and target frameworks of the .NET build, the SDK and Node pins, and the identifiers of every file that is not a document; the documents' own text never counts. A footprint generated at build time, read only by a platform, or living outside this repository is not seen, and this row is then wrong. — docs/getting-started/introduction.md:106
  • docs/getting-started/introduction.md links to `/events`, but `events` does not exist. Checked without a model against the repository: its files and folders, the scripts and dependencies of every package.json, the projects, namespaces, package references and target frameworks of the .NET build, the SDK and Node pins, and the identifiers of every file that is not a document; the documents' own text never counts. A footprint generated at build time, read only by a platform, or living outside this repository is not seen, and this row is then wrong. — docs/getting-started/introduction.md:108
  • docs/getting-started/quickstart.md links to `/documentation/#messages`, but `documentation` does not exist. Checked without a model against the repository: its files and folders, the scripts and dependencies of every package.json, the projects, namespaces, package references and target frameworks of the .NET build, the SDK and Node pins, and the identifiers of every file that is not a document; the documents' own text never counts. A footprint generated at build time, read only by a platform, or living outside this repository is not seen, and this row is then wrong. — docs/getting-started/quickstart.md:96
  • docs/getting-started/quickstart.md links to `/documentation/streams`, but `documentation/streams` does not exist. Checked without a model against the repository: its files and folders, the scripts and dependencies of every package.json, the projects, namespaces, package references and target frameworks of the .NET build, the SDK and Node pins, and the identifiers of every file that is not a document; the documents' own text never counts. A footprint generated at build time, read only by a platform, or living outside this repository is not seen, and this row is then wrong. — docs/getting-started/quickstart.md:225
  • docs/getting-started/quickstart.md links to `/intro`, but `intro` does not exist. Checked without a model against the repository: its files and folders, the scripts and dependencies of every package.json, the projects, namespaces, package references and target frameworks of the .NET build, the SDK and Node pins, and the identifiers of every file that is not a document; the documents' own text never counts. A footprint generated at build time, read only by a platform, or living outside this repository is not seen, and this row is then wrong. — docs/getting-started/quickstart.md:263
  • docs/getting-started/quickstart.md links to `/powered-by`, but `powered-by` does not exist. Checked without a model against the repository: its files and folders, the scripts and dependencies of every package.json, the projects, namespaces, package references and target frameworks of the .NET build, the SDK and Node pins, and the identifiers of every file that is not a document; the documents' own text never counts. A footprint generated at build time, read only by a platform, or living outside this repository is not seen, and this row is then wrong. — docs/getting-started/quickstart.md:264
  • docs/getting-started/quickstart.md links to `/events`, but `events` does not exist. Checked without a model against the repository: its files and folders, the scripts and dependencies of every package.json, the projects, namespaces, package references and target frameworks of the .NET build, the SDK and Node pins, and the identifiers of every file that is not a document; the documents' own text never counts. A footprint generated at build time, read only by a platform, or living outside this repository is not seen, and this row is then wrong. — docs/getting-started/quickstart.md:265
  • docs/getting-started/uses.md links to `/documentation.html#compaction`, but `documentation.html` does not exist. Checked without a model against the repository: its files and folders, the scripts and dependencies of every package.json, the projects, namespaces, package references and target frameworks of the .NET build, the SDK and Node pins, and the identifiers of every file that is not a document; the documents' own text never counts. A footprint generated at build time, read only by a platform, or living outside this repository is not seen, and this row is then wrong. — docs/getting-started/uses.md:63
  • docs/operations/geo-replication-(cross-cluster-data-mirroring).md links to `/documentation/#mirrormakerconfigs`, but `documentation` does not exist. Checked without a model against the repository: its files and folders, the scripts and dependencies of every package.json, the projects, namespaces, package references and target frameworks of the .NET build, the SDK and Node pins, and the identifiers of every file that is not a document; the documents' own text never counts. A footprint generated at build time, read only by a platform, or living outside this repository is not seen, and this row is then wrong. — docs/operations/geo-replication-(cross-cluster-data-mirroring).md:250
  • docs/operations/kraft.md documents the environment variable `CONTROLLER_0_UUID`, but no code, script or configuration file names it. Checked without a model against the repository: its files and folders, the scripts and dependencies of every package.json, the projects, namespaces, package references and target frameworks of the .NET build, the SDK and Node pins, and the identifiers of every file that is not a document; the documents' own text never counts. A footprint generated at build time, read only by a platform, or living outside this repository is not seen, and this row is then wrong. — docs/operations/kraft.md:133
  • docs/operations/kraft.md documents the environment variable `CONTROLLER_1_UUID`, but no code, script or configuration file names it. Checked without a model against the repository: its files and folders, the scripts and dependencies of every package.json, the projects, namespaces, package references and target frameworks of the .NET build, the SDK and Node pins, and the identifiers of every file that is not a document; the documents' own text never counts. A footprint generated at build time, read only by a platform, or living outside this repository is not seen, and this row is then wrong. — docs/operations/kraft.md:134
  • docs/operations/kraft.md documents the environment variable `CONTROLLER_2_UUID`, but no code, script or configuration file names it. Checked without a model against the repository: its files and folders, the scripts and dependencies of every package.json, the projects, namespaces, package references and target frameworks of the .NET build, the SDK and Node pins, and the identifiers of every file that is not a document; the documents' own text never counts. A footprint generated at build time, read only by a platform, or living outside this repository is not seen, and this row is then wrong. — docs/operations/kraft.md:135
  • docs/streams/architecture.md links to `/documentation`, but `documentation` does not exist. Checked without a model against the repository: its files and folders, the scripts and dependencies of every package.json, the projects, namespaces, package references and target frameworks of the .NET build, the SDK and Node pins, and the identifiers of every file that is not a document; the documents' own text never counts. A footprint generated at build time, read only by a platform, or living outside this repository is not seen, and this row is then wrong. — docs/streams/architecture.md:96
  • docs/streams/architecture.md links to `/documentation/streams`, but `documentation/streams` does not exist. Checked without a model against the repository: its files and folders, the scripts and dependencies of every package.json, the projects, namespaces, package references and target frameworks of the .NET build, the SDK and Node pins, and the identifiers of every file that is not a document; the documents' own text never counts. A footprint generated at build time, read only by a platform, or living outside this repository is not seen, and this row is then wrong. — docs/streams/architecture.md:97
  • docs/streams/core-concepts.md links to `/documentation`, but `documentation` does not exist. Checked without a model against the repository: its files and folders, the scripts and dependencies of every package.json, the projects, namespaces, package references and target frameworks of the .NET build, the SDK and Node pins, and the identifiers of every file that is not a document; the documents' own text never counts. A footprint generated at build time, read only by a platform, or living outside this repository is not seen, and this row is then wrong. — docs/streams/core-concepts.md:173
  • docs/streams/core-concepts.md links to `/documentation/streams`, but `documentation/streams` does not exist. Checked without a model against the repository: its files and folders, the scripts and dependencies of every package.json, the projects, namespaces, package references and target frameworks of the .NET build, the SDK and Node pins, and the identifiers of every file that is not a document; the documents' own text never counts. A footprint generated at build time, read only by a platform, or living outside this repository is not seen, and this row is then wrong. — docs/streams/core-concepts.md:174
  • docs/streams/quickstart.md links to `/documentation`, but `documentation` does not exist. Checked without a model against the repository: its files and folders, the scripts and dependencies of every package.json, the projects, namespaces, package references and target frameworks of the .NET build, the SDK and Node pins, and the identifiers of every file that is not a document; the documents' own text never counts. A footprint generated at build time, read only by a platform, or living outside this repository is not seen, and this row is then wrong. — docs/streams/quickstart.md:258
  • docs/streams/quickstart.md links to `/documentation/streams`, but `documentation/streams` does not exist. Checked without a model against the repository: its files and folders, the scripts and dependencies of every package.json, the projects, namespaces, package references and target frameworks of the .NET build, the SDK and Node pins, and the identifiers of every file that is not a document; the documents' own text never counts. A footprint generated at build time, read only by a platform, or living outside this repository is not seen, and this row is then wrong. — docs/streams/quickstart.md:259
  • docs/streams/tutorial.md links to `/documentation`, but `documentation` does not exist. Checked without a model against the repository: its files and folders, the scripts and dependencies of every package.json, the projects, namespaces, package references and target frameworks of the .NET build, the SDK and Node pins, and the identifiers of every file that is not a document; the documents' own text never counts. A footprint generated at build time, read only by a platform, or living outside this repository is not seen, and this row is then wrong. — docs/streams/tutorial.md:461
  • docs/streams/tutorial.md links to `/documentation/streams`, but `documentation/streams` does not exist. Checked without a model against the repository: its files and folders, the scripts and dependencies of every package.json, the projects, namespaces, package references and target frameworks of the .NET build, the SDK and Node pins, and the identifiers of every file that is not a document; the documents' own text never counts. A footprint generated at build time, read only by a platform, or living outside this repository is not seen, and this row is then wrong. — docs/streams/tutorial.md:462
  • docs/streams/developer-guide/app-reset-tool.md links to `../manage-topics#streams-developer-guide-topics-user`, but `docs/streams/manage-topics` does not exist. Checked without a model against the repository: its files and folders, the scripts and dependencies of every package.json, the projects, namespaces, package references and target frameworks of the .NET build, the SDK and Node pins, and the identifiers of every file that is not a document; the documents' own text never counts. A footprint generated at build time, read only by a platform, or living outside this repository is not seen, and this row is then wrong. — docs/streams/developer-guide/app-reset-tool.md:31
  • docs/streams/developer-guide/app-reset-tool.md links to `/documentation`, but `documentation` does not exist. Checked without a model against the repository: its files and folders, the scripts and dependencies of every package.json, the projects, namespaces, package references and target frameworks of the .NET build, the SDK and Node pins, and the identifiers of every file that is not a document; the documents' own text never counts. A footprint generated at build time, read only by a platform, or living outside this repository is not seen, and this row is then wrong. — docs/streams/developer-guide/app-reset-tool.md:139
  • docs/streams/developer-guide/app-reset-tool.md links to `/documentation/streams`, but `documentation/streams` does not exist. Checked without a model against the repository: its files and folders, the scripts and dependencies of every package.json, the projects, namespaces, package references and target frameworks of the .NET build, the SDK and Node pins, and the identifiers of every file that is not a document; the documents' own text never counts. A footprint generated at build time, read only by a platform, or living outside this repository is not seen, and this row is then wrong. — docs/streams/developer-guide/app-reset-tool.md:140
  • docs/streams/developer-guide/app-reset-tool.md links to `/documentation/streams/developer-guide/`, but `documentation/streams/developer-guide` does not exist. Checked without a model against the repository: its files and folders, the scripts and dependencies of every package.json, the projects, namespaces, package references and target frameworks of the .NET build, the SDK and Node pins, and the identifiers of every file that is not a document; the documents' own text never counts. A footprint generated at build time, read only by a platform, or living outside this repository is not seen, and this row is then wrong. — docs/streams/developer-guide/app-reset-tool.md:141
  • docs/streams/developer-guide/config-streams.md links to `../datatypes#streams-developer-guide-serdes`, but `docs/streams/datatypes` does not exist. Checked without a model against the repository: its files and folders, the scripts and dependencies of every package.json, the projects, namespaces, package references and target frameworks of the .NET build, the SDK and Node pins, and the identifiers of every file that is not a document; the documents' own text never counts. A footprint generated at build time, read only by a platform, or living outside this repository is not seen, and this row is then wrong. — docs/streams/developer-guide/config-streams.md:1385
  • docs/streams/developer-guide/config-streams.md links to `../../architecture#streams_architecture_threads`, but `docs/architecture` does not exist. Checked without a model against the repository: its files and folders, the scripts and dependencies of every package.json, the projects, namespaces, package references and target frameworks of the .NET build, the SDK and Node pins, and the identifiers of every file that is not a document; the documents' own text never counts. A footprint generated at build time, read only by a platform, or living outside this repository is not seen, and this row is then wrong. — docs/streams/developer-guide/config-streams.md:1507
  • docs/streams/developer-guide/config-streams.md links to `/documentation`, but `documentation` does not exist. Checked without a model against the repository: its files and folders, the scripts and dependencies of every package.json, the projects, namespaces, package references and target frameworks of the .NET build, the SDK and Node pins, and the identifiers of every file that is not a document; the documents' own text never counts. A footprint generated at build time, read only by a platform, or living outside this repository is not seen, and this row is then wrong. — docs/streams/developer-guide/config-streams.md:2156
  • docs/streams/developer-guide/config-streams.md links to `/documentation/streams`, but `documentation/streams` does not exist. Checked without a model against the repository: its files and folders, the scripts and dependencies of every package.json, the projects, namespaces, package references and target frameworks of the .NET build, the SDK and Node pins, and the identifiers of every file that is not a document; the documents' own text never counts. A footprint generated at build time, read only by a platform, or living outside this repository is not seen, and this row is then wrong. — docs/streams/developer-guide/config-streams.md:2157
  • docs/streams/developer-guide/config-streams.md links to `/documentation/streams/developer-guide/`, but `documentation/streams/developer-guide` does not exist. Checked without a model against the repository: its files and folders, the scripts and dependencies of every package.json, the projects, namespaces, package references and target frameworks of the .NET build, the SDK and Node pins, and the identifiers of every file that is not a document; the documents' own text never counts. A footprint generated at build time, read only by a platform, or living outside this repository is not seen, and this row is then wrong. — docs/streams/developer-guide/config-streams.md:2158

What to do

  • Reconcile the README with reality: tests/README.md changes into `kafka/tests`, but no such folder exists; docs/configuration/system-properties.md links to `/community/cve-list/#[CVE redacted]`, but `community/cve-list` does not exist; docs/design/design.md links to `/documentation.html#topicconfigs`, but `documentation.html` does not exist; docs/design/protocol.md links to `/documentation/#recordbatch`, but `documentation` does not exist; docs/getting-started/compatibility.md links to `/40/documentation.html#upgrade_400_notable_consumer`, but `40/documentation.html` does not exist.
P1 · CI/CD gates10.0 / 10Exemplary○ Nothing flagged

Readiness · Readiness — Whether an automated pipeline builds and tests every change.

Method: Filesystem scan: CI workflow files (.github/workflows, .gitlab-ci.yml, etc.) for build and test stages. Exhaustive, deterministic.

P10 · Library API & versioning6.0 / 10Adequate✓ Tool-verified

Readiness · Readiness — For a library: a deliberate (small) public API surface and explicit semantic versioning so consumers can depend on it safely.

Method: Roslyn scan: public API surface area and semantic-versioning markers (SemVer attributes, changelog entries) for libraries; off .NET, a library is the ecosystem's publication act (an npm package that is not private and names an entry point, a PyPI distribution with a build system, a Rust library crate, a Maven/Gradle module that publishes, a Go module with no package main, a gemspec, a Composer library, a SwiftPM library product, a pub.dev or Hex package), its surface is the share of types the language model records as public (Rust, Swift, Java, Kotlin, Go, Dart; not measured where the model records no type visibility or, as in TypeScript, only module-level export), and its version is read from the manifest, a semver CHANGELOG, release tooling or semver git tags. Exhaustive, deterministic.

  • 4132/5576 types (74%) declared in the published library are public. For a library, every public type is a stability contract — keep implementation types off the surface and expose only the intended API.

What to do

  • Keep implementation types off the public surface (Java: package-private (no modifier), or leave its package out of `module-info` exports) so internals can change without breaking consumers.
P2 · Observability8.5 / 10Strong✓ Tool-verified

Readiness · Readiness — Whether the code is diagnosable in production — structured logging, tracing/metrics, health checks.

Method: Filesystem/Roslyn scan: structured-logging frameworks (Serilog, NLog), OpenTelemetry, and health-check endpoint patterns. Exhaustive, deterministic.

  • Only 3/6 runnable modules use logging (modules with no entry point or server are excluded — they are libraries a runnable module hosts). Silent: `docker`, `release`, `streams/quickstart/java/src/main/resources/archetype-resources`.

What to do

  • Extend structured logging to the remaining runnable modules so everything you run is diagnosable in production.
P3 · Security & performance tooling7.0 / 10Strong✓ Tool-verified

Readiness · Readiness — Whether SAST, secret/dependency scanning and performance benchmarking are wired in (presence, not runtime).

Method: Filesystem scan: SAST configuration, dependency-update automation, secret scanning, and a benchmark harness or benchmark step — in this repository's own ecosystem. Exhaustive, deterministic.

What to do

  • Your ecosystem's static analyzer is declared as a dependency but is not wired into CI — run it as a required step on push/PR (e.g. `composer phpstan` / `mix sobelow` / `bundle exec brakeman` / the spotbugs Gradle task / `sbt scalafixAll --check` / `golangci-lint run` / `rebar3 lint`) so a regression fails the build instead of relying on someone running it locally.
  • Dependabot is configured but does not watch `pip`, `maven`, `gradle` — add those `package-ecosystem` entries to .github/dependabot.yml so those dependencies get the same automatic update and advisory pressure as the ones it already covers.
  • Add gitleaks/trufflehog in CI to block PRs that introduce committed secrets.
P4 · Deployment & Rollback7.0 / 10Strong✓ Tool-verified

Readiness · Readiness — Whether releases are automated and safely reversible (probes, rolling updates, approval gates) — from manifests/pipeline files, not the live environment.

Method: Filesystem scan: deployment manifests/IaC (K8s YAML, Helm, Terraform) for rolling updates, probes, approval gates, migration hooks. Exhaustive, deterministic.

P5 · DR & Backup4.0 / 10Weak✓ Tool-verified

Readiness · Readiness — Whether disaster recovery is planned and codified — backups, geo-recovery, RTO/RPO, persistence guarantees — from IaC + container manifests + docs, never the live cloud.

Method: Filesystem scan: disaster recovery, backup, geo-recovery, RTO/RPO, persistence guarantees from IaC, manifests, and docs. Exhaustive, deterministic, never a live environment.

What to do

  • Document RTO/RPO and a tested restore procedure (a backup config alone isn't disaster recovery).
  • Enable purge protection / soft-delete (and prevent_destroy on critical resources) so data stores can't be lost to an accidental or malicious delete.
P6 · Release Hygiene5.0 / 10Adequate✓ Tool-verified

Readiness · Readiness — Whether releases are traceable — a maintained changelog and explicit version stamping.

Method: Filesystem scan: changelog file presence and version tags in csproj or git tags. Exhaustive, deterministic.

  • No CHANGELOG/HISTORY/RELEASES file — what shipped when isn't easy to reconstruct for support or audit. (Versioning/tagging makes releases traceable, but a changelog records the what.)

What to do

  • Keep a changelog (e.g. Keep-a-Changelog) recording what shipped in each release.
P7 · Outbound HTTP resilience3.0 / 10Weak✓ Tool-verified

Readiness · Readiness — Whether outbound HTTP calls are wrapped in resilience (retry/timeout/circuit-breaker) so a failing dependency doesn't cascade.

Method: Source scan: outbound HTTP clients and what bounds them — resilience handlers (Polly, AddStandardResilienceHandler) on .NET; on Go, the JVM, Python, JavaScript/TypeScript, Ruby, PHP, Rust, Elixir, Swift, Dart and Erlang, a timeout, deadline, retry or breaker beside each call, or a process-wide client default (a framework-wide deadline such as Drupal core's, Laravel's or actix's awc counts). Exhaustive, deterministic.

  • `urllib.request.urlopen(` makes an outbound HTTP call, and nothing bounds it: no timeout, deadline, retry or circuit breaker is set for it here, and the client has no process-wide default. A slow or failing dependency will hold this service's request, thread or connection until the call gives up on its own — or never, for a client with no default timeout. — REDACTED:82
  • `HttpClient(` makes an outbound HTTP call, and nothing bounds it: no timeout, deadline, retry or circuit breaker is set for it here, and the client has no process-wide default. A slow or failing dependency will hold this service's request, thread or connection until the call gives up on its own — or never, for a client with no default timeout. (×2) — connect/runtime/src/main/java/org/apache/kafka/connect/runtime/rest/RestClient.java:75, connect/runtime/src/main/java/org/apache/kafka/connect/runtime/rest/RestClient.java:77
  • `.openConnection(` makes an outbound HTTP call, and nothing bounds it: no timeout, deadline, retry or circuit breaker is set for it here, and the client has no process-wide default. A slow or failing dependency will hold this service's request, thread or connection until the call gives up on its own — or never, for a client with no default timeout. (×3) — tools/src/main/java/org/apache/kafka/tools/ManifestWorkspace.java:551, tools/src/main/java/org/apache/kafka/tools/PushHttpMetricsReporter.java:233, trogdor/src/main/java/org/apache/kafka/trogdor/rest/JsonRestServer.java:183

What to do

  • Pass `timeout=` on every `requests`/`httpx` call (requests has no default and will wait forever), mount an `HTTPAdapter(max_retries=Retry(...))` on shared sessions, and wrap calls to flaky dependencies in `tenacity` retries or a `pybreaker` circuit breaker.
  • Set connect and read timeouts on every client (`RestTemplateBuilder.connectTimeout/readTimeout`, WebClient `responseTimeout`, `HttpRequest.Builder.timeout`, `HttpURLConnection.setReadTimeout`, Feign `connectTimeout`/`readTimeout` in configuration), and wrap calls to dependencies in resilience4j `@Retry`/`@CircuitBreaker`/`@TimeLimiter` (or Spring Retry).
PF1 · Benchmark discipline9.5 / 10Exemplary✓ Tool-verified

Readiness · Performance — Whether the code protects its performance with benchmarks — a benchmark suite, allocation/memory measurement, and (ideally) a CI gate. Presence is credited as a bonus, never a deduction.

Method: Repo + source scan: BenchmarkDotNet referenced (csproj/source), [Benchmark]/[MemoryDiagnoser] attribute counts, and a benchmark step in CI; off .NET, the same ladder over Go testing.B, Rust criterion/#[bench]/divan, JMH/kotlinx-benchmark, pytest-benchmark/asv/pyperf, tinybench/mitata/vitest bench/benchmark.js and Swift package-benchmark — scored as a bonus ladder (absence is neutral, never a deduction). Deterministic, presence detection.

PF2 · Allocation hygiene7.1 / 10Strong✓ Tool-verified

Readiness · Performance — Whether the code is written to minimise allocations so it doesn't pressure its host's memory manager — buffer/slice views over copies, object pooling, stack or value-type allocation, and buffer writers. Reward-only: credited where present, never penalised where a simpler style is fine.

Method: Production-source scan: density (per 1k LoC) of allocation-aware APIs — in .NET Span/Memory, ArrayPool/ObjectPool, stackalloc, ValueTask, value-type structs, IBufferWriter, string.Create, SkipLocalsInit; off .NET, with comments and strings blanked, Go's sync.Pool, preallocated slices/maps, Grow, strconv.Append* and buf[:0] reuse; the JVM's NIO buffer views, MemorySegment, primitive collections, pools and literal presizes (plus Kotlin primitive arrays and value classes, Scala AnyVal and @specialized); Swift's reserveCapacity, ContiguousArray, withUnsafe* access and ~Copyable. Activated off .NET on the same floor (400 lines, and benchmarks or 8 uses); Rust and garbage-collected scripting languages are not applicable. Reward-only. Deterministic, syntax/text detection.

What to do

  • Raise allocation-aware density on the hot paths — currently 1487 use(s) across 693,363 production line(s) (~2.1/1k). More of the idioms below on the allocation-heavy paths climbs this toward 10.
  • Java: on hot paths, work through buffer views (ByteBuffer/LongBuffer slices, MemorySegment) instead of copies, avoid boxing with primitive collections (fastutil, Eclipse Collections, HPPC, Trove), presize collections and StringBuilders, and pool expensive buffers (Netty's pooled allocator, commons-pool).
  • Scala: on hot paths, make small wrappers value classes (extends AnyVal), @specialized generic code over primitives, use primitive collections, and presize builders.
X1 · Async correctness10.0 / 10Exemplary○ Nothing flagged

Other · Code Health — Whether the code avoids sync-over-async (deadlock-prone blocking on tasks) and async void.

Method: Roslyn syntax scan: async methods scanned for .Wait()/.GetAwaiter().GetResult() and async-void outside event handlers. Deterministic, hard fact per invocation.

X12 · Unreachable branch10.0 / 10Exemplary○ Nothing flagged

Other · Code Health — Whether any branch is dead by construction — a switch arm whose label can never equal a case-normalised subject, or an `else if` whose predicate the arm above has already swallowed.

Method: Roslyn syntax + semantics: switch labels compared against the subject's own case normaliser, and if/else-if chains checked for a literal an earlier arm's containment test already swallows. Deterministic, provable per finding. Advisory.

X13 · Undrained process stream10.0 / 10Exemplary○ Nothing flagged

Other · Code Health — Whether a child process that has BOTH standard streams redirected drains both — reading one to the end while the other is never read deadlocks once the child fills the unread pipe.

Method: Roslyn syntax + semantics: ProcessStartInfo launches with both streams redirected, checked for a drain of each stream across the enclosing type. On a repository with no .NET source it reads JavaScript/TypeScript off the engine’s own token stream (test, vendored and minified paths not) with the same rule: a `spawn` imported from `child_process` whose stdout and stderr are both pipes (no options, no `stdio`, or `stdio` of `'pipe'`), bound to a local that never leaves its scope, where exactly one of the two streams is read, the other never, and the child’s `close`/`exit` (or the read stream’s end) is awaited; a shell redirect in the call’s arguments or a `kill` of the child suppresses it. The same rule reads Python’s `subprocess.Popen`, Dart’s `Process.start`, Ruby’s `Open3.popen3`, and Scala’s JDK process starts (`new ProcessBuilder(…).start()` with no `redirectErrorStream`/`redirectError`/`redirectOutput`/`inheritIO`, `Runtime.getRuntime.exec`) where one of `getInputStream`/`getErrorStream` is read and the other never while `waitFor()` is called or the read stream is read to its end. Deterministic, provable per finding. Advisory.

X14 · Bypassable address classification10.0 / 10Exemplary○ Nothing flagged

Other · Security — Whether a hand-rolled public/private IP check can be walked past — a method that unwraps IPv4-mapped IPv6 but returns the opposite verdict for the same host written as IPv4-compatible, 6to4 or NAT64.

Method: Roslyn syntax + semantics: methods that unwrap IPv4-mapped IPv6 and hand-roll IPv4 range carve-outs, checked for whether the IPv6 branch also accounts for the IPv4-compatible, 6to4 and NAT64 embeddings. Deterministic, provable per finding. Advisory.

X15 · Unvalidated length from an untrusted reader10.0 / 10Exemplary○ Nothing flagged

Other · Security — Whether a length read out of the stream being parsed is bounded before it is allocated or read — an unchecked count taken from the input lets the input choose the allocation.

Method: Roslyn syntax + semantics: integer lengths read from a BinaryReader and spent on a bulk read or an array allocation, checked for any comparison or bounding call on the value anywhere in the method. Deterministic, provable per finding. Advisory.

X16 · Unfloored truncation loop10.0 / 10Exemplary○ Nothing flagged

Other · Code Health — Whether a loop that shortens a string until it fits a length budget has a floor — one with none grinds the value down to the empty string, or past it into a negative-length `Substring`.

Method: Roslyn syntax + semantics: while/do loops whose body's only effect on a string is to drop its last character, checked for whether anything — a direct comparison on the length, a body guard, a break — bounds that length below. On a repository with no .NET source it reads JavaScript/TypeScript off the engine’s own token stream (test, vendored and minified paths not) with the same rule: a `while`/`do` loop whose body’s one assignment to a value is `x = x.slice(0, -1)` or `x = x.slice|substring|substr(0, x.length - 1)`, driven by a condition that reads `x.length` only as a term of a larger expression — never compared directly, never tested for truthiness, and with no other read of `x` — and whose body has no `break`, `return`, `throw` or `if` naming `x`. Deterministic, provable per finding. Advisory.

X17 · Uncapped recursion over a caller-supplied document10.0 / 10Exemplary○ Nothing flagged

Other · Security — Whether a walk that recurses through a JSON/XML tree handed in by its caller bounds how deep it will go — an uncapped walk lets the document's nesting choose the stack depth, and the resulting StackOverflowException cannot be caught.

Method: Roslyn syntax + semantics: methods that take a JSON/XML document node and call themselves with a child of it, reachable from an externally-callable member of the same type that accepts a document, checked for any depth parameter, descent counter or threaded arithmetic anywhere in the walk. On a repository with no .NET source it reads TypeScript off the engine’s own token stream (test, vendored, generated and minified paths and `.d.ts` not) with the same rule: a function or method with a parameter typed as a document value — `unknown`, `any`, `object`, `Record<string, unknown|any>`, a JSON alias (`JsonValue`, `JSONObject`, …) or a DOM node global the file does not rebind — that calls itself (bare, or through `this` for a method, or hands itself to a call over the value as in `value.map(walk)`) with something it took out of that value and never through an ancestor accessor such as `closest()` or `parentElement`, that is exported or reached from an exported function (a public method of the same exported class) taking such a value, and that names no depth, level, nesting, recursion, remaining or budget anywhere and threads no `+`/`-` arithmetic through a self-call. Plain JavaScript is not read: with no annotation nothing tells a parsed document from a tree the code built itself. Deterministic, provable per finding. Advisory.

X18 · Disposal-pattern correctness7.9 / 10Strong✓ Tool-verified

Other · Code Health — Whether a type's disposal matches what it OWNS — releasing what it created, leaving alone what it was handed, and not declaring a finalizer for state that has nothing unmanaged to finalize.

Method: Roslyn syntax + semantics: every assignment to a disposable field is read to decide whether the type CREATED the value or was handed it, and the type's disposal is checked against that answer — an injected interface it disposes, a value it constructed and never releases, a finalizer on a type holding nothing unmanaged, and a disposable local whose every reference is a plain member read. A value handed to a container that disposes its contents (a parent control's `Controls` collection, a component `IContainer`) is released by that container and is not reported; generated code is out of population. On a repository with no .NET source the same ownership questions are read in JavaScript/TypeScript off the engine’s own token stream (test, vendored, generated and minified paths not): a class declaring `dispose()`, `[Symbol.dispose]()` or `[Symbol.asyncDispose]()` that disposes a field it was handed through a constructor parameter typed as a repository interface or resolved by a dependency-injection container; that assigns a field only ever from `new X(…)` of a disposable class and neither releases it anywhere in the class nor names it in its disposal member or a method that member calls, nor hands it to anything else; and a `const`/`let` local built from literals only whose every reference opens a statement operating on a non-release member of it. A class is disposable when every repository declaration of its name declares or inherits a disposal member, or when it is a documented library disposable (`vscode` EventEmitter, CancellationTokenSource and Disposable; three.js geometries, materials, textures, render targets, renderers, controls and composers). The finalizer arm has no JavaScript counterpart: a class cannot declare one. Dart is read for the owned-and-never-released arm: a Flutter `State` (or a class declaring `dispose()`/`close()`) whose library-private field is written only with direct creations of a framework controller, `FocusNode`, `StreamController` or periodic `Timer` (or a `.listen(…)` into a field declared `StreamSubscription`), which nothing in the class or its library releases (`dispose`/`close`/`cancel`) and which is never handed on except as a named argument. Ruby is read for the owned-and-never-released arm and the abandoned-local arm: a class declaring an instance `close`, `dispose`, `shutdown`, `stop`, `disconnect` or `terminate` whose instance variable is written only with a blockless core descriptor creation (`File.open`/`new`, `Tempfile`, `Dir.open`, `IO.popen`, the `socket` and `openssl` socket classes) that no method of the class closes and that is never handed on (passed, returned, stored, exposed by `attr_reader`, delegated) — a class whose superclass or mixin lies outside the repository is not judged — and a blockless creation read through and dropped (`File.open(path).read`) or held in a local that is never closed, returned, passed or stored (a `&:read` block-pass, an `autoclose: false` borrow and a `fileno` hand-over are not abandonment). PHP is read for the same two arms: a class (not a trait, and not one using a trait) declaring an instance `close`, `dispose`, `shutdown`, `stop`, `disconnect` or `terminate` whose `private` property (or a `final` class's `protected` one) is written only with a direct core `fopen`, `tmpfile`, `popen`, `proc_open`, `fsockopen`, `stream_socket_client`/`server` or `opendir` that nothing in the class closes (`fclose`, `pclose`, `closedir`, `unset`, a reset to `null`) and that is never handed on, and a handle held in a function's local, or read through as the argument of a reader, that is never closed, returned, passed, captured or stored; a `php://` stream, `curl_init`, `SplFileObject`, `PDO` and a function the repository declares under the core name are not read. Deterministic, provable per finding. Advisory.

  • `AbstractCoordinator` declares `close()` — so it has told every caller, and every try-with-resources, that it holds something worth releasing — and it creates `sensors` itself (line 197, `new GroupCoordinatorMetrics(…)`), which makes that instance its own. But `sensors` is named in none of the methods the disposal search covered: `close` (line 1120), `close` (line 1127), `closeHeartbeatThread` (line 433), `onLeavePrepare` (line 263), `maybeLeaveGroup` (line 1168), `checkAndGetCoordinator` (line 981), `shouldSendLeaveGroupRequest` (line 1188), `resetGenerationOnLeaveGroup` (line 1083), `markCoordinatorUnknown` (line 994), `markCoordinatorUnknown` (line 998), `markCoordinatorUnknown` (line 1002), `coordinatorUnknown` (line 971), `isDynamicMember` (line 1196), `resetStateAndRejoin` (line 1072), `resetStateAndGeneration` (line 1059), `requestRejoin` (line 1094), `requestRejoin` (line 1105) — that is `close()` plus every method it calls on `this` BY NAME, so a release reached through a superclass, a callback or a registry is not followed and is worth checking before acting. The field is released nowhere else in the class and is never handed to anything else, so no other owner can be releasing it. On what was read, closing this object releases everything except the one thing it owns: whatever `new GroupCoordinatorMetrics(…)` holds — a file descriptor, a socket, a pool's live threads — outlives it, and a long-running process runs out of them one closed instance at a time. Release it in `close()` (`sensors.close()`), or, if it truly does not need releasing, drop the `close()` so the claim and the behaviour agree. — clients/src/main/java/org/apache/kafka/clients/consumer/internals/AbstractCoordinator.java:197
  • `KTableTransformValuesProcessor` declares `close()` — so it has told every caller, and every try-with-resources, that it holds something worth releasing — and it creates `store` itself (line 108, `new KeyValueStoreWrapper(…)`), which makes that instance its own. But `store` is named in none of the methods the disposal search covered: `close` (line 135) — that is `close()` plus every method it calls on `this` BY NAME, so a release reached through a superclass, a callback or a registry is not followed and is worth checking before acting. The field is released nowhere else in the class and is never handed to anything else, so no other owner can be releasing it. On what was read, closing this object releases everything except the one thing it owns: whatever `new KeyValueStoreWrapper(…)` holds — a file descriptor, a socket, a pool's live threads — outlives it, and a long-running process runs out of them one closed instance at a time. Release it in `close()` (`store.close()`), or, if it truly does not need releasing, drop the `close()` so the claim and the behaviour agree. — streams/src/main/java/org/apache/kafka/streams/kstream/internals/KTableTransformValues.java:108

What to do

  • Each finding names the value and the span that decides who owns it — the `new` that created it, or the constructor parameter that handed it over. Confirm ownership from that span, then make the disposal match it: release what this type created, leave what it was injected with to whoever created THAT, and drop a finalizer whose type holds nothing unmanaged to release.
X19 · Unrestored process-global state10.0 / 10Exemplary○ Nothing flagged

Other · Code Health — Whether a method that temporarily changes state belonging to the whole process — the working directory, an environment variable — puts it back on EVERY path: a restore reached only when nothing throws leaks the change to the rest of the process.

Method: Roslyn syntax + semantics: method bodies that write the process working directory or an environment variable and write it back in the same body, checked for whether that restore sits in a `finally`/`catch` or only on the straight-line path. On a repository with no .NET source the same rule reads production JavaScript/TypeScript off the engine’s own token stream (test, vendored and minified paths not): `process.chdir`, `process.env.NAME =`/`["NAME"] =` and `delete process.env.NAME`, and Deno’s `Deno.chdir`/`Deno.env.set`/`Deno.env.delete`, paired per function body (a nested function or arrow is its own body, and module top-level code is none), where the last write puts back a local the body captured from the same global or deletes a variable the first write set, with at least one statement between them; a write in a `catch`/`finally` of that body silences it. Deterministic, provable per finding. Advisory.

X20 · Mistyped argument guard10.0 / 10Exemplary○ Nothing flagged

Other · Code Health — Whether an argument guard throws the exception its own condition describes — a guard that rejects a value for being EMPTY and reports it as `NullPointerException` (Java, Kotlin, Scala), `ArgumentError.notNull` (Dart) or `ArgumentNullException` (F#'s `nullArg`) tells the caller a parameter was null when it provably was not.

Method: Roslyn syntax: `throw new ArgumentNullException(nameof(p))` statements controlled by an `if`, whose condition is read for a test that is true of a NON-null `p` — an emptiness test that dereferences it (`p.Count == 0`, `!p.Any()`) or a BCL predicate documented true of the empty value (`string.IsNullOrEmpty(p)`). Deterministic, provable per finding. Advisory.

X21 · Side-effecting pattern guard10.0 / 10Exemplary○ Nothing flagged

Other · Code Health — Whether a `when` guard is free of side effects — a guard that increments a counter or assigns while deciding whether its arm matches applies that change during PATTERN MATCHING, on an arm that may not be selected, and skips it entirely when a short-circuit to its left answers first.

Method: Roslyn syntax: `when` guards on case labels and switch-expression arms, read for a mutation (`++`/`--`/assignment) sitting in a position the guard's own `&&`/`||`/`??`/`?:`/`?.` can skip. Deterministic, provable per finding. Advisory.

X22 · Contradicted release guard10.0 / 10Exemplary○ Nothing flagged

Other · Code Health — Whether a method that TAKES a lock or semaphore and gives it back from a flag-guarded `finally` returns the value that flag implies — reporting success while the guard hands the primitive back admits a second caller the exclusion was there to keep out, and reporting failure while the guard keeps it leaves nothing to ever give it back.

Method: Roslyn syntax: `try` statements whose `finally` releases a synchronisation primitive under a bare local-bool guard, where the method also TOOK that same primitive before the `try`, checked for a `return` of a bool literal whose value disagrees with the flag state the method's own straight-line assignments put it in. Deterministic, provable per finding. Advisory.

X23 · Unguarded diagnostic materialisation7.8 / 10Strong✓ Tool-verified

Other · Code Health — Whether the work a diagnostic log line costs is paid only when that line is wanted — C# evaluates a call's arguments BEFORE the call, so a trace/debug message joined or projected out of a collection is built in full on every pass, and then discarded by a sink the shipped configuration leaves switched off.

Method: Roslyn syntax: log calls at a diagnostic level (a `Log`-prefixed method naming Trace/Debug/Verbose, or a bare `Debug`/`Trace`/`Verbose` on a receiver named for a logger), whose argument list is read for a call whose cost scales with a sequence — a LINQ operator, a materialisation, `string.Join`, a serializer — with no enclosing level check or conditional-compilation region. On a repository with no .NET source it reads JavaScript/TypeScript off the engine’s own token stream (test, vendored and minified paths not) with the same rule: a `debug`/`trace`/`verbose` call on a receiver named for a logger, or a `log`-prefixed method naming the level, whose argument calls an array operator (`map`/`filter`/`reduce`/`sort`/…), `Array.from`, `Object.keys/values/entries`, `JSON.stringify`/`util.inspect` over anything but a literal, or an array `join` — outside any arrow or function passed as an argument, which the logger calls only when the level is on — with no enclosing `if`, `&&` or `?:` whose condition names a level, a level string, or the `NODE_ENV`/`__DEV__`/`DEV` build switch. Deterministic, provable per finding. Advisory.

  • `debug` at line 219 is called with an argument built by `Arrays.toString(mechs)` (line 220), whose cost grows with the collection it walks. Java evaluates a call's arguments BEFORE entering the method, so that join/projection runs in full every time this line is reached — and then the level check inside the logger discards the string it produced, because debug is a level a shipped configuration normally leaves off. Nothing here decides beforehand whether the message is wanted: no `isDebugEnabled`/`isTraceEnabled` test, no debug flag, no lambda or `Supplier` the logger calls only when the level is on. — clients/src/main/java/org/apache/kafka/common/security/authenticator/SaslClientAuthenticator.java:219
  • `debug` at line 331 is called with an argument built by `String.join("…", topics)` (line 331), whose cost grows with the collection it walks. Java evaluates a call's arguments BEFORE entering the method, so that join/projection runs in full every time this line is reached — and then the level check inside the logger discards the string it produced, because debug is a level a shipped configuration normally leaves off. Nothing here decides beforehand whether the message is wanted: no `isDebugEnabled`/`isTraceEnabled` test, no debug flag, no lambda or `Supplier` the logger calls only when the level is on. — connect/runtime/src/main/java/org/apache/kafka/connect/runtime/WorkerSinkTask.java:331
  • `debug` at line 479 is called with an argument built by `candidateWorkerLoad.stream()` (line 481), whose cost grows with the collection it walks. Java evaluates a call's arguments BEFORE entering the method, so that join/projection runs in full every time this line is reached — and then the level check inside the logger discards the string it produced, because debug is a level a shipped configuration normally leaves off. Nothing here decides beforehand whether the message is wanted: no `isDebugEnabled`/`isTraceEnabled` test, no debug flag, no lambda or `Supplier` the logger calls only when the level is on. — connect/runtime/src/main/java/org/apache/kafka/connect/runtime/distributed/IncrementalCooperativeAssignor.java:479
  • `debug` at line 88 is called with an argument built by `stream()` (line 89), whose cost grows with the collection it walks. Java evaluates a call's arguments BEFORE entering the method, so that join/projection runs in full every time this line is reached — and then the level check inside the logger discards the string it produced, because debug is a level a shipped configuration normally leaves off. Nothing here decides beforehand whether the message is wanted: no `isDebugEnabled`/`isTraceEnabled` test, no debug flag, no lambda or `Supplier` the logger calls only when the level is on. — group-coordinator/src/main/java/org/apache/kafka/coordinator/group/streams/topics/ChangelogTopics.java:88
  • `trace` at line 306 is called with an argument built by `Arrays.toString(partition.lastKnownElr)` (line 307), whose cost grows with the collection it walks. Java evaluates a call's arguments BEFORE entering the method, so that join/projection runs in full every time this line is reached — and then the level check inside the logger discards the string it produced, because trace is a level a shipped configuration normally leaves off. Nothing here decides beforehand whether the message is wanted: no `isDebugEnabled`/`isTraceEnabled` test, no debug flag, no lambda or `Supplier` the logger calls only when the level is on. — metadata/src/main/java/org/apache/kafka/controller/PartitionChangeBuilder.java:306
  • `debug` at line 160 is called with an argument built by `Arrays.stream(partition.replicas)` (line 160), whose cost grows with the collection it walks. Java evaluates a call's arguments BEFORE entering the method, so that join/projection runs in full every time this line is reached — and then the level check inside the logger discards the string it produced, because debug is a level a shipped configuration normally leaves off. Nothing here decides beforehand whether the message is wanted: no `isDebugEnabled`/`isTraceEnabled` test, no debug flag, no lambda or `Supplier` the logger calls only when the level is on. — metadata/src/main/java/org/apache/kafka/metadata/KRaftMetadataCache.java:160
  • `debug` at line 163 is called with an argument built by `Arrays.stream(partition.isr)` (line 163), whose cost grows with the collection it walks. Java evaluates a call's arguments BEFORE entering the method, so that join/projection runs in full every time this line is reached — and then the level check inside the logger discards the string it produced, because debug is a level a shipped configuration normally leaves off. Nothing here decides beforehand whether the message is wanted: no `isDebugEnabled`/`isTraceEnabled` test, no debug flag, no lambda or `Supplier` the logger calls only when the level is on. — metadata/src/main/java/org/apache/kafka/metadata/KRaftMetadataCache.java:163
  • `debug` at line 326 is called with an argument built by `Arrays.stream(targetStates)` (line 328), whose cost grows with the collection it walks. Java evaluates a call's arguments BEFORE entering the method, so that join/projection runs in full every time this line is reached — and then the level check inside the logger discards the string it produced, because debug is a level a shipped configuration normally leaves off. Nothing here decides beforehand whether the message is wanted: no `isDebugEnabled`/`isTraceEnabled` test, no debug flag, no lambda or `Supplier` the logger calls only when the level is on. — streams/src/main/java/org/apache/kafka/streams/KafkaStreams.java:326
  • `debug` at line 176 is called with an argument built by `stream()` (line 176), whose cost grows with the collection it walks. Java evaluates a call's arguments BEFORE entering the method, so that join/projection runs in full every time this line is reached — and then the level check inside the logger discards the string it produced, because debug is a level a shipped configuration normally leaves off. Nothing here decides beforehand whether the message is wanted: no `isDebugEnabled`/`isTraceEnabled` test, no debug flag, no lambda or `Supplier` the logger calls only when the level is on. — streams/src/main/java/org/apache/kafka/streams/processor/internals/TaskExecutor.java:176
  • `debug` at line 141 is called with an argument built by `String.join("…", args)` (line 141), whose cost grows with the collection it walks. Java evaluates a call's arguments BEFORE entering the method, so that join/projection runs in full every time this line is reached — and then the level check inside the logger discards the string it produced, because debug is a level a shipped configuration normally leaves off. Nothing here decides beforehand whether the message is wanted: no `isDebugEnabled`/`isTraceEnabled` test, no debug flag, no lambda or `Supplier` the logger calls only when the level is on. — tools/src/main/java/org/apache/kafka/tools/ConfigCommand.java:141
  • `debug` at line 145 is called with an argument built by `String.join("…", args)` (line 145), whose cost grows with the collection it walks. Java evaluates a call's arguments BEFORE entering the method, so that join/projection runs in full every time this line is reached — and then the level check inside the logger discards the string it produced, because debug is a level a shipped configuration normally leaves off. Nothing here decides beforehand whether the message is wanted: no `isDebugEnabled`/`isTraceEnabled` test, no debug flag, no lambda or `Supplier` the logger calls only when the level is on. — tools/src/main/java/org/apache/kafka/tools/ConfigCommand.java:145
  • `debug` at line 149 is called with an argument built by `String.join("…", args)` (line 149), whose cost grows with the collection it walks. Java evaluates a call's arguments BEFORE entering the method, so that join/projection runs in full every time this line is reached — and then the level check inside the logger discards the string it produced, because debug is a level a shipped configuration normally leaves off. Nothing here decides beforehand whether the message is wanted: no `isDebugEnabled`/`isTraceEnabled` test, no debug flag, no lambda or `Supplier` the logger calls only when the level is on. — tools/src/main/java/org/apache/kafka/tools/ConfigCommand.java:149

What to do

  • In Java, put the construction behind the logger's own check (`if (log.isDebugEnabled())` for SLF4J and Log4j, `if (logger.isLoggable(Level.FINE))` for java.util.logging), or hand the logger a lambda it calls only when the level is on (Log4j 2's `Supplier` overloads, SLF4J 2's `log.atDebug().addArgument(() -> …)`). A `{}` placeholder alone is not the fix: it defers the formatting, not the stream, join or serialisation in the argument.
X24 · Document value interpolated into markup unescaped10.0 / 10Exemplary○ Nothing flagged

Other · Security — Whether text read out of the document being converted is escaped before it is written into generated markup — a value the document's author chose, interpolated into an attribute the surrounding literal delimits, can close that attribute and open another.

Method: Roslyn semantic model over the whole compilation: a string-typed `Value`/`InnerText`/`InnerXml`/`Text` member declared inside `DocumentFormat.OpenXml` or `System.Xml` is a taint SOURCE, propagated through assignments, returns, arguments, tuple elements and string composition to its transitive closure, then read at interpolated-string holes that sit in a markup position the surrounding literal itself delimits. Escaper/encoder calls and enclosing validator conditions cut the flow. Flow- and container-insensitive by construction. A second arm needs no provenance at all and reports a type that CONTRADICTS ITSELF — the same expression escaped at one delimited markup hole and interpolated raw at another hole in the same markup position of the same type, which the type's own escaping proves is a defect without knowing where the value came from. On a repository with no .NET source it reads JavaScript/TypeScript off the token stream with the same rule: a DOM read of raw document text (`getAttribute`, `textContent`, `innerText`, `nodeValue`) is the source, propagated through local bindings and string composition, and judged at template-literal and concatenation holes in the same two delimited markup positions; escapers and validating conditions cut it, and documentation-site, test, vendored and minified scripts are not read. Deterministic, provable per finding. Advisory.

X25 · Inert configuration knob10.0 / 10Exemplary○ Nothing flagged

Other · Code Health — Whether a value the caller is invited to supply is the value the type actually uses — a constructor parameter stored in a private field that nothing ever reads while the default it was given is spelled out a second time at the site that should have read it, a keyed lookup that falls back to a different setting than the one its key names while the same type falls back to the matching one for that same key, or a culture-sensitive parse given no format provider by a type that feeds its own settable culture to the same kind of parse elsewhere, or a number an entry point writes to standard output under the host's culture while the same entry point formats with the invariant culture elsewhere. Either way, every caller who supplies a value silently gets something else.

Method: Roslyn syntax: private instance fields of a non-partial type assigned in a constructor from one of its own parameters with a `??` fallback, checked for whether anything in the type body reads the field and whether that same fallback expression is spelled out again outside the constructor; and `??` fallbacks onto a member access from a lookup call carrying exactly one string literal, grouped by that key across the type and checked for a fallback member whose folded name disagrees with the key while a sibling site for the same key agrees with it. On a repository with no .NET source the first two arms read JavaScript/TypeScript off the engine’s own token stream (tests included, bundles and vendored paths not): a `#x`, `private` or `private` parameter-property instance field filled in the constructor from a parameter (or one member of one) through `??`/`||` or a parameter default, never read anywhere in the file by name, whose constructed default is spelled again in the class body; and `lookup("key") ?? s.member` grouped by key per class, or per module outside every class. The culture arm has no JavaScript counterpart: its parses take no locale. Deterministic, provable per finding. Advisory.

X26 · Unsynchronised callback handoff10.0 / 10Exemplary○ Nothing flagged

Other · Code Health — Whether a value handed from a callback to the body that waits on it crosses on something built to be crossed — a `Queue<T>`/`List<T>`/`Dictionary<K,V>` written inside an event handler and read back outside it is mutated by two flows at once, and the semaphore or completion source beside it orders how MANY items exist while leaving the collection's own head, tail and backing array unprotected.

Method: Roslyn syntax: method, accessor, local-function and lambda bodies that declare BOTH a non-thread-safe generic collection (`Queue`/`Stack`/`List`/`Dictionary`/`HashSet`/`Sorted*`/`LinkedList`) and a synchronisation primitive (`SemaphoreSlim`/`TaskCompletionSource`/`ManualResetEvent(Slim)`/`AutoResetEvent`/`CountdownEvent`) as locals, then read for a `+=`-registered lambda that raises that primitive while the body outside every lambda waits on it — and, in that scope, a mutating call on the collection inside the lambda paired with a mention of it outside. Any `lock` in the scope abstains it. On a repository with no .NET source the same handoff is read in Java off the engine’s own token stream (test source sets, vendored and demonstration paths not): an `ArrayList`/`LinkedList`/`ArrayDeque`/`PriorityQueue`/`Hash*`/`LinkedHash*`/`Tree*` local and a `CountDownLatch`/`Semaphore`/`CompletableFuture` local, a lambda or anonymous class that raises the primitive and mutates the collection, and a wait outside it; any `synchronized` or `lock()` abstains the body. Because each of those primitives orders what the callback wrote before raising it, only a touch that provably overlaps the callback is convicted: one after the registration and before the next wait, or one in a loop registered-before, waiting on every pass and not declaring the collection. Deterministic, provable per finding. Advisory.

X27 · Collection changed while being enumerated10.0 / 10Exemplary○ Nothing flagged

Other · Code Health — Whether an enhanced `for` leaves the collection it is walking alone — a body that adds to or removes from the very collection the loop is iterating invalidates the fail-fast iterator it is holding, so the next `next()` throws `ConcurrentModificationException` and the remaining elements are never seen. Whether a `for` loop leaves the `dict`, `set` or `deque` it is walking alone — CPython's iterators over those check that the collection has not changed size since the loop began, so a body that removes from (or empties) the very collection the loop is walking makes the next step raise `RuntimeError: dictionary changed size during iteration` and the remaining items are never seen. Whether a `for` comprehension or `foreach` leaves the mutable collection it is walking alone — an `ArrayBuffer` or `ListBuffer` counts its changes and its iterator checks the count, an `ArrayDeque` (and `mutable.Queue`/`mutable.Stack`) is walked by index up to its starting length, and a `java.util` collection walked through `asScala` is fail-fast, so a body that adds to or removes from the very collection the loop is walking makes a later step throw `ConcurrentModificationException` (`IndexOutOfBoundsException` for a deque) and the remaining elements are never seen.

Method: Roslyn syntax + semantics: `foreach` statements whose body calls a structural mutator (`Add`/`Remove`/`Clear`/`Insert`/…) on the very expression the loop is enumerating. Two arms. ARM A — the source is a concrete fragile BCL collection, or a live `Keys`/`Values` view over one, and the mutator resolves to that same collection's own member; concurrent and immutable collections and arrays are outside the population by construction, since their enumerators survive a structural change. ARM B — the source is an argument-less accessor CALL on a receiver whose body is in source: the accessor must return a stored field VERBATIM and a sibling member must structurally change that same field, both read off the implementations rather than from the members' names. A mutation the loop provably exits immediately after (`break`/`return`/`throw`/`goto`), or one written inside a nested loop or a lambda, is counted and never reported. Deterministic, provable per finding. Advisory.

X28 · Index access outside its own emptiness guard10.0 / 10Exemplary○ Nothing flagged

Other · Code Health — Whether a condition that tests a value for emptiness indexes that same value only where the test holds — an `||` written one parenthesis too far to the left leaves an index access outside the guard beside it, so the empty case the guard exists to anticipate reaches the index and throws.

Method: Roslyn syntax only, no semantic model: the OUTERMOST `&&`/`||` of every boolean condition, read for a symbol the condition tests for emptiness (`string.IsNullOrEmpty`/`IsNullOrWhiteSpace`, a `Length`/`Count` comparison against a literal, `Any()`, a `Length`/`Count` pattern, or a comparison against `""`) and ALSO indexes. Each `symbol[...]` access is placed by a boolean-reachability walk from the access up to the outermost connective: an access is COVERED when some enclosing step has it in the right operand and the left operand, under the truth value that step forces, proves the symbol non-empty — a recursion over `&&`/`||` whose true- and false-directions are asymmetric. A finding needs BOTH an uncovered access and a covered one on the same symbol in the same condition, which is the agreeing twin that separates a misplaced parenthesis from an unrelated length test. Bare index accesses with no emptiness test in the condition are neither counted nor reported; a non-identifier receiver and a lambda nested inside the condition are outside the population. Deterministic, provable per finding. Advisory.

X29 · Per-element action decided by a fixed element10.0 / 10Exemplary○ Nothing flagged

Other · Code Health — Whether a decision taken once per element is taken ABOUT that element — a test inside a counted loop that reads a fixed subscript of the very collection its guarded statement indexes by the loop variable applies element zero's answer to all of them, so the elements that differ from it are all handled wrongly, and in the same direction.

Method: Roslyn syntax only, no semantic model: every `for` statement declaring exactly ONE loop variable, and every `if` inside its body that is not under a nested loop or a lambda. A site enters the population when the `if`’s condition never mentions the loop variable while the statement it guards indexes some collection by that variable ALONE (`c[i]`; `c[i + 1]` and `c[i, j]` are outside it). A finding additionally needs the AGREEING TWIN at the same-collection grain: the condition must read THAT SAME collection at a subscript that does not move — written into the condition, or reached through a local declared BEFORE the loop, so an alias bound inside the body is not followed. Both collection expressions must be simple identifiers. On a repository with no .NET source the same rule reads JavaScript/TypeScript off the engine’s own token stream (tests included, bundles and vendored paths not): a `for (let|var|const x = …; …; …)` with one declarator and a braced body, an alias followed only when it is declared before the loop in a block that encloses it and never assigned inside the loop. Deterministic, provable per finding. Advisory.

X3 · Exception handling7.9 / 10Strong✓ Tool-verified

Other · Code Health — Whether exceptions are handled rather than silently swallowed or rethrown with lost stack traces.

Method: Roslyn syntax scan: every catch clause counted; empty catches and bare rethrows flagged. Population is all catch clauses, not estimated. Deterministic, hard fact.

  • `catch (Exception)` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter. (×5) — clients/src/main/java/org/apache/kafka/common/network/SaslChannelBuilder.java:158, clients/src/main/java/org/apache/kafka/common/security/kerberos/KerberosError.java:73, metadata/src/main/java/org/apache/kafka/image/node/TopicsImageByIdNode.java:57, …
  • An empty catch block silently discards the error — failures vanish with no log and no rethrow. On a teardown path letting it propagate is not an option (throwing out of `close()` masks the failure already in flight and abandons the rest of the cleanup), so make the swallow deliberate instead: narrow the catch to the exception this release can actually raise, and record it through whatever this codebase already uses to report problems — or, if it truly cannot matter, say why in a comment on the catch. — clients/src/main/java/org/apache/kafka/common/security/ssl/SslFactory.java:531
  • `case _: Exception` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter. — core/src/main/scala/kafka/server/DynamicBrokerConfig.scala:380
  • An empty catch block silently discards the error — failures vanish with no log and no rethrow. Log it, handle it, or don't catch it. (×2) — jmh-benchmarks/src/main/java/org/apache/kafka/jmh/connect/ValuesBenchmark.java:140, jmh-benchmarks/src/main/java/org/apache/kafka/jmh/connect/ValuesBenchmark.java:153
  • `except Exception` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter. — release/gpg.py:35
  • `catch (Throwable)` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter. — tools/src/main/java/org/apache/kafka/tools/FeatureCommand.java:232

What to do

  • Swallowed exception (caught, then discarded)
X30 · Support guard that admits what it rejects10.0 / 10Exemplary○ Nothing flagged

Other · Code Health — Whether a guard written as a NEGATED `||` says what its author meant — `!(a || b || x != k)` is `!a && !b && x == k` by De Morgan, so a bail-out that mixes capabilities the code needs with a fault it refuses turns inside out: it fires only where the capabilities are ABSENT, and lets every value the fault term names walk straight into the body that cannot handle it.

Method: Roslyn syntax only, no semantic model: every logical-not whose operand is a parenthesised `||` chain of two or more disjuncts, flattened (a left-nested `a || b || c` read once would see `(a || b)` as one disjunct). A site enters the population on that shape alone. A finding additionally needs the disjuncts to DISAGREE in polarity: at least one bare boolean read — an identifier or member access, never an invocation, which is a predicate rather than a capability flag — and at least one `x != <constant>`, the only form that negates into an exact-value pin (`== null` negates into a looser requirement and is outside the fault set). Consistently-polarised disjunctions, all-fault or all-capability, are counted and never reported; a negated `&&` is outside the population entirely. No same-receiver gate: it was measured to cost a real defect and remove no false positive. Deterministic, provable per finding. Advisory.

X4 · Structured logging7.6 / 10Strong✓ Tool-verified

Other · Code Health — Whether log calls use message templates (queryable) rather than interpolated strings.

Method: Roslyn syntax scan: every log call-site counted; interpolated-string first-argument violations flagged. Population is all log calls, not estimated. On a repository with no .NET source it reads JavaScript/TypeScript off the engine’s own token stream (test, vendored and minified paths not) with the same rule: a `trace`/`debug`/`info`/`warn`/`error`/`fatal`/`verbose`/`silly`/`http`/`log` call on a receiver named for a logger, in a package whose own or an enclosing `package.json` declares a logger that carries values as fields (pino, pino-http, nestjs-pino, Fastify, winston, bunyan, tslog, LogTape, roarr), whose first deciding argument is a template literal with substitutions; an object-literal fields argument is stepped over, a plain string message clears the call. Python is read the same way: a `debug`/`info`/`warning`/`error`/`exception`/`critical`/`log` call on a logger in a file that imports the standard library’s `logging` or structlog (loguru, which formats at the call, is not judged), whose message is a whole f-string with a non-constant field; a `%`-formatted, `.format()`-ed or concatenated message is not convicted, as in C#. PHP is read the same way: a PSR-3 level call (`emergency`…`debug`, `log`) on a logger (`$logger`, `$this->logger`, Laravel’s `Log::`, `logger()`, `\Drupal::logger()`) in a package whose `composer.json` requires a PSR-3 logger or a framework that hands one out (psr/log, Monolog, Laravel, Symfony, Drupal, CakePHP), or a file that imports one, whose message is a double-quoted string interpolating a variable; a single-quoted message clears the call, and `sprintf` or `.` concatenation is not convicted, as in C#. Dart is read the same way: a `trace`/`debug`/`info`/`warn`/`error`/`fatal` call on Sentry’s structured logger (`Sentry.logger`) whose message is a whole string literal interpolating a value (`$name`, `${…}`); the `Sentry.logger.fmt` template API clears the call. Dart that logs only through loggers with one message and no fields (package:logging, package:logger, talker, dart:developer) is not applicable rather than a reach gap. Ruby is read the same way: a `trace`/`debug`/`info`/`warn`/`error`/`fatal` call on the console gem’s `Console` (declared by a Gemfile, gemspec or Gemfile.lock, or required) or, where SemanticLogger, Ougai or dry-logger is declared or required, on a receiver named for a logger (`logger`, `@logger`, `Rails.logger`, `log`), whose first deciding argument is, as the whole argument, a double-quoted string interpolating a non-constant value (`#{…}`, `#@ivar`); a plain literal clears the call, keyword arguments are the fields, and a block, `%`-format or `+` concatenation is not convicted. Ruby that logs only through the standard Logger (Rails.logger) is not applicable rather than a reach gap. Deterministic.

  • `info` at line 74 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.info("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `log.info("order moved", order_id=order_id, status=status)` with structlog. — committer-tools/refresh_collaborators.py:74
  • `info` at line 100 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.info("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `log.info("order moved", order_id=order_id, status=status)` with structlog. — committer-tools/refresh_collaborators.py:100
  • `info` at line 111 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.info("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `log.info("order moved", order_id=order_id, status=status)` with structlog. — committer-tools/refresh_collaborators.py:111
  • `info` at line 131 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.info("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `log.info("order moved", order_id=order_id, status=status)` with structlog. — committer-tools/refresh_collaborators.py:131
  • `error` at line 150 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.error("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `log.error("order moved", order_id=order_id, status=status)` with structlog. — committer-tools/refresh_collaborators.py:150
  • `warn` at line 114 is handed a message assembled at the call — a string concatenated with a value, or `String.format` — through SLF4J or log4j 2, so the logger receives one finished string: the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the level is filtered out. Pass a constant pattern and the values beside it instead: `log.warn("Order {} moved to {}", orderId, status)`, which keeps the pattern and its arguments apart on the event for a structured encoder (logstash-logback-encoder, log4j 2's JsonTemplateLayout, OpenTelemetry), or `log.atInfo().addKeyValue("order_id", orderId).log("order moved")` with SLF4J 2's fluent API. An exception goes last, as the throwable argument, not into the text. — clients/src/main/java/org/apache/kafka/common/security/oauthbearer/internals/expiring/ExpiringCredentialRefreshingLogin.java:114
  • `info` at line 164 is handed a message assembled at the call — a string concatenated with a value, or `String.format` — through SLF4J or log4j 2, so the logger receives one finished string: the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the level is filtered out. Pass a constant pattern and the values beside it instead: `log.info("Order {} moved to {}", orderId, status)`, which keeps the pattern and its arguments apart on the event for a structured encoder (logstash-logback-encoder, log4j 2's JsonTemplateLayout, OpenTelemetry), or `log.atInfo().addKeyValue("order_id", orderId).log("order moved")` with SLF4J 2's fluent API. An exception goes last, as the throwable argument, not into the text. — clients/src/main/java/org/apache/kafka/common/security/ssl/CommonNameLoggingTrustManagerFactoryWrapper.java:164
  • `info` at line 261 is handed a message assembled at the call — a string concatenated with a value, or `String.format` — through SLF4J or log4j 2, so the logger receives one finished string: the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the level is filtered out. Pass a constant pattern and the values beside it instead: `log.info("Order {} moved to {}", orderId, status)`, which keeps the pattern and its arguments apart on the event for a structured encoder (logstash-logback-encoder, log4j 2's JsonTemplateLayout, OpenTelemetry), or `log.atInfo().addKeyValue("order_id", orderId).log("order moved")` with SLF4J 2's fluent API. An exception goes last, as the throwable argument, not into the text. — metadata/src/main/java/org/apache/kafka/image/loader/MetadataLoader.java:261
  • `info` at line 266 is handed a message assembled at the call — a string concatenated with a value, or `String.format` — through SLF4J or log4j 2, so the logger receives one finished string: the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the level is filtered out. Pass a constant pattern and the values beside it instead: `log.info("Order {} moved to {}", orderId, status)`, which keeps the pattern and its arguments apart on the event for a structured encoder (logstash-logback-encoder, log4j 2's JsonTemplateLayout, OpenTelemetry), or `log.atInfo().addKeyValue("order_id", orderId).log("order moved")` with SLF4J 2's fluent API. An exception goes last, as the throwable argument, not into the text. — metadata/src/main/java/org/apache/kafka/image/loader/MetadataLoader.java:266
  • `debug` at line 221 is handed a message assembled at the call — a string concatenated with a value, or `String.format` — through SLF4J or log4j 2, so the logger receives one finished string: the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the level is filtered out. Pass a constant pattern and the values beside it instead: `log.debug("Order {} moved to {}", orderId, status)`, which keeps the pattern and its arguments apart on the event for a structured encoder (logstash-logback-encoder, log4j 2's JsonTemplateLayout, OpenTelemetry), or `log.atInfo().addKeyValue("order_id", orderId).log("order moved")` with SLF4J 2's fluent API. An exception goes last, as the throwable argument, not into the text. — shell/src/main/java/org/apache/kafka/shell/MetadataShell.java:221
  • `error` at line 225 is handed a message assembled at the call — a string concatenated with a value, or `String.format` — through SLF4J or log4j 2, so the logger receives one finished string: the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the level is filtered out. Pass a constant pattern and the values beside it instead: `log.error("Order {} moved to {}", orderId, status)`, which keeps the pattern and its arguments apart on the event for a structured encoder (logstash-logback-encoder, log4j 2's JsonTemplateLayout, OpenTelemetry), or `log.atInfo().addKeyValue("order_id", orderId).log("order moved")` with SLF4J 2's fluent API. An exception goes last, as the throwable argument, not into the text. — shell/src/main/java/org/apache/kafka/shell/MetadataShell.java:225
  • `trace` at line 99 is handed a message assembled at the call — a string concatenated with a value, or `String.format` — through SLF4J or log4j 2, so the logger receives one finished string: the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the level is filtered out. Pass a constant pattern and the values beside it instead: `log.trace("Order {} moved to {}", orderId, status)`, which keeps the pattern and its arguments apart on the event for a structured encoder (logstash-logback-encoder, log4j 2's JsonTemplateLayout, OpenTelemetry), or `log.atInfo().addKeyValue("order_id", orderId).log("order moved")` with SLF4J 2's fluent API. An exception goes last, as the throwable argument, not into the text. (×2) — shell/src/main/java/org/apache/kafka/shell/command/TreeCommandHandler.java:99, shell/src/main/java/org/apache/kafka/shell/command/CatCommandHandler.java:99
  • `debug` at line 140 is handed a message assembled at the call — a string concatenated with a value, or `String.format` — through SLF4J or log4j 2, so the logger receives one finished string: the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the level is filtered out. Pass a constant pattern and the values beside it instead: `log.debug("Order {} moved to {}", orderId, status)`, which keeps the pattern and its arguments apart on the event for a structured encoder (logstash-logback-encoder, log4j 2's JsonTemplateLayout, OpenTelemetry), or `log.atInfo().addKeyValue("order_id", orderId).log("order moved")` with SLF4J 2's fluent API. An exception goes last, as the throwable argument, not into the text. — shell/src/main/java/org/apache/kafka/shell/glob/GlobComponent.java:140
  • `debug` at line 2128 is handed a message assembled at the call — a string concatenated with a value, or `String.format` — through SLF4J or log4j 2, so the logger receives one finished string: the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the level is filtered out. Pass a constant pattern and the values beside it instead: `log.debug("Order {} moved to {}", orderId, status)`, which keeps the pattern and its arguments apart on the event for a structured encoder (logstash-logback-encoder, log4j 2's JsonTemplateLayout, OpenTelemetry), or `log.atInfo().addKeyValue("order_id", orderId).log("order moved")` with SLF4J 2's fluent API. An exception goes last, as the throwable argument, not into the text. — streams/src/main/java/org/apache/kafka/streams/KafkaStreams.java:2128
  • `debug` at line 942 is handed a message assembled at the call — a string concatenated with a value, or `String.format` — through SLF4J or log4j 2, so the logger receives one finished string: the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the level is filtered out. Pass a constant pattern and the values beside it instead: `log.debug("Order {} moved to {}", orderId, status)`, which keeps the pattern and its arguments apart on the event for a structured encoder (logstash-logback-encoder, log4j 2's JsonTemplateLayout, OpenTelemetry), or `log.atInfo().addKeyValue("order_id", orderId).log("order moved")` with SLF4J 2's fluent API. An exception goes last, as the throwable argument, not into the text. — streams/src/main/java/org/apache/kafka/streams/processor/internals/TaskManager.java:942
  • `error` at line 107 is handed a message assembled at the call — a string concatenated with a value, or `String.format` — through SLF4J or log4j 2, so the logger receives one finished string: the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the level is filtered out. Pass a constant pattern and the values beside it instead: `log.error("Order {} moved to {}", orderId, status)`, which keeps the pattern and its arguments apart on the event for a structured encoder (logstash-logback-encoder, log4j 2's JsonTemplateLayout, OpenTelemetry), or `log.atInfo().addKeyValue("order_id", orderId).log("order moved")` with SLF4J 2's fluent API. An exception goes last, as the throwable argument, not into the text. — streams/src/main/java/org/apache/kafka/streams/processor/internals/TaskExecutor.java:107
  • `error` at line 118 is handed a message assembled at the call — a string concatenated with a value, or `String.format` — through SLF4J or log4j 2, so the logger receives one finished string: the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the level is filtered out. Pass a constant pattern and the values beside it instead: `log.error("Order {} moved to {}", orderId, status)`, which keeps the pattern and its arguments apart on the event for a structured encoder (logstash-logback-encoder, log4j 2's JsonTemplateLayout, OpenTelemetry), or `log.atInfo().addKeyValue("order_id", orderId).log("order moved")` with SLF4J 2's fluent API. An exception goes last, as the throwable argument, not into the text. — streams/src/main/java/org/apache/kafka/streams/processor/internals/TaskExecutor.java:118
  • `error` at line 122 is handed a message assembled at the call — a string concatenated with a value, or `String.format` — through SLF4J or log4j 2, so the logger receives one finished string: the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the level is filtered out. Pass a constant pattern and the values beside it instead: `log.error("Order {} moved to {}", orderId, status)`, which keeps the pattern and its arguments apart on the event for a structured encoder (logstash-logback-encoder, log4j 2's JsonTemplateLayout, OpenTelemetry), or `log.atInfo().addKeyValue("order_id", orderId).log("order moved")` with SLF4J 2's fluent API. An exception goes last, as the throwable argument, not into the text. — streams/src/main/java/org/apache/kafka/streams/processor/internals/TaskExecutor.java:122
  • `error` at line 189 is handed a message assembled at the call — a string concatenated with a value, or `String.format` — through SLF4J or log4j 2, so the logger receives one finished string: the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the level is filtered out. Pass a constant pattern and the values beside it instead: `log.error("Order {} moved to {}", orderId, status)`, which keeps the pattern and its arguments apart on the event for a structured encoder (logstash-logback-encoder, log4j 2's JsonTemplateLayout, OpenTelemetry), or `log.atInfo().addKeyValue("order_id", orderId).log("order moved")` with SLF4J 2's fluent API. An exception goes last, as the throwable argument, not into the text. — streams/src/main/java/org/apache/kafka/streams/processor/internals/TaskExecutor.java:189
  • `error` at line 216 is handed a message assembled at the call — a string concatenated with a value, or `String.format` — through SLF4J or log4j 2, so the logger receives one finished string: the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the level is filtered out. Pass a constant pattern and the values beside it instead: `log.error("Order {} moved to {}", orderId, status)`, which keeps the pattern and its arguments apart on the event for a structured encoder (logstash-logback-encoder, log4j 2's JsonTemplateLayout, OpenTelemetry), or `log.atInfo().addKeyValue("order_id", orderId).log("order moved")` with SLF4J 2's fluent API. An exception goes last, as the throwable argument, not into the text. — streams/src/main/java/org/apache/kafka/streams/processor/internals/TaskExecutor.java:216
  • `warn` at line 1016 is handed a message assembled at the call — a string concatenated with a value, or `String.format` — through SLF4J or log4j 2, so the logger receives one finished string: the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the level is filtered out. Pass a constant pattern and the values beside it instead: `log.warn("Order {} moved to {}", orderId, status)`, which keeps the pattern and its arguments apart on the event for a structured encoder (logstash-logback-encoder, log4j 2's JsonTemplateLayout, OpenTelemetry), or `log.atInfo().addKeyValue("order_id", orderId).log("order moved")` with SLF4J 2's fluent API. An exception goes last, as the throwable argument, not into the text. — streams/src/main/java/org/apache/kafka/streams/processor/internals/StreamThread.java:1016
  • `debug` at line 1792 is handed a message assembled at the call — a string concatenated with a value, or `String.format` — through SLF4J or log4j 2, so the logger receives one finished string: the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the level is filtered out. Pass a constant pattern and the values beside it instead: `log.debug("Order {} moved to {}", orderId, status)`, which keeps the pattern and its arguments apart on the event for a structured encoder (logstash-logback-encoder, log4j 2's JsonTemplateLayout, OpenTelemetry), or `log.atInfo().addKeyValue("order_id", orderId).log("order moved")` with SLF4J 2's fluent API. An exception goes last, as the throwable argument, not into the text. — streams/src/main/java/org/apache/kafka/streams/processor/internals/StreamThread.java:1792
  • `debug` at line 1478 is handed a message assembled at the call — a string concatenated with a value, or `String.format` — through SLF4J or log4j 2, so the logger receives one finished string: the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the level is filtered out. Pass a constant pattern and the values beside it instead: `log.debug("Order {} moved to {}", orderId, status)`, which keeps the pattern and its arguments apart on the event for a structured encoder (logstash-logback-encoder, log4j 2's JsonTemplateLayout, OpenTelemetry), or `log.atInfo().addKeyValue("order_id", orderId).log("order moved")` with SLF4J 2's fluent API. An exception goes last, as the throwable argument, not into the text. — streams/src/main/java/org/apache/kafka/streams/processor/internals/StreamTask.java:1478
  • `warn` at line 555 is handed a message assembled at the call — a string concatenated with a value, or `String.format` — through SLF4J or log4j 2, so the logger receives one finished string: the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the level is filtered out. Pass a constant pattern and the values beside it instead: `log.warn("Order {} moved to {}", orderId, status)`, which keeps the pattern and its arguments apart on the event for a structured encoder (logstash-logback-encoder, log4j 2's JsonTemplateLayout, OpenTelemetry), or `log.atInfo().addKeyValue("order_id", orderId).log("order moved")` with SLF4J 2's fluent API. An exception goes last, as the throwable argument, not into the text. — streams/src/main/java/org/apache/kafka/streams/processor/internals/StoreChangelogReader.java:555
  • `warn` at line 169 is handed a message assembled at the call — a string concatenated with a value, or `String.format` — through SLF4J or log4j 2, so the logger receives one finished string: the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the level is filtered out. Pass a constant pattern and the values beside it instead: `log.warn("Order {} moved to {}", orderId, status)`, which keeps the pattern and its arguments apart on the event for a structured encoder (logstash-logback-encoder, log4j 2's JsonTemplateLayout, OpenTelemetry), or `log.atInfo().addKeyValue("order_id", orderId).log("order moved")` with SLF4J 2's fluent API. An exception goes last, as the throwable argument, not into the text. — streams/src/main/java/org/apache/kafka/streams/processor/internals/StateDirectory.java:169
  • `error` at line 581 is handed a message assembled at the call — a string concatenated with a value, or `String.format` — through SLF4J or log4j 2, so the logger receives one finished string: the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the level is filtered out. Pass a constant pattern and the values beside it instead: `log.error("Order {} moved to {}", orderId, status)`, which keeps the pattern and its arguments apart on the event for a structured encoder (logstash-logback-encoder, log4j 2's JsonTemplateLayout, OpenTelemetry), or `log.atInfo().addKeyValue("order_id", orderId).log("order moved")` with SLF4J 2's fluent API. An exception goes last, as the throwable argument, not into the text. — streams/src/main/java/org/apache/kafka/streams/processor/internals/StateDirectory.java:581
  • `error` at line 628 is handed a message assembled at the call — a string concatenated with a value, or `String.format` — through SLF4J or log4j 2, so the logger receives one finished string: the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the level is filtered out. Pass a constant pattern and the values beside it instead: `log.error("Order {} moved to {}", orderId, status)`, which keeps the pattern and its arguments apart on the event for a structured encoder (logstash-logback-encoder, log4j 2's JsonTemplateLayout, OpenTelemetry), or `log.atInfo().addKeyValue("order_id", orderId).log("order moved")` with SLF4J 2's fluent API. An exception goes last, as the throwable argument, not into the text. — streams/src/main/java/org/apache/kafka/streams/processor/internals/StateDirectory.java:628
  • `warn` at line 670 is handed a message assembled at the call — a string concatenated with a value, or `String.format` — through SLF4J or log4j 2, so the logger receives one finished string: the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the level is filtered out. Pass a constant pattern and the values beside it instead: `log.warn("Order {} moved to {}", orderId, status)`, which keeps the pattern and its arguments apart on the event for a structured encoder (logstash-logback-encoder, log4j 2's JsonTemplateLayout, OpenTelemetry), or `log.atInfo().addKeyValue("order_id", orderId).log("order moved")` with SLF4J 2's fluent API. An exception goes last, as the throwable argument, not into the text. — streams/src/main/java/org/apache/kafka/streams/processor/internals/StateDirectory.java:670
  • `warn` at line 750 is handed a message assembled at the call — a string concatenated with a value, or `String.format` — through SLF4J or log4j 2, so the logger receives one finished string: the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the level is filtered out. Pass a constant pattern and the values beside it instead: `log.warn("Order {} moved to {}", orderId, status)`, which keeps the pattern and its arguments apart on the event for a structured encoder (logstash-logback-encoder, log4j 2's JsonTemplateLayout, OpenTelemetry), or `log.atInfo().addKeyValue("order_id", orderId).log("order moved")` with SLF4J 2's fluent API. An exception goes last, as the throwable argument, not into the text. — streams/src/main/java/org/apache/kafka/streams/processor/internals/StateDirectory.java:750
  • `error` at line 756 is handed a message assembled at the call — a string concatenated with a value, or `String.format` — through SLF4J or log4j 2, so the logger receives one finished string: the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the level is filtered out. Pass a constant pattern and the values beside it instead: `log.error("Order {} moved to {}", orderId, status)`, which keeps the pattern and its arguments apart on the event for a structured encoder (logstash-logback-encoder, log4j 2's JsonTemplateLayout, OpenTelemetry), or `log.atInfo().addKeyValue("order_id", orderId).log("order moved")` with SLF4J 2's fluent API. An exception goes last, as the throwable argument, not into the text. — streams/src/main/java/org/apache/kafka/streams/processor/internals/StateDirectory.java:756
  • `error` at line 785 is handed a message assembled at the call — a string concatenated with a value, or `String.format` — through SLF4J or log4j 2, so the logger receives one finished string: the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the level is filtered out. Pass a constant pattern and the values beside it instead: `log.error("Order {} moved to {}", orderId, status)`, which keeps the pattern and its arguments apart on the event for a structured encoder (logstash-logback-encoder, log4j 2's JsonTemplateLayout, OpenTelemetry), or `log.atInfo().addKeyValue("order_id", orderId).log("order moved")` with SLF4J 2's fluent API. An exception goes last, as the throwable argument, not into the text. — streams/src/main/java/org/apache/kafka/streams/processor/internals/StateDirectory.java:785
  • `error` at line 811 is handed a message assembled at the call — a string concatenated with a value, or `String.format` — through SLF4J or log4j 2, so the logger receives one finished string: the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the level is filtered out. Pass a constant pattern and the values beside it instead: `log.error("Order {} moved to {}", orderId, status)`, which keeps the pattern and its arguments apart on the event for a structured encoder (logstash-logback-encoder, log4j 2's JsonTemplateLayout, OpenTelemetry), or `log.atInfo().addKeyValue("order_id", orderId).log("order moved")` with SLF4J 2's fluent API. An exception goes last, as the throwable argument, not into the text. — streams/src/main/java/org/apache/kafka/streams/processor/internals/StateDirectory.java:811
  • `debug` at line 341 is handed a message assembled at the call — a string concatenated with a value, or `String.format` — through SLF4J or log4j 2, so the logger receives one finished string: the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the level is filtered out. Pass a constant pattern and the values beside it instead: `log.debug("Order {} moved to {}", orderId, status)`, which keeps the pattern and its arguments apart on the event for a structured encoder (logstash-logback-encoder, log4j 2's JsonTemplateLayout, OpenTelemetry), or `log.atInfo().addKeyValue("order_id", orderId).log("order moved")` with SLF4J 2's fluent API. An exception goes last, as the throwable argument, not into the text. — streams/src/main/java/org/apache/kafka/streams/processor/internals/RecordCollectorImpl.java:341
  • `error` at line 360 is handed a message assembled at the call — a string concatenated with a value, or `String.format` — through SLF4J or log4j 2, so the logger receives one finished string: the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the level is filtered out. Pass a constant pattern and the values beside it instead: `log.error("Order {} moved to {}", orderId, status)`, which keeps the pattern and its arguments apart on the event for a structured encoder (logstash-logback-encoder, log4j 2's JsonTemplateLayout, OpenTelemetry), or `log.atInfo().addKeyValue("order_id", orderId).log("order moved")` with SLF4J 2's fluent API. An exception goes last, as the throwable argument, not into the text. — streams/src/main/java/org/apache/kafka/streams/processor/internals/RecordCollectorImpl.java:360
  • `info` at line 749 is handed a message assembled at the call — a string concatenated with a value, or `String.format` — through SLF4J or log4j 2, so the logger receives one finished string: the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the level is filtered out. Pass a constant pattern and the values beside it instead: `log.info("Order {} moved to {}", orderId, status)`, which keeps the pattern and its arguments apart on the event for a structured encoder (logstash-logback-encoder, log4j 2's JsonTemplateLayout, OpenTelemetry), or `log.atInfo().addKeyValue("order_id", orderId).log("order moved")` with SLF4J 2's fluent API. An exception goes last, as the throwable argument, not into the text. — streams/src/main/java/org/apache/kafka/streams/processor/internals/InternalTopicManager.java:749
  • `info` at line 832 is handed a message assembled at the call — a string concatenated with a value, or `String.format` — through SLF4J or log4j 2, so the logger receives one finished string: the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the level is filtered out. Pass a constant pattern and the values beside it instead: `log.info("Order {} moved to {}", orderId, status)`, which keeps the pattern and its arguments apart on the event for a structured encoder (logstash-logback-encoder, log4j 2's JsonTemplateLayout, OpenTelemetry), or `log.atInfo().addKeyValue("order_id", orderId).log("order moved")` with SLF4J 2's fluent API. An exception goes last, as the throwable argument, not into the text. — streams/src/main/java/org/apache/kafka/streams/processor/internals/InternalTopicManager.java:832
  • `info` at line 586 is handed a message assembled at the call — a string concatenated with a value, or `String.format` — through SLF4J or log4j 2, so the logger receives one finished string: the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the level is filtered out. Pass a constant pattern and the values beside it instead: `log.info("Order {} moved to {}", orderId, status)`, which keeps the pattern and its arguments apart on the event for a structured encoder (logstash-logback-encoder, log4j 2's JsonTemplateLayout, OpenTelemetry), or `log.atInfo().addKeyValue("order_id", orderId).log("order moved")` with SLF4J 2's fluent API. An exception goes last, as the throwable argument, not into the text. — streams/src/main/java/org/apache/kafka/streams/processor/internals/DefaultStateUpdater.java:586
  • `debug` at line 590 is handed a message assembled at the call — a string concatenated with a value, or `String.format` — through SLF4J or log4j 2, so the logger receives one finished string: the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the level is filtered out. Pass a constant pattern and the values beside it instead: `log.debug("Order {} moved to {}", orderId, status)`, which keeps the pattern and its arguments apart on the event for a structured encoder (logstash-logback-encoder, log4j 2's JsonTemplateLayout, OpenTelemetry), or `log.atInfo().addKeyValue("order_id", orderId).log("order moved")` with SLF4J 2's fluent API. An exception goes last, as the throwable argument, not into the text. — streams/src/main/java/org/apache/kafka/streams/processor/internals/DefaultStateUpdater.java:590
  • `info` at line 596 is handed a message assembled at the call — a string concatenated with a value, or `String.format` — through SLF4J or log4j 2, so the logger receives one finished string: the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the level is filtered out. Pass a constant pattern and the values beside it instead: `log.info("Order {} moved to {}", orderId, status)`, which keeps the pattern and its arguments apart on the event for a structured encoder (logstash-logback-encoder, log4j 2's JsonTemplateLayout, OpenTelemetry), or `log.atInfo().addKeyValue("order_id", orderId).log("order moved")` with SLF4J 2's fluent API. An exception goes last, as the throwable argument, not into the text. — streams/src/main/java/org/apache/kafka/streams/processor/internals/DefaultStateUpdater.java:596

What to do

  • Interpolated log message defeats structured logging
X5 · Nullable reference types2.0 / 10Critical✓ Tool-verified

Other · Code Health — Whether Java packages are null-marked and not undermined by heavy nullness suppression — a package under `@NullMarked` (or `@NonNullApi`, `@ParametersAreNonnullByDefault`, `@NonNullByDefault`, or a NullAway/Checker Framework configuration naming it) makes an unannotated reference exclude null, and `@SuppressWarnings("NullAway")`, `("nullness")`, `("null")` and `castToNonNull(…)` are what silence it.

Method: Roslyn compiler-options scan: NullableContextOptions per project; null-forgiving (!) suppression density per 1k syntax nodes. Deterministic, adoption plus suppression penalty.

  • 0/291 of this repository's Java package directories are under a non-null default: a `package-info.java` declaring `@NullMarked` (JSpecify) or `@NonNullApi`, `@ParametersAreNonnullByDefault`, `@NonNullByDefault`, `@DefaultQualifier(NonNull.class)`; a `module-info.java` declaring `@NullMarked`; every type in it `@NullMarked`; or a build that runs NullAway with the package in `AnnotatedPackages`, or the Checker Framework's `NullnessChecker`. Elsewhere every reference admits null and no checker warns on the dereference that throws a `NullPointerException`.

What to do

  • Declare the default where Java declares it: `@NullMarked` (org.jspecify.annotations) in each package's `package-info.java`, or once in `module-info.java`, and run NullAway (Error Prone) or the Checker Framework so the declaration is enforced. Then annotate the real exceptions `@Nullable` and resolve the suppressions rather than adding to them: a `@SuppressWarnings("NullAway")` or `castToNonNull(x)` on a value the checker could show to be null is a `NullPointerException` waiting for the path that makes it true — where the value genuinely cannot be null, say something the checker can see instead (a null check, `Objects.requireNonNull`, a non-null field initialised in the constructor).

Reference — by lens

The score is the rank-weighted fold of these lenses (worst-heaviest), each including its meta-dimensions; a lens with a Critical contributor is capped at Fair (its band reads "gated by …") and is never the strongest area however high its average.

LensScoreRatingImpact
Code Health65%Adequate — gated by X5Capped at Fair by a Critical contributor — resolve it before relying on this lens.
Architecture87%StrongStrongest area.
Maturity73%StrongSolid.
Readiness49%Weak — gated by P7Capped at Fair by a Critical contributor — resolve it before relying on this lens.
Security53%Adequate — gated by D28, D29, D36Capped at Fair by a Critical contributor — resolve it before relying on this lens.
Performance81%StrongSolid.
Unscored — 2 check(s) recorded observations but carry no score

These checks ran and found something, but they do not carry a score — either by design (an advisory check reports evidence rather than grading it) or because they could not be scored here. They are excluded from the score for that reason, not because there was nothing to see.

  • X10 Duplicated predicate — 25 observation(s) recorded · Advisory — this card reports evidence and never carries a score.
  • X7 Silent fallback defaults — 7 observation(s) recorded · Advisory — this card reports evidence and never carries a score.
Not evidenced — 3 control(s) we could not find positive evidence for

These checks grade a working control, and the repository shows no evidence of one. That is deliberately not scored as a zero: a repository cannot show an ops runbook, a database TTL or an infrastructure-side audit log, so absence of evidence here is not evidence the control is missing. It is also not a statement that the check is irrelevant to this codebase — the thing it grades applies; we just could not see it. Excluded from the score either way.

  • C3 Audit Trail — Not assessed: these audit controls are read from a source model (declarative annotations, request middleware, entity/column names, guard methods) that was not loaded for this repository — because the repository is written in a language this check does not yet model, or because its projects failed to load. Absence of an idiom this check recognises is NOT evidence that this repository lacks audit controls: it may implement them entirely in its own ecosystem. This is a gap in the analyzer's language coverage, not a finding about this repository.
  • C4 Data Retention — Not assessed: these retention controls are read from a source model (declarative annotations, request middleware, entity/column names, guard methods) that was not loaded for this repository — because the repository is written in a language this check does not yet model, or because its projects failed to load. Absence of an idiom this check recognises is NOT evidence that this repository lacks retention controls: it may implement them entirely in its own ecosystem. This is a gap in the analyzer's language coverage, not a finding about this repository.
  • C5 Data-Subject Rights — Not assessed: these data-subject rights controls are read from a source model (declarative annotations, request middleware, entity/column names, guard methods) that was not loaded for this repository — because the repository is written in a language this check does not yet model, or because its projects failed to load. Absence of an idiom this check recognises is NOT evidence that this repository lacks data-subject rights controls: it may implement them entirely in its own ecosystem. This is a gap in the analyzer's language coverage, not a finding about this repository.
Not included — 48 check(s) not relevant to this codebase

These checks had nothing to measure here (no tests, no git history, the codebase is small, or the architecture style doesn't apply), so they're omitted above rather than scored low.

  • AC1 Text alternatives — Frontend below the scale floor (2 DOM element(s) < 25) — too little surface to assess accessibility.
  • AC2 Forms & labels — Frontend below the scale floor (2 DOM element(s) < 25) — too little surface to assess accessibility.
  • AC3 Page structure — Frontend below the scale floor (2 DOM element(s) < 25) — too little surface to assess accessibility.
  • AC4 Keyboard semantics — Frontend below the scale floor (2 DOM element(s) < 25) — too little surface to assess accessibility.
  • AC5 ARIA correctness — Frontend below the scale floor (2 DOM element(s) < 25) — too little surface to assess accessibility.
  • AC6 Visual & motion safety — Frontend below the scale floor (2 DOM element(s) < 25) — too little surface to assess accessibility.
  • AC7 A11y enforcement — Frontend below the scale floor (2 DOM element(s) < 25) — too little surface to assess accessibility.
  • AX1 Captive dependencies — not analysed — these correctness checks read a source model that was not loaded for this repository, because the repository is written in a language this check does not yet model, or because its projects failed to load. This is a gap in the analyzer, not a finding about this repository
  • AX2 Stateful singletons — No container singleton was found, so there is no shared instance for concurrent requests to race on. No class in this Java code is a Spring, JSR-330 or CDI singleton bean. No function in this Python code is served by a threaded web framework (a Flask, Bottle or FastAPI route, a Django or Pyramid view), so no module is shared between request threads. No class in this Scala code is a Play controller, a Cask routes object, a Scalatra servlet, a Finatra controller, an Akka/Pekko HTTP routes holder or a JSR-330/Spring singleton, so no instance is shared between request threads.
  • AX4 Dependency direction — not applicable to a CQRS architecture (the inward-dependency rule is for layered/clean styles)
  • AX7 Slice cohesion — not applicable — not a vertical-slice architecture
  • AX8 Test isolation — no test/production split to check
  • AXB2 Runtime readiness — Advisory — this card reports evidence and never carries a score, so there is nothing missing here.
  • AXR1 Runtime accessibility — compose up failed (exit 15 — the compose project is invalid) — time="2026-10-23T04:25:58Z" level=warning msg="The \"IMAGE\" variable is not set. Defaulting to a blank string." time="2026-10-23T04:25:58Z" level=warning msg="The \"IMAGE\" variable is not set. Defaulting to a blank string." service "kafka-3" has neither an image nor a build context specified: invalid compose project; runtime evidence skipped This is a statement about this run, not a statement about your application: nothing here says the surface is inaccessible, only that it was never rendered.
  • C1 Data Protection — Not assessed: these personal data controls are read from a source model (declarative annotations, request middleware, entity/column names, guard methods) that was not loaded for this repository — because the repository is written in a language this check does not yet model, or because its projects failed to load. Absence of an idiom this check recognises is NOT evidence that this repository lacks personal data controls: it may implement them entirely in its own ecosystem. This is a gap in the analyzer's language coverage, not a finding about this repository.
  • C2 Access Controls — Not assessed: these authorization controls are read from a source model (declarative annotations, request middleware, entity/column names, guard methods) that was not loaded for this repository — because the repository is written in a language this check does not yet model, or because its projects failed to load. Absence of an idiom this check recognises is NOT evidence that this repository lacks authorization controls: it may implement them entirely in its own ecosystem. This is a gap in the analyzer's language coverage, not a finding about this repository.
  • D11 Test Reliability — Test reliability not included — the .java suite was found but not re-run
  • D12 Dependency Hygiene — Not scored — 8 Maven/Gradle manifest(s) were read, stating a version for 2 dependency(ies) and leaving 16 to a parent or an imported BOM, but no build resolved the dependency graph, so the outdated signal was not established. NOT a finding that these dependencies are current or healthy.
  • D14 License Compliance — Not scored — this repository's 2 declared JVM dependency coordinate(s) were read from its 8 Maven/Gradle manifest(s), but Maven Central could not be asked for the licence of 2 of them (HTTP 429 Too Many Requests from https://repo1.maven.org/maven2/org/slf4j/slf4j-reload4j/2.0.16/slf4j-reload4j-2.0.16.pom), and a licence verdict over part of a dependency graph is not a licence verdict. Nothing is asserted about this repository's licensing in either direction.
  • D18 Solution Shape — D18 scores the shape of a .NET solution; this repository has no .NET solution or project files, so the dimension does not apply.
  • D22 Internal API Consistency — The exposed public-API surface could not be collected — no C#/VB projects loaded.
  • D23 Boundary Type-Coupling — No bounded-context organisation was detected either — neither a context-shaped layout, nor 2+ sibling source directories each declaring an aggregate root, nor 2+ projects each declaring an entity of their own. Declaring this codebase's bounded contexts (≥2) would let cross-boundary type coupling be assessed. Declare them in `.codehealth/config.yaml` at the repository root (create it if absent), mapping each context name to the module-path or namespace prefixes that belong to it — e.g. `architecture:` → `contexts:` → `Billing: ["src/billing", "Acme.Billing"]`, `Catalog: ["src/catalog", "Acme.Catalog"]`.
  • D24 Comment Value — No inline comments to assess — comment value is not applicable here.
  • D25 ADR Conformance — no ADRs to check
  • D27 Navigability — D27 counts a call into the standard library or a dependency as unresolved for this repository's language (.java), so too few call sites counted as resolved to assess navigability. Not scored: this is a gap in the analyzer, not a verdict about this repository.
  • D30 Dependency Vulnerabilities — Scanner failed to run — not a clean result
  • D32 Data Compliance (PII/GDPR) — 3 file(s) were not parsed by semgrep — the PII/GDPR ruleset never ran over them
  • D39 IL Efficiency — D39 measures the IL emitted by a .NET build; this repository has no .NET solution or project files, so the dimension does not apply.
  • D40 Network Egress Confinement — No Kubernetes/orchestration workloads found in the repository manifests; network egress policy is a cluster-native control that may live at the platform/firewall layer, so there is nothing to assess here.
  • D41 Kernel & Syscall Confinement — No Kubernetes/orchestration workloads found in the repository manifests; seccomp/AppArmor/SELinux confinement is a workload-level control, so there is nothing to assess here.
  • D42 Runtime Threat Enforcement — No Kubernetes/orchestration workloads found in the repository manifests; runtime threat-detection and admission-control policy are cluster-level controls, so there is nothing to assess here.
  • D43 Malicious Dependencies — Scanner failed to run — not a clean result
  • D7 Architectural Integrity — no checkable ADRs, and no project-reference graph for the cycle pass to read — so this dimension makes no claim about dependency cycles in either direction (where this repository's language has an import-cycle lens, cycles are reported there). Architectural integrity not assessed
  • D8 Code Coverage — Coverage not included — suite not readable by the collector
  • DM1 Domain Modelling — applicable but not scored (2 signals for this style, 2 needed — the count is met but a required primary signal is absent): 1000 value object(s); 45 domain event(s); its domain events are published by services or handlers — no domain entity raises one
  • ED1 Event-Driven — not scored — this repository shows only 1 of the 3 signals this lens looks for (23 CQRS handler(s))
  • ED5 Idempotency — Not assessed, and this one is on us: 19 command handler(s) or message consumer(s) were found here, but this check does not yet recognise persistence writes in this repository's language. Idempotency was neither confirmed nor ruled out — this is a limit of the analyzer, not a finding about your code.
  • ES1 Event Sourcing — not scored — this repository shows none of the 3 signals this lens looks for
  • GD1 Unfinished & placeholder code — no source files were read — this check reads C#, F#, JavaScript/TypeScript, Dart, Ruby and Scala, and none was read for this repository's product. That is a limit of the analyzer, not a finding about your code.
  • P12 CI test-gate honesty — Reported, not scored — and nothing was matched here. The coverage check applies to any stack, and the automatic-re-run check to any GitHub-Actions workflow, but the checks for excluded tests, skipped tests and sleep-based synchronisation currently recognise only some ecosystems' test-runner idioms, so on a repository built with another stack the zeros below mean 'not checked', not 'clean'.
  • P8 Schema migrations — no ORM, schema-migration tool or schema auto-create was found in this repository's dependency manifests or source, so there is no database schema for this check to judge
  • P9 Domain vs controller coverage — no coverage report found on disk — produce a coverage report in a standard format (JaCoCo XML — the Gradle `jacocoTestReport` task) and commit it — a hosted scan measures a clone of the repository, so a report that exists only in a working tree, a CI runner's or your own, never reaches it; the artefact is commonly gitignored, so `git add -f` that one file (or un-ignore its path) and commit it alongside the code it measures, or wire coverage collection into CI, to enable this cross-layer check
  • PF3 Async & latency hygiene — Not applicable: this repository declares no async functions, so there is no asynchronous code for a blocking call to stall.
  • S1 Web-Security Posture — Not assessed: these web-security controls are read from a source model (declarative annotations, request middleware, entity/column names, guard methods) that was not loaded for this repository — because the repository is written in a language this check does not yet model, or because its projects failed to load. Absence of an idiom this check recognises is NOT evidence that this repository lacks web-security controls: it may implement them entirely in its own ecosystem. This is a gap in the analyzer's language coverage, not a finding about this repository.
  • X2 Cancellation propagation — no C# was loaded; this repository's Scala, Java and Python were read, and no request in it can be cancelled by a caller — a Scala request takes no token: a Future cannot be cancelled, and cats-effect, ZIO and Monix interrupt the fiber that made the request from outside the call, not through a parameter; a Java request off Android takes no token: it is cancelled through the handle it returns (Future.cancel, Call.cancel, a Disposable), ambiently (io.grpc.Context) or by interrupting its thread, not through a parameter; a Python request takes no token: asyncio cancels the task and trio or anyio the scope that made it, from outside the call, and requests, httpx, aiohttp and gRPC take a timeout, not a cancellation
  • X32 Type resolved by simple name across every loaded assembly — This check is about how a .NET program searches the assemblies loaded into its process for a type, and this repository contains no .NET source, so there is nothing here for it to assess. Not a gap in the analyzer and not a finding about your code.
  • X6 Hand-rolled structured-format parsing — Advisory — this card reports evidence and never carries a score, so there is nothing missing here.
  • X9 Subsumed condition operand — Advisory — this card reports evidence and never carries a score, so there is nothing missing here.

Appendix A — Findings (grouped)

The findings behind the scores, grouped by severity, then by dimension and kind. The high-severity issues are enumerated in full below; items per group are capped at 25 with any overflow stated explicitly per group, never silently truncated. The complete machine-readable list of every finding (all severities) is the companion findings.md in this report's bundle.

Critical — 143 finding(s)
D29 · Static Analysis (SAST) · REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • + 27 more in this group — see findings.md.
D34 · Knowledge Freshness · Orphaned knowledge · ×50
  • Orphaned knowledge clients/src/main/java/org/apache/kafka/clients/consumer/internals/AbstractStickyAssignor.java:1 — No living knowledge remains for this large file — its last meaningful change has decayed away; if it breaks, no one currently understands it. Schedule a read-through / add characterisation tests before it bites.
  • Orphaned knowledge connect/api/src/main/java/org/apache/kafka/connect/data/Values.java:1 — No living knowledge remains for this large file — its last meaningful change has decayed away; if it breaks, no one currently understands it. Schedule a read-through / add characterisation tests before it bites.
  • Orphaned knowledge streams/src/main/java/org/apache/kafka/streams/processor/assignment/TaskAssignmentUtils.java:1 — No living knowledge remains for this large file — its last meaningful change has decayed away; if it breaks, no one currently understands it. Schedule a read-through / add characterisation tests before it bites.
  • Orphaned knowledge connect/runtime/src/main/java/org/apache/kafka/connect/runtime/distributed/IncrementalCooperativeAssignor.java:1 — No living knowledge remains for this large file — its last meaningful change has decayed away; if it breaks, no one currently understands it. Schedule a read-through / add characterisation tests before it bites.
  • Orphaned knowledge connect/runtime/src/main/java/org/apache/kafka/connect/runtime/ConnectorConfig.java:1 — No living knowledge remains for this large file — its last meaningful change has decayed away; if it breaks, no one currently understands it. Schedule a read-through / add characterisation tests before it bites.
  • Orphaned knowledge streams/streams-scala/src/main/scala/org/apache/kafka/streams/scala/kstream/KTable.scala:1 — No living knowledge remains for this large file — its last meaningful change has decayed away; if it breaks, no one currently understands it. Schedule a read-through / add characterisation tests before it bites.
  • Orphaned knowledge connect/runtime/src/main/java/org/apache/kafka/connect/util/TopicAdmin.java:1 — No living knowledge remains for this large file — its last meaningful change has decayed away; if it breaks, no one currently understands it. Schedule a read-through / add characterisation tests before it bites.
  • Orphaned knowledge streams/src/main/java/org/apache/kafka/streams/state/internals/metrics/RocksDBMetrics.java:1 — No living knowledge remains for this large file — its last meaningful change has decayed away; if it breaks, no one currently understands it. Schedule a read-through / add characterisation tests before it bites.
  • Orphaned knowledge connect/json/src/main/java/org/apache/kafka/connect/json/JsonConverter.java:1 — No living knowledge remains for this large file — its last meaningful change has decayed away; if it breaks, no one currently understands it. Schedule a read-through / add characterisation tests before it bites.
  • Orphaned knowledge clients/src/main/java/org/apache/kafka/common/security/authenticator/SaslClientAuthenticator.java:1 — No living knowledge remains for this large file — its last meaningful change has decayed away; if it breaks, no one currently understands it. Schedule a read-through / add characterisation tests before it bites.
  • Orphaned knowledge streams/src/main/java/org/apache/kafka/streams/state/internals/RocksDBVersionedStoreSegmentValueFormatter.java:1 — No living knowledge remains for this large file — its last meaningful change has decayed away; if it breaks, no one currently understands it. Schedule a read-through / add characterisation tests before it bites.
  • Orphaned knowledge connect/runtime/src/main/java/org/apache/kafka/connect/runtime/ConnectMetricsRegistry.java:1 — No living knowledge remains for this large file — its last meaningful change has decayed away; if it breaks, no one currently understands it. Schedule a read-through / add characterisation tests before it bites.
  • Orphaned knowledge connect/runtime/src/main/java/org/apache/kafka/connect/runtime/AbstractWorkerSourceTask.java:1 — No living knowledge remains for this large file — its last meaningful change has decayed away; if it breaks, no one currently understands it. Schedule a read-through / add characterisation tests before it bites.
  • Orphaned knowledge connect/runtime/src/main/java/org/apache/kafka/connect/util/KafkaBasedLog.java:1 — No living knowledge remains for this large file — its last meaningful change has decayed away; if it breaks, no one currently understands it. Schedule a read-through / add characterisation tests before it bites.
  • Orphaned knowledge clients/src/main/java/org/apache/kafka/common/network/KafkaChannel.java:1 — No living knowledge remains for this large file — its last meaningful change has decayed away; if it breaks, no one currently understands it. Schedule a read-through / add characterisation tests before it bites.
  • Orphaned knowledge streams/src/main/java/org/apache/kafka/streams/state/internals/metrics/RocksDBMetricsRecorder.java:1 — No living knowledge remains for this large file — its last meaningful change has decayed away; if it breaks, no one currently understands it. Schedule a read-through / add characterisation tests before it bites.
  • Orphaned knowledge trogdor/src/main/java/org/apache/kafka/trogdor/coordinator/TaskManager.java:1 — No living knowledge remains for this large file — its last meaningful change has decayed away; if it breaks, no one currently understands it. Schedule a read-through / add characterisation tests before it bites.
  • Orphaned knowledge connect/runtime/src/main/java/org/apache/kafka/connect/runtime/distributed/WorkerCoordinator.java:1 — No living knowledge remains for this large file — its last meaningful change has decayed away; if it breaks, no one currently understands it. Schedule a read-through / add characterisation tests before it bites.
  • Orphaned knowledge clients/src/main/java/org/apache/kafka/common/security/ssl/SslFactory.java:1 — No living knowledge remains for this large file — its last meaningful change has decayed away; if it breaks, no one currently understands it. Schedule a read-through / add characterisation tests before it bites.
  • Orphaned knowledge clients/src/main/java/org/apache/kafka/common/utils/internals/LogContext.java:1 — No living knowledge remains for this large file — its last meaningful change has decayed away; if it breaks, no one currently understands it. Schedule a read-through / add characterisation tests before it bites.
  • Orphaned knowledge tools/src/main/java/org/apache/kafka/tools/ManifestWorkspace.java:1 — No living knowledge remains for this large file — its last meaningful change has decayed away; if it breaks, no one currently understands it. Schedule a read-through / add characterisation tests before it bites.
  • Orphaned knowledge connect/runtime/src/main/java/org/apache/kafka/connect/runtime/ExactlyOnceWorkerSourceTask.java:1 — No living knowledge remains for this large file — its last meaningful change has decayed away; if it breaks, no one currently understands it. Schedule a read-through / add characterisation tests before it bites.
  • Orphaned knowledge trogdor/src/main/java/org/apache/kafka/trogdor/agent/WorkerManager.java:1 — No living knowledge remains for this large file — its last meaningful change has decayed away; if it breaks, no one currently understands it. Schedule a read-through / add characterisation tests before it bites.
  • Orphaned knowledge streams/src/main/java/org/apache/kafka/streams/processor/internals/assignment/RackAwareTaskAssignor.java:1 — No living knowledge remains for this large file — its last meaningful change has decayed away; if it breaks, no one currently understands it. Schedule a read-through / add characterisation tests before it bites.
  • Orphaned knowledge generator/src/main/java/org/apache/kafka/message/JsonConverterGenerator.java:1 — No living knowledge remains for this large file — its last meaningful change has decayed away; if it breaks, no one currently understands it. Schedule a read-through / add characterisation tests before it bites.
  • + 25 more in this group — see findings.md.
D28 · Secrets (history) · High secret · ×8
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
D29 · Static Analysis (SAST) · REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
D31 · IaC & Container Security · High IaC · ×7
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
D10 · Test Quality · No assertions (empty test) · ×4
  • No assertions (empty test): canConsume connect/api/src/test/java/org/apache/kafka/connect/data/ValuesTest.java:1043 — Test method has an empty body — it asserts nothing and exercises no code.
  • No assertions (empty test): testInconsistentConfigs connect/runtime/src/test/java/org/apache/kafka/connect/runtime/distributed/DistributedHerderTest.java:3760 — Test method has an empty body — it asserts nothing and exercises no code.
  • No assertions (empty test): shouldEvenlyDistributeByTaskIdAndPartition streams/src/test/java/org/apache/kafka/streams/processor/internals/assignment/CustomStickyTaskAssignorTest.java:640 — Test method has an empty body — it asserts nothing and exercises no code.
  • No assertions (empty test): shouldDelegateInit streams/src/test/java/org/apache/kafka/streams/state/internals/ChangeLoggingSessionBytesStoreTest.java:79 — Test method has an empty body — it asserts nothing and exercises no code.
D29 · Static Analysis (SAST) · REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
D29 · Static Analysis (SAST) · REDACTED
  • REDACTED
  • REDACTED
D29 · Static Analysis (SAST) · REDACTED
  • REDACTED
  • REDACTED
D29 · Static Analysis (SAST) · REDACTED · ×2
  • REDACTED
  • REDACTED
D13 · Secret Scanning · Leaked secret · ×1
  • REDACTED
D29 · Static Analysis (SAST) · REDACTED · ×1
  • REDACTED
D35 · Change Coupling · Boundary-crossing change coupling · ×1
  • Boundary-crossing change coupling: ApiKeys.java ↔ RequestConvertToJson.java clients/src/main/java/org/apache/kafka/common/protocol/ApiKeys.java:1 — `clients/src/main/java/org/apache/kafka/common/protocol/ApiKeys.java` (context clients) and `server/src/main/java/org/apache/kafka/network/RequestConvertToJson.java` (context main) sit in DIFFERENT parts of the tree yet change together 69% of the time (9 of the 13 commits that touched whichever of the two files changed less often, counting a file under its earlier names as well, and counted over this repository's 10,000 most recent commits rather than its whole history — a repo-wide or module-wide sweep is evidence about the sweep rather than about any pair inside it and is left out of BOTH sides of this ratio, while a dependency bump, a formatter/rename sweep, or a commit whose edit to one of the two files was a tool directive such as //go:generate or whitespace only is left out of the shared count ONLY, so the two sides are not taken over identical commit sets) — the bounded-context boundary may be in the wrong place, or one context is leaking into the other. This is the behavioural boundary violation a static scan can't see. You can check this without leaving the row: of the 9 shared commits counted here, the most recent 3 are `7997c9eb` KAFKA-20620: Add StreamsGroupTopologyDescriptionUpdate RPC schema and…; `29ce9615` MINOR; Revert "KAFKA-18681: Created GetReplicaLogInfo RPCs (#19664)" …; `d86ba7f5` KAFKA-18681: Created GetReplicaLogInfo RPCs (#19664) — run `git show` on any of them.
D36 · Supply-chain Provenance & Signing · REDACTED · ×1
  • REDACTED
Serious — 3175 finding(s)
D10 · Test Quality · No assertions · ×993
  • No assertions: testCoalescedFulfillment clients/src/test/java/org/apache/kafka/clients/admin/internals/AdminApiDriverTest.java:89 — This method's body runs code, and no assertion was recognised in it. Recognised: JUnit's assertion methods (assertEquals, assertTrue, assertInstanceOf, assertThrows, assertThrowsExactly, assertTimeoutPreemptively, assertAll and the rest of JUnit 5's list), assertThat (AssertJ, Hamcrest, Truth), fail, Mockito's verify and the `assert` statement, in the test body and in helper methods of the test's own class or an in-repository base class, followed three calls deep. Verification through a helper on another object or in another class, through a custom matcher library, or through a harness that fails by throwing under some other name is not visible to this check and is not counted here. Read it as 'no assertion this check knows how to see', and if that is right, add one.
  • No assertions: testCoalescedLookup clients/src/test/java/org/apache/kafka/clients/admin/internals/AdminApiDriverTest.java:66 — This method's body runs code, and no assertion was recognised in it. Recognised: JUnit's assertion methods (assertEquals, assertTrue, assertInstanceOf, assertThrows, assertThrowsExactly, assertTimeoutPreemptively, assertAll and the rest of JUnit 5's list), assertThat (AssertJ, Hamcrest, Truth), fail, Mockito's verify and the `assert` statement, in the test body and in helper methods of the test's own class or an in-repository base class, followed three calls deep. Verification through a helper on another object or in another class, through a custom matcher library, or through a harness that fails by throwing under some other name is not visible to this check and is not counted here. Read it as 'no assertion this check knows how to see', and if that is right, add one.
  • No assertions: testFulfillmentFailure clients/src/test/java/org/apache/kafka/clients/admin/internals/AdminApiDriverTest.java:212 — This method's body runs code, and no assertion was recognised in it. Recognised: JUnit's assertion methods (assertEquals, assertTrue, assertInstanceOf, assertThrows, assertThrowsExactly, assertTimeoutPreemptively, assertAll and the rest of JUnit 5's list), assertThat (AssertJ, Hamcrest, Truth), fail, Mockito's verify and the `assert` statement, in the test body and in helper methods of the test's own class or an in-repository base class, followed three calls deep. Verification through a helper on another object or in another class, through a custom matcher library, or through a harness that fails by throwing under some other name is not visible to this check and is not counted here. Read it as 'no assertion this check knows how to see', and if that is right, add one.
  • No assertions: testFulfillmentFailureUnsupportedVersion clients/src/test/java/org/apache/kafka/clients/admin/internals/AdminApiDriverTest.java:290 — This method's body runs code, and no assertion was recognised in it. Recognised: JUnit's assertion methods (assertEquals, assertTrue, assertInstanceOf, assertThrows, assertThrowsExactly, assertTimeoutPreemptively, assertAll and the rest of JUnit 5's list), assertThat (AssertJ, Hamcrest, Truth), fail, Mockito's verify and the `assert` statement, in the test body and in helper methods of the test's own class or an in-repository base class, followed three calls deep. Verification through a helper on another object or in another class, through a custom matcher library, or through a harness that fails by throwing under some other name is not visible to this check and is not counted here. Read it as 'no assertion this check knows how to see', and if that is right, add one.
  • No assertions: testFulfillmentRetriableUnsupportedVersion clients/src/test/java/org/apache/kafka/clients/admin/internals/AdminApiDriverTest.java:307 — This method's body runs code, and no assertion was recognised in it. Recognised: JUnit's assertion methods (assertEquals, assertTrue, assertInstanceOf, assertThrows, assertThrowsExactly, assertTimeoutPreemptively, assertAll and the rest of JUnit 5's list), assertThat (AssertJ, Hamcrest, Truth), fail, Mockito's verify and the `assert` statement, in the test body and in helper methods of the test's own class or an in-repository base class, followed three calls deep. Verification through a helper on another object or in another class, through a custom matcher library, or through a harness that fails by throwing under some other name is not visible to this check and is not counted here. Read it as 'no assertion this check knows how to see', and if that is right, add one.
  • No assertions: testFulfillmentRetry clients/src/test/java/org/apache/kafka/clients/admin/internals/AdminApiDriverTest.java:230 — This method's body runs code, and no assertion was recognised in it. Recognised: JUnit's assertion methods (assertEquals, assertTrue, assertInstanceOf, assertThrows, assertThrowsExactly, assertTimeoutPreemptively, assertAll and the rest of JUnit 5's list), assertThat (AssertJ, Hamcrest, Truth), fail, Mockito's verify and the `assert` statement, in the test body and in helper methods of the test's own class or an in-repository base class, followed three calls deep. Verification through a helper on another object or in another class, through a custom matcher library, or through a harness that fails by throwing under some other name is not visible to this check and is not counted here. Read it as 'no assertion this check knows how to see', and if that is right, add one.
  • No assertions: testFulfillmentUnmapping clients/src/test/java/org/apache/kafka/clients/admin/internals/AdminApiDriverTest.java:254 — This method's body runs code, and no assertion was recognised in it. Recognised: JUnit's assertion methods (assertEquals, assertTrue, assertInstanceOf, assertThrows, assertThrowsExactly, assertTimeoutPreemptively, assertAll and the rest of JUnit 5's list), assertThat (AssertJ, Hamcrest, Truth), fail, Mockito's verify and the `assert` statement, in the test body and in helper methods of the test's own class or an in-repository base class, followed three calls deep. Verification through a helper on another object or in another class, through a custom matcher library, or through a harness that fails by throwing under some other name is not visible to this check and is not counted here. Read it as 'no assertion this check knows how to see', and if that is right, add one.
  • No assertions: testKeyLookupFailure clients/src/test/java/org/apache/kafka/clients/admin/internals/AdminApiDriverTest.java:112 — This method's body runs code, and no assertion was recognised in it. Recognised: JUnit's assertion methods (assertEquals, assertTrue, assertInstanceOf, assertThrows, assertThrowsExactly, assertTimeoutPreemptively, assertAll and the rest of JUnit 5's list), assertThat (AssertJ, Hamcrest, Truth), fail, Mockito's verify and the `assert` statement, in the test body and in helper methods of the test's own class or an in-repository base class, followed three calls deep. Verification through a helper on another object or in another class, through a custom matcher library, or through a harness that fails by throwing under some other name is not visible to this check and is not counted here. Read it as 'no assertion this check knows how to see', and if that is right, add one.
  • No assertions: testKeyLookupRetry clients/src/test/java/org/apache/kafka/clients/admin/internals/AdminApiDriverTest.java:142 — This method's body runs code, and no assertion was recognised in it. Recognised: JUnit's assertion methods (assertEquals, assertTrue, assertInstanceOf, assertThrows, assertThrowsExactly, assertTimeoutPreemptively, assertAll and the rest of JUnit 5's list), assertThat (AssertJ, Hamcrest, Truth), fail, Mockito's verify and the `assert` statement, in the test body and in helper methods of the test's own class or an in-repository base class, followed three calls deep. Verification through a helper on another object or in another class, through a custom matcher library, or through a harness that fails by throwing under some other name is not visible to this check and is not counted here. Read it as 'no assertion this check knows how to see', and if that is right, add one.
  • No assertions: testRecoalescedLookup clients/src/test/java/org/apache/kafka/clients/admin/internals/AdminApiDriverTest.java:343 — This method's body runs code, and no assertion was recognised in it. Recognised: JUnit's assertion methods (assertEquals, assertTrue, assertInstanceOf, assertThrows, assertThrowsExactly, assertTimeoutPreemptively, assertAll and the rest of JUnit 5's list), assertThat (AssertJ, Hamcrest, Truth), fail, Mockito's verify and the `assert` statement, in the test body and in helper methods of the test's own class or an in-repository base class, followed three calls deep. Verification through a helper on another object or in another class, through a custom matcher library, or through a harness that fails by throwing under some other name is not visible to this check and is not counted here. Read it as 'no assertion this check knows how to see', and if that is right, add one.
  • No assertions: testStaticMapping clients/src/test/java/org/apache/kafka/clients/admin/internals/AdminApiDriverTest.java:175 — This method's body runs code, and no assertion was recognised in it. Recognised: JUnit's assertion methods (assertEquals, assertTrue, assertInstanceOf, assertThrows, assertThrowsExactly, assertTimeoutPreemptively, assertAll and the rest of JUnit 5's list), assertThat (AssertJ, Hamcrest, Truth), fail, Mockito's verify and the `assert` statement, in the test body and in helper methods of the test's own class or an in-repository base class, followed three calls deep. Verification through a helper on another object or in another class, through a custom matcher library, or through a harness that fails by throwing under some other name is not visible to this check and is not counted here. Read it as 'no assertion this check knows how to see', and if that is right, add one.
  • No assertions: testTopLevelErrorConstructor clients/src/test/java/org/apache/kafka/clients/admin/DeleteConsumerGroupOffsetsResultTest.java:62 — This method's body runs code, and no assertion was recognised in it. Recognised: JUnit's assertion methods (assertEquals, assertTrue, assertInstanceOf, assertThrows, assertThrowsExactly, assertTimeoutPreemptively, assertAll and the rest of JUnit 5's list), assertThat (AssertJ, Hamcrest, Truth), fail, Mockito's verify and the `assert` statement, in the test body and in helper methods of the test's own class or an in-repository base class, followed three calls deep. Verification through a helper on another object or in another class, through a custom matcher library, or through a harness that fails by throwing under some other name is not visible to this check and is not counted here. Read it as 'no assertion this check knows how to see', and if that is right, add one.
  • No assertions: testTopLevelError clients/src/test/java/org/apache/kafka/clients/admin/DescribeUserScramCredentialsResultTest.java:36 — This method's body runs code, and no assertion was recognised in it. Recognised: JUnit's assertion methods (assertEquals, assertTrue, assertInstanceOf, assertThrows, assertThrowsExactly, assertTimeoutPreemptively, assertAll and the rest of JUnit 5's list), assertThat (AssertJ, Hamcrest, Truth), fail, Mockito's verify and the `assert` statement, in the test body and in helper methods of the test's own class or an in-repository base class, followed three calls deep. Verification through a helper on another object or in another class, through a custom matcher library, or through a harness that fails by throwing under some other name is not visible to this check and is not counted here. Read it as 'no assertion this check knows how to see', and if that is right, add one.
  • No assertions: testIncrementalAlterConfigs clients/src/test/java/org/apache/kafka/clients/admin/KafkaAdminClientConfigTest.java:406 — This method's body runs code, and no assertion was recognised in it. Recognised: JUnit's assertion methods (assertEquals, assertTrue, assertInstanceOf, assertThrows, assertThrowsExactly, assertTimeoutPreemptively, assertAll and the rest of JUnit 5's list), assertThat (AssertJ, Hamcrest, Truth), fail, Mockito's verify and the `assert` statement, in the test body and in helper methods of the test's own class or an in-repository base class, followed three calls deep. Verification through a helper on another object or in another class, through a custom matcher library, or through a harness that fails by throwing under some other name is not visible to this check and is not counted here. Read it as 'no assertion this check knows how to see', and if that is right, add one.
  • No assertions: testIncrementalAlterConfigsToController clients/src/test/java/org/apache/kafka/clients/admin/KafkaAdminClientConfigTest.java:500 — This method's body runs code, and no assertion was recognised in it. Recognised: JUnit's assertion methods (assertEquals, assertTrue, assertInstanceOf, assertThrows, assertThrowsExactly, assertTimeoutPreemptively, assertAll and the rest of JUnit 5's list), assertThat (AssertJ, Hamcrest, Truth), fail, Mockito's verify and the `assert` statement, in the test body and in helper methods of the test's own class or an in-repository base class, followed three calls deep. Verification through a helper on another object or in another class, through a custom matcher library, or through a harness that fails by throwing under some other name is not visible to this check and is not counted here. Read it as 'no assertion this check knows how to see', and if that is right, add one.
  • No assertions: testAlterConsumerGroupOffsetsFindCoordinatorNonRetriableErrors clients/src/test/java/org/apache/kafka/clients/admin/KafkaAdminClientConsumerGroupTest.java:3167 — This method's body runs code, and no assertion was recognised in it. Recognised: JUnit's assertion methods (assertEquals, assertTrue, assertInstanceOf, assertThrows, assertThrowsExactly, assertTimeoutPreemptively, assertAll and the rest of JUnit 5's list), assertThat (AssertJ, Hamcrest, Truth), fail, Mockito's verify and the `assert` statement, in the test body and in helper methods of the test's own class or an in-repository base class, followed three calls deep. Verification through a helper on another object or in another class, through a custom matcher library, or through a harness that fails by throwing under some other name is not visible to this check and is not counted here. Read it as 'no assertion this check knows how to see', and if that is right, add one.
  • No assertions: testAlterConsumerGroupOffsetsNonRetriableErrors clients/src/test/java/org/apache/kafka/clients/admin/KafkaAdminClientConsumerGroupTest.java:3109 — This method's body runs code, and no assertion was recognised in it. Recognised: JUnit's assertion methods (assertEquals, assertTrue, assertInstanceOf, assertThrows, assertThrowsExactly, assertTimeoutPreemptively, assertAll and the rest of JUnit 5's list), assertThat (AssertJ, Hamcrest, Truth), fail, Mockito's verify and the `assert` statement, in the test body and in helper methods of the test's own class or an in-repository base class, followed three calls deep. Verification through a helper on another object or in another class, through a custom matcher library, or through a harness that fails by throwing under some other name is not visible to this check and is not counted here. Read it as 'no assertion this check knows how to see', and if that is right, add one.
  • No assertions: testDeleteConsumerGroupOffsetsFindCoordinatorNonRetriableErrors clients/src/test/java/org/apache/kafka/clients/admin/KafkaAdminClientConsumerGroupTest.java:2530 — This method's body runs code, and no assertion was recognised in it. Recognised: JUnit's assertion methods (assertEquals, assertTrue, assertInstanceOf, assertThrows, assertThrowsExactly, assertTimeoutPreemptively, assertAll and the rest of JUnit 5's list), assertThat (AssertJ, Hamcrest, Truth), fail, Mockito's verify and the `assert` statement, in the test body and in helper methods of the test's own class or an in-repository base class, followed three calls deep. Verification through a helper on another object or in another class, through a custom matcher library, or through a harness that fails by throwing under some other name is not visible to this check and is not counted here. Read it as 'no assertion this check knows how to see', and if that is right, add one.
  • No assertions: testDeleteConsumerGroupOffsetsNonRetriableErrors clients/src/test/java/org/apache/kafka/clients/admin/KafkaAdminClientConsumerGroupTest.java:2475 — This method's body runs code, and no assertion was recognised in it. Recognised: JUnit's assertion methods (assertEquals, assertTrue, assertInstanceOf, assertThrows, assertThrowsExactly, assertTimeoutPreemptively, assertAll and the rest of JUnit 5's list), assertThat (AssertJ, Hamcrest, Truth), fail, Mockito's verify and the `assert` statement, in the test body and in helper methods of the test's own class or an in-repository base class, followed three calls deep. Verification through a helper on another object or in another class, through a custom matcher library, or through a harness that fails by throwing under some other name is not visible to this check and is not counted here. Read it as 'no assertion this check knows how to see', and if that is right, add one.
  • No assertions: testDeleteConsumerGroupOffsetsNumRetries clients/src/test/java/org/apache/kafka/clients/admin/KafkaAdminClientConsumerGroupTest.java:2316 — This method's body runs code, and no assertion was recognised in it. Recognised: JUnit's assertion methods (assertEquals, assertTrue, assertInstanceOf, assertThrows, assertThrowsExactly, assertTimeoutPreemptively, assertAll and the rest of JUnit 5's list), assertThat (AssertJ, Hamcrest, Truth), fail, Mockito's verify and the `assert` statement, in the test body and in helper methods of the test's own class or an in-repository base class, followed three calls deep. Verification through a helper on another object or in another class, through a custom matcher library, or through a harness that fails by throwing under some other name is not visible to this check and is not counted here. Read it as 'no assertion this check knows how to see', and if that is right, add one.
  • No assertions: testDeleteConsumerGroupsNumRetries clients/src/test/java/org/apache/kafka/clients/admin/KafkaAdminClientConsumerGroupTest.java:2089 — This method's body runs code, and no assertion was recognised in it. Recognised: JUnit's assertion methods (assertEquals, assertTrue, assertInstanceOf, assertThrows, assertThrowsExactly, assertTimeoutPreemptively, assertAll and the rest of JUnit 5's list), assertThat (AssertJ, Hamcrest, Truth), fail, Mockito's verify and the `assert` statement, in the test body and in helper methods of the test's own class or an in-repository base class, followed three calls deep. Verification through a helper on another object or in another class, through a custom matcher library, or through a harness that fails by throwing under some other name is not visible to this check and is not counted here. Read it as 'no assertion this check knows how to see', and if that is right, add one.
  • No assertions: testDescribeConsumerGroupNumRetries clients/src/test/java/org/apache/kafka/clients/admin/KafkaAdminClientConsumerGroupTest.java:1244 — This method's body runs code, and no assertion was recognised in it. Recognised: JUnit's assertion methods (assertEquals, assertTrue, assertInstanceOf, assertThrows, assertThrowsExactly, assertTimeoutPreemptively, assertAll and the rest of JUnit 5's list), assertThat (AssertJ, Hamcrest, Truth), fail, Mockito's verify and the `assert` statement, in the test body and in helper methods of the test's own class or an in-repository base class, followed three calls deep. Verification through a helper on another object or in another class, through a custom matcher library, or through a harness that fails by throwing under some other name is not visible to this check and is not counted here. Read it as 'no assertion this check knows how to see', and if that is right, add one.
  • No assertions: testDescribeGroupsWithBothUnsupportedApis clients/src/test/java/org/apache/kafka/clients/admin/KafkaAdminClientConsumerGroupTest.java:1638 — This method's body runs code, and no assertion was recognised in it. Recognised: JUnit's assertion methods (assertEquals, assertTrue, assertInstanceOf, assertThrows, assertThrowsExactly, assertTimeoutPreemptively, assertAll and the rest of JUnit 5's list), assertThat (AssertJ, Hamcrest, Truth), fail, Mockito's verify and the `assert` statement, in the test body and in helper methods of the test's own class or an in-repository base class, followed three calls deep. Verification through a helper on another object or in another class, through a custom matcher library, or through a harness that fails by throwing under some other name is not visible to this check and is not counted here. Read it as 'no assertion this check knows how to see', and if that is right, add one.
  • No assertions: testDescribeNonConsumerGroups clients/src/test/java/org/apache/kafka/clients/admin/KafkaAdminClientConsumerGroupTest.java:1607 — This method's body runs code, and no assertion was recognised in it. Recognised: JUnit's assertion methods (assertEquals, assertTrue, assertInstanceOf, assertThrows, assertThrowsExactly, assertTimeoutPreemptively, assertAll and the rest of JUnit 5's list), assertThat (AssertJ, Hamcrest, Truth), fail, Mockito's verify and the `assert` statement, in the test body and in helper methods of the test's own class or an in-repository base class, followed three calls deep. Verification through a helper on another object or in another class, through a custom matcher library, or through a harness that fails by throwing under some other name is not visible to this check and is not counted here. Read it as 'no assertion this check knows how to see', and if that is right, add one.
  • No assertions: testListConsumerGroupOffsetsNonRetriableErrors clients/src/test/java/org/apache/kafka/clients/admin/KafkaAdminClientConsumerGroupTest.java:1914 — This method's body runs code, and no assertion was recognised in it. Recognised: JUnit's assertion methods (assertEquals, assertTrue, assertInstanceOf, assertThrows, assertThrowsExactly, assertTimeoutPreemptively, assertAll and the rest of JUnit 5's list), assertThat (AssertJ, Hamcrest, Truth), fail, Mockito's verify and the `assert` statement, in the test body and in helper methods of the test's own class or an in-repository base class, followed three calls deep. Verification through a helper on another object or in another class, through a custom matcher library, or through a harness that fails by throwing under some other name is not visible to this check and is not counted here. Read it as 'no assertion this check knows how to see', and if that is right, add one.
  • + 968 more in this group — see findings.md.
D3 · God Classes · TooManyMethods · ×153
  • TooManyMethods: RocksDBGenericOptionsToDbOptionsColumnFamilyOptionsAdapter streams/src/main/java/org/apache/kafka/streams/state/internals/RocksDBGenericOptionsToDbOptionsColumnFamilyOptionsAdapter.java:65 — TooManyMethods — 308 methods. The bar is 30 methods; this is 278 over it, 10.27× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • TooManyMethods: GroupMetadataManager group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java:278 — TooManyMethods — 266 methods. The bar is 30 methods; this is 236 over it, 8.87× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • TooManyMethods: UnifiedLog storage/src/main/java/org/apache/kafka/storage/internals/log/UnifiedLog.java:105 — TooManyMethods — 153 methods. The bar is 30 methods; this is 123 over it, 5.10× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • TooManyMethods: KafkaRaftClient raft/src/main/java/org/apache/kafka/raft/KafkaRaftClient.java:170 — TooManyMethods — 139 methods. The bar is 30 methods; this is 109 over it, 4.63× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • TooManyMethods: AbstractKafkaConfig server/src/main/java/org/apache/kafka/server/config/AbstractKafkaConfig.java:75 — TooManyMethods — 135 methods. The bar is 30 methods; this is 105 over it, 4.50× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • TooManyMethods: TaskManager streams/src/main/java/org/apache/kafka/streams/processor/internals/TaskManager.java:78 — TooManyMethods — 121 methods. The bar is 30 methods; this is 91 over it, 4.03× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • TooManyMethods: KafkaAdminClient clients/src/main/java/org/apache/kafka/clients/admin/KafkaAdminClient.java:328 — TooManyMethods — 116 methods. The bar is 30 methods; this is 86 over it, 3.87× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • TooManyMethods: AsyncKafkaConsumer clients/src/main/java/org/apache/kafka/clients/consumer/internals/AsyncKafkaConsumer.java:177 — TooManyMethods — 105 methods. The bar is 30 methods; this is 75 over it, 3.50× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • TooManyMethods: ConsumerSubscriptionState clients/src/main/java/org/apache/kafka/clients/consumer/internals/ConsumerSubscriptionState.java:77 — TooManyMethods — 103 methods. The bar is 30 methods; this is 73 over it, 3.43× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • TooManyMethods: Utils clients/src/main/java/org/apache/kafka/common/utils/Utils.java:101 — TooManyMethods — 102 methods. The bar is 30 methods; this is 72 over it, 3.40× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • TooManyMethods: DistributedHerder connect/runtime/src/main/java/org/apache/kafka/connect/runtime/distributed/DistributedHerder.java:154 — TooManyMethods — 100 methods. The bar is 30 methods; this is 70 over it, 3.33× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • TooManyMethods: StreamsGroup group-coordinator/src/main/java/org/apache/kafka/coordinator/group/streams/StreamsGroup.java:72 — TooManyMethods — 99 methods. The bar is 30 methods; this is 69 over it, 3.30× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • TooManyMethods: TransactionManager clients/src/main/java/org/apache/kafka/clients/producer/internals/TransactionManager.java:99 — TooManyMethods — 96 methods. The bar is 30 methods; this is 66 over it, 3.20× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • TooManyMethods: KafkaApis core/src/main/scala/kafka/server/KafkaApis.scala:95 — TooManyMethods — 96 methods. The bar is 30 methods; this is 66 over it, 3.20× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • TooManyMethods: SharePartition core/src/main/java/kafka/server/share/SharePartition.java:104 — TooManyMethods — 95 methods. The bar is 30 methods; this is 65 over it, 3.17× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • TooManyMethods: InternalTopologyBuilder streams/src/main/java/org/apache/kafka/streams/processor/internals/InternalTopologyBuilder.java:72 — TooManyMethods — 95 methods. The bar is 30 methods; this is 65 over it, 3.17× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • TooManyMethods: ReplicaManager core/src/main/scala/kafka/server/ReplicaManager.scala:154 — TooManyMethods — 91 methods. The bar is 30 methods; this is 61 over it, 3.03× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • TooManyMethods: LogManager storage/src/main/java/org/apache/kafka/storage/internals/log/LogManager.java:81 — TooManyMethods — 89 methods. The bar is 30 methods; this is 59 over it, 2.97× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • TooManyMethods: KStreamImpl streams/src/main/java/org/apache/kafka/streams/kstream/internals/KStreamImpl.java:79 — TooManyMethods — 87 methods. The bar is 30 methods; this is 57 over it, 2.90× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • TooManyMethods: Worker connect/runtime/src/main/java/org/apache/kafka/connect/runtime/Worker.java:140 — TooManyMethods — 86 methods. The bar is 30 methods; this is 56 over it, 2.87× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • TooManyMethods: ClassicGroup group-coordinator/src/main/java/org/apache/kafka/coordinator/group/classic/ClassicGroup.java:77 — TooManyMethods — 85 methods. The bar is 30 methods; this is 55 over it, 2.83× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • TooManyMethods: Partition core/src/main/scala/kafka/cluster/Partition.scala:163 — TooManyMethods — 84 methods. The bar is 30 methods; this is 54 over it, 2.80× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • TooManyMethods: GroupCoordinatorConfig group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupCoordinatorConfig.java:74 — TooManyMethods — 84 methods. The bar is 30 methods; this is 54 over it, 2.80× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • TooManyMethods: MockConsumer clients/src/main/java/org/apache/kafka/clients/consumer/MockConsumer.java:62 — TooManyMethods — 81 methods. The bar is 30 methods; this is 51 over it, 2.70× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • TooManyMethods: AbstractHerder connect/runtime/src/main/java/org/apache/kafka/connect/runtime/AbstractHerder.java:133 — TooManyMethods — 77 methods. The bar is 30 methods; this is 47 over it, 2.57× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • + 128 more in this group — see findings.md.
D17 · Explicit Debt · TodoComment · ×135
  • TodoComment clients/clients-integration-tests/src/test/java/org/apache/kafka/clients/consumer/PlaintextConsumerCommitTest.java:583 — // TODO: This only works in the new consumer, but should be fixed for the old consumer as well — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `// REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • TodoComment clients/clients-integration-tests/src/test/java/org/apache/kafka/clients/consumer/PlaintextConsumerCommitTest.java:610 — // TODO: This only works in the new consumer, but should be fixed for the old consumer as well — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `// REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • TodoComment clients/src/main/java/org/apache/kafka/clients/consumer/internals/FetchRequestManager.java:134 — // TODO: move the logic to poll to handle signal close — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `// REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • TodoComment clients/src/main/java/org/apache/kafka/clients/consumer/internals/CommitRequestManager.java:1352 — // TODO: Optimization question: Do we need to retry all partitions upon a single partition error? — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `// REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • TodoComment clients/src/main/java/org/apache/kafka/clients/producer/KafkaProducer.java:482 — // The chunked path does not support compression yet (TODO: KAFKA-20579)
  • TodoComment clients/src/main/java/org/apache/kafka/clients/producer/internals/ChunkedRecordAccumulator.java:82 — // TODO: drop this once the incremental strategy supports compressed data (with the — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `// REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • TodoComment clients/src/main/java/org/apache/kafka/clients/producer/internals/ChunkedRecordAccumulator.java:194 — // TODO: review when compression is supported. — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `// REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • TodoComment clients/src/main/java/org/apache/kafka/clients/producer/internals/ChunkedRecordAccumulator.java:259 — // TODO: review when compression is supported. — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `// REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • TodoComment clients/src/main/java/org/apache/kafka/clients/producer/internals/ChunkedByteBufferOutputStream.java:161 — // TODO: KAFKA-20579. With compression support, grow here instead of throwing.
  • TodoComment clients/src/main/java/org/apache/kafka/clients/producer/internals/ChunkedByteBufferOutputStream.java:329 — // TODO: review with KAFKA-20579, but growth support should belong in advanceToNextChunk, not here.
  • TodoComment clients/src/main/java/org/apache/kafka/common/compress/Lz4BlockOutputStream.java:125 — // TODO write uncompressed content size, update flg.validate() — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `// REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • TodoComment clients/src/main/java/org/apache/kafka/common/compress/Lz4BlockOutputStream.java:184 — // TODO implement content checksum, update flg.validate() — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `// REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • TodoComment clients/src/main/java/org/apache/kafka/common/compress/Lz4BlockInputStream.java:173 — // TODO: verify this content checksum — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `// REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • TodoComment clients/src/main/java/org/apache/kafka/common/requests/FetchResponse.java:240 — // TODO: remove as a part of KAFKA-12410
  • TodoComment clients/src/main/java/org/apache/kafka/common/serialization/Serdes.java:204 — // TODO: we can also serializes objects of type T using generic Java serialization by default — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `// REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • TodoComment clients/src/test/java/org/apache/kafka/clients/consumer/KafkaConsumerTest.java:1179 — // TODO: this test triggers a bug with the CONSUMER group protocol implementation. — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `// REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • TodoComment clients/src/test/java/org/apache/kafka/clients/consumer/KafkaConsumerTest.java:2593 — // TODO: this test triggers a bug with the CONSUMER group protocol implementation. — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `// REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • TodoComment clients/src/test/java/org/apache/kafka/clients/consumer/KafkaConsumerTest.java:2603 — // TODO: this test triggers a bug with the CONSUMER group protocol implementation. — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `// REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • TodoComment clients/src/test/java/org/apache/kafka/clients/consumer/KafkaConsumerTest.java:2630 — // TODO: this test triggers a bug with the CONSUMER group protocol implementation. — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `// REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • TodoComment clients/src/test/java/org/apache/kafka/clients/consumer/KafkaConsumerTest.java:2640 — // TODO: this test triggers a bug with the CONSUMER group protocol implementation. — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `// REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • TodoComment clients/src/test/java/org/apache/kafka/clients/consumer/KafkaConsumerTest.java:2651 — // TODO: this test triggers a bug with the CONSUMER group protocol implementation. — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `// REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • TodoComment clients/src/test/java/org/apache/kafka/clients/consumer/KafkaConsumerTest.java:3975 — // TODO: this test triggers a bug with the CONSUMER group protocol implementation. — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `// REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • TodoComment clients/src/test/java/org/apache/kafka/clients/consumer/KafkaConsumerTest.java:2213 — // TODO: this test references RPCs to be sent that are not part of the CONSUMER group protocol. — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `// REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • TodoComment clients/src/test/java/org/apache/kafka/clients/consumer/KafkaConsumerTest.java:2226 — // TODO: this test references RPCs to be sent that are not part of the CONSUMER group protocol. — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `// REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • TodoComment clients/src/test/java/org/apache/kafka/clients/consumer/KafkaConsumerTest.java:2562 — // TODO: this test requires topic metadata logic which is not yet implemented in the CONSUMER group protocol. — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `// REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • + 110 more in this group — see findings.md.
D3 · God Classes · ClassTooLong · ×133
  • ClassTooLong: GroupMetadataManager group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java:278 — ClassTooLong — 5070 significant lines (blank, comment-only and punctuation-only lines excluded), 266 methods. The bar is 400 significant lines; this is 4670 over it, 12.68× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • ClassTooLong: KafkaAdminClient clients/src/main/java/org/apache/kafka/clients/admin/KafkaAdminClient.java:328 — ClassTooLong — 3321 significant lines (blank, comment-only and punctuation-only lines excluded), 116 methods. The bar is 400 significant lines; this is 2921 over it, 8.30× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • ClassTooLong: KafkaRaftClient raft/src/main/java/org/apache/kafka/raft/KafkaRaftClient.java:170 — ClassTooLong — 2462 significant lines (blank, comment-only and punctuation-only lines excluded), 139 methods. The bar is 400 significant lines; this is 2062 over it, 6.16× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • ClassTooLong: DistributedHerder connect/runtime/src/main/java/org/apache/kafka/connect/runtime/distributed/DistributedHerder.java:154 — ClassTooLong — 1789 significant lines (blank, comment-only and punctuation-only lines excluded), 100 methods. The bar is 400 significant lines; this is 1389 over it, 4.47× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • ClassTooLong: SharePartition core/src/main/java/kafka/server/share/SharePartition.java:104 — ClassTooLong — 1787 significant lines (blank, comment-only and punctuation-only lines excluded), 95 methods. The bar is 400 significant lines; this is 1387 over it, 4.47× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • ClassTooLong: ReplicationControlManager metadata/src/main/java/org/apache/kafka/controller/ReplicationControlManager.java:149 — ClassTooLong — 1601 significant lines (blank, comment-only and punctuation-only lines excluded), 72 methods. The bar is 400 significant lines; this is 1201 over it, 4.00× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • ClassTooLong: GroupCoordinatorService group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupCoordinatorService.java:166 — ClassTooLong — 1545 significant lines (blank, comment-only and punctuation-only lines excluded), 71 methods. The bar is 400 significant lines; this is 1145 over it, 3.86× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • ClassTooLong: MessageDataGenerator generator/src/main/java/org/apache/kafka/message/MessageDataGenerator.java:32 — ClassTooLong — 1424 significant lines (blank, comment-only and punctuation-only lines excluded), 53 methods. The bar is 400 significant lines; this is 1024 over it, 3.56× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • ClassTooLong: InternalTopologyBuilder streams/src/main/java/org/apache/kafka/streams/processor/internals/InternalTopologyBuilder.java:72 — ClassTooLong — 1421 significant lines (blank, comment-only and punctuation-only lines excluded), 95 methods. The bar is 400 significant lines; this is 1021 over it, 3.55× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • ClassTooLong: RemoteLogManager storage/src/main/java/org/apache/kafka/server/log/remote/storage/RemoteLogManager.java:151 — ClassTooLong — 1418 significant lines (blank, comment-only and punctuation-only lines excluded), 68 methods. The bar is 400 significant lines; this is 1018 over it, 3.55× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • ClassTooLong: Worker connect/runtime/src/main/java/org/apache/kafka/connect/runtime/Worker.java:140 — ClassTooLong — 1407 significant lines (blank, comment-only and punctuation-only lines excluded), 86 methods. The bar is 400 significant lines; this is 1007 over it, 3.52× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • ClassTooLong: AsyncKafkaConsumer clients/src/main/java/org/apache/kafka/clients/consumer/internals/AsyncKafkaConsumer.java:177 — ClassTooLong — 1405 significant lines (blank, comment-only and punctuation-only lines excluded), 105 methods. The bar is 400 significant lines; this is 1005 over it, 3.51× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • ClassTooLong: UnifiedLog storage/src/main/java/org/apache/kafka/storage/internals/log/UnifiedLog.java:105 — ClassTooLong — 1403 significant lines (blank, comment-only and punctuation-only lines excluded), 153 methods. The bar is 400 significant lines; this is 1003 over it, 3.51× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • ClassTooLong: StreamThread streams/src/main/java/org/apache/kafka/streams/processor/internals/StreamThread.java:113 — ClassTooLong — 1314 significant lines (blank, comment-only and punctuation-only lines excluded), 77 methods. The bar is 400 significant lines; this is 914 over it, 3.29× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • ClassTooLong: QuorumController metadata/src/main/java/org/apache/kafka/controller/QuorumController.java:177 — ClassTooLong — 1307 significant lines (blank, comment-only and punctuation-only lines excluded), 64 methods. The bar is 400 significant lines; this is 907 over it, 3.27× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • ClassTooLong: TaskManager streams/src/main/java/org/apache/kafka/streams/processor/internals/TaskManager.java:78 — ClassTooLong — 1295 significant lines (blank, comment-only and punctuation-only lines excluded), 121 methods. The bar is 400 significant lines; this is 895 over it, 3.24× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • ClassTooLong: TransactionManager clients/src/main/java/org/apache/kafka/clients/producer/internals/TransactionManager.java:99 — ClassTooLong — 1160 significant lines (blank, comment-only and punctuation-only lines excluded), 96 methods. The bar is 400 significant lines; this is 760 over it, 2.90× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • ClassTooLong: CoordinatorRuntime coordinator-common/src/main/java/org/apache/kafka/coordinator/common/runtime/CoordinatorRuntime.java:100 — ClassTooLong — 1152 significant lines (blank, comment-only and punctuation-only lines excluded), 20 methods. The bar is 400 significant lines; this is 752 over it, 2.88× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • ClassTooLong: RocksDBGenericOptionsToDbOptionsColumnFamilyOptionsAdapter streams/src/main/java/org/apache/kafka/streams/state/internals/RocksDBGenericOptionsToDbOptionsColumnFamilyOptionsAdapter.java:65 — ClassTooLong — 1105 significant lines (blank, comment-only and punctuation-only lines excluded), 308 methods. The bar is 400 significant lines; this is 705 over it, 2.76× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • ClassTooLong: PersisterStateManager server-common/src/main/java/org/apache/kafka/server/share/persister/PersisterStateManager.java:92 — ClassTooLong — 1102 significant lines (blank, comment-only and punctuation-only lines excluded), 7 methods. The bar is 400 significant lines; this is 702 over it, 2.76× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • ClassTooLong: KafkaStreams streams/src/main/java/org/apache/kafka/streams/KafkaStreams.java:165 — ClassTooLong — 1073 significant lines (blank, comment-only and punctuation-only lines excluded), 65 methods. The bar is 400 significant lines; this is 673 over it, 2.68× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • ClassTooLong: LogManager storage/src/main/java/org/apache/kafka/storage/internals/log/LogManager.java:81 — ClassTooLong — 1013 significant lines (blank, comment-only and punctuation-only lines excluded), 89 methods. The bar is 400 significant lines; this is 613 over it, 2.53× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • ClassTooLong: ShareConsumeRequestManager clients/src/main/java/org/apache/kafka/clients/consumer/internals/ShareConsumeRequestManager.java:86 — ClassTooLong — 1005 significant lines (blank, comment-only and punctuation-only lines excluded), 39 methods. The bar is 400 significant lines; this is 605 over it, 2.51× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • ClassTooLong: KTableImpl streams/src/main/java/org/apache/kafka/streams/kstream/internals/KTableImpl.java:104 — ClassTooLong — 1002 significant lines (blank, comment-only and punctuation-only lines excluded), 68 methods. The bar is 400 significant lines; this is 602 over it, 2.51× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • ClassTooLong: StreamsPartitionAssignor streams/src/main/java/org/apache/kafka/streams/processor/internals/StreamsPartitionAssignor.java:105 — ClassTooLong — 984 significant lines (blank, comment-only and punctuation-only lines excluded), 42 methods. The bar is 400 significant lines; this is 584 over it, 2.46× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • + 108 more in this group — see findings.md.
D3 · God Classes · FileTooLong · ×122
  • FileTooLong: group/GroupMetadataManager.java group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java — FileTooLong — 5316 significant lines (blank, comment-only and punctuation-only lines excluded), about 95% of them inside a single declaration: GroupMetadataManager (278-10190). The bar is 500 significant lines; this is 4816 over it, 10.63× the bar. Moving the declarations that sit BESIDE it into sibling files will not shorten this file. Extract from INSIDE that declaration instead: lift each cohesive group of its body — the parts that share the same inputs and are named together — into its own unit in a sibling file, and have the original call them.
  • FileTooLong: admin/KafkaAdminClient.java clients/src/main/java/org/apache/kafka/clients/admin/KafkaAdminClient.java — FileTooLong — 3618 significant lines (blank, comment-only and punctuation-only lines excluded), about 92% of them inside a single declaration: KafkaAdminClient (328-5387). The bar is 500 significant lines; this is 3118 over it, 7.24× the bar. Moving the declarations that sit BESIDE it into sibling files will not shorten this file. Extract from INSIDE that declaration instead: lift each cohesive group of its body — the parts that share the same inputs and are named together — into its own unit in a sibling file, and have the original call them.
  • FileTooLong: server/KafkaApis.scala core/src/main/scala/kafka/server/KafkaApis.scala — FileTooLong — 3034 significant lines (blank, comment-only and punctuation-only lines excluded), about 97% of them inside a single declaration: KafkaApis (95-4388). The bar is 500 significant lines; this is 2534 over it, 6.07× the bar. Moving the declarations that sit BESIDE it into sibling files will not shorten this file. Extract from INSIDE that declaration instead: lift each cohesive group of its body — the parts that share the same inputs and are named together — into its own unit in a sibling file, and have the original call them.
  • FileTooLong: raft/KafkaRaftClient.java raft/src/main/java/org/apache/kafka/raft/KafkaRaftClient.java — FileTooLong — 2570 significant lines (blank, comment-only and punctuation-only lines excluded), about 96% of them inside a single declaration: KafkaRaftClient (170-4185). The bar is 500 significant lines; this is 2070 over it, 5.14× the bar. Moving the declarations that sit BESIDE it into sibling files will not shorten this file. Extract from INSIDE that declaration instead: lift each cohesive group of its body — the parts that share the same inputs and are named together — into its own unit in a sibling file, and have the original call them.
  • FileTooLong: distributed/DistributedHerder.java connect/runtime/src/main/java/org/apache/kafka/connect/runtime/distributed/DistributedHerder.java — FileTooLong — 1891 significant lines (blank, comment-only and punctuation-only lines excluded), about 95% of them inside a single declaration: DistributedHerder (154-3126). The bar is 500 significant lines; this is 1391 over it, 3.78× the bar. Moving the declarations that sit BESIDE it into sibling files will not shorten this file. Extract from INSIDE that declaration instead: lift each cohesive group of its body — the parts that share the same inputs and are named together — into its own unit in a sibling file, and have the original call them.
  • FileTooLong: share/SharePartition.java core/src/main/java/kafka/server/share/SharePartition.java — FileTooLong — 1864 significant lines (blank, comment-only and punctuation-only lines excluded), about 96% of them inside a single declaration: SharePartition (104-3656). The bar is 500 significant lines; this is 1364 over it, 3.73× the bar. Moving the declarations that sit BESIDE it into sibling files will not shorten this file. Extract from INSIDE that declaration instead: lift each cohesive group of its body — the parts that share the same inputs and are named together — into its own unit in a sibling file, and have the original call them.
  • FileTooLong: controller/ReplicationControlManager.java metadata/src/main/java/org/apache/kafka/controller/ReplicationControlManager.java — FileTooLong — 1721 significant lines (blank, comment-only and punctuation-only lines excluded), about 93% of them inside a single declaration: ReplicationControlManager (149-2604). The bar is 500 significant lines; this is 1221 over it, 3.44× the bar. Moving the declarations that sit BESIDE it into sibling files will not shorten this file. Extract from INSIDE that declaration instead: lift each cohesive group of its body — the parts that share the same inputs and are named together — into its own unit in a sibling file, and have the original call them.
  • FileTooLong: group/GroupCoordinatorService.java group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupCoordinatorService.java — FileTooLong — 1686 significant lines (blank, comment-only and punctuation-only lines excluded), about 92% of them inside a single declaration: GroupCoordinatorService (166-2735). The bar is 500 significant lines; this is 1186 over it, 3.37× the bar. Moving the declarations that sit BESIDE it into sibling files will not shorten this file. Extract from INSIDE that declaration instead: lift each cohesive group of its body — the parts that share the same inputs and are named together — into its own unit in a sibling file, and have the original call them.
  • FileTooLong: server/ReplicaManager.scala core/src/main/scala/kafka/server/ReplicaManager.scala — FileTooLong — 1604 significant lines (blank, comment-only and punctuation-only lines excluded), about 93% of them inside a single declaration: ReplicaManager (154-2577). The bar is 500 significant lines; this is 1104 over it, 3.21× the bar. Moving the declarations that sit BESIDE it into sibling files will not shorten this file. Extract from INSIDE that declaration instead: lift each cohesive group of its body — the parts that share the same inputs and are named together — into its own unit in a sibling file, and have the original call them.
  • FileTooLong: internals/AsyncKafkaConsumer.java clients/src/main/java/org/apache/kafka/clients/consumer/internals/AsyncKafkaConsumer.java — FileTooLong — 1547 significant lines (blank, comment-only and punctuation-only lines excluded), about 91% of them inside a single declaration: AsyncKafkaConsumer (177-2557). The bar is 500 significant lines; this is 1047 over it, 3.09× the bar. Moving the declarations that sit BESIDE it into sibling files will not shorten this file. Extract from INSIDE that declaration instead: lift each cohesive group of its body — the parts that share the same inputs and are named together — into its own unit in a sibling file, and have the original call them.
  • FileTooLong: storage/RemoteLogManager.java storage/src/main/java/org/apache/kafka/server/log/remote/storage/RemoteLogManager.java — FileTooLong — 1538 significant lines (blank, comment-only and punctuation-only lines excluded), about 92% of them inside a single declaration: RemoteLogManager (151-2477). The bar is 500 significant lines; this is 1038 over it, 3.08× the bar. Moving the declarations that sit BESIDE it into sibling files will not shorten this file. Extract from INSIDE that declaration instead: lift each cohesive group of its body — the parts that share the same inputs and are named together — into its own unit in a sibling file, and have the original call them.
  • FileTooLong: runtime/Worker.java connect/runtime/src/main/java/org/apache/kafka/connect/runtime/Worker.java — FileTooLong — 1516 significant lines (blank, comment-only and punctuation-only lines excluded), about 93% of them inside a single declaration: Worker (140-2512). The bar is 500 significant lines; this is 1016 over it, 3.03× the bar. Moving the declarations that sit BESIDE it into sibling files will not shorten this file. Extract from INSIDE that declaration instead: lift each cohesive group of its body — the parts that share the same inputs and are named together — into its own unit in a sibling file, and have the original call them.
  • FileTooLong: log/UnifiedLog.java storage/src/main/java/org/apache/kafka/storage/internals/log/UnifiedLog.java — FileTooLong — 1475 significant lines (blank, comment-only and punctuation-only lines excluded), about 95% of them inside a single declaration: UnifiedLog (105-2806). The bar is 500 significant lines; this is 975 over it, 2.95× the bar. Moving the declarations that sit BESIDE it into sibling files will not shorten this file. Extract from INSIDE that declaration instead: lift each cohesive group of its body — the parts that share the same inputs and are named together — into its own unit in a sibling file, and have the original call them.
  • FileTooLong: internals/InternalTopologyBuilder.java streams/src/main/java/org/apache/kafka/streams/processor/internals/InternalTopologyBuilder.java — FileTooLong — 1471 significant lines (blank, comment-only and punctuation-only lines excluded), about 97% of them inside a single declaration: InternalTopologyBuilder (72-2362). The bar is 500 significant lines; this is 971 over it, 2.94× the bar. Moving the declarations that sit BESIDE it into sibling files will not shorten this file. Extract from INSIDE that declaration instead: lift each cohesive group of its body — the parts that share the same inputs and are named together — into its own unit in a sibling file, and have the original call them.
  • FileTooLong: controller/QuorumController.java metadata/src/main/java/org/apache/kafka/controller/QuorumController.java — FileTooLong — 1440 significant lines (blank, comment-only and punctuation-only lines excluded), about 91% of them inside a single declaration: QuorumController (177-2245). The bar is 500 significant lines; this is 940 over it, 2.88× the bar. Moving the declarations that sit BESIDE it into sibling files will not shorten this file. Extract from INSIDE that declaration instead: lift each cohesive group of its body — the parts that share the same inputs and are named together — into its own unit in a sibling file, and have the original call them.
  • FileTooLong: message/MessageDataGenerator.java generator/src/main/java/org/apache/kafka/message/MessageDataGenerator.java — FileTooLong — 1433 significant lines (blank, comment-only and punctuation-only lines excluded), about 99% of them inside a single declaration: MessageDataGenerator (32-1716). The bar is 500 significant lines; this is 933 over it, 2.87× the bar. Moving the declarations that sit BESIDE it into sibling files will not shorten this file. Extract from INSIDE that declaration instead: lift each cohesive group of its body — the parts that share the same inputs and are named together — into its own unit in a sibling file, and have the original call them.
  • FileTooLong: internals/StreamThread.java streams/src/main/java/org/apache/kafka/streams/processor/internals/StreamThread.java — FileTooLong — 1405 significant lines (blank, comment-only and punctuation-only lines excluded), about 94% of them inside a single declaration: StreamThread (113-2280). The bar is 500 significant lines; this is 905 over it, 2.81× the bar. Moving the declarations that sit BESIDE it into sibling files will not shorten this file. Extract from INSIDE that declaration instead: lift each cohesive group of its body — the parts that share the same inputs and are named together — into its own unit in a sibling file, and have the original call them.
  • FileTooLong: streams/StreamsConfig.java streams/src/main/java/org/apache/kafka/streams/StreamsConfig.java — FileTooLong — 1377 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 877 over it, 2.75× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
  • FileTooLong: internals/TaskManager.java streams/src/main/java/org/apache/kafka/streams/processor/internals/TaskManager.java — FileTooLong — 1351 significant lines (blank, comment-only and punctuation-only lines excluded), about 96% of them inside a single declaration: TaskManager (78-2242). The bar is 500 significant lines; this is 851 over it, 2.70× the bar. Moving the declarations that sit BESIDE it into sibling files will not shorten this file. Extract from INSIDE that declaration instead: lift each cohesive group of its body — the parts that share the same inputs and are named together — into its own unit in a sibling file, and have the original call them.
  • FileTooLong: internals/TransactionManager.java clients/src/main/java/org/apache/kafka/clients/producer/internals/TransactionManager.java — FileTooLong — 1235 significant lines (blank, comment-only and punctuation-only lines excluded), about 94% of them inside a single declaration: TransactionManager (99-2066). The bar is 500 significant lines; this is 735 over it, 2.47× the bar. Moving the declarations that sit BESIDE it into sibling files will not shorten this file. Extract from INSIDE that declaration instead: lift each cohesive group of its body — the parts that share the same inputs and are named together — into its own unit in a sibling file, and have the original call them.
  • FileTooLong: runtime/CoordinatorRuntime.java coordinator-common/src/main/java/org/apache/kafka/coordinator/common/runtime/CoordinatorRuntime.java — FileTooLong — 1205 significant lines (blank, comment-only and punctuation-only lines excluded), about 96% of them inside a single declaration: CoordinatorRuntime (100-2541). The bar is 500 significant lines; this is 705 over it, 2.41× the bar. Moving the declarations that sit BESIDE it into sibling files will not shorten this file. Extract from INSIDE that declaration instead: lift each cohesive group of its body — the parts that share the same inputs and are named together — into its own unit in a sibling file, and have the original call them.
  • FileTooLong: streams/KafkaStreams.java streams/src/main/java/org/apache/kafka/streams/KafkaStreams.java — FileTooLong — 1177 significant lines (blank, comment-only and punctuation-only lines excluded), about 91% of them inside a single declaration: KafkaStreams (165-2363). The bar is 500 significant lines; this is 677 over it, 2.35× the bar. Moving the declarations that sit BESIDE it into sibling files will not shorten this file. Extract from INSIDE that declaration instead: lift each cohesive group of its body — the parts that share the same inputs and are named together — into its own unit in a sibling file, and have the original call them.
  • FileTooLong: persister/PersisterStateManager.java server-common/src/main/java/org/apache/kafka/server/share/persister/PersisterStateManager.java — FileTooLong — 1165 significant lines (blank, comment-only and punctuation-only lines excluded), about 95% of them inside a single declaration: PersisterStateManager (92-1832). The bar is 500 significant lines; this is 665 over it, 2.33× the bar. Moving the declarations that sit BESIDE it into sibling files will not shorten this file. Extract from INSIDE that declaration instead: lift each cohesive group of its body — the parts that share the same inputs and are named together — into its own unit in a sibling file, and have the original call them.
  • FileTooLong: internals/RocksDBGenericOptionsToDbOptionsColumnFamilyOptionsAdapter.java streams/src/main/java/org/apache/kafka/streams/state/internals/RocksDBGenericOptionsToDbOptionsColumnFamilyOptionsAdapter.java — FileTooLong — 1143 significant lines (blank, comment-only and punctuation-only lines excluded), about 97% of them inside a single declaration: RocksDBGenericOptionsToDbOptionsColumnFamilyOptionsAdapter (65-1802). The bar is 500 significant lines; this is 643 over it, 2.29× the bar. Moving the declarations that sit BESIDE it into sibling files will not shorten this file. Extract from INSIDE that declaration instead: lift each cohesive group of its body — the parts that share the same inputs and are named together — into its own unit in a sibling file, and have the original call them.
  • FileTooLong: clients/NetworkClient.java clients/src/main/java/org/apache/kafka/clients/NetworkClient.java — FileTooLong — 1127 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 627 over it, 2.25× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
  • + 97 more in this group — see findings.md.
D4 · Code Duplication · Duplicated block (5 lines × 2) · ×66
  • Duplicated block (5 lines × 2) clients/src/main/java/org/apache/kafka/clients/FetchSessionHandler.java:451 — clients/src/main/java/org/apache/kafka/clients/FetchSessionHandler.java:451-455 | clients/src/main/java/org/apache/kafka/clients/FetchSessionHandler.java:478-482 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `clients/src/main/java/org/apache/kafka/clients/FetchSessionHandler.java:451` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (5 lines × 2) clients/src/main/java/org/apache/kafka/clients/admin/ConsumerGroupDescription.java:93 — clients/src/main/java/org/apache/kafka/clients/admin/ConsumerGroupDescription.java:93-97 | clients/src/main/java/org/apache/kafka/clients/admin/ConsumerGroupDescription.java:115-119 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `clients/src/main/java/org/apache/kafka/clients/admin/ConsumerGroupDescription.java:98` calls `parse`, `toString` and `clients/src/main/java/org/apache/kafka/clients/admin/ConsumerGroupDescription.java:120` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (5 lines × 2) clients/src/main/java/org/apache/kafka/clients/admin/KafkaAdminClient.java:3566 — clients/src/main/java/org/apache/kafka/clients/admin/KafkaAdminClient.java:3566-3570 | clients/src/main/java/org/apache/kafka/clients/admin/KafkaAdminClient.java:3728-3732 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `clients/src/main/java/org/apache/kafka/clients/admin/KafkaAdminClient.java:3566` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (5 lines × 2) clients/src/main/java/org/apache/kafka/clients/admin/KafkaAdminClient.java:3613 — clients/src/main/java/org/apache/kafka/clients/admin/KafkaAdminClient.java:3613-3617 | clients/src/main/java/org/apache/kafka/clients/admin/KafkaAdminClient.java:3777-3781 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `clients/src/main/java/org/apache/kafka/clients/admin/KafkaAdminClient.java:3613` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (5 lines × 2) clients/src/main/java/org/apache/kafka/clients/admin/StreamsGroupMemberDescription.java:204 — clients/src/main/java/org/apache/kafka/clients/admin/StreamsGroupMemberDescription.java:204-208 | group-coordinator/src/main/java/org/apache/kafka/coordinator/group/modern/consumer/ConsumerGroupMember.java:574-578 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
  • Duplicated block (5 lines × 2) clients/src/main/java/org/apache/kafka/clients/consumer/internals/AsyncKafkaConsumer.java:497 — clients/src/main/java/org/apache/kafka/clients/consumer/internals/AsyncKafkaConsumer.java:497-501 | clients/src/main/java/org/apache/kafka/clients/consumer/internals/ClassicKafkaConsumer.java:186-191 — before extracting anything, compare `clients/src/main/java/org/apache/kafka/clients/consumer/internals/AsyncKafkaConsumer.java` and `clients/src/main/java/org/apache/kafka/clients/consumer/internals/ClassicKafkaConsumer.java` as WHOLE FILES: this scan already matched 11 separate duplicated blocks between them, totalling at least 102 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `clients/src/main/java/org/apache/kafka/clients/consumer/internals/AsyncKafkaConsumer.java:497` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (5 lines × 2) clients/src/main/java/org/apache/kafka/clients/consumer/internals/ConsumerMembershipManager.java:224 — clients/src/main/java/org/apache/kafka/clients/consumer/internals/ConsumerMembershipManager.java:224-228 | clients/src/main/java/org/apache/kafka/clients/consumer/internals/ShareMembershipManager.java:138-142 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `clients/src/main/java/org/apache/kafka/clients/consumer/internals/ConsumerMembershipManager.java:224` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (5 lines × 2) clients/src/main/java/org/apache/kafka/clients/producer/internals/TransactionManager.java:1827 — clients/src/main/java/org/apache/kafka/clients/producer/internals/TransactionManager.java:1827-1831 | clients/src/main/java/org/apache/kafka/clients/producer/internals/TransactionManager.java:1890-1894 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `clients/src/main/java/org/apache/kafka/clients/producer/internals/TransactionManager.java:1827` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `clients/src/main/java/org/apache/kafka/clients/producer/internals/TransactionManager.java:1896` calls `abortableErrorIfPossible`, `exception` and `clients/src/main/java/org/apache/kafka/clients/producer/internals/TransactionManager.java:1832` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (5 lines × 2) clients/src/main/java/org/apache/kafka/common/network/SslTransportLayer.java:681 — clients/src/main/java/org/apache/kafka/common/network/SslTransportLayer.java:681-686 | clients/src/main/java/org/apache/kafka/common/network/SslTransportLayer.java:755-759 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `clients/src/main/java/org/apache/kafka/common/network/SslTransportLayer.java:681` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (5 lines × 2) clients/src/main/java/org/apache/kafka/common/protocol/types/ArrayOf.java:85 — clients/src/main/java/org/apache/kafka/common/protocol/types/ArrayOf.java:85-89 | clients/src/main/java/org/apache/kafka/common/protocol/types/CompactArrayOf.java:90-94 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `clients/src/main/java/org/apache/kafka/common/protocol/types/ArrayOf.java:85` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (5 lines × 2) clients/src/main/java/org/apache/kafka/common/serialization/DoubleSerializer.java:30 — clients/src/main/java/org/apache/kafka/common/serialization/DoubleSerializer.java:30-34 | clients/src/main/java/org/apache/kafka/common/serialization/LongSerializer.java:28-32 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `clients/src/main/java/org/apache/kafka/common/serialization/DoubleSerializer.java:30` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `clients/src/main/java/org/apache/kafka/common/serialization/DoubleSerializer.java:29` calls `doubleToLongBits` and `clients/src/main/java/org/apache/kafka/common/serialization/LongSerializer.java:26` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (5 lines × 2) connect/runtime/src/main/java/org/apache/kafka/connect/runtime/Worker.java:2070 — connect/runtime/src/main/java/org/apache/kafka/connect/runtime/Worker.java:2070-2074 | connect/runtime/src/main/java/org/apache/kafka/connect/runtime/Worker.java:2135-2139 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `connect/runtime/src/main/java/org/apache/kafka/connect/runtime/Worker.java:2070` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (5 lines × 2) connect/runtime/src/main/java/org/apache/kafka/connect/runtime/distributed/ExtendedAssignment.java:249 — connect/runtime/src/main/java/org/apache/kafka/connect/runtime/distributed/ExtendedAssignment.java:249-253 | connect/runtime/src/main/java/org/apache/kafka/connect/runtime/distributed/ExtendedAssignment.java:270-274 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `connect/runtime/src/main/java/org/apache/kafka/connect/runtime/distributed/ExtendedAssignment.java:249` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (5 lines × 2) connect/runtime/src/main/java/org/apache/kafka/connect/runtime/distributed/IncrementalCooperativeAssignor.java:346 — connect/runtime/src/main/java/org/apache/kafka/connect/runtime/distributed/IncrementalCooperativeAssignor.java:346-351 | connect/runtime/src/main/java/org/apache/kafka/connect/runtime/distributed/IncrementalCooperativeAssignor.java:355-359 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `connect/runtime/src/main/java/org/apache/kafka/connect/runtime/distributed/IncrementalCooperativeAssignor.java:355` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (5 lines × 2) examples/src/main/java/kafka/examples/TransactionalClientDemo.java:187 — examples/src/main/java/kafka/examples/TransactionalClientDemo.java:187-191 | tools/src/main/java/org/apache/kafka/tools/TransactionalMessageCopier.java:239-243 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `examples/src/main/java/kafka/examples/TransactionalClientDemo.java:187` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `examples/src/main/java/kafka/examples/TransactionalClientDemo.java:185` calls `printOut` and `tools/src/main/java/org/apache/kafka/tools/TransactionalMessageCopier.java:237` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (5 lines × 2) group-coordinator/src/main/java/org/apache/kafka/coordinator/group/assignor/SimpleHeterogeneousAssignmentBuilder.java:109 — group-coordinator/src/main/java/org/apache/kafka/coordinator/group/assignor/SimpleHeterogeneousAssignmentBuilder.java:109-113 | group-coordinator/src/main/java/org/apache/kafka/coordinator/group/assignor/SimpleHomogeneousAssignmentBuilder.java:140-144 — before extracting anything, compare `group-coordinator/src/main/java/org/apache/kafka/coordinator/group/assignor/SimpleHeterogeneousAssignmentBuilder.java` and `group-coordinator/src/main/java/org/apache/kafka/coordinator/group/assignor/SimpleHomogeneousAssignmentBuilder.java` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 42 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (5 lines × 2) group-coordinator/src/main/java/org/apache/kafka/coordinator/group/assignor/UniformHeterogeneousAssignmentBuilder.java:857 — group-coordinator/src/main/java/org/apache/kafka/coordinator/group/assignor/UniformHeterogeneousAssignmentBuilder.java:857-861 | group-coordinator/src/main/java/org/apache/kafka/coordinator/group/assignor/UniformHeterogeneousAssignmentBuilder.java:889-893 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (5 lines × 2) group-coordinator/src/main/java/org/apache/kafka/coordinator/group/modern/consumer/ConsumerGroup.java:1190 — group-coordinator/src/main/java/org/apache/kafka/coordinator/group/modern/consumer/ConsumerGroup.java:1190-1194 | group-coordinator/src/main/java/org/apache/kafka/coordinator/group/modern/share/ShareGroup.java:345-349 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `group-coordinator/src/main/java/org/apache/kafka/coordinator/group/modern/consumer/ConsumerGroup.java:1190` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (5 lines × 2) server-common/src/main/java/org/apache/kafka/server/share/persister/PersisterStateManager.java:472 — server-common/src/main/java/org/apache/kafka/server/share/persister/PersisterStateManager.java:472-476 | server/src/main/java/org/apache/kafka/server/share/dlq/ShareGroupDLQStateManager.java:515-519 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `server-common/src/main/java/org/apache/kafka/server/share/persister/PersisterStateManager.java:472` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (5 lines × 2) server/src/main/java/org/apache/kafka/network/Request.java:293 — server/src/main/java/org/apache/kafka/network/Request.java:293-297 | server/src/main/java/org/apache/kafka/network/Request.java:302-306 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `server/src/main/java/org/apache/kafka/network/Request.java:293` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (5 lines × 2) server/src/main/java/org/apache/kafka/server/AuthHelper.java:108 — server/src/main/java/org/apache/kafka/server/AuthHelper.java:108-112 | server/src/main/java/org/apache/kafka/server/AuthHelper.java:172-176 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (5 lines × 2) streams/src/main/java/org/apache/kafka/streams/kstream/internals/KStreamImpl.java:154 — streams/src/main/java/org/apache/kafka/streams/kstream/internals/KStreamImpl.java:154-158 | streams/src/main/java/org/apache/kafka/streams/kstream/internals/KStreamImpl.java:183-187 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (5 lines × 2) streams/src/main/java/org/apache/kafka/streams/kstream/internals/TimestampedCacheFlushListener.java:41 — streams/src/main/java/org/apache/kafka/streams/kstream/internals/TimestampedCacheFlushListener.java:41-45 | streams/src/main/java/org/apache/kafka/streams/kstream/internals/TimestampedCacheFlushListenerWithHeaders.java:41-45 — before extracting anything, compare `streams/src/main/java/org/apache/kafka/streams/kstream/internals/TimestampedCacheFlushListener.java` and `streams/src/main/java/org/apache/kafka/streams/kstream/internals/TimestampedCacheFlushListenerWithHeaders.java` as WHOLE FILES: 83% of the shorter file's lines also appear in the other, so this reads as one file having been copied from the other rather than as a helper waiting to be extracted. The 2 duplicated block(s) this scan matched between them are fragments of that copy, not the extent of it — treat the file pair as the unit. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `streams/src/main/java/org/apache/kafka/streams/kstream/internals/TimestampedCacheFlushListener.java:41` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note first that the copies are not typed on the same thing: the declarations holding them bind `record` to `Record<KOut, Change<ValueAndTimestamp<VOut>>>` in one and `Record<KOut, Change<ValueTimestampHeaders<VOut>>>` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
  • Duplicated block (5 lines × 2) streams/src/main/java/org/apache/kafka/streams/processor/internals/StreamsMetadataState.java:444 — streams/src/main/java/org/apache/kafka/streams/processor/internals/StreamsMetadataState.java:444-448 | streams/src/main/java/org/apache/kafka/streams/processor/internals/StreamsMetadataState.java:452-456 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (5 lines × 2) streams/src/main/java/org/apache/kafka/streams/processor/internals/assignment/Graph.java:249 — streams/src/main/java/org/apache/kafka/streams/processor/internals/assignment/Graph.java:249-253 | streams/src/main/java/org/apache/kafka/streams/processor/internals/assignment/Graph.java:277-281 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • + 41 more in this group — see findings.md.
D3 · God Classes · MethodTooLong · ×57
  • MethodTooLong: GroupCoordinatorMetrics.<init> group-coordinator/src/main/java/org/apache/kafka/coordinator/group/metrics/GroupCoordinatorMetrics.java:173 — MethodTooLong — <init> runs 275 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 175 over it, 2.75× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • MethodTooLong: ConnectMetricsRegistry.<init> connect/runtime/src/main/java/org/apache/kafka/connect/runtime/ConnectMetricsRegistry.java:142 — MethodTooLong — <init> runs 266 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 166 over it, 2.66× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • MethodTooLong: DistributedConfig.config connect/runtime/src/main/java/org/apache/kafka/connect/runtime/distributed/DistributedConfig.java:323 — MethodTooLong — config runs 242 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 142 over it, 2.42× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • MethodTooLong: GroupMetadataManager.streamsGroupHeartbeat group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java:2113 — MethodTooLong — streamsGroupHeartbeat runs 239 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 139 over it, 2.39× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • MethodTooLong: CoordinatorClient.main trogdor/src/main/java/org/apache/kafka/trogdor/coordinator/CoordinatorClient.java:225 — MethodTooLong — main runs 214 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 114 over it, 2.14× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • MethodTooLong: RemoteLogManagerConfig.configDef storage/src/main/java/org/apache/kafka/server/log/remote/storage/RemoteLogManagerConfig.java:236 — MethodTooLong — configDef runs 196 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 96 over it, 1.96× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • MethodTooLong: AbstractRequest.doParseRequest clients/src/main/java/org/apache/kafka/common/requests/AbstractRequest.java:177 — MethodTooLong — doParseRequest runs 187 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 87 over it, 1.87× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • MethodTooLong: AbstractResponse.parseResponse clients/src/main/java/org/apache/kafka/common/requests/AbstractResponse.java:113 — MethodTooLong — parseResponse runs 187 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 87 over it, 1.87× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • MethodTooLong: RequestConvertToJson.request server/src/main/java/org/apache/kafka/network/RequestConvertToJson.java:403 — MethodTooLong — request runs 184 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 84 over it, 1.84× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • MethodTooLong: ProducerPerformance.argParser tools/src/main/java/org/apache/kafka/tools/ProducerPerformance.java:254 — MethodTooLong — argParser runs 179 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 79 over it, 1.79× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • MethodTooLong: RequestConvertToJson.response server/src/main/java/org/apache/kafka/network/RequestConvertToJson.java:590 — MethodTooLong — response runs 178 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 78 over it, 1.78× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • MethodTooLong: MessageDataGenerator.generateClassWriter generator/src/main/java/org/apache/kafka/message/MessageDataGenerator.java:731 — MethodTooLong — generateClassWriter runs 171 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 71 over it, 1.71× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • MethodTooLong: ConsoleProducerOptions.<init> tools/src/main/java/org/apache/kafka/tools/ConsoleProducer.java:144 — MethodTooLong — <init> runs 165 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 65 over it, 1.65× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • MethodTooLong: MessageDataGenerator.generateVariableLengthFieldSize generator/src/main/java/org/apache/kafka/message/MessageDataGenerator.java:1183 — MethodTooLong — generateVariableLengthFieldSize runs 153 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 53 over it, 1.53× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • MethodTooLong: QuorumController.<init> metadata/src/main/java/org/apache/kafka/controller/QuorumController.java:1499 — MethodTooLong — <init> runs 153 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 53 over it, 1.53× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • MethodTooLong: KTableImpl.doJoinOnForeignKey streams/src/main/java/org/apache/kafka/streams/kstream/internals/KTableImpl.java:1207 — MethodTooLong — doJoinOnForeignKey runs 153 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 53 over it, 1.53× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • MethodTooLong: ConsoleConsumerOptions.<init> tools/src/main/java/org/apache/kafka/tools/consumer/ConsoleConsumerOptions.java:72 — MethodTooLong — <init> runs 152 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 52 over it, 1.52× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • MethodTooLong: RequestManagers.supplier clients/src/main/java/org/apache/kafka/clients/consumer/internals/RequestManagers.java:161 — MethodTooLong — supplier runs 150 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 50 over it, 1.50× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • MethodTooLong: KafkaProducer.<init> clients/src/main/java/org/apache/kafka/clients/producer/KafkaProducer.java:359 — MethodTooLong — <init> runs 147 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 47 over it, 1.47× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • MethodTooLong: GroupMetadataManager.classicGroupJoinToConsumerGroup group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java:2763 — MethodTooLong — classicGroupJoinToConsumerGroup runs 139 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 39 over it, 1.39× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • MethodTooLong: StreamThread.create streams/src/main/java/org/apache/kafka/streams/processor/internals/StreamThread.java:405 — MethodTooLong — create runs 136 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 36 over it, 1.36× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • MethodTooLong: ConsoleShareConsumerOptions.<init> tools/src/main/java/org/apache/kafka/tools/consumer/ConsoleShareConsumerOptions.java:58 — MethodTooLong — <init> runs 133 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 33 over it, 1.33× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • MethodTooLong: GroupCoordinatorShard.replay group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupCoordinatorShard.java:1298 — MethodTooLong — replay runs 132 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 32 over it, 1.32× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • MethodTooLong: MessageDataGenerator.generateClassReader generator/src/main/java/org/apache/kafka/message/MessageDataGenerator.java:419 — MethodTooLong — generateClassReader runs 131 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 31 over it, 1.31× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • MethodTooLong: AsyncKafkaConsumer.<init> clients/src/main/java/org/apache/kafka/clients/consumer/internals/AsyncKafkaConsumer.java:462 — MethodTooLong — <init> runs 124 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 24 over it, 1.24× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • + 32 more in this group — see findings.md.
D4 · Code Duplication · Duplicated block (7 lines × 2) · ×57
  • Duplicated block (7 lines × 2) clients/src/main/java/org/apache/kafka/clients/admin/internals/DescribeClassicGroupsHandler.java:91 — clients/src/main/java/org/apache/kafka/clients/admin/internals/DescribeClassicGroupsHandler.java:91-97 | clients/src/main/java/org/apache/kafka/clients/admin/internals/DescribeShareGroupsHandler.java:86-92 — before extracting anything, compare `clients/src/main/java/org/apache/kafka/clients/admin/internals/DescribeClassicGroupsHandler.java` and `clients/src/main/java/org/apache/kafka/clients/admin/internals/DescribeShareGroupsHandler.java` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 36 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (7 lines × 2) clients/src/main/java/org/apache/kafka/clients/consumer/internals/StreamsMembershipManager.java:1235 — clients/src/main/java/org/apache/kafka/clients/consumer/internals/StreamsMembershipManager.java:1235-1241 | clients/src/main/java/org/apache/kafka/clients/consumer/internals/StreamsMembershipManager.java:1308-1314 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (7 lines × 2) clients/src/main/java/org/apache/kafka/common/security/ssl/SslFactory.java:328 — clients/src/main/java/org/apache/kafka/common/security/ssl/SslFactory.java:328-334 | clients/src/main/java/org/apache/kafka/common/security/ssl/SslFactory.java:352-358 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `clients/src/main/java/org/apache/kafka/common/security/ssl/SslFactory.java:328` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (7 lines × 2) connect/runtime/src/main/java/org/apache/kafka/connect/storage/KafkaConfigBackingStore.java:526 — connect/runtime/src/main/java/org/apache/kafka/connect/storage/KafkaConfigBackingStore.java:526-532 | connect/runtime/src/main/java/org/apache/kafka/connect/storage/KafkaConfigBackingStore.java:551-559 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `connect/runtime/src/main/java/org/apache/kafka/connect/storage/KafkaConfigBackingStore.java:526` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (7 lines × 2) core/src/main/java/kafka/server/share/SharePartition.java:2553 — core/src/main/java/kafka/server/share/SharePartition.java:2553-2559 | core/src/main/java/kafka/server/share/SharePartition.java:2592-2598 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `core/src/main/java/kafka/server/share/SharePartition.java:2553` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (7 lines × 2) group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupCoordinatorService.java:852 — group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupCoordinatorService.java:852-858 | group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupCoordinatorService.java:894-900 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupCoordinatorService.java:852` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (7 lines × 2) group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java:1779 — group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java:1779-1785 | group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java:1798-1804 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit. Note first that the copies are not typed on the same thing: the declarations holding them bind `member` to `ConsumerGroupMember` in one and `StreamsGroupMember` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
  • Duplicated block (7 lines × 2) group-coordinator/src/main/java/org/apache/kafka/coordinator/group/Utils.java:262 — group-coordinator/src/main/java/org/apache/kafka/coordinator/group/Utils.java:262-268 | group-coordinator/src/main/java/org/apache/kafka/coordinator/group/streams/TasksTupleWithEpochs.java:165-171 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `group-coordinator/src/main/java/org/apache/kafka/coordinator/group/Utils.java:262` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (7 lines × 2) group-coordinator/src/main/java/org/apache/kafka/coordinator/group/streams/assignor/BalancedTaskAssignor.java:368 — group-coordinator/src/main/java/org/apache/kafka/coordinator/group/streams/assignor/BalancedTaskAssignor.java:368-374 | group-coordinator/src/main/java/org/apache/kafka/coordinator/group/streams/assignor/StickyTaskAssignor.java:276-282 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
  • Duplicated block (7 lines × 2) metadata/src/main/java/org/apache/kafka/controller/ConfigurationControlManager.java:340 — metadata/src/main/java/org/apache/kafka/controller/ConfigurationControlManager.java:340-346 | metadata/src/main/java/org/apache/kafka/controller/ConfigurationControlManager.java:550-556 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `metadata/src/main/java/org/apache/kafka/controller/ConfigurationControlManager.java:340` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (7 lines × 2) metadata/src/main/java/org/apache/kafka/controller/PeriodicTaskControlManager.java:226 — metadata/src/main/java/org/apache/kafka/controller/PeriodicTaskControlManager.java:226-232 | metadata/src/main/java/org/apache/kafka/controller/PeriodicTaskControlManager.java:242-248 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `metadata/src/main/java/org/apache/kafka/controller/PeriodicTaskControlManager.java:226` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (7 lines × 2) raft/src/main/java/org/apache/kafka/raft/KafkaRaftClient.java:3253 — raft/src/main/java/org/apache/kafka/raft/KafkaRaftClient.java:3253-3263 | raft/src/main/java/org/apache/kafka/raft/KafkaRaftClient.java:3275-3281 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `raft/src/main/java/org/apache/kafka/raft/KafkaRaftClient.java:3253` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (7 lines × 2) server/src/main/java/org/apache/kafka/server/FetchContext.java:348 — server/src/main/java/org/apache/kafka/server/FetchContext.java:348-354 | server/src/main/java/org/apache/kafka/server/FetchContext.java:371-377 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `server/src/main/java/org/apache/kafka/server/FetchContext.java:348` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (7 lines × 2) streams/src/main/java/org/apache/kafka/streams/kstream/internals/SlidingWindowedKStreamImpl.java:93 — streams/src/main/java/org/apache/kafka/streams/kstream/internals/SlidingWindowedKStreamImpl.java:93-99 | streams/src/main/java/org/apache/kafka/streams/kstream/internals/SlidingWindowedKStreamImpl.java:192-198 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `streams/src/main/java/org/apache/kafka/streams/kstream/internals/SlidingWindowedKStreamImpl.java:93` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (7 lines × 2) streams/src/main/java/org/apache/kafka/streams/kstream/internals/foreignkeyjoin/ForeignTableJoinProcessorSupplier.java:84 — streams/src/main/java/org/apache/kafka/streams/kstream/internals/foreignkeyjoin/ForeignTableJoinProcessorSupplier.java:84-90 | streams/src/main/java/org/apache/kafka/streams/kstream/internals/foreignkeyjoin/SubscriptionReceiveProcessorSupplier.java:69-76 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Note first that the copies are not typed on the same thing: the declarations holding them bind `context` to `ProcessorContext<KLeft, SubscriptionResponseWrapper<VRight>>` in one and `ProcessorContext<CombinedKey<KRight, KLeft>, Change<ValueTimestampHeaders<SubscriptionWrapper<KLeft>>>>` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `streams/src/main/java/org/apache/kafka/streams/kstream/internals/foreignkeyjoin/SubscriptionReceiveProcessorSupplier.java:79` calls `init` and `streams/src/main/java/org/apache/kafka/streams/kstream/internals/foreignkeyjoin/ForeignTableJoinProcessorSupplier.java:92` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (7 lines × 2) streams/src/main/java/org/apache/kafka/streams/processor/assignment/TaskAssignmentUtils.java:941 — streams/src/main/java/org/apache/kafka/streams/processor/assignment/TaskAssignmentUtils.java:941-947 | streams/src/main/java/org/apache/kafka/streams/processor/internals/assignment/ClientTagAwareStandbyTaskAssignor.java:183-189 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `streams/src/main/java/org/apache/kafka/streams/processor/assignment/TaskAssignmentUtils.java:941` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `streams/src/main/java/org/apache/kafka/streams/processor/assignment/TaskAssignmentUtils.java:949` calls `kafkaStreamsStates` and `streams/src/main/java/org/apache/kafka/streams/processor/internals/assignment/ClientTagAwareStandbyTaskAssignor.java:191` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (7 lines × 2) streams/src/main/java/org/apache/kafka/streams/processor/internals/InternalTopicManager.java:249 — streams/src/main/java/org/apache/kafka/streams/processor/internals/InternalTopicManager.java:249-255 | streams/src/main/java/org/apache/kafka/streams/processor/internals/InternalTopicManager.java:850-856 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `streams/src/main/java/org/apache/kafka/streams/processor/internals/InternalTopicManager.java:249` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `streams/src/main/java/org/apache/kafka/streams/processor/internals/InternalTopicManager.java:247` calls `addMissingTopic`, `remove` and `streams/src/main/java/org/apache/kafka/streams/processor/internals/InternalTopicManager.java:849` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (7 lines × 2) streams/src/main/java/org/apache/kafka/streams/state/internals/InMemorySessionStore.java:428 — streams/src/main/java/org/apache/kafka/streams/state/internals/InMemorySessionStore.java:428-434 | streams/src/main/java/org/apache/kafka/streams/state/internals/InMemorySessionStore.java:453-459 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `streams/src/main/java/org/apache/kafka/streams/state/internals/InMemorySessionStore.java:426` calls `requireNonNull` and `streams/src/main/java/org/apache/kafka/streams/state/internals/InMemorySessionStore.java:452` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (7 lines × 2) streams/src/main/java/org/apache/kafka/streams/state/internals/InMemorySessionTransactionBuffer.java:136 — streams/src/main/java/org/apache/kafka/streams/state/internals/InMemorySessionTransactionBuffer.java:136-142 | streams/src/main/java/org/apache/kafka/streams/state/internals/InMemorySessionTransactionBuffer.java:158-164 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `streams/src/main/java/org/apache/kafka/streams/state/internals/InMemorySessionTransactionBuffer.java:136` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `streams/src/main/java/org/apache/kafka/streams/state/internals/InMemorySessionTransactionBuffer.java:166` calls `deepCopy` and `streams/src/main/java/org/apache/kafka/streams/state/internals/InMemorySessionTransactionBuffer.java:144` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (7 lines × 2) streams/src/main/java/org/apache/kafka/streams/state/internals/InMemoryWindowTransactionBuffer.java:127 — streams/src/main/java/org/apache/kafka/streams/state/internals/InMemoryWindowTransactionBuffer.java:127-133 | streams/src/main/java/org/apache/kafka/streams/state/internals/InMemoryWindowTransactionBuffer.java:149-155 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `streams/src/main/java/org/apache/kafka/streams/state/internals/InMemoryWindowTransactionBuffer.java:127` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `streams/src/main/java/org/apache/kafka/streams/state/internals/InMemoryWindowTransactionBuffer.java:157` calls `deepCopy` and `streams/src/main/java/org/apache/kafka/streams/state/internals/InMemoryWindowTransactionBuffer.java:135` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (7 lines × 2) streams/src/main/java/org/apache/kafka/streams/state/internals/Murmur3.java:264 — streams/src/main/java/org/apache/kafka/streams/state/internals/Murmur3.java:264-270 | streams/src/main/java/org/apache/kafka/streams/state/internals/Murmur3.java:339-345 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `streams/src/main/java/org/apache/kafka/streams/state/internals/Murmur3.java:264` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (7 lines × 2) streams/src/main/java/org/apache/kafka/streams/state/internals/Murmur3.java:387 — streams/src/main/java/org/apache/kafka/streams/state/internals/Murmur3.java:387-393 | streams/src/main/java/org/apache/kafka/streams/state/internals/Murmur3.java:406-412 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `streams/src/main/java/org/apache/kafka/streams/state/internals/Murmur3.java:387` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (7 lines × 2) streams/src/main/java/org/apache/kafka/streams/state/internals/PlainToHeadersWindowStoreAdapter.java:172 — streams/src/main/java/org/apache/kafka/streams/state/internals/PlainToHeadersWindowStoreAdapter.java:172-178 | streams/src/main/java/org/apache/kafka/streams/state/internals/TimestampedToHeadersWindowStoreAdapter.java:218-224 — before extracting anything, compare `streams/src/main/java/org/apache/kafka/streams/state/internals/PlainToHeadersWindowStoreAdapter.java` and `streams/src/main/java/org/apache/kafka/streams/state/internals/TimestampedToHeadersWindowStoreAdapter.java` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 33 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `streams/src/main/java/org/apache/kafka/streams/state/internals/PlainToHeadersWindowStoreAdapter.java:172` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (7 lines × 2) tools/src/main/java/org/apache/kafka/tools/reassign/ReassignPartitionsCommand.java:814 — tools/src/main/java/org/apache/kafka/tools/reassign/ReassignPartitionsCommand.java:814-820 | tools/src/main/java/org/apache/kafka/tools/reassign/ReassignPartitionsCommand.java:1308-1314 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `tools/src/main/java/org/apache/kafka/tools/reassign/ReassignPartitionsCommand.java:814` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (7 lines × 2) trogdor/src/main/java/org/apache/kafka/trogdor/workload/ConsumeBenchWorker.java:378 — trogdor/src/main/java/org/apache/kafka/trogdor/workload/ConsumeBenchWorker.java:378-384 | trogdor/src/main/java/org/apache/kafka/trogdor/workload/ShareConsumeBenchWorker.java:416-422 — before extracting anything, compare `trogdor/src/main/java/org/apache/kafka/trogdor/workload/ConsumeBenchWorker.java` and `trogdor/src/main/java/org/apache/kafka/trogdor/workload/ShareConsumeBenchWorker.java` as WHOLE FILES: this scan already matched 12 separate duplicated blocks between them, totalling at least 137 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • + 32 more in this group — see findings.md.
D4 · Code Duplication · Duplicated block (6 lines × 2) · ×57
  • Duplicated block (6 lines × 2) clients/src/main/java/org/apache/kafka/clients/producer/internals/TransactionManager.java:1832 — clients/src/main/java/org/apache/kafka/clients/producer/internals/TransactionManager.java:1832-1837 | clients/src/main/java/org/apache/kafka/clients/producer/internals/TransactionManager.java:1897-1902 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `clients/src/main/java/org/apache/kafka/clients/producer/internals/TransactionManager.java:1832` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `clients/src/main/java/org/apache/kafka/clients/producer/internals/TransactionManager.java:1896` calls `abortableErrorIfPossible`, `exception` and `clients/src/main/java/org/apache/kafka/clients/producer/internals/TransactionManager.java:1831` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (6 lines × 2) clients/src/main/java/org/apache/kafka/common/protocol/MessageUtil.java:207 — clients/src/main/java/org/apache/kafka/common/protocol/MessageUtil.java:207-212 | clients/src/main/java/org/apache/kafka/common/protocol/MessageUtil.java:234-239 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `clients/src/main/java/org/apache/kafka/common/protocol/MessageUtil.java:207` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (6 lines × 2) clients/src/main/java/org/apache/kafka/common/security/plain/PlainLoginModule.java:40 — clients/src/main/java/org/apache/kafka/common/security/plain/PlainLoginModule.java:40-45 | clients/src/main/java/org/apache/kafka/common/security/scram/ScramLoginModule.java:43-48 — before extracting anything, compare `clients/src/main/java/org/apache/kafka/common/security/plain/PlainLoginModule.java` and `clients/src/main/java/org/apache/kafka/common/security/scram/ScramLoginModule.java` as WHOLE FILES: 83% of the shorter file's lines also appear in the other, so this reads as one file having been copied from the other rather than as a helper waiting to be extracted. The 1 duplicated block(s) this scan matched between them are fragments of that copy, not the extent of it — treat the file pair as the unit. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
  • Duplicated block (6 lines × 2) clients/src/main/java/org/apache/kafka/common/serialization/ListDeserializer.java:109 — clients/src/main/java/org/apache/kafka/common/serialization/ListDeserializer.java:109-115 | clients/src/main/java/org/apache/kafka/common/serialization/ListSerializer.java:79-84 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `clients/src/main/java/org/apache/kafka/common/serialization/ListDeserializer.java:109` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (6 lines × 2) connect/transforms/src/main/java/org/apache/kafka/connect/transforms/Cast.java:393 — connect/transforms/src/main/java/org/apache/kafka/connect/transforms/Cast.java:393-398 | connect/transforms/src/main/java/org/apache/kafka/connect/transforms/Cast.java:402-407 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (6 lines × 2) generator/src/main/java/org/apache/kafka/message/checker/Unifier.java:101 — generator/src/main/java/org/apache/kafka/message/checker/Unifier.java:101-106 | generator/src/main/java/org/apache/kafka/message/checker/Unifier.java:121-126 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (6 lines × 2) metadata/src/main/java/org/apache/kafka/image/ClusterDelta.java:167 — metadata/src/main/java/org/apache/kafka/image/ClusterDelta.java:167-172 | metadata/src/main/java/org/apache/kafka/image/ClusterDelta.java:184-189 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `metadata/src/main/java/org/apache/kafka/image/ClusterDelta.java:167` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (6 lines × 2) metadata/src/main/java/org/apache/kafka/metadata/BrokerRegistration.java:354 — metadata/src/main/java/org/apache/kafka/metadata/BrokerRegistration.java:354-360 | metadata/src/main/java/org/apache/kafka/metadata/ControllerRegistration.java:180-185 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `metadata/src/main/java/org/apache/kafka/metadata/BrokerRegistration.java:354` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (6 lines × 2) storage/src/main/java/org/apache/kafka/server/log/remote/metadata/storage/serialization/RemoteLogSegmentMetadataSnapshotTransform.java:35 — storage/src/main/java/org/apache/kafka/server/log/remote/metadata/storage/serialization/RemoteLogSegmentMetadataSnapshotTransform.java:35-40 | storage/src/main/java/org/apache/kafka/server/log/remote/metadata/storage/serialization/RemoteLogSegmentMetadataTransform.java:39-44 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `storage/src/main/java/org/apache/kafka/server/log/remote/metadata/storage/serialization/RemoteLogSegmentMetadataSnapshotTransform.java:35` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note first that the copies are not typed on the same thing: the declarations holding them bind `segmentMetadata` to `RemoteLogSegmentMetadataSnapshot` in one and `RemoteLogSegmentMetadata` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
  • Duplicated block (6 lines × 2) storage/src/main/java/org/apache/kafka/server/log/remote/metadata/storage/serialization/RemoteLogSegmentMetadataSnapshotTransform.java:42 — storage/src/main/java/org/apache/kafka/server/log/remote/metadata/storage/serialization/RemoteLogSegmentMetadataSnapshotTransform.java:42-47 | storage/src/main/java/org/apache/kafka/server/log/remote/metadata/storage/serialization/RemoteLogSegmentMetadataTransform.java:46-51 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `storage/src/main/java/org/apache/kafka/server/log/remote/metadata/storage/serialization/RemoteLogSegmentMetadataSnapshotTransform.java:42` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note first that the copies are not typed on the same thing: the declarations holding them bind `segmentMetadata` to `RemoteLogSegmentMetadataSnapshot` in one and `RemoteLogSegmentMetadata` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
  • Duplicated block (6 lines × 2) storage/src/main/java/org/apache/kafka/storage/internals/log/UnifiedLog.java:1717 — storage/src/main/java/org/apache/kafka/storage/internals/log/UnifiedLog.java:1717-1722 | storage/src/main/java/org/apache/kafka/storage/internals/log/UnifiedLog.java:1796-1801 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `storage/src/main/java/org/apache/kafka/storage/internals/log/UnifiedLog.java:1796` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (6 lines × 2) streams/src/main/java/org/apache/kafka/streams/StreamsBuilder.java:328 — streams/src/main/java/org/apache/kafka/streams/StreamsBuilder.java:328-333 | streams/src/main/java/org/apache/kafka/streams/StreamsBuilder.java:393-398 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `streams/src/main/java/org/apache/kafka/streams/StreamsBuilder.java:328` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (6 lines × 2) streams/src/main/java/org/apache/kafka/streams/kstream/internals/AbstractKStreamTimeWindowAggregateProcessor.java:82 — streams/src/main/java/org/apache/kafka/streams/kstream/internals/AbstractKStreamTimeWindowAggregateProcessor.java:82-87 | streams/src/main/java/org/apache/kafka/streams/kstream/internals/KStreamSessionWindowAggregate.java:131-136 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `streams/src/main/java/org/apache/kafka/streams/kstream/internals/AbstractKStreamTimeWindowAggregateProcessor.java:82` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (6 lines × 2) streams/src/main/java/org/apache/kafka/streams/kstream/internals/KTableFilter.java:153 — streams/src/main/java/org/apache/kafka/streams/kstream/internals/KTableFilter.java:153-158 | streams/src/main/java/org/apache/kafka/streams/kstream/internals/KTableMapValues.java:157-162 — before extracting anything, compare `streams/src/main/java/org/apache/kafka/streams/kstream/internals/KTableFilter.java` and `streams/src/main/java/org/apache/kafka/streams/kstream/internals/KTableMapValues.java` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 42 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `streams/src/main/java/org/apache/kafka/streams/kstream/internals/KTableFilter.java:153` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (6 lines × 2) streams/src/main/java/org/apache/kafka/streams/processor/internals/TaskManager.java:1310 — streams/src/main/java/org/apache/kafka/streams/processor/internals/TaskManager.java:1310-1315 | streams/src/main/java/org/apache/kafka/streams/processor/internals/TaskManager.java:1363-1368 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `streams/src/main/java/org/apache/kafka/streams/processor/internals/TaskManager.java:1310` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (6 lines × 2) streams/src/main/java/org/apache/kafka/streams/processor/internals/assignment/MinTrafficGraphConstructor.java:70 — streams/src/main/java/org/apache/kafka/streams/processor/internals/assignment/MinTrafficGraphConstructor.java:70-75 | streams/src/main/java/org/apache/kafka/streams/processor/internals/assignment/RackAwareGraphConstructor.java:122-127 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `streams/src/main/java/org/apache/kafka/streams/processor/internals/assignment/MinTrafficGraphConstructor.java:70` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (6 lines × 2) streams/src/main/java/org/apache/kafka/streams/state/internals/RocksDBStore.java:1241 — streams/src/main/java/org/apache/kafka/streams/state/internals/RocksDBStore.java:1241-1246 | streams/src/main/java/org/apache/kafka/streams/state/internals/RocksDBStore.java:1252-1257 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (6 lines × 2) tools/src/main/java/org/apache/kafka/tools/ConsumerPerformance.java:418 — tools/src/main/java/org/apache/kafka/tools/ConsumerPerformance.java:418-423 | tools/src/main/java/org/apache/kafka/tools/ShareConsumerPerformance.java:460-465 — before extracting anything, compare `tools/src/main/java/org/apache/kafka/tools/ConsumerPerformance.java` and `tools/src/main/java/org/apache/kafka/tools/ShareConsumerPerformance.java` as WHOLE FILES: this scan already matched 10 separate duplicated blocks between them, totalling at least 119 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `tools/src/main/java/org/apache/kafka/tools/ConsumerPerformance.java:418` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `tools/src/main/java/org/apache/kafka/tools/ConsumerPerformance.java:415` calls `put`, `has` and `tools/src/main/java/org/apache/kafka/tools/ShareConsumerPerformance.java:458` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (6 lines × 2) tools/src/main/java/org/apache/kafka/tools/consumer/group/ConsumerGroupCommand.java:274 — tools/src/main/java/org/apache/kafka/tools/consumer/group/ConsumerGroupCommand.java:274-279 | tools/src/main/java/org/apache/kafka/tools/streams/StreamsGroupCommand.java:237-242 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `tools/src/main/java/org/apache/kafka/tools/consumer/group/ConsumerGroupCommand.java:274` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (6 lines × 2) tools/src/main/java/org/apache/kafka/tools/reassign/ReassignPartitionsCommand.java:1202 — tools/src/main/java/org/apache/kafka/tools/reassign/ReassignPartitionsCommand.java:1202-1207 | tools/src/main/java/org/apache/kafka/tools/reassign/ReassignPartitionsCommand.java:1224-1229 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `tools/src/main/java/org/apache/kafka/tools/reassign/ReassignPartitionsCommand.java:1202` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (6 lines × 2) trogdor/src/main/java/org/apache/kafka/trogdor/workload/SustainedConnectionWorker.java:185 — trogdor/src/main/java/org/apache/kafka/trogdor/workload/SustainedConnectionWorker.java:185-190 | trogdor/src/main/java/org/apache/kafka/trogdor/workload/SustainedConnectionWorker.java:248-253 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `trogdor/src/main/java/org/apache/kafka/trogdor/workload/SustainedConnectionWorker.java:185` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (6 lines × 2) clients/src/main/java/org/apache/kafka/clients/FetchSessionHandler.java:399 — clients/src/main/java/org/apache/kafka/clients/FetchSessionHandler.java:399-404 | clients/src/main/java/org/apache/kafka/clients/consumer/internals/ShareSessionHandler.java:267-272 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (6 lines × 2) clients/src/main/java/org/apache/kafka/clients/consumer/internals/AbstractMembershipManager.java:391 — clients/src/main/java/org/apache/kafka/clients/consumer/internals/AbstractMembershipManager.java:391-396 | clients/src/main/java/org/apache/kafka/clients/consumer/internals/StreamsMembershipManager.java:390-395 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (6 lines × 2) clients/src/main/java/org/apache/kafka/clients/consumer/internals/metrics/KafkaConsumerMetrics.java:96 — clients/src/main/java/org/apache/kafka/clients/consumer/internals/metrics/KafkaConsumerMetrics.java:96-101 | clients/src/main/java/org/apache/kafka/clients/consumer/internals/metrics/KafkaShareConsumerMetrics.java:73-78 — before extracting anything, compare `clients/src/main/java/org/apache/kafka/clients/consumer/internals/metrics/KafkaConsumerMetrics.java` and `clients/src/main/java/org/apache/kafka/clients/consumer/internals/metrics/KafkaShareConsumerMetrics.java` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 38 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (6 lines × 2) clients/src/main/java/org/apache/kafka/clients/consumer/internals/metrics/KafkaConsumerMetrics.java:103 — clients/src/main/java/org/apache/kafka/clients/consumer/internals/metrics/KafkaConsumerMetrics.java:103-108 | clients/src/main/java/org/apache/kafka/clients/consumer/internals/metrics/KafkaShareConsumerMetrics.java:80-85 — before extracting anything, compare `clients/src/main/java/org/apache/kafka/clients/consumer/internals/metrics/KafkaConsumerMetrics.java` and `clients/src/main/java/org/apache/kafka/clients/consumer/internals/metrics/KafkaShareConsumerMetrics.java` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 38 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • + 32 more in this group — see findings.md.
D4 · Code Duplication · Duplicated block (8 lines × 2) · ×55
  • Duplicated block (8 lines × 2) clients/src/main/java/org/apache/kafka/clients/admin/internals/DeleteConsumerGroupOffsetsHandler.java:115 — clients/src/main/java/org/apache/kafka/clients/admin/internals/DeleteConsumerGroupOffsetsHandler.java:115-122 | clients/src/main/java/org/apache/kafka/clients/admin/internals/RemoveMembersFromConsumerGroupHandler.java:98-105 — before extracting anything, compare `clients/src/main/java/org/apache/kafka/clients/admin/internals/DeleteConsumerGroupOffsetsHandler.java` and `clients/src/main/java/org/apache/kafka/clients/admin/internals/RemoveMembersFromConsumerGroupHandler.java` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 61 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `clients/src/main/java/org/apache/kafka/clients/admin/internals/DeleteConsumerGroupOffsetsHandler.java:115` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (8 lines × 2) clients/src/main/java/org/apache/kafka/clients/consumer/internals/AbstractCoordinator.java:647 — clients/src/main/java/org/apache/kafka/clients/consumer/internals/AbstractCoordinator.java:647-654 | clients/src/main/java/org/apache/kafka/clients/consumer/internals/AbstractCoordinator.java:828-835 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `clients/src/main/java/org/apache/kafka/clients/consumer/internals/AbstractCoordinator.java:647` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (8 lines × 2) clients/src/main/java/org/apache/kafka/clients/consumer/internals/AsyncKafkaConsumer.java:504 — clients/src/main/java/org/apache/kafka/clients/consumer/internals/AsyncKafkaConsumer.java:504-511 | clients/src/main/java/org/apache/kafka/clients/consumer/internals/ClassicKafkaConsumer.java:194-201 — before extracting anything, compare `clients/src/main/java/org/apache/kafka/clients/consumer/internals/AsyncKafkaConsumer.java` and `clients/src/main/java/org/apache/kafka/clients/consumer/internals/ClassicKafkaConsumer.java` as WHOLE FILES: this scan already matched 11 separate duplicated blocks between them, totalling at least 102 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (8 lines × 2) clients/src/main/java/org/apache/kafka/clients/consumer/internals/AsyncKafkaConsumer.java:1667 — clients/src/main/java/org/apache/kafka/clients/consumer/internals/AsyncKafkaConsumer.java:1667-1674 | clients/src/main/java/org/apache/kafka/clients/consumer/internals/ShareConsumerImpl.java:1035-1042 — before extracting anything, compare `clients/src/main/java/org/apache/kafka/clients/consumer/internals/AsyncKafkaConsumer.java` and `clients/src/main/java/org/apache/kafka/clients/consumer/internals/ShareConsumerImpl.java` as WHOLE FILES: this scan already matched 13 separate duplicated blocks between them, totalling at least 131 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (8 lines × 2) clients/src/main/java/org/apache/kafka/clients/consumer/internals/OffsetFetcher.java:391 — clients/src/main/java/org/apache/kafka/clients/consumer/internals/OffsetFetcher.java:391-398 | clients/src/main/java/org/apache/kafka/clients/consumer/internals/OffsetsRequestManager.java:970-977 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `clients/src/main/java/org/apache/kafka/clients/consumer/internals/OffsetFetcher.java:391` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (8 lines × 2) clients/src/main/java/org/apache/kafka/common/requests/InitializeShareGroupStateResponse.java:47 — clients/src/main/java/org/apache/kafka/common/requests/InitializeShareGroupStateResponse.java:47-54 | clients/src/main/java/org/apache/kafka/common/requests/ReadShareGroupStateResponse.java:47-54 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
  • Duplicated block (8 lines × 2) clients/src/main/java/org/apache/kafka/common/requests/ShareAcknowledgeResponse.java:66 — clients/src/main/java/org/apache/kafka/common/requests/ShareAcknowledgeResponse.java:66-73 | clients/src/main/java/org/apache/kafka/common/requests/ShareFetchResponse.java:73-80 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `clients/src/main/java/org/apache/kafka/common/requests/ShareAcknowledgeResponse.java:66` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (8 lines × 2) connect/mirror-client/src/main/java/org/apache/kafka/connect/mirror/MirrorClientConfig.java:88 — connect/mirror-client/src/main/java/org/apache/kafka/connect/mirror/MirrorClientConfig.java:88-95 | connect/mirror/src/main/java/org/apache/kafka/connect/mirror/MirrorConnectorConfig.java:248-255 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
  • Duplicated block (8 lines × 2) connect/runtime/src/main/java/org/apache/kafka/connect/storage/KafkaConfigBackingStore.java:1199 — connect/runtime/src/main/java/org/apache/kafka/connect/storage/KafkaConfigBackingStore.java:1199-1206 | connect/runtime/src/main/java/org/apache/kafka/connect/storage/KafkaConfigBackingStore.java:1239-1246 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `connect/runtime/src/main/java/org/apache/kafka/connect/storage/KafkaConfigBackingStore.java:1199` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (8 lines × 2) connect/runtime/src/main/java/org/apache/kafka/connect/storage/KafkaConfigBackingStore.java:1272 — connect/runtime/src/main/java/org/apache/kafka/connect/storage/KafkaConfigBackingStore.java:1272-1279 | connect/runtime/src/main/java/org/apache/kafka/connect/storage/KafkaStatusBackingStore.java:522-529 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `connect/runtime/src/main/java/org/apache/kafka/connect/storage/KafkaConfigBackingStore.java:1272` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `connect/runtime/src/main/java/org/apache/kafka/connect/storage/KafkaStatusBackingStore.java:530` calls `warn` and `connect/runtime/src/main/java/org/apache/kafka/connect/storage/KafkaConfigBackingStore.java:1280` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (8 lines × 2) coordinator-common/src/main/java/org/apache/kafka/coordinator/common/runtime/KRaftCoordinatorMetadataImage.java:57 — coordinator-common/src/main/java/org/apache/kafka/coordinator/common/runtime/KRaftCoordinatorMetadataImage.java:57-64 | coordinator-common/src/main/java/org/apache/kafka/coordinator/common/runtime/KRaftCoordinatorMetadataImage.java:68-75 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
  • Duplicated block (8 lines × 2) generator/src/main/java/org/apache/kafka/message/MetadataRecordTypeGenerator.java:121 — generator/src/main/java/org/apache/kafka/message/MetadataRecordTypeGenerator.java:121-128 | generator/src/main/java/org/apache/kafka/message/MetadataRecordTypeGenerator.java:146-153 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `generator/src/main/java/org/apache/kafka/message/MetadataRecordTypeGenerator.java:121` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (8 lines × 2) group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupCoordinatorService.java:481 — group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupCoordinatorService.java:481-488 | group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupCoordinatorService.java:576-583 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupCoordinatorService.java:481` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note first that the copies are not typed on the same thing: the declarations holding them bind `request` to `ConsumerGroupHeartbeatRequestData` in one and `StreamsGroupHeartbeatRequestData` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
  • Duplicated block (8 lines × 2) group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java:1739 — group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java:1739-1746 | group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java:1759-1766 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit. Note first that the copies are not typed on the same thing: the declarations holding them bind `member` to `ConsumerGroupMember` in one and `StreamsGroupMember` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
  • Duplicated block (8 lines × 2) group-coordinator/src/main/java/org/apache/kafka/coordinator/group/streams/assignor/StickyTaskAssignor.java:167 — group-coordinator/src/main/java/org/apache/kafka/coordinator/group/streams/assignor/StickyTaskAssignor.java:167-174 | group-coordinator/src/main/java/org/apache/kafka/coordinator/group/streams/assignor/StickyTaskAssignor.java:181-188 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `group-coordinator/src/main/java/org/apache/kafka/coordinator/group/streams/assignor/StickyTaskAssignor.java:167` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (8 lines × 2) group-coordinator/src/main/java/org/apache/kafka/coordinator/group/streams/assignor/StickyTaskAssignor.java:299 — group-coordinator/src/main/java/org/apache/kafka/coordinator/group/streams/assignor/StickyTaskAssignor.java:299-306 | group-coordinator/src/main/java/org/apache/kafka/coordinator/group/streams/assignor/StickyTaskAssignor.java:313-320 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `group-coordinator/src/main/java/org/apache/kafka/coordinator/group/streams/assignor/StickyTaskAssignor.java:299` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (8 lines × 2) metadata/src/main/java/org/apache/kafka/controller/ClusterControlManager.java:667 — metadata/src/main/java/org/apache/kafka/controller/ClusterControlManager.java:667-674 | metadata/src/main/java/org/apache/kafka/image/ClusterDelta.java:141-148 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `metadata/src/main/java/org/apache/kafka/image/ClusterDelta.java:140` calls `getBrokerOrThrow`, `brokerId`, `brokerEpoch` and `metadata/src/main/java/org/apache/kafka/controller/ClusterControlManager.java:666` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (8 lines × 2) server-common/src/main/java/org/apache/kafka/server/share/persister/DefaultStatePersister.java:284 — server-common/src/main/java/org/apache/kafka/server/share/persister/DefaultStatePersister.java:284-291 | server-common/src/main/java/org/apache/kafka/server/share/persister/DefaultStatePersister.java:437-445 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Note first that the copies are not typed on the same thing: the declarations holding them bind `request` to `ReadShareGroupStateParameters` in one and `ReadShareGroupStateSummaryParameters` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
  • Duplicated block (8 lines × 2) storage/src/main/java/org/apache/kafka/server/log/remote/storage/RemoteLogManager.java:1131 — storage/src/main/java/org/apache/kafka/server/log/remote/storage/RemoteLogManager.java:1131-1138 | storage/src/main/java/org/apache/kafka/server/log/remote/storage/RemoteLogManager.java:1154-1161 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `storage/src/main/java/org/apache/kafka/server/log/remote/storage/RemoteLogManager.java:1131` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (8 lines × 2) streams/src/main/java/org/apache/kafka/streams/kstream/internals/AbstractKStreamTimeWindowAggregateProcessor.java:95 — streams/src/main/java/org/apache/kafka/streams/kstream/internals/AbstractKStreamTimeWindowAggregateProcessor.java:95-102 | streams/src/main/java/org/apache/kafka/streams/kstream/internals/KStreamSessionWindowAggregate.java:144-151 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `streams/src/main/java/org/apache/kafka/streams/kstream/internals/AbstractKStreamTimeWindowAggregateProcessor.java:95` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (8 lines × 2) streams/src/main/java/org/apache/kafka/streams/kstream/internals/graph/ProcessorParameters.java:73 — streams/src/main/java/org/apache/kafka/streams/kstream/internals/graph/ProcessorParameters.java:73-80 | streams/src/main/java/org/apache/kafka/streams/kstream/internals/graph/ProcessorParameters.java:88-95 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `streams/src/main/java/org/apache/kafka/streams/kstream/internals/graph/ProcessorParameters.java:73` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (8 lines × 2) streams/src/main/java/org/apache/kafka/streams/processor/internals/StreamThread.java:2062 — streams/src/main/java/org/apache/kafka/streams/processor/internals/StreamThread.java:2062-2069 | streams/src/main/java/org/apache/kafka/streams/processor/internals/StreamThread.java:2072-2079 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `streams/src/main/java/org/apache/kafka/streams/processor/internals/StreamThread.java:2062` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (8 lines × 2) streams/src/main/java/org/apache/kafka/streams/processor/internals/StreamsMetadataState.java:491 — streams/src/main/java/org/apache/kafka/streams/processor/internals/StreamsMetadataState.java:491-498 | streams/src/main/java/org/apache/kafka/streams/processor/internals/StreamsMetadataState.java:526-533 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `streams/src/main/java/org/apache/kafka/streams/processor/internals/StreamsMetadataState.java:491` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `streams/src/main/java/org/apache/kafka/streams/processor/internals/StreamsMetadataState.java:534` calls `topologyName`, `equals` and `streams/src/main/java/org/apache/kafka/streams/processor/internals/StreamsMetadataState.java:499` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (8 lines × 2) streams/src/main/java/org/apache/kafka/streams/processor/internals/assignment/RackUtils.java:104 — streams/src/main/java/org/apache/kafka/streams/processor/internals/assignment/RackUtils.java:104-111 | streams/src/main/java/org/apache/kafka/streams/processor/internals/assignment/RackUtils.java:120-127 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `streams/src/main/java/org/apache/kafka/streams/processor/internals/assignment/RackUtils.java:104` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (8 lines × 2) streams/src/main/java/org/apache/kafka/streams/state/internals/AbstractMergedSortedCacheStoreIterator.java:172 — streams/src/main/java/org/apache/kafka/streams/state/internals/AbstractMergedSortedCacheStoreIterator.java:172-179 | streams/src/main/java/org/apache/kafka/streams/state/internals/AbstractMergedSortedCacheStoreIterator.java:273-280 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `streams/src/main/java/org/apache/kafka/streams/state/internals/AbstractMergedSortedCacheStoreIterator.java:172` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • + 30 more in this group — see findings.md.
D4 · Code Duplication · Duplicated block (9 lines × 2) · ×53
  • Duplicated block (9 lines × 2) clients/src/main/java/org/apache/kafka/clients/admin/AlterConsumerGroupOffsetsResult.java:45 — clients/src/main/java/org/apache/kafka/clients/admin/AlterConsumerGroupOffsetsResult.java:45-53 | clients/src/main/java/org/apache/kafka/clients/admin/AlterShareGroupOffsetsResult.java:47-55 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `clients/src/main/java/org/apache/kafka/clients/admin/AlterConsumerGroupOffsetsResult.java:45` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (9 lines × 2) clients/src/main/java/org/apache/kafka/clients/admin/internals/ListConsumerGroupOffsetsHandler.java:100 — clients/src/main/java/org/apache/kafka/clients/admin/internals/ListConsumerGroupOffsetsHandler.java:100-108 | clients/src/main/java/org/apache/kafka/clients/consumer/internals/ConsumerCoordinator.java:1490-1498 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `clients/src/main/java/org/apache/kafka/clients/admin/internals/ListConsumerGroupOffsetsHandler.java:100` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (9 lines × 2) clients/src/main/java/org/apache/kafka/clients/consumer/internals/AbstractCoordinator.java:757 — clients/src/main/java/org/apache/kafka/clients/consumer/internals/AbstractCoordinator.java:757-765 | clients/src/main/java/org/apache/kafka/clients/consumer/internals/AbstractCoordinator.java:790-798 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `clients/src/main/java/org/apache/kafka/clients/consumer/internals/AbstractCoordinator.java:757` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (9 lines × 2) clients/src/main/java/org/apache/kafka/clients/consumer/internals/ConsumerRebalanceListenerInvoker.java:79 — clients/src/main/java/org/apache/kafka/clients/consumer/internals/ConsumerRebalanceListenerInvoker.java:79-87 | clients/src/main/java/org/apache/kafka/clients/consumer/internals/ConsumerRebalanceListenerInvoker.java:107-115 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `clients/src/main/java/org/apache/kafka/clients/consumer/internals/ConsumerRebalanceListenerInvoker.java:79` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (9 lines × 2) clients/src/main/java/org/apache/kafka/common/network/SaslChannelBuilder.java:377 — clients/src/main/java/org/apache/kafka/common/network/SaslChannelBuilder.java:377-385 | clients/src/main/java/org/apache/kafka/common/security/authenticator/SaslServerAuthenticator.java:225-233 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
  • Duplicated block (9 lines × 2) clients/src/main/java/org/apache/kafka/common/requests/FetchMetadata.java:154 — clients/src/main/java/org/apache/kafka/common/requests/FetchMetadata.java:154-162 | clients/src/main/java/org/apache/kafka/common/requests/ShareRequestMetadata.java:107-115 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `clients/src/main/java/org/apache/kafka/common/requests/FetchMetadata.java:154` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (9 lines × 2) clients/src/main/java/org/apache/kafka/common/requests/ShareAcknowledgeResponse.java:137 — clients/src/main/java/org/apache/kafka/common/requests/ShareAcknowledgeResponse.java:137-145 | clients/src/main/java/org/apache/kafka/common/requests/ShareFetchResponse.java:195-203 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `clients/src/main/java/org/apache/kafka/common/requests/ShareAcknowledgeResponse.java:137` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (9 lines × 2) connect/api/src/main/java/org/apache/kafka/connect/data/Values.java:503 — connect/api/src/main/java/org/apache/kafka/connect/data/Values.java:503-511 | connect/api/src/main/java/org/apache/kafka/connect/data/Values.java:531-539 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `connect/api/src/main/java/org/apache/kafka/connect/data/Values.java:503` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (9 lines × 2) connect/runtime/src/main/java/org/apache/kafka/connect/runtime/rest/HerderRequestHandler.java:70 — connect/runtime/src/main/java/org/apache/kafka/connect/runtime/rest/HerderRequestHandler.java:70-78 | connect/runtime/src/main/java/org/apache/kafka/connect/runtime/rest/resources/ConnectorPluginsResource.java:128-136 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `connect/runtime/src/main/java/org/apache/kafka/connect/runtime/rest/HerderRequestHandler.java:70` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (9 lines × 2) connect/transforms/src/main/java/org/apache/kafka/connect/transforms/InsertField.java:155 — connect/transforms/src/main/java/org/apache/kafka/connect/transforms/InsertField.java:155-163 | connect/transforms/src/main/java/org/apache/kafka/connect/transforms/InsertField.java:189-197 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (9 lines × 2) connect/transforms/src/main/java/org/apache/kafka/connect/transforms/InsertField.java:175 — connect/transforms/src/main/java/org/apache/kafka/connect/transforms/InsertField.java:175-183 | connect/transforms/src/main/java/org/apache/kafka/connect/transforms/ReplaceField.java:171-179 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
  • Duplicated block (9 lines × 2) generator/src/main/java/org/apache/kafka/message/CoordinatorRecordTypeGenerator.java:188 — generator/src/main/java/org/apache/kafka/message/CoordinatorRecordTypeGenerator.java:188-196 | generator/src/main/java/org/apache/kafka/message/CoordinatorRecordTypeGenerator.java:213-221 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `generator/src/main/java/org/apache/kafka/message/CoordinatorRecordTypeGenerator.java:188` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (9 lines × 2) generator/src/main/java/org/apache/kafka/message/JsonConverterGenerator.java:91 — generator/src/main/java/org/apache/kafka/message/JsonConverterGenerator.java:91-99 | generator/src/main/java/org/apache/kafka/message/JsonConverterGenerator.java:275-283 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `generator/src/main/java/org/apache/kafka/message/JsonConverterGenerator.java:90` calls `printf` and `generator/src/main/java/org/apache/kafka/message/JsonConverterGenerator.java:274` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (9 lines × 2) generator/src/main/java/org/apache/kafka/message/JsonConverterGenerator.java:274 — generator/src/main/java/org/apache/kafka/message/JsonConverterGenerator.java:274-282 | generator/src/main/java/org/apache/kafka/message/MessageDataGenerator.java:737-745 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
  • Duplicated block (9 lines × 2) generator/src/main/java/org/apache/kafka/message/MetadataJsonConvertersGenerator.java:71 — generator/src/main/java/org/apache/kafka/message/MetadataJsonConvertersGenerator.java:71-79 | generator/src/main/java/org/apache/kafka/message/MetadataJsonConvertersGenerator.java:98-106 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `generator/src/main/java/org/apache/kafka/message/MetadataJsonConvertersGenerator.java:71` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (9 lines × 2) group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupCoordinatorService.java:1961 — group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupCoordinatorService.java:1961-1969 | group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupCoordinatorService.java:2024-2032 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (9 lines × 2) group-coordinator/src/main/java/org/apache/kafka/coordinator/group/assignor/SimpleHeterogeneousAssignmentBuilder.java:153 — group-coordinator/src/main/java/org/apache/kafka/coordinator/group/assignor/SimpleHeterogeneousAssignmentBuilder.java:153-161 | group-coordinator/src/main/java/org/apache/kafka/coordinator/group/assignor/SimpleHomogeneousAssignmentBuilder.java:210-218 — before extracting anything, compare `group-coordinator/src/main/java/org/apache/kafka/coordinator/group/assignor/SimpleHeterogeneousAssignmentBuilder.java` and `group-coordinator/src/main/java/org/apache/kafka/coordinator/group/assignor/SimpleHomogeneousAssignmentBuilder.java` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 42 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `group-coordinator/src/main/java/org/apache/kafka/coordinator/group/assignor/SimpleHeterogeneousAssignmentBuilder.java:153` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (9 lines × 2) group-coordinator/src/main/java/org/apache/kafka/coordinator/group/assignor/SimpleHeterogeneousAssignmentBuilder.java:426 — group-coordinator/src/main/java/org/apache/kafka/coordinator/group/assignor/SimpleHeterogeneousAssignmentBuilder.java:426-434 | group-coordinator/src/main/java/org/apache/kafka/coordinator/group/assignor/SimpleHomogeneousAssignmentBuilder.java:352-360 — before extracting anything, compare `group-coordinator/src/main/java/org/apache/kafka/coordinator/group/assignor/SimpleHeterogeneousAssignmentBuilder.java` and `group-coordinator/src/main/java/org/apache/kafka/coordinator/group/assignor/SimpleHomogeneousAssignmentBuilder.java` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 42 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `group-coordinator/src/main/java/org/apache/kafka/coordinator/group/assignor/SimpleHeterogeneousAssignmentBuilder.java:426` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (9 lines × 2) group-coordinator/src/main/java/org/apache/kafka/coordinator/group/assignor/SimpleHeterogeneousAssignmentBuilder.java:436 — group-coordinator/src/main/java/org/apache/kafka/coordinator/group/assignor/SimpleHeterogeneousAssignmentBuilder.java:436-444 | group-coordinator/src/main/java/org/apache/kafka/coordinator/group/assignor/SimpleHomogeneousAssignmentBuilder.java:362-370 — before extracting anything, compare `group-coordinator/src/main/java/org/apache/kafka/coordinator/group/assignor/SimpleHeterogeneousAssignmentBuilder.java` and `group-coordinator/src/main/java/org/apache/kafka/coordinator/group/assignor/SimpleHomogeneousAssignmentBuilder.java` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 42 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `group-coordinator/src/main/java/org/apache/kafka/coordinator/group/assignor/SimpleHeterogeneousAssignmentBuilder.java:436` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (9 lines × 2) group-coordinator/src/main/java/org/apache/kafka/coordinator/group/streams/TasksTuple.java:193 — group-coordinator/src/main/java/org/apache/kafka/coordinator/group/streams/TasksTuple.java:193-201 | group-coordinator/src/main/java/org/apache/kafka/coordinator/group/streams/TasksTupleWithEpochs.java:219-227 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `group-coordinator/src/main/java/org/apache/kafka/coordinator/group/streams/TasksTuple.java:193` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `group-coordinator/src/main/java/org/apache/kafka/coordinator/group/streams/TasksTupleWithEpochs.java:229` calls `get` and `group-coordinator/src/main/java/org/apache/kafka/coordinator/group/streams/TasksTuple.java:202` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (9 lines × 2) jmh-benchmarks/src/main/java/org/apache/kafka/jmh/assignor/AssignorBenchmarkUtils.java:205 — jmh-benchmarks/src/main/java/org/apache/kafka/jmh/assignor/AssignorBenchmarkUtils.java:205-213 | jmh-benchmarks/src/main/java/org/apache/kafka/jmh/assignor/AssignorBenchmarkUtils.java:263-271 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `jmh-benchmarks/src/main/java/org/apache/kafka/jmh/assignor/AssignorBenchmarkUtils.java:205` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (9 lines × 2) jmh-benchmarks/src/main/java/org/apache/kafka/jmh/connect/JsonConverterBenchmark.java:350 — jmh-benchmarks/src/main/java/org/apache/kafka/jmh/connect/JsonConverterBenchmark.java:350-358 | jmh-benchmarks/src/main/java/org/apache/kafka/jmh/connect/JsonConverterBenchmark.java:390-398 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `jmh-benchmarks/src/main/java/org/apache/kafka/jmh/connect/JsonConverterBenchmark.java:350` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (9 lines × 2) jmh-benchmarks/src/main/java/org/apache/kafka/jmh/util/ByteUtilsBenchmark.java:305 — jmh-benchmarks/src/main/java/org/apache/kafka/jmh/util/ByteUtilsBenchmark.java:305-313 | jmh-benchmarks/src/main/java/org/apache/kafka/jmh/util/ByteUtilsBenchmark.java:322-330 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `jmh-benchmarks/src/main/java/org/apache/kafka/jmh/util/ByteUtilsBenchmark.java:305` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (9 lines × 2) metadata/src/main/java/org/apache/kafka/controller/BrokersToElrs.java:63 — metadata/src/main/java/org/apache/kafka/controller/BrokersToElrs.java:63-72 | metadata/src/main/java/org/apache/kafka/controller/BrokersToIsrs.java:144-152 — before extracting anything, compare `metadata/src/main/java/org/apache/kafka/controller/BrokersToElrs.java` and `metadata/src/main/java/org/apache/kafka/controller/BrokersToIsrs.java` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 62 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `metadata/src/main/java/org/apache/kafka/controller/BrokersToElrs.java:63` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (9 lines × 2) metadata/src/main/java/org/apache/kafka/metadata/BrokerRegistration.java:398 — metadata/src/main/java/org/apache/kafka/metadata/BrokerRegistration.java:398-406 | metadata/src/main/java/org/apache/kafka/metadata/ControllerRegistration.java:219-227 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
  • + 28 more in this group — see findings.md.
D4 · Code Duplication · Duplicated block (10 lines × 2) · ×50
  • Duplicated block (10 lines × 2) clients/src/main/java/org/apache/kafka/clients/consumer/internals/Acknowledgements.java:201 — clients/src/main/java/org/apache/kafka/clients/consumer/internals/Acknowledgements.java:201-210 | clients/src/main/java/org/apache/kafka/clients/consumer/internals/Acknowledgements.java:220-229 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `clients/src/main/java/org/apache/kafka/clients/consumer/internals/Acknowledgements.java:231` calls `AcknowledgementBatch`, `setFirstOffset` and `clients/src/main/java/org/apache/kafka/clients/consumer/internals/Acknowledgements.java:211` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (10 lines × 2) clients/src/main/java/org/apache/kafka/clients/consumer/internals/AsyncKafkaConsumer.java:1035 — clients/src/main/java/org/apache/kafka/clients/consumer/internals/AsyncKafkaConsumer.java:1035-1045 | clients/src/main/java/org/apache/kafka/clients/consumer/internals/AsyncKafkaConsumer.java:1070-1079 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `clients/src/main/java/org/apache/kafka/clients/consumer/internals/AsyncKafkaConsumer.java:1035` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `clients/src/main/java/org/apache/kafka/clients/consumer/internals/AsyncKafkaConsumer.java:1047` calls `isEmpty` and `clients/src/main/java/org/apache/kafka/clients/consumer/internals/AsyncKafkaConsumer.java:1080` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (10 lines × 2) clients/src/main/java/org/apache/kafka/clients/consumer/internals/AsyncKafkaConsumer.java:2373 — clients/src/main/java/org/apache/kafka/clients/consumer/internals/AsyncKafkaConsumer.java:2373-2382 | clients/src/main/java/org/apache/kafka/clients/consumer/internals/ShareConsumerImpl.java:1287-1296 — before extracting anything, compare `clients/src/main/java/org/apache/kafka/clients/consumer/internals/AsyncKafkaConsumer.java` and `clients/src/main/java/org/apache/kafka/clients/consumer/internals/ShareConsumerImpl.java` as WHOLE FILES: this scan already matched 13 separate duplicated blocks between them, totalling at least 131 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `clients/src/main/java/org/apache/kafka/clients/consumer/internals/AsyncKafkaConsumer.java:2373` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (10 lines × 2) clients/src/main/java/org/apache/kafka/clients/consumer/internals/CommitRequestManager.java:825 — clients/src/main/java/org/apache/kafka/clients/consumer/internals/CommitRequestManager.java:825-834 | clients/src/main/java/org/apache/kafka/clients/consumer/internals/ConsumerCoordinator.java:1297-1306 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `clients/src/main/java/org/apache/kafka/clients/consumer/internals/CommitRequestManager.java:825` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `clients/src/main/java/org/apache/kafka/clients/consumer/internals/CommitRequestManager.java:824` calls `setTopicId` and `clients/src/main/java/org/apache/kafka/clients/consumer/internals/ConsumerCoordinator.java:1296` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (10 lines × 2) clients/src/main/java/org/apache/kafka/clients/consumer/internals/CompletedFetch.java:382 — clients/src/main/java/org/apache/kafka/clients/consumer/internals/CompletedFetch.java:382-391 | core/src/main/java/kafka/server/share/SharePartition.java:3448-3457 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
  • Duplicated block (10 lines × 2) clients/src/main/java/org/apache/kafka/clients/consumer/internals/FetchMetricsRegistry.java:91 — clients/src/main/java/org/apache/kafka/clients/consumer/internals/FetchMetricsRegistry.java:91-100 | clients/src/main/java/org/apache/kafka/clients/consumer/internals/ShareFetchMetricsRegistry.java:84-93 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `clients/src/main/java/org/apache/kafka/clients/consumer/internals/FetchMetricsRegistry.java:91` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (10 lines × 2) clients/src/main/java/org/apache/kafka/clients/consumer/internals/ShareConsumeRequestManager.java:1037 — clients/src/main/java/org/apache/kafka/clients/consumer/internals/ShareConsumeRequestManager.java:1037-1046 | clients/src/main/java/org/apache/kafka/clients/consumer/internals/ShareConsumeRequestManager.java:1079-1088 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `clients/src/main/java/org/apache/kafka/clients/consumer/internals/ShareConsumeRequestManager.java:1037` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (10 lines × 2) clients/src/main/java/org/apache/kafka/clients/consumer/internals/ShareConsumeRequestManager.java:1169 — clients/src/main/java/org/apache/kafka/clients/consumer/internals/ShareConsumeRequestManager.java:1169-1178 | clients/src/main/java/org/apache/kafka/clients/consumer/internals/ShareConsumeRequestManager.java:1201-1210 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `clients/src/main/java/org/apache/kafka/clients/consumer/internals/ShareConsumeRequestManager.java:1169` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (10 lines × 2) clients/src/main/java/org/apache/kafka/clients/consumer/internals/events/ApplicationEventProcessor.java:265 — clients/src/main/java/org/apache/kafka/clients/consumer/internals/events/ApplicationEventProcessor.java:265-274 | clients/src/main/java/org/apache/kafka/clients/consumer/internals/events/ApplicationEventProcessor.java:283-292 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `clients/src/main/java/org/apache/kafka/clients/consumer/internals/events/ApplicationEventProcessor.java:265` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note first that the copies are not typed on the same thing: the declarations holding them bind `event` to `AsyncCommitEvent` in one and `SyncCommitEvent` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
  • Duplicated block (10 lines × 2) clients/src/main/java/org/apache/kafka/common/security/authenticator/SaslClientCallbackHandler.java:75 — clients/src/main/java/org/apache/kafka/common/security/authenticator/SaslClientCallbackHandler.java:75-84 | clients/src/main/java/org/apache/kafka/common/security/kerberos/KerberosClientCallbackHandler.java:58-67 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `clients/src/main/java/org/apache/kafka/common/security/authenticator/SaslClientCallbackHandler.java:75` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (10 lines × 2) connect/runtime/src/main/java/org/apache/kafka/connect/storage/KafkaConfigBackingStore.java:1035 — connect/runtime/src/main/java/org/apache/kafka/connect/storage/KafkaConfigBackingStore.java:1035-1044 | connect/runtime/src/main/java/org/apache/kafka/connect/storage/KafkaConfigBackingStore.java:1233-1242 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (10 lines × 2) core/src/main/java/kafka/server/share/SharePartition.java:2397 — core/src/main/java/kafka/server/share/SharePartition.java:2397-2406 | core/src/main/java/kafka/server/share/SharePartition.java:2484-2493 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `core/src/main/java/kafka/server/share/SharePartition.java:2397` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (10 lines × 2) generator/src/main/java/org/apache/kafka/message/MessageDataGenerator.java:252 — generator/src/main/java/org/apache/kafka/message/MessageDataGenerator.java:252-261 | generator/src/main/java/org/apache/kafka/message/MessageDataGenerator.java:264-273 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
  • Duplicated block (10 lines × 2) generator/src/main/java/org/apache/kafka/message/MetadataJsonConvertersGenerator.java:43 — generator/src/main/java/org/apache/kafka/message/MetadataJsonConvertersGenerator.java:43-52 | generator/src/main/java/org/apache/kafka/message/MetadataRecordTypeGenerator.java:44-53 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
  • Duplicated block (10 lines × 2) group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java:4394 — group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java:4394-4403 | group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java:4489-4498 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java:4394` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (10 lines × 2) group-coordinator/src/main/java/org/apache/kafka/coordinator/group/assignor/SimpleHeterogeneousAssignmentBuilder.java:373 — group-coordinator/src/main/java/org/apache/kafka/coordinator/group/assignor/SimpleHeterogeneousAssignmentBuilder.java:373-382 | group-coordinator/src/main/java/org/apache/kafka/coordinator/group/assignor/SimpleHomogeneousAssignmentBuilder.java:304-313 — before extracting anything, compare `group-coordinator/src/main/java/org/apache/kafka/coordinator/group/assignor/SimpleHeterogeneousAssignmentBuilder.java` and `group-coordinator/src/main/java/org/apache/kafka/coordinator/group/assignor/SimpleHomogeneousAssignmentBuilder.java` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 42 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `group-coordinator/src/main/java/org/apache/kafka/coordinator/group/assignor/SimpleHeterogeneousAssignmentBuilder.java:373` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (10 lines × 2) metadata/src/main/java/org/apache/kafka/controller/ConfigurationControlManager.java:370 — metadata/src/main/java/org/apache/kafka/controller/ConfigurationControlManager.java:370-379 | metadata/src/main/java/org/apache/kafka/controller/ConfigurationControlManager.java:391-400 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `metadata/src/main/java/org/apache/kafka/controller/ConfigurationControlManager.java:370` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (10 lines × 2) metadata/src/main/java/org/apache/kafka/metadata/authorizer/ClusterMetadataAuthorizer.java:108 — metadata/src/main/java/org/apache/kafka/metadata/authorizer/ClusterMetadataAuthorizer.java:108-117 | metadata/src/main/java/org/apache/kafka/metadata/authorizer/ClusterMetadataAuthorizer.java:148-157 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `metadata/src/main/java/org/apache/kafka/metadata/authorizer/ClusterMetadataAuthorizer.java:108` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (10 lines × 2) raft/src/main/java/org/apache/kafka/raft/RequestManager.java:77 — raft/src/main/java/org/apache/kafka/raft/RequestManager.java:77-86 | raft/src/main/java/org/apache/kafka/raft/RequestManager.java:148-157 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `raft/src/main/java/org/apache/kafka/raft/RequestManager.java:77` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (10 lines × 2) storage/api/src/main/java/org/apache/kafka/server/log/remote/storage/RemoteStorageMetrics.java:116 — storage/api/src/main/java/org/apache/kafka/server/log/remote/storage/RemoteStorageMetrics.java:116-125 | storage/api/src/main/java/org/apache/kafka/server/log/remote/storage/RemoteStorageMetrics.java:145-154 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (10 lines × 2) streams/src/main/java/org/apache/kafka/streams/kstream/internals/KTableKTableInnerJoin.java:115 — streams/src/main/java/org/apache/kafka/streams/kstream/internals/KTableKTableInnerJoin.java:115-124 | streams/src/main/java/org/apache/kafka/streams/kstream/internals/KTableKTableRightJoin.java:115-124 — before extracting anything, compare `streams/src/main/java/org/apache/kafka/streams/kstream/internals/KTableKTableInnerJoin.java` and `streams/src/main/java/org/apache/kafka/streams/kstream/internals/KTableKTableRightJoin.java` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 55 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (10 lines × 2) streams/src/main/java/org/apache/kafka/streams/kstream/internals/KTableKTableInnerJoin.java:126 — streams/src/main/java/org/apache/kafka/streams/kstream/internals/KTableKTableInnerJoin.java:126-135 | streams/src/main/java/org/apache/kafka/streams/kstream/internals/KTableKTableLeftJoin.java:135-144 — before extracting anything, compare `streams/src/main/java/org/apache/kafka/streams/kstream/internals/KTableKTableInnerJoin.java` and `streams/src/main/java/org/apache/kafka/streams/kstream/internals/KTableKTableLeftJoin.java` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 55 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `streams/src/main/java/org/apache/kafka/streams/kstream/internals/KTableKTableInnerJoin.java:126` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (10 lines × 2) streams/src/main/java/org/apache/kafka/streams/processor/internals/StandbyTask.java:352 — streams/src/main/java/org/apache/kafka/streams/processor/internals/StandbyTask.java:352-361 | streams/src/main/java/org/apache/kafka/streams/processor/internals/StreamTask.java:1428-1437 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
  • Duplicated block (10 lines × 2) streams/src/main/java/org/apache/kafka/streams/processor/internals/StreamThread.java:1331 — streams/src/main/java/org/apache/kafka/streams/processor/internals/StreamThread.java:1331-1340 | streams/src/main/java/org/apache/kafka/streams/processor/internals/StreamThread.java:1441-1450 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `streams/src/main/java/org/apache/kafka/streams/processor/internals/StreamThread.java:1331` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (10 lines × 2) streams/src/main/java/org/apache/kafka/streams/processor/internals/TaskExecutor.java:188 — streams/src/main/java/org/apache/kafka/streams/processor/internals/TaskExecutor.java:188-197 | streams/src/main/java/org/apache/kafka/streams/processor/internals/TaskExecutor.java:215-224 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `streams/src/main/java/org/apache/kafka/streams/processor/internals/TaskExecutor.java:188` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • + 25 more in this group — see findings.md.
D4 · Code Duplication · Duplicated block (11 lines × 2) · ×42
  • Duplicated block (11 lines × 2) clients/src/main/java/org/apache/kafka/clients/consumer/internals/AbstractFetch.java:158 — clients/src/main/java/org/apache/kafka/clients/consumer/internals/AbstractFetch.java:158-168 | clients/src/main/java/org/apache/kafka/clients/consumer/internals/ShareConsumeRequestManager.java:913-923 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `clients/src/main/java/org/apache/kafka/clients/consumer/internals/AbstractFetch.java:158` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (11 lines × 2) clients/src/main/java/org/apache/kafka/clients/consumer/internals/ShareConsumeRequestManager.java:801 — clients/src/main/java/org/apache/kafka/clients/consumer/internals/ShareConsumeRequestManager.java:801-811 | clients/src/main/java/org/apache/kafka/clients/consumer/internals/ShareConsumeRequestManager.java:891-901 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `clients/src/main/java/org/apache/kafka/clients/consumer/internals/ShareConsumeRequestManager.java:801` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (11 lines × 2) clients/src/main/java/org/apache/kafka/common/config/provider/FileConfigProvider.java:84 — clients/src/main/java/org/apache/kafka/common/config/provider/FileConfigProvider.java:84-94 | clients/src/main/java/org/apache/kafka/common/config/provider/FileConfigProvider.java:123-133 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `clients/src/main/java/org/apache/kafka/common/config/provider/FileConfigProvider.java:84` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (11 lines × 2) connect/runtime/src/main/java/org/apache/kafka/connect/runtime/Worker.java:1606 — connect/runtime/src/main/java/org/apache/kafka/connect/runtime/Worker.java:1606-1616 | connect/runtime/src/main/java/org/apache/kafka/connect/runtime/Worker.java:1649-1659 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `connect/runtime/src/main/java/org/apache/kafka/connect/runtime/Worker.java:1606` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (11 lines × 2) connect/runtime/src/main/java/org/apache/kafka/connect/storage/KafkaConfigBackingStore.java:1003 — connect/runtime/src/main/java/org/apache/kafka/connect/storage/KafkaConfigBackingStore.java:1003-1013 | connect/runtime/src/main/java/org/apache/kafka/connect/storage/KafkaConfigBackingStore.java:1039-1049 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `connect/runtime/src/main/java/org/apache/kafka/connect/storage/KafkaConfigBackingStore.java:1051` calls `computeIfAbsent`, `connector` and `connect/runtime/src/main/java/org/apache/kafka/connect/storage/KafkaConfigBackingStore.java:1014` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (11 lines × 2) core/src/main/java/kafka/server/share/SharePartition.java:1987 — core/src/main/java/kafka/server/share/SharePartition.java:1987-1997 | core/src/main/java/kafka/server/share/SharePartition.java:3100-3110 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `core/src/main/java/kafka/server/share/SharePartition.java:1987` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (11 lines × 2) group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java:6036 — group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java:6036-6046 | group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java:6347-6357 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java:6036` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note first that the copies are not typed on the same thing: the declarations holding them bind `value` to `ConsumerGroupMemberMetadataValue` in one and `ConsumerGroupRegularExpressionValue` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
  • Duplicated block (11 lines × 2) group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java:6273 — group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java:6273-6283 | group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java:6583-6593 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java:6273` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (11 lines × 2) metadata/src/main/java/org/apache/kafka/controller/BrokersToElrs.java:109 — metadata/src/main/java/org/apache/kafka/controller/BrokersToElrs.java:109-119 | metadata/src/main/java/org/apache/kafka/controller/BrokersToIsrs.java:197-207 — before extracting anything, compare `metadata/src/main/java/org/apache/kafka/controller/BrokersToElrs.java` and `metadata/src/main/java/org/apache/kafka/controller/BrokersToIsrs.java` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 62 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `metadata/src/main/java/org/apache/kafka/controller/BrokersToElrs.java:109` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (11 lines × 2) metadata/src/main/java/org/apache/kafka/controller/BrokersToElrs.java:141 — metadata/src/main/java/org/apache/kafka/controller/BrokersToElrs.java:141-151 | metadata/src/main/java/org/apache/kafka/controller/BrokersToIsrs.java:257-267 — before extracting anything, compare `metadata/src/main/java/org/apache/kafka/controller/BrokersToElrs.java` and `metadata/src/main/java/org/apache/kafka/controller/BrokersToIsrs.java` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 62 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `metadata/src/main/java/org/apache/kafka/controller/BrokersToElrs.java:141` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (11 lines × 2) metadata/src/main/java/org/apache/kafka/controller/BrokersToIsrs.java:124 — metadata/src/main/java/org/apache/kafka/controller/BrokersToIsrs.java:124-134 | metadata/src/main/java/org/apache/kafka/controller/BrokersToIsrs.java:135-145 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (11 lines × 2) server-common/src/main/java/org/apache/kafka/server/metrics/KafkaMetricsGroup.java:62 — server-common/src/main/java/org/apache/kafka/server/metrics/KafkaMetricsGroup.java:62-72 | server-common/src/main/java/org/apache/kafka/server/metrics/KafkaYammerMetrics.java:106-116 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
  • Duplicated block (11 lines × 2) server-common/src/main/java/org/apache/kafka/server/share/persister/PersisterStateManager.java:533 — server-common/src/main/java/org/apache/kafka/server/share/persister/PersisterStateManager.java:533-543 | server-common/src/main/java/org/apache/kafka/server/share/persister/PersisterStateManager.java:551-561 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (11 lines × 2) server-common/src/main/java/org/apache/kafka/server/share/persister/PersisterStateManager.java:905 — server-common/src/main/java/org/apache/kafka/server/share/persister/PersisterStateManager.java:905-915 | server-common/src/main/java/org/apache/kafka/server/share/persister/PersisterStateManager.java:931-941 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (11 lines × 2) streams/src/main/java/org/apache/kafka/streams/kstream/internals/KTableAggregate.java:129 — streams/src/main/java/org/apache/kafka/streams/kstream/internals/KTableAggregate.java:129-139 | streams/src/main/java/org/apache/kafka/streams/kstream/internals/KTableReduce.java:121-131 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `streams/src/main/java/org/apache/kafka/streams/kstream/internals/KTableAggregate.java:129` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note first that the copies are not typed on the same thing: the declarations holding them bind `record` to `Record<KIn, Change<VIn>>` in one and `Record<K, Change<V>>` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
  • Duplicated block (11 lines × 2) streams/src/main/java/org/apache/kafka/streams/kstream/internals/KTableKTableLeftJoin.java:177 — streams/src/main/java/org/apache/kafka/streams/kstream/internals/KTableKTableLeftJoin.java:177-187 | streams/src/main/java/org/apache/kafka/streams/kstream/internals/KTableKTableRightJoin.java:168-178 — before extracting anything, compare `streams/src/main/java/org/apache/kafka/streams/kstream/internals/KTableKTableLeftJoin.java` and `streams/src/main/java/org/apache/kafka/streams/kstream/internals/KTableKTableRightJoin.java` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 56 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `streams/src/main/java/org/apache/kafka/streams/kstream/internals/KTableKTableLeftJoin.java:177` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (11 lines × 2) streams/src/main/java/org/apache/kafka/streams/kstream/internals/SlidingWindowedCogroupedKStreamImpl.java:77 — streams/src/main/java/org/apache/kafka/streams/kstream/internals/SlidingWindowedCogroupedKStreamImpl.java:77-87 | streams/src/main/java/org/apache/kafka/streams/kstream/internals/TimeWindowedCogroupedKStreamImpl.java:81-91 — before extracting anything, compare `streams/src/main/java/org/apache/kafka/streams/kstream/internals/SlidingWindowedCogroupedKStreamImpl.java` and `streams/src/main/java/org/apache/kafka/streams/kstream/internals/TimeWindowedCogroupedKStreamImpl.java` as WHOLE FILES: 86% of the shorter file's lines also appear in the other, so this reads as one file having been copied from the other rather than as a helper waiting to be extracted. The 2 duplicated block(s) this scan matched between them are fragments of that copy, not the extent of it — treat the file pair as the unit. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `streams/src/main/java/org/apache/kafka/streams/kstream/internals/SlidingWindowedCogroupedKStreamImpl.java:77` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (11 lines × 2) streams/src/main/java/org/apache/kafka/streams/kstream/internals/SlidingWindowedKStreamImpl.java:127 — streams/src/main/java/org/apache/kafka/streams/kstream/internals/SlidingWindowedKStreamImpl.java:127-137 | streams/src/main/java/org/apache/kafka/streams/kstream/internals/TimeWindowedKStreamImpl.java:144-154 — before extracting anything, compare `streams/src/main/java/org/apache/kafka/streams/kstream/internals/SlidingWindowedKStreamImpl.java` and `streams/src/main/java/org/apache/kafka/streams/kstream/internals/TimeWindowedKStreamImpl.java` as WHOLE FILES: this scan already matched 7 separate duplicated blocks between them, totalling at least 61 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `streams/src/main/java/org/apache/kafka/streams/kstream/internals/SlidingWindowedKStreamImpl.java:127` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (11 lines × 2) streams/src/main/java/org/apache/kafka/streams/kstream/internals/TimeWindowedKStreamImpl.java:105 — streams/src/main/java/org/apache/kafka/streams/kstream/internals/TimeWindowedKStreamImpl.java:105-115 | streams/src/main/java/org/apache/kafka/streams/kstream/internals/TimeWindowedKStreamImpl.java:216-226 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `streams/src/main/java/org/apache/kafka/streams/kstream/internals/TimeWindowedKStreamImpl.java:105` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (11 lines × 2) streams/src/main/java/org/apache/kafka/streams/processor/internals/StoreChangelogReader.java:887 — streams/src/main/java/org/apache/kafka/streams/processor/internals/StoreChangelogReader.java:887-897 | streams/src/main/java/org/apache/kafka/streams/processor/internals/StoreChangelogReader.java:919-929 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `streams/src/main/java/org/apache/kafka/streams/processor/internals/StoreChangelogReader.java:887` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (11 lines × 2) tools/src/main/java/org/apache/kafka/tools/ClientMetricsCommand.java:92 — tools/src/main/java/org/apache/kafka/tools/ClientMetricsCommand.java:92-102 | tools/src/main/java/org/apache/kafka/tools/GroupsCommand.java:77-87 — before extracting anything, compare `tools/src/main/java/org/apache/kafka/tools/ClientMetricsCommand.java` and `tools/src/main/java/org/apache/kafka/tools/GroupsCommand.java` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 35 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `tools/src/main/java/org/apache/kafka/tools/ClientMetricsCommand.java:92` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (11 lines × 2) tools/src/main/java/org/apache/kafka/tools/ConsumerPerformance.java:305 — tools/src/main/java/org/apache/kafka/tools/ConsumerPerformance.java:305-315 | tools/src/main/java/org/apache/kafka/tools/ShareConsumerPerformance.java:345-355 — before extracting anything, compare `tools/src/main/java/org/apache/kafka/tools/ConsumerPerformance.java` and `tools/src/main/java/org/apache/kafka/tools/ShareConsumerPerformance.java` as WHOLE FILES: this scan already matched 10 separate duplicated blocks between them, totalling at least 119 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `tools/src/main/java/org/apache/kafka/tools/ConsumerPerformance.java:305` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `tools/src/main/java/org/apache/kafka/tools/ConsumerPerformance.java:316` calls `accepts` and `tools/src/main/java/org/apache/kafka/tools/ShareConsumerPerformance.java:356` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (11 lines × 2) tools/src/main/java/org/apache/kafka/tools/ProducerPerformance.java:298 — tools/src/main/java/org/apache/kafka/tools/ProducerPerformance.java:298-308 | tools/src/main/java/org/apache/kafka/tools/ProducerPerformance.java:361-371 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `tools/src/main/java/org/apache/kafka/tools/ProducerPerformance.java:298` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (11 lines × 2) tools/src/main/java/org/apache/kafka/tools/ProducerPerformance.java:289 — tools/src/main/java/org/apache/kafka/tools/ProducerPerformance.java:289-299 | tools/src/main/java/org/apache/kafka/tools/VerifiableProducer.java:173-183 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `tools/src/main/java/org/apache/kafka/tools/ProducerPerformance.java:289` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `tools/src/main/java/org/apache/kafka/tools/VerifiableProducer.java:172` calls `setDefault` and `tools/src/main/java/org/apache/kafka/tools/ProducerPerformance.java:288` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (11 lines × 2) tools/src/main/java/org/apache/kafka/tools/TransactionsCommand.java:109 — tools/src/main/java/org/apache/kafka/tools/TransactionsCommand.java:109-119 | tools/src/main/java/org/apache/kafka/tools/TransactionsCommand.java:319-329 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • + 17 more in this group — see findings.md.
D4 · Code Duplication · Duplicated block (12 lines × 2) · ×23
  • Duplicated block (12 lines × 2) clients/src/main/java/org/apache/kafka/clients/admin/KafkaAdminClient.java:2036 — clients/src/main/java/org/apache/kafka/clients/admin/KafkaAdminClient.java:2036-2047 | clients/src/main/java/org/apache/kafka/clients/admin/KafkaAdminClient.java:2061-2072 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `clients/src/main/java/org/apache/kafka/clients/admin/KafkaAdminClient.java:2036` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (12 lines × 2) clients/src/main/java/org/apache/kafka/clients/admin/KafkaAdminClient.java:3467 — clients/src/main/java/org/apache/kafka/clients/admin/KafkaAdminClient.java:3467-3478 | clients/src/main/java/org/apache/kafka/clients/admin/KafkaAdminClient.java:3501-3512 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `clients/src/main/java/org/apache/kafka/clients/admin/KafkaAdminClient.java:3467` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (12 lines × 2) clients/src/main/java/org/apache/kafka/clients/consumer/internals/AbstractMembershipManager.java:511 — clients/src/main/java/org/apache/kafka/clients/consumer/internals/AbstractMembershipManager.java:511-522 | clients/src/main/java/org/apache/kafka/clients/consumer/internals/StreamsMembershipManager.java:557-568 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `clients/src/main/java/org/apache/kafka/clients/consumer/internals/AbstractMembershipManager.java:511` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (12 lines × 2) connect/runtime/src/main/java/org/apache/kafka/connect/runtime/distributed/DistributedHerder.java:1531 — connect/runtime/src/main/java/org/apache/kafka/connect/runtime/distributed/DistributedHerder.java:1531-1542 | connect/runtime/src/main/java/org/apache/kafka/connect/runtime/distributed/DistributedHerder.java:1568-1579 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `connect/runtime/src/main/java/org/apache/kafka/connect/runtime/distributed/DistributedHerder.java:1531` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (12 lines × 2) generator/src/main/java/org/apache/kafka/message/CoordinatorRecordTypeGenerator.java:103 — generator/src/main/java/org/apache/kafka/message/CoordinatorRecordTypeGenerator.java:103-114 | generator/src/main/java/org/apache/kafka/message/MetadataRecordTypeGenerator.java:73-84 — before extracting anything, compare `generator/src/main/java/org/apache/kafka/message/CoordinatorRecordTypeGenerator.java` and `generator/src/main/java/org/apache/kafka/message/MetadataRecordTypeGenerator.java` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 56 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `generator/src/main/java/org/apache/kafka/message/CoordinatorRecordTypeGenerator.java:103` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (12 lines × 2) raft/src/main/java/org/apache/kafka/raft/internals/AddVoterHandler.java:164 — raft/src/main/java/org/apache/kafka/raft/internals/AddVoterHandler.java:164-175 | raft/src/main/java/org/apache/kafka/raft/internals/RemoveVoterHandler.java:150-161 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `raft/src/main/java/org/apache/kafka/raft/internals/AddVoterHandler.java:164` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (12 lines × 2) share-coordinator/src/main/java/org/apache/kafka/coordinator/share/ShareCoordinatorService.java:666 — share-coordinator/src/main/java/org/apache/kafka/coordinator/share/ShareCoordinatorService.java:666-677 | share-coordinator/src/main/java/org/apache/kafka/coordinator/share/ShareCoordinatorService.java:775-786 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `share-coordinator/src/main/java/org/apache/kafka/coordinator/share/ShareCoordinatorService.java:666` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (12 lines × 2) streams/src/main/java/org/apache/kafka/streams/kstream/internals/TimestampedCacheFlushListener.java:47 — streams/src/main/java/org/apache/kafka/streams/kstream/internals/TimestampedCacheFlushListener.java:47-58 | streams/src/main/java/org/apache/kafka/streams/kstream/internals/TimestampedCacheFlushListenerWithHeaders.java:47-58 — before extracting anything, compare `streams/src/main/java/org/apache/kafka/streams/kstream/internals/TimestampedCacheFlushListener.java` and `streams/src/main/java/org/apache/kafka/streams/kstream/internals/TimestampedCacheFlushListenerWithHeaders.java` as WHOLE FILES: 83% of the shorter file's lines also appear in the other, so this reads as one file having been copied from the other rather than as a helper waiting to be extracted. The 2 duplicated block(s) this scan matched between them are fragments of that copy, not the extent of it — treat the file pair as the unit. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `streams/src/main/java/org/apache/kafka/streams/kstream/internals/TimestampedCacheFlushListener.java:47` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note first that the copies are not typed on the same thing: the declarations holding them bind `record` to `Record<KOut, Change<ValueAndTimestamp<VOut>>>` in one and `Record<KOut, Change<ValueTimestampHeaders<VOut>>>` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
  • Duplicated block (12 lines × 2) streams/src/main/java/org/apache/kafka/streams/processor/internals/RecordCollectorImpl.java:375 — streams/src/main/java/org/apache/kafka/streams/processor/internals/RecordCollectorImpl.java:375-386 | streams/src/main/java/org/apache/kafka/streams/processor/internals/RecordCollectorImpl.java:513-524 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Note first that the copies are not typed on the same thing: the declarations holding them bind `context` to `InternalProcessorContext<Void, Void>` in one and `InternalProcessorContext<?, ?>` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
  • Duplicated block (12 lines × 2) streams/src/main/java/org/apache/kafka/streams/state/internals/InMemorySessionStore.java:133 — streams/src/main/java/org/apache/kafka/streams/state/internals/InMemorySessionStore.java:133-144 | streams/src/main/java/org/apache/kafka/streams/state/internals/InMemoryWindowStore.java:129-140 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `streams/src/main/java/org/apache/kafka/streams/state/internals/InMemorySessionStore.java:133` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (12 lines × 2) streams/src/main/java/org/apache/kafka/streams/state/internals/PlainToHeadersStoreAdapter.java:158 — streams/src/main/java/org/apache/kafka/streams/state/internals/PlainToHeadersStoreAdapter.java:158-169 | streams/src/main/java/org/apache/kafka/streams/state/internals/TimestampedToHeadersStoreAdapter.java:160-171 — before extracting anything, compare `streams/src/main/java/org/apache/kafka/streams/state/internals/PlainToHeadersStoreAdapter.java` and `streams/src/main/java/org/apache/kafka/streams/state/internals/TimestampedToHeadersStoreAdapter.java` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 44 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `streams/src/main/java/org/apache/kafka/streams/state/internals/PlainToHeadersStoreAdapter.java:158` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (12 lines × 2) tools/src/main/java/org/apache/kafka/tools/ConsumerPerformance.java:373 — tools/src/main/java/org/apache/kafka/tools/ConsumerPerformance.java:373-384 | tools/src/main/java/org/apache/kafka/tools/ShareConsumerPerformance.java:417-428 — before extracting anything, compare `tools/src/main/java/org/apache/kafka/tools/ConsumerPerformance.java` and `tools/src/main/java/org/apache/kafka/tools/ShareConsumerPerformance.java` as WHOLE FILES: this scan already matched 10 separate duplicated blocks between them, totalling at least 119 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `tools/src/main/java/org/apache/kafka/tools/ConsumerPerformance.java:373` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (12 lines × 2) tools/src/main/java/org/apache/kafka/tools/TransactionsCommand.java:310 — tools/src/main/java/org/apache/kafka/tools/TransactionsCommand.java:310-321 | tools/src/main/java/org/apache/kafka/tools/TransactionsCommand.java:550-561 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `tools/src/main/java/org/apache/kafka/tools/TransactionsCommand.java:563` calls `setDefault` and `tools/src/main/java/org/apache/kafka/tools/TransactionsCommand.java:323` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (12 lines × 2) tools/src/main/java/org/apache/kafka/tools/VerifiableConsumer.java:571 — tools/src/main/java/org/apache/kafka/tools/VerifiableConsumer.java:571-582 | tools/src/main/java/org/apache/kafka/tools/VerifiableShareConsumer.java:658-669 — before extracting anything, compare `tools/src/main/java/org/apache/kafka/tools/VerifiableConsumer.java` and `tools/src/main/java/org/apache/kafka/tools/VerifiableShareConsumer.java` as WHOLE FILES: this scan already matched 9 separate duplicated blocks between them, totalling at least 130 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `tools/src/main/java/org/apache/kafka/tools/VerifiableConsumer.java:571` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `tools/src/main/java/org/apache/kafka/tools/VerifiableShareConsumer.java:657` calls `setDefault` and `tools/src/main/java/org/apache/kafka/tools/VerifiableConsumer.java:570` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (12 lines × 2) tools/src/main/java/org/apache/kafka/tools/consumer/ConsoleConsumer.java:92 — tools/src/main/java/org/apache/kafka/tools/consumer/ConsoleConsumer.java:92-103 | tools/src/main/java/org/apache/kafka/tools/consumer/ConsoleShareConsumer.java:93-104 — before extracting anything, compare `tools/src/main/java/org/apache/kafka/tools/consumer/ConsoleConsumer.java` and `tools/src/main/java/org/apache/kafka/tools/consumer/ConsoleShareConsumer.java` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 36 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit. Note first that the copies are not typed on the same thing: the declarations holding them bind `conf` to `ConsoleConsumerOptions` in one and `ConsoleShareConsumerOptions` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
  • Duplicated block (12 lines × 2) tools/src/main/java/org/apache/kafka/tools/consumer/ConsoleConsumerOptions.java:255 — tools/src/main/java/org/apache/kafka/tools/consumer/ConsoleConsumerOptions.java:255-266 | tools/src/main/java/org/apache/kafka/tools/consumer/ConsoleShareConsumerOptions.java:216-227 — before extracting anything, compare `tools/src/main/java/org/apache/kafka/tools/consumer/ConsoleConsumerOptions.java` and `tools/src/main/java/org/apache/kafka/tools/consumer/ConsoleShareConsumerOptions.java` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 157 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (12 lines × 2) trogdor/src/main/java/org/apache/kafka/trogdor/workload/ConfigurableProducerWorker.java:86 — trogdor/src/main/java/org/apache/kafka/trogdor/workload/ConfigurableProducerWorker.java:86-97 | trogdor/src/main/java/org/apache/kafka/trogdor/workload/ProduceBenchWorker.java:85-96 — before extracting anything, compare `trogdor/src/main/java/org/apache/kafka/trogdor/workload/ConfigurableProducerWorker.java` and `trogdor/src/main/java/org/apache/kafka/trogdor/workload/ProduceBenchWorker.java` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 53 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
  • Duplicated block (12 lines × 2) trogdor/src/main/java/org/apache/kafka/trogdor/workload/ConsumeBenchWorker.java:299 — trogdor/src/main/java/org/apache/kafka/trogdor/workload/ConsumeBenchWorker.java:299-310 | trogdor/src/main/java/org/apache/kafka/trogdor/workload/ShareConsumeBenchWorker.java:335-346 — before extracting anything, compare `trogdor/src/main/java/org/apache/kafka/trogdor/workload/ConsumeBenchWorker.java` and `trogdor/src/main/java/org/apache/kafka/trogdor/workload/ShareConsumeBenchWorker.java` as WHOLE FILES: this scan already matched 12 separate duplicated blocks between them, totalling at least 137 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
  • Duplicated block (12 lines × 2) streams/src/main/java/org/apache/kafka/streams/errors/TaskIdFormatException.java:33 — streams/src/main/java/org/apache/kafka/streams/errors/TaskIdFormatException.java:33-44 | streams/src/main/java/org/apache/kafka/streams/errors/TopologyException.java:31-42 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
  • Duplicated block (12 lines × 2) streams/src/main/java/org/apache/kafka/streams/processor/api/FixedKeyRecord.java:52 — streams/src/main/java/org/apache/kafka/streams/processor/api/FixedKeyRecord.java:52-63 | streams/src/main/java/org/apache/kafka/streams/processor/api/Record.java:61-72 — before extracting anything, compare `streams/src/main/java/org/apache/kafka/streams/processor/api/FixedKeyRecord.java` and `streams/src/main/java/org/apache/kafka/streams/processor/api/Record.java` as WHOLE FILES: 84% of the shorter file's lines also appear in the other, so this reads as one file having been copied from the other rather than as a helper waiting to be extracted. The 1 duplicated block(s) this scan matched between them are fragments of that copy, not the extent of it — treat the file pair as the unit. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (12 lines × 2) streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredSessionStore.java:408 — streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredSessionStore.java:408-419 | streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredWindowStore.java:322-333 — before extracting anything, compare `streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredSessionStore.java` and `streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredWindowStore.java` as WHOLE FILES: this scan already matched 11 separate duplicated blocks between them, totalling at least 156 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (12 lines × 2) trogdor/src/main/java/org/apache/kafka/trogdor/workload/ConsumeBenchWorker.java:517 — trogdor/src/main/java/org/apache/kafka/trogdor/workload/ConsumeBenchWorker.java:517-528 | trogdor/src/main/java/org/apache/kafka/trogdor/workload/ShareConsumeBenchWorker.java:585-596 — before extracting anything, compare `trogdor/src/main/java/org/apache/kafka/trogdor/workload/ConsumeBenchWorker.java` and `trogdor/src/main/java/org/apache/kafka/trogdor/workload/ShareConsumeBenchWorker.java` as WHOLE FILES: this scan already matched 12 separate duplicated blocks between them, totalling at least 137 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (12 lines × 2) core/src/main/scala/kafka/network/SocketServer.scala:414 — core/src/main/scala/kafka/network/SocketServer.scala:414-425 | core/src/main/scala/kafka/server/DynamicBrokerConfig.scala:825-836 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `core/src/main/scala/kafka/network/SocketServer.scala:414` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (13 lines × 2) · ×22
  • Duplicated block (13 lines × 2) clients/src/main/java/org/apache/kafka/clients/admin/KafkaAdminClient.java:5185 — clients/src/main/java/org/apache/kafka/clients/admin/KafkaAdminClient.java:5185-5197 | clients/src/main/java/org/apache/kafka/clients/admin/KafkaAdminClient.java:5227-5239 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `clients/src/main/java/org/apache/kafka/clients/admin/KafkaAdminClient.java:5185` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (13 lines × 2) clients/src/main/java/org/apache/kafka/clients/consumer/internals/AsyncKafkaConsumer.java:1180 — clients/src/main/java/org/apache/kafka/clients/consumer/internals/AsyncKafkaConsumer.java:1180-1192 | clients/src/main/java/org/apache/kafka/clients/consumer/internals/ClassicKafkaConsumer.java:833-845 — before extracting anything, compare `clients/src/main/java/org/apache/kafka/clients/consumer/internals/AsyncKafkaConsumer.java` and `clients/src/main/java/org/apache/kafka/clients/consumer/internals/ClassicKafkaConsumer.java` as WHOLE FILES: this scan already matched 11 separate duplicated blocks between them, totalling at least 102 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `clients/src/main/java/org/apache/kafka/clients/consumer/internals/AsyncKafkaConsumer.java:1180` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (13 lines × 2) clients/src/main/java/org/apache/kafka/clients/consumer/internals/WakeupTrigger.java:101 — clients/src/main/java/org/apache/kafka/clients/consumer/internals/WakeupTrigger.java:101-113 | clients/src/main/java/org/apache/kafka/clients/consumer/internals/WakeupTrigger.java:120-132 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `clients/src/main/java/org/apache/kafka/clients/consumer/internals/WakeupTrigger.java:101` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (13 lines × 2) clients/src/main/java/org/apache/kafka/common/protocol/Protocol.java:193 — clients/src/main/java/org/apache/kafka/common/protocol/Protocol.java:193-205 | clients/src/main/java/org/apache/kafka/common/protocol/Protocol.java:223-235 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (13 lines × 2) clients/src/main/java/org/apache/kafka/common/record/internal/DefaultRecord.java:335 — clients/src/main/java/org/apache/kafka/common/record/internal/DefaultRecord.java:335-347 | clients/src/main/java/org/apache/kafka/common/record/internal/DefaultRecord.java:412-424 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (13 lines × 2) clients/src/main/java/org/apache/kafka/common/requests/ShareFetchRequest.java:75 — clients/src/main/java/org/apache/kafka/common/requests/ShareFetchRequest.java:75-87 | clients/src/main/java/org/apache/kafka/common/requests/ShareFetchRequest.java:95-107 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (13 lines × 2) clients/src/main/java/org/apache/kafka/common/serialization/StringDeserializer.java:41 — clients/src/main/java/org/apache/kafka/common/serialization/StringDeserializer.java:41-53 | clients/src/main/java/org/apache/kafka/common/serialization/StringSerializer.java:38-50 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
  • Duplicated block (13 lines × 2) group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java:6060 — group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java:6060-6072 | group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java:6456-6468 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java:6060` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (13 lines × 2) raft/src/main/java/org/apache/kafka/raft/QuorumState.java:432 — raft/src/main/java/org/apache/kafka/raft/QuorumState.java:432-444 | raft/src/main/java/org/apache/kafka/raft/QuorumState.java:484-496 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `raft/src/main/java/org/apache/kafka/raft/QuorumState.java:432` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `raft/src/main/java/org/apache/kafka/raft/QuorumState.java:483` calls `prospectiveStateOrThrow` and `raft/src/main/java/org/apache/kafka/raft/QuorumState.java:431` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (13 lines × 2) server-common/src/main/java/org/apache/kafka/server/share/persister/DefaultStatePersister.java:303 — server-common/src/main/java/org/apache/kafka/server/share/persister/DefaultStatePersister.java:303-315 | server-common/src/main/java/org/apache/kafka/server/share/persister/DefaultStatePersister.java:457-470 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `server-common/src/main/java/org/apache/kafka/server/share/persister/DefaultStatePersister.java:303` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (13 lines × 2) streams/src/main/java/org/apache/kafka/streams/kstream/internals/InternalStreamsBuilder.java:103 — streams/src/main/java/org/apache/kafka/streams/kstream/internals/InternalStreamsBuilder.java:103-115 | streams/src/main/java/org/apache/kafka/streams/kstream/internals/InternalStreamsBuilder.java:119-131 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
  • Duplicated block (13 lines × 2) streams/src/main/java/org/apache/kafka/streams/kstream/internals/KStreamSlidingWindowAggregate.java:163 — streams/src/main/java/org/apache/kafka/streams/kstream/internals/KStreamSlidingWindowAggregate.java:163-175 | streams/src/main/java/org/apache/kafka/streams/kstream/internals/KStreamSlidingWindowAggregate.java:225-237 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `streams/src/main/java/org/apache/kafka/streams/kstream/internals/KStreamSlidingWindowAggregate.java:163` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (13 lines × 2) streams/src/main/java/org/apache/kafka/streams/kstream/internals/KStreamSlidingWindowAggregate.java:507 — streams/src/main/java/org/apache/kafka/streams/kstream/internals/KStreamSlidingWindowAggregate.java:507-519 | streams/src/main/java/org/apache/kafka/streams/kstream/internals/KStreamWindowAggregate.java:220-232 — before extracting anything, compare `streams/src/main/java/org/apache/kafka/streams/kstream/internals/KStreamSlidingWindowAggregate.java` and `streams/src/main/java/org/apache/kafka/streams/kstream/internals/KStreamWindowAggregate.java` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 36 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `streams/src/main/java/org/apache/kafka/streams/kstream/internals/KStreamSlidingWindowAggregate.java:507` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (13 lines × 2) streams/src/main/java/org/apache/kafka/streams/processor/internals/DefaultStateUpdater.java:329 — streams/src/main/java/org/apache/kafka/streams/processor/internals/DefaultStateUpdater.java:329-341 | streams/src/main/java/org/apache/kafka/streams/processor/internals/GlobalStreamThread.java:513-525 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `streams/src/main/java/org/apache/kafka/streams/processor/internals/DefaultStateUpdater.java:329` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (13 lines × 2) streams/src/main/java/org/apache/kafka/streams/state/internals/PrefixedSessionKeySchemas.java:375 — streams/src/main/java/org/apache/kafka/streams/state/internals/PrefixedSessionKeySchemas.java:375-387 | streams/src/main/java/org/apache/kafka/streams/state/internals/PrefixedWindowKeySchemas.java:392-404 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
  • Duplicated block (13 lines × 2) tools/src/main/java/org/apache/kafka/tools/ProducerPerformance.java:369 — tools/src/main/java/org/apache/kafka/tools/ProducerPerformance.java:369-381 | tools/src/main/java/org/apache/kafka/tools/TransactionalMessageCopier.java:153-165 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `tools/src/main/java/org/apache/kafka/tools/ProducerPerformance.java:369` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (13 lines × 2) tools/src/main/java/org/apache/kafka/tools/consumer/ConsoleConsumerOptions.java:174 — tools/src/main/java/org/apache/kafka/tools/consumer/ConsoleConsumerOptions.java:174-186 | tools/src/main/java/org/apache/kafka/tools/consumer/ConsoleShareConsumerOptions.java:147-159 — before extracting anything, compare `tools/src/main/java/org/apache/kafka/tools/consumer/ConsoleConsumerOptions.java` and `tools/src/main/java/org/apache/kafka/tools/consumer/ConsoleShareConsumerOptions.java` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 157 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `tools/src/main/java/org/apache/kafka/tools/consumer/ConsoleConsumerOptions.java:174` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `tools/src/main/java/org/apache/kafka/tools/consumer/ConsoleShareConsumerOptions.java:144` calls `accepts` and `tools/src/main/java/org/apache/kafka/tools/consumer/ConsoleConsumerOptions.java:172` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (13 lines × 2) tools/src/main/java/org/apache/kafka/tools/streams/StreamsGroupCommand.java:507 — tools/src/main/java/org/apache/kafka/tools/streams/StreamsGroupCommand.java:507-519 | tools/src/main/java/org/apache/kafka/tools/streams/StreamsGroupCommand.java:528-540 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `tools/src/main/java/org/apache/kafka/tools/streams/StreamsGroupCommand.java:507` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (13 lines × 2) trogdor/src/main/java/org/apache/kafka/trogdor/workload/ConsumeBenchWorker.java:275 — trogdor/src/main/java/org/apache/kafka/trogdor/workload/ConsumeBenchWorker.java:275-287 | trogdor/src/main/java/org/apache/kafka/trogdor/workload/ShareConsumeBenchWorker.java:311-323 — before extracting anything, compare `trogdor/src/main/java/org/apache/kafka/trogdor/workload/ConsumeBenchWorker.java` and `trogdor/src/main/java/org/apache/kafka/trogdor/workload/ShareConsumeBenchWorker.java` as WHOLE FILES: this scan already matched 12 separate duplicated blocks between them, totalling at least 137 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `trogdor/src/main/java/org/apache/kafka/trogdor/workload/ConsumeBenchWorker.java:275` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (13 lines × 2) trogdor/src/main/java/org/apache/kafka/trogdor/workload/ProduceBenchWorker.java:103 — trogdor/src/main/java/org/apache/kafka/trogdor/workload/ProduceBenchWorker.java:103-115 | trogdor/src/main/java/org/apache/kafka/trogdor/workload/RoundTripWorkerBase.java:137-149 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
  • Duplicated block (13 lines × 2) streams/src/main/java/org/apache/kafka/streams/state/internals/InMemoryTimeOrderedKeyValueChangeBuffer.java:341 — streams/src/main/java/org/apache/kafka/streams/state/internals/InMemoryTimeOrderedKeyValueChangeBuffer.java:341-353 | streams/src/main/java/org/apache/kafka/streams/state/internals/RocksDBTimeOrderedKeyValueBuffer.java:348-360 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
  • Duplicated block (13 lines × 2) .github/scripts/pr-format.py:66 — .github/scripts/pr-format.py:66-78 | .github/scripts/pr-reviewers-trailer.py:63-75 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
D4 · Code Duplication · Duplicated block (14 lines × 2) · ×18
  • Duplicated block (14 lines × 2) clients/src/main/java/org/apache/kafka/clients/admin/KafkaAdminClient.java:1948 — clients/src/main/java/org/apache/kafka/clients/admin/KafkaAdminClient.java:1948-1961 | clients/src/main/java/org/apache/kafka/clients/admin/KafkaAdminClient.java:3341-3354 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `clients/src/main/java/org/apache/kafka/clients/admin/KafkaAdminClient.java:1948` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (14 lines × 2) clients/src/main/java/org/apache/kafka/clients/consumer/internals/AbstractMembershipManager.java:236 — clients/src/main/java/org/apache/kafka/clients/consumer/internals/AbstractMembershipManager.java:236-249 | clients/src/main/java/org/apache/kafka/clients/consumer/internals/StreamsMembershipManager.java:607-620 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `clients/src/main/java/org/apache/kafka/clients/consumer/internals/AbstractMembershipManager.java:250` calls `forEach`, `onMemberStateChange` and `clients/src/main/java/org/apache/kafka/clients/consumer/internals/StreamsMembershipManager.java:621` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (14 lines × 2) connect/runtime/src/main/java/org/apache/kafka/connect/runtime/distributed/DistributedHerder.java:1015 — connect/runtime/src/main/java/org/apache/kafka/connect/runtime/distributed/DistributedHerder.java:1015-1028 | connect/runtime/src/main/java/org/apache/kafka/connect/runtime/distributed/DistributedHerder.java:1053-1066 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `connect/runtime/src/main/java/org/apache/kafka/connect/runtime/distributed/DistributedHerder.java:1015` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (14 lines × 2) raft/src/main/java/org/apache/kafka/raft/KafkaRaftClient.java:2263 — raft/src/main/java/org/apache/kafka/raft/KafkaRaftClient.java:2263-2276 | raft/src/main/java/org/apache/kafka/raft/KafkaRaftClient.java:2420-2433 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `raft/src/main/java/org/apache/kafka/raft/KafkaRaftClient.java:2263` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (14 lines × 2) streams/src/main/java/org/apache/kafka/streams/StreamsConfig.java:1457 — streams/src/main/java/org/apache/kafka/streams/StreamsConfig.java:1457-1470 | streams/src/main/java/org/apache/kafka/streams/TopologyConfig.java:98-111 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
  • Duplicated block (14 lines × 2) streams/src/main/java/org/apache/kafka/streams/kstream/internals/AbstractKStreamTimeWindowAggregateProcessor.java:107 — streams/src/main/java/org/apache/kafka/streams/kstream/internals/AbstractKStreamTimeWindowAggregateProcessor.java:107-120 | streams/src/main/java/org/apache/kafka/streams/kstream/internals/KStreamSessionWindowAggregate.java:154-167 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `streams/src/main/java/org/apache/kafka/streams/kstream/internals/AbstractKStreamTimeWindowAggregateProcessor.java:107` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (14 lines × 2) streams/src/main/java/org/apache/kafka/streams/kstream/internals/KStreamImpl.java:1346 — streams/src/main/java/org/apache/kafka/streams/kstream/internals/KStreamImpl.java:1346-1359 | streams/src/main/java/org/apache/kafka/streams/kstream/internals/KStreamImpl.java:1395-1408 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `streams/src/main/java/org/apache/kafka/streams/kstream/internals/KStreamImpl.java:1346` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note first that the copies are not typed on the same thing: the declarations holding them bind `processorSupplier` to `ProcessorSupplier<? super K, ? super V, ? extends KOut, ? extends VOut>` in one and `FixedKeyProcessorSupplier<? super K, ? super V, ? extends VOut>` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `streams/src/main/java/org/apache/kafka/streams/kstream/internals/KStreamImpl.java:1360` calls `setKeyChangingOperation` and `streams/src/main/java/org/apache/kafka/streams/kstream/internals/KStreamImpl.java:1409` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (14 lines × 2) streams/src/main/java/org/apache/kafka/streams/processor/internals/StreamsMetadataState.java:500 — streams/src/main/java/org/apache/kafka/streams/processor/internals/StreamsMetadataState.java:500-513 | streams/src/main/java/org/apache/kafka/streams/processor/internals/StreamsMetadataState.java:538-551 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `streams/src/main/java/org/apache/kafka/streams/processor/internals/StreamsMetadataState.java:500` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (14 lines × 2) streams/src/main/java/org/apache/kafka/streams/state/internals/AbstractDualSchemaRocksDBSegmentedBytesStore.java:346 — streams/src/main/java/org/apache/kafka/streams/state/internals/AbstractDualSchemaRocksDBSegmentedBytesStore.java:346-359 | streams/src/main/java/org/apache/kafka/streams/state/internals/AbstractRocksDBSegmentedBytesStore.java:396-409 — before extracting anything, compare `streams/src/main/java/org/apache/kafka/streams/state/internals/AbstractDualSchemaRocksDBSegmentedBytesStore.java` and `streams/src/main/java/org/apache/kafka/streams/state/internals/AbstractRocksDBSegmentedBytesStore.java` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 80 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
  • Duplicated block (14 lines × 2) streams/src/main/java/org/apache/kafka/streams/state/internals/CachingWindowStore.java:125 — streams/src/main/java/org/apache/kafka/streams/state/internals/CachingWindowStore.java:125-138 | streams/src/main/java/org/apache/kafka/streams/state/internals/TimeOrderedCachingWindowStore.java:227-240 — before extracting anything, compare `streams/src/main/java/org/apache/kafka/streams/state/internals/CachingWindowStore.java` and `streams/src/main/java/org/apache/kafka/streams/state/internals/TimeOrderedCachingWindowStore.java` as WHOLE FILES: this scan already matched 9 separate duplicated blocks between them, totalling at least 121 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `streams/src/main/java/org/apache/kafka/streams/state/internals/CachingWindowStore.java:125` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (14 lines × 2) streams/src/main/java/org/apache/kafka/streams/state/internals/InMemorySessionStore.java:354 — streams/src/main/java/org/apache/kafka/streams/state/internals/InMemorySessionStore.java:354-367 | streams/src/main/java/org/apache/kafka/streams/state/internals/InMemorySessionStore.java:398-411 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `streams/src/main/java/org/apache/kafka/streams/state/internals/InMemorySessionStore.java:354` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (14 lines × 2) streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredKeyValueStore.java:288 — streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredKeyValueStore.java:288-301 | streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredTimestampedKeyValueStore.java:263-276 — before extracting anything, compare `streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredKeyValueStore.java` and `streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredTimestampedKeyValueStore.java` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 46 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (14 lines × 2) streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredSessionStoreWithHeaders.java:201 — streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredSessionStoreWithHeaders.java:201-214 | streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredTimestampedWindowStoreWithHeaders.java:165-178 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredSessionStoreWithHeaders.java:201` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (14 lines × 2) streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredTimestampedWindowStoreWithHeaders.java:270 — streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredTimestampedWindowStoreWithHeaders.java:270-283 | streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredTimestampedWindowStoreWithHeaders.java:386-399 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredTimestampedWindowStoreWithHeaders.java:270` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on. Note first that the copies are not typed on the same thing: the declarations holding them bind `query` to `TimestampedWindowKeyWithHeadersQuery<K, V>` in one and `TimestampedWindowRangeWithHeadersQuery<K, V>` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
  • Duplicated block (14 lines × 2) tools/src/main/java/org/apache/kafka/tools/TransactionalMessageCopier.java:92 — tools/src/main/java/org/apache/kafka/tools/TransactionalMessageCopier.java:92-105 | tools/src/main/java/org/apache/kafka/tools/TransactionalMessageCopier.java:145-158 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `tools/src/main/java/org/apache/kafka/tools/TransactionalMessageCopier.java:92` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `tools/src/main/java/org/apache/kafka/tools/TransactionalMessageCopier.java:144` calls `setDefault` and `tools/src/main/java/org/apache/kafka/tools/TransactionalMessageCopier.java:91` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (14 lines × 2) trogdor/src/main/java/org/apache/kafka/trogdor/agent/AgentClient.java:205 — trogdor/src/main/java/org/apache/kafka/trogdor/agent/AgentClient.java:205-218 | trogdor/src/main/java/org/apache/kafka/trogdor/coordinator/CoordinatorClient.java:229-242 — before extracting anything, compare `trogdor/src/main/java/org/apache/kafka/trogdor/agent/AgentClient.java` and `trogdor/src/main/java/org/apache/kafka/trogdor/coordinator/CoordinatorClient.java` as WHOLE FILES: this scan already matched 9 separate duplicated blocks between them, totalling at least 91 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `trogdor/src/main/java/org/apache/kafka/trogdor/agent/AgentClient.java:205` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `trogdor/src/main/java/org/apache/kafka/trogdor/agent/AgentClient.java:204` calls `defaultHelp` and `trogdor/src/main/java/org/apache/kafka/trogdor/coordinator/CoordinatorClient.java:228` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (14 lines × 2) trogdor/src/main/java/org/apache/kafka/trogdor/workload/ConsumeBenchWorker.java:207 — trogdor/src/main/java/org/apache/kafka/trogdor/workload/ConsumeBenchWorker.java:207-220 | trogdor/src/main/java/org/apache/kafka/trogdor/workload/ShareConsumeBenchWorker.java:243-256 — before extracting anything, compare `trogdor/src/main/java/org/apache/kafka/trogdor/workload/ConsumeBenchWorker.java` and `trogdor/src/main/java/org/apache/kafka/trogdor/workload/ShareConsumeBenchWorker.java` as WHOLE FILES: this scan already matched 12 separate duplicated blocks between them, totalling at least 137 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `trogdor/src/main/java/org/apache/kafka/trogdor/workload/ConsumeBenchWorker.java:207` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note first that the copies are not typed on the same thing: the declarations holding them bind `consumer` to `ThreadSafeConsumer` in one and `ThreadSafeShareConsumer` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
  • Duplicated block (14 lines × 2) core/src/main/scala/kafka/coordinator/transaction/TransactionCoordinator.scala:681 — core/src/main/scala/kafka/coordinator/transaction/TransactionCoordinator.scala:681-694 | core/src/main/scala/kafka/coordinator/transaction/TransactionCoordinator.scala:1007-1020 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `core/src/main/scala/kafka/coordinator/transaction/TransactionCoordinator.scala:681` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `core/src/main/scala/kafka/coordinator/transaction/TransactionCoordinator.scala:696` calls `hasFailedEpochFence` and `core/src/main/scala/kafka/coordinator/transaction/TransactionCoordinator.scala:1023` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (5 lines × 3) · ×18
  • Duplicated block (5 lines × 3) clients/src/main/java/org/apache/kafka/clients/consumer/internals/AsyncKafkaConsumer.java:2236 — clients/src/main/java/org/apache/kafka/clients/consumer/internals/AsyncKafkaConsumer.java:2236-2240 | clients/src/main/java/org/apache/kafka/clients/consumer/internals/ClassicKafkaConsumer.java:1275-1279 | clients/src/main/java/org/apache/kafka/clients/consumer/internals/ShareConsumerImpl.java:1147-1151 — before extracting anything, compare `clients/src/main/java/org/apache/kafka/clients/consumer/internals/AsyncKafkaConsumer.java` and `clients/src/main/java/org/apache/kafka/clients/consumer/internals/ClassicKafkaConsumer.java` as WHOLE FILES: this scan already matched 11 separate duplicated blocks between them, totalling at least 102 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (5 lines × 3) clients/src/main/java/org/apache/kafka/clients/consumer/internals/ShareConsumeRequestManager.java:686 — clients/src/main/java/org/apache/kafka/clients/consumer/internals/ShareConsumeRequestManager.java:686-690 | clients/src/main/java/org/apache/kafka/clients/consumer/internals/ShareConsumeRequestManager.java:758-762 | clients/src/main/java/org/apache/kafka/clients/consumer/internals/ShareConsumeRequestManager.java:835-839 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `clients/src/main/java/org/apache/kafka/clients/consumer/internals/ShareConsumeRequestManager.java:686` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (5 lines × 3) group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java:7536 — group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java:7536-7540 | group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java:7581-7585 | group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java:8325-8329 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java:7536` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (5 lines × 3) server-common/src/main/java/org/apache/kafka/server/share/persister/DeleteShareGroupStateResult.java:47 — server-common/src/main/java/org/apache/kafka/server/share/persister/DeleteShareGroupStateResult.java:47-51 | server-common/src/main/java/org/apache/kafka/server/share/persister/InitializeShareGroupStateResult.java:47-51 | server-common/src/main/java/org/apache/kafka/server/share/persister/WriteShareGroupStateResult.java:44-48 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 3 call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `server-common/src/main/java/org/apache/kafka/server/share/persister/DeleteShareGroupStateResult.java:47` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (5 lines × 3) tools/src/main/java/org/apache/kafka/tools/consumer/group/ConsumerGroupCommand.java:975 — tools/src/main/java/org/apache/kafka/tools/consumer/group/ConsumerGroupCommand.java:975-979 | tools/src/main/java/org/apache/kafka/tools/consumer/group/ShareGroupCommand.java:527-531 | tools/src/main/java/org/apache/kafka/tools/streams/StreamsGroupCommand.java:1006-1010 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. Read the line range as the matched WINDOW rather than a finished unit: at `tools/src/main/java/org/apache/kafka/tools/consumer/group/ConsumerGroupCommand.java:975` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `tools/src/main/java/org/apache/kafka/tools/consumer/group/ConsumerGroupCommand.java:972` calls `checkAllTopicPartitionsValid` and `tools/src/main/java/org/apache/kafka/tools/streams/StreamsGroupCommand.java:1004` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (5 lines × 3) clients/src/main/java/org/apache/kafka/common/requests/GetTelemetrySubscriptionsResponse.java:43 — clients/src/main/java/org/apache/kafka/common/requests/GetTelemetrySubscriptionsResponse.java:43-47 | clients/src/main/java/org/apache/kafka/common/requests/ListTransactionsResponse.java:40-44 | clients/src/main/java/org/apache/kafka/common/requests/PushTelemetryResponse.java:43-47 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 3 call sites, so a change lands once. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (5 lines × 3) connect/api/src/main/java/org/apache/kafka/connect/storage/StringConverter.java:80 — connect/api/src/main/java/org/apache/kafka/connect/storage/StringConverter.java:80-84 | connect/json/src/main/java/org/apache/kafka/connect/json/JsonConverter.java:300-304 | connect/runtime/src/main/java/org/apache/kafka/connect/converters/NumberConverter.java:88-92 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times.
  • Duplicated block (5 lines × 3) generator/src/main/java/org/apache/kafka/message/ApiMessageTypeGenerator.java:82 — generator/src/main/java/org/apache/kafka/message/ApiMessageTypeGenerator.java:82-86 | generator/src/main/java/org/apache/kafka/message/MetadataJsonConvertersGenerator.java:30-34 | generator/src/main/java/org/apache/kafka/message/MetadataRecordTypeGenerator.java:31-35 — before extracting anything, compare `generator/src/main/java/org/apache/kafka/message/ApiMessageTypeGenerator.java` and `generator/src/main/java/org/apache/kafka/message/MetadataRecordTypeGenerator.java` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 33 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (5 lines × 3) streams/src/main/java/org/apache/kafka/streams/state/internals/PrefixedSessionKeySchemas.java:175 — streams/src/main/java/org/apache/kafka/streams/state/internals/PrefixedSessionKeySchemas.java:175-179 | streams/src/main/java/org/apache/kafka/streams/state/internals/PrefixedSessionKeySchemas.java:322-326 | streams/src/main/java/org/apache/kafka/streams/state/internals/SessionKeySchema.java:152-156 — there are 3 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 3 sites; resolving a subset leaves the remainder to drift apart. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (5 lines × 3) streams/src/main/java/org/apache/kafka/streams/state/internals/PrefixedSessionKeySchemas.java:184 — streams/src/main/java/org/apache/kafka/streams/state/internals/PrefixedSessionKeySchemas.java:184-188 | streams/src/main/java/org/apache/kafka/streams/state/internals/PrefixedSessionKeySchemas.java:338-342 | streams/src/main/java/org/apache/kafka/streams/state/internals/SessionKeySchema.java:146-150 — there are 3 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 3 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `streams/src/main/java/org/apache/kafka/streams/state/internals/PrefixedSessionKeySchemas.java:184` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (5 lines × 3) streams/src/main/java/org/apache/kafka/streams/state/internals/PrefixedWindowKeySchemas.java:172 — streams/src/main/java/org/apache/kafka/streams/state/internals/PrefixedWindowKeySchemas.java:172-176 | streams/src/main/java/org/apache/kafka/streams/state/internals/PrefixedWindowKeySchemas.java:384-388 | streams/src/main/java/org/apache/kafka/streams/state/internals/WindowKeySchema.java:227-231 — there are 3 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 3 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `streams/src/main/java/org/apache/kafka/streams/state/internals/PrefixedWindowKeySchemas.java:172` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (5 lines × 3) streams/src/main/java/org/apache/kafka/streams/state/internals/PrefixedWindowKeySchemas.java:216 — streams/src/main/java/org/apache/kafka/streams/state/internals/PrefixedWindowKeySchemas.java:216-220 | streams/src/main/java/org/apache/kafka/streams/state/internals/PrefixedWindowKeySchemas.java:360-364 | streams/src/main/java/org/apache/kafka/streams/state/internals/WindowKeySchema.java:242-246 — there are 3 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 3 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `streams/src/main/java/org/apache/kafka/streams/state/internals/PrefixedWindowKeySchemas.java:216` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (5 lines × 3) trogdor/src/main/java/org/apache/kafka/trogdor/fault/Kibosh.java:47 — trogdor/src/main/java/org/apache/kafka/trogdor/fault/Kibosh.java:47-51 | trogdor/src/main/java/org/apache/kafka/trogdor/fault/Kibosh.java:147-151 | trogdor/src/main/java/org/apache/kafka/trogdor/rest/Message.java:26-30 — before extracting anything, compare `trogdor/src/main/java/org/apache/kafka/trogdor/fault/Kibosh.java` and `trogdor/src/main/java/org/apache/kafka/trogdor/rest/Message.java` as WHOLE FILES: 87% of the shorter file's lines also appear in the other, so this reads as one file having been copied from the other rather than as a helper waiting to be extracted. The 1 duplicated block(s) this scan matched between them are fragments of that copy, not the extent of it — treat the file pair as the unit. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (5 lines × 3) clients/src/main/java/org/apache/kafka/clients/consumer/internals/events/StreamsOnAllTasksLostCallbackCompletedEvent.java:31 — clients/src/main/java/org/apache/kafka/clients/consumer/internals/events/StreamsOnAllTasksLostCallbackCompletedEvent.java:31-35 | clients/src/main/java/org/apache/kafka/clients/consumer/internals/events/StreamsOnTasksAssignedCallbackCompletedEvent.java:31-35 | clients/src/main/java/org/apache/kafka/clients/consumer/internals/events/StreamsOnTasksRevokedCallbackCompletedEvent.java:31-35 — before extracting anything, compare `clients/src/main/java/org/apache/kafka/clients/consumer/internals/events/StreamsOnAllTasksLostCallbackCompletedEvent.java` and `clients/src/main/java/org/apache/kafka/clients/consumer/internals/events/StreamsOnTasksAssignedCallbackCompletedEvent.java` as WHOLE FILES: 84% of the shorter file's lines also appear in the other, so this reads as one file having been copied from the other rather than as a helper waiting to be extracted. The 1 duplicated block(s) this scan matched between them are fragments of that copy, not the extent of it — treat the file pair as the unit. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `clients/src/main/java/org/apache/kafka/clients/consumer/internals/events/StreamsOnAllTasksLostCallbackCompletedEvent.java:31` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (5 lines × 3) clients/src/main/java/org/apache/kafka/common/requests/AlterClientQuotasRequest.java:92 — clients/src/main/java/org/apache/kafka/common/requests/AlterClientQuotasRequest.java:92-96 | clients/src/main/java/org/apache/kafka/common/requests/AlterClientQuotasResponse.java:44-48 | clients/src/main/java/org/apache/kafka/common/requests/DescribeClientQuotasResponse.java:51-55 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 3 call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `clients/src/main/java/org/apache/kafka/common/requests/AlterClientQuotasRequest.java:92` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note first that the copies are not typed on the same thing: `EntityData` names `org.apache.kafka.common.message.AlterClientQuotasRequestData.EntityData` in one and `org.apache.kafka.common.message.AlterClientQuotasResponseData.EntityData` in another — different types that share a simple name, which is why the text matched. A single extracted unit cannot be given a parameter type that fits both, so unifying those types (or introducing a shared abstraction over them) is the step that has to come BEFORE the extraction above; if they are deliberately separate, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
  • Duplicated block (5 lines × 3) server-common/src/main/java/org/apache/kafka/server/share/persister/DefaultStatePersister.java:197 — server-common/src/main/java/org/apache/kafka/server/share/persister/DefaultStatePersister.java:197-201 | server-common/src/main/java/org/apache/kafka/server/share/persister/DefaultStatePersister.java:242-246 | server-common/src/main/java/org/apache/kafka/server/share/persister/DefaultStatePersister.java:545-549 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `server-common/src/main/java/org/apache/kafka/server/share/persister/DefaultStatePersister.java:197` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note first that the copies are not typed on the same thing: the declarations holding them bind `futureMap` to `Map<Uuid, Map<Integer, CompletableFuture<InitializeShareGroupStateResponse>>>` in one and `Map<Uuid, Map<Integer, CompletableFuture<WriteShareGroupStateResponse>>>` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
  • Duplicated block (5 lines × 3) tools/src/main/java/org/apache/kafka/tools/consumer/group/ConsumerGroupCommand.java:934 — tools/src/main/java/org/apache/kafka/tools/consumer/group/ConsumerGroupCommand.java:934-938 | tools/src/main/java/org/apache/kafka/tools/consumer/group/ShareGroupCommand.java:765-769 | tools/src/main/java/org/apache/kafka/tools/streams/StreamsGroupCommand.java:1111-1115 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
  • Duplicated block (5 lines × 3) streams/quickstart/java/src/main/resources/archetype-resources/src/main/java/LineSplit.java:41 — streams/quickstart/java/src/main/resources/archetype-resources/src/main/java/LineSplit.java:41-45 | streams/quickstart/java/src/main/resources/archetype-resources/src/main/java/Pipe.java:38-42 | streams/quickstart/java/src/main/resources/archetype-resources/src/main/java/WordCount.java:47-51 — before extracting anything, compare `streams/quickstart/java/src/main/resources/archetype-resources/src/main/java/LineSplit.java` and `streams/quickstart/java/src/main/resources/archetype-resources/src/main/java/Pipe.java` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 40 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
D4 · Code Duplication · Duplicated block (15 lines × 2) · ×17
  • Duplicated block (15 lines × 2) group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java:6055 — group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java:6055-6069 | group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java:6545-6559 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java:6055` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (15 lines × 2) group-coordinator/src/main/java/org/apache/kafka/coordinator/group/OffsetMetadataManager.java:666 — group-coordinator/src/main/java/org/apache/kafka/coordinator/group/OffsetMetadataManager.java:666-680 | group-coordinator/src/main/java/org/apache/kafka/coordinator/group/OffsetMetadataManager.java:744-758 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `group-coordinator/src/main/java/org/apache/kafka/coordinator/group/OffsetMetadataManager.java:666` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on. Note first that the copies are not typed on the same thing: the declarations holding them bind `request` to `OffsetCommitRequestData` in one and `TxnOffsetCommitRequestData` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
  • Duplicated block (15 lines × 2) metadata/src/main/java/org/apache/kafka/controller/BrokersToElrs.java:124 — metadata/src/main/java/org/apache/kafka/controller/BrokersToElrs.java:124-138 | metadata/src/main/java/org/apache/kafka/controller/BrokersToIsrs.java:240-254 — before extracting anything, compare `metadata/src/main/java/org/apache/kafka/controller/BrokersToElrs.java` and `metadata/src/main/java/org/apache/kafka/controller/BrokersToIsrs.java` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 62 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `metadata/src/main/java/org/apache/kafka/controller/BrokersToElrs.java:124` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (15 lines × 2) metadata/src/main/java/org/apache/kafka/controller/DelegationTokenControlManager.java:242 — metadata/src/main/java/org/apache/kafka/controller/DelegationTokenControlManager.java:242-256 | metadata/src/main/java/org/apache/kafka/controller/DelegationTokenControlManager.java:293-307 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. Note first that the copies are not typed on the same thing: the declarations holding them bind `requestData` to `RenewDelegationTokenRequestData` in one and `ExpireDelegationTokenRequestData` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `metadata/src/main/java/org/apache/kafka/controller/DelegationTokenControlManager.java:258` calls `maxTimestamp`, `expiryTimestamp`, `atomicOf` and `metadata/src/main/java/org/apache/kafka/controller/DelegationTokenControlManager.java:309` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (15 lines × 2) streams/src/main/java/org/apache/kafka/streams/kstream/internals/ChangedSerializer.java:55 — streams/src/main/java/org/apache/kafka/streams/kstream/internals/ChangedSerializer.java:55-69 | streams/src/main/java/org/apache/kafka/streams/kstream/internals/foreignkeyjoin/SubscriptionWrapperSerde.java:75-89 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `streams/src/main/java/org/apache/kafka/streams/kstream/internals/ChangedSerializer.java:55` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (15 lines × 2) streams/src/main/java/org/apache/kafka/streams/kstream/internals/KStreamSlidingWindowAggregate.java:108 — streams/src/main/java/org/apache/kafka/streams/kstream/internals/KStreamSlidingWindowAggregate.java:108-122 | streams/src/main/java/org/apache/kafka/streams/kstream/internals/KStreamWindowAggregate.java:110-124 — before extracting anything, compare `streams/src/main/java/org/apache/kafka/streams/kstream/internals/KStreamSlidingWindowAggregate.java` and `streams/src/main/java/org/apache/kafka/streams/kstream/internals/KStreamWindowAggregate.java` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 36 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `streams/src/main/java/org/apache/kafka/streams/kstream/internals/KStreamSlidingWindowAggregate.java:108` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (15 lines × 2) streams/src/main/java/org/apache/kafka/streams/processor/assignment/TaskAssignmentUtils.java:305 — streams/src/main/java/org/apache/kafka/streams/processor/assignment/TaskAssignmentUtils.java:305-319 | streams/src/main/java/org/apache/kafka/streams/processor/assignment/TaskAssignmentUtils.java:404-418 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `streams/src/main/java/org/apache/kafka/streams/processor/assignment/TaskAssignmentUtils.java:305` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (15 lines × 2) streams/src/main/java/org/apache/kafka/streams/state/internals/CachingWindowStore.java:106 — streams/src/main/java/org/apache/kafka/streams/state/internals/CachingWindowStore.java:106-120 | streams/src/main/java/org/apache/kafka/streams/state/internals/TimeOrderedCachingWindowStore.java:206-220 — before extracting anything, compare `streams/src/main/java/org/apache/kafka/streams/state/internals/CachingWindowStore.java` and `streams/src/main/java/org/apache/kafka/streams/state/internals/TimeOrderedCachingWindowStore.java` as WHOLE FILES: this scan already matched 9 separate duplicated blocks between them, totalling at least 121 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `streams/src/main/java/org/apache/kafka/streams/state/internals/CachingWindowStore.java:106` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (15 lines × 2) streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredSessionStoreWithHeaders.java:360 — streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredSessionStoreWithHeaders.java:360-374 | streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredSessionStoreWithHeaders.java:401-415 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredSessionStoreWithHeaders.java:360` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on. Note first that the copies are not typed on the same thing: the declarations holding them bind `query` to `WindowRangeQuery<K, AGG>` in one and `TimestampedWindowRangeWithHeadersQuery<K, AGG>` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
  • Duplicated block (15 lines × 2) tools/src/main/java/org/apache/kafka/tools/FeatureCommand.java:149 — tools/src/main/java/org/apache/kafka/tools/FeatureCommand.java:149-163 | tools/src/main/java/org/apache/kafka/tools/FeatureCommand.java:168-182 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (15 lines × 2) tools/src/main/java/org/apache/kafka/tools/VerifiableConsumer.java:579 — tools/src/main/java/org/apache/kafka/tools/VerifiableConsumer.java:579-593 | tools/src/main/java/org/apache/kafka/tools/VerifiableShareConsumer.java:611-625 — before extracting anything, compare `tools/src/main/java/org/apache/kafka/tools/VerifiableConsumer.java` and `tools/src/main/java/org/apache/kafka/tools/VerifiableShareConsumer.java` as WHOLE FILES: this scan already matched 9 separate duplicated blocks between them, totalling at least 130 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `tools/src/main/java/org/apache/kafka/tools/VerifiableConsumer.java:579` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (15 lines × 2) tools/src/main/java/org/apache/kafka/tools/consumer/ConsoleConsumerOptions.java:447 — tools/src/main/java/org/apache/kafka/tools/consumer/ConsoleConsumerOptions.java:447-461 | tools/src/main/java/org/apache/kafka/tools/consumer/ConsoleShareConsumerOptions.java:315-329 — before extracting anything, compare `tools/src/main/java/org/apache/kafka/tools/consumer/ConsoleConsumerOptions.java` and `tools/src/main/java/org/apache/kafka/tools/consumer/ConsoleShareConsumerOptions.java` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 157 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
  • Duplicated block (15 lines × 2) tools/src/main/java/org/apache/kafka/tools/consumer/group/ConsumerGroupCommand.java:496 — tools/src/main/java/org/apache/kafka/tools/consumer/group/ConsumerGroupCommand.java:496-510 | tools/src/main/java/org/apache/kafka/tools/consumer/group/ShareGroupCommand.java:744-758 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `tools/src/main/java/org/apache/kafka/tools/consumer/group/ConsumerGroupCommand.java:496` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (15 lines × 2) trogdor/src/main/java/org/apache/kafka/trogdor/workload/ConfigurableProducerWorker.java:189 — trogdor/src/main/java/org/apache/kafka/trogdor/workload/ConfigurableProducerWorker.java:189-203 | trogdor/src/main/java/org/apache/kafka/trogdor/workload/ProduceBenchWorker.java:249-263 — before extracting anything, compare `trogdor/src/main/java/org/apache/kafka/trogdor/workload/ConfigurableProducerWorker.java` and `trogdor/src/main/java/org/apache/kafka/trogdor/workload/ProduceBenchWorker.java` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 53 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `trogdor/src/main/java/org/apache/kafka/trogdor/workload/ConfigurableProducerWorker.java:189` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (15 lines × 2) group-coordinator/src/main/java/org/apache/kafka/coordinator/group/modern/MemberState.java:63 — group-coordinator/src/main/java/org/apache/kafka/coordinator/group/modern/MemberState.java:63-77 | group-coordinator/src/main/java/org/apache/kafka/coordinator/group/streams/MemberState.java:59-73 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (15 lines × 2) raft/src/main/java/org/apache/kafka/raft/CandidateState.java:150 — raft/src/main/java/org/apache/kafka/raft/CandidateState.java:150-165 | raft/src/main/java/org/apache/kafka/raft/ResignedState.java:150-164 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `raft/src/main/java/org/apache/kafka/raft/CandidateState.java:150` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (15 lines × 2) raft/src/main/java/org/apache/kafka/raft/internals/AddVoterHandlerState.java:84 — raft/src/main/java/org/apache/kafka/raft/internals/AddVoterHandlerState.java:84-98 | raft/src/main/java/org/apache/kafka/raft/internals/UpdateVoterHandlerState.java:89-103 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
D6 · Cohesion (LCOM4) · Low cohesion · ×16
  • Low cohesion: ShareConsumerTestBase (LCOM4 9) clients/clients-integration-tests/src/test/java/org/apache/kafka/clients/consumer/ShareConsumerTestBase.java:89 — ShareConsumerTestBase's methods fall into 9 groups that share no field and call none of each other, against a bar of more than 3 for this run (LCOM4, configurable — your repository's bar is the one quoted here). Each group is a set of methods reachable from one another through shared fields or direct calls, so 9 groups means the type has that many internally-connected clusters with nothing tying them together. Types whose shape makes a high count expected — and which would otherwise dominate this list — are excluded before this row is raised, so this is a genuine split candidate rather than a metric reading. It is still a shape, not a defect: confirm the groups match responsibilities you can name before splitting.
  • Low cohesion: PapiDslIntegrationTest (LCOM4 9) streams/integration-tests/src/test/java/org/apache/kafka/streams/integration/PapiDslIntegrationTest.java:70 — PapiDslIntegrationTest's methods fall into 9 groups that share no field and call none of each other, against a bar of more than 3 for this run (LCOM4, configurable — your repository's bar is the one quoted here). Each group is a set of methods reachable from one another through shared fields or direct calls, so 9 groups means the type has that many internally-connected clusters with nothing tying them together. Types whose shape makes a high count expected — and which would otherwise dominate this list — are excluded before this row is raised, so this is a genuine split candidate rather than a metric reading. It is still a shape, not a defect: confirm the groups match responsibilities you can name before splitting.
  • Low cohesion: BaseRepartitionNodeBuilder (LCOM4 9) streams/src/main/java/org/apache/kafka/streams/kstream/internals/graph/BaseRepartitionNode.java:96 — BaseRepartitionNodeBuilder's methods fall into 9 groups that share no field and call none of each other, against a bar of more than 3 for this run (LCOM4, configurable — your repository's bar is the one quoted here). Each group is a set of methods reachable from one another through shared fields or direct calls, so 9 groups means the type has that many internally-connected clusters with nothing tying them together. Types whose shape makes a high count expected — and which would otherwise dominate this list — are excluded before this row is raised, so this is a genuine split candidate rather than a metric reading. It is still a shape, not a defect: confirm the groups match responsibilities you can name before splitting.
  • Low cohesion: KStreamImpl (LCOM4 9) streams/src/main/java/org/apache/kafka/streams/kstream/internals/KStreamImpl.java:79 — KStreamImpl's methods fall into 9 groups that share no field and call none of each other, against a bar of more than 3 for this run (LCOM4, configurable — your repository's bar is the one quoted here). Each group is a set of methods reachable from one another through shared fields or direct calls, so 9 groups means the type has that many internally-connected clusters with nothing tying them together. Types whose shape makes a high count expected — and which would otherwise dominate this list — are excluded before this row is raised, so this is a genuine split candidate rather than a metric reading. It is still a shape, not a defect: confirm the groups match responsibilities you can name before splitting.
  • Low cohesion: StandbyTask (LCOM4 8) streams/src/main/java/org/apache/kafka/streams/processor/internals/StandbyTask.java:46 — StandbyTask's methods fall into 8 groups that share no field and call none of each other, against a bar of more than 3 for this run (LCOM4, configurable — your repository's bar is the one quoted here). Each group is a set of methods reachable from one another through shared fields or direct calls, so 8 groups means the type has that many internally-connected clusters with nothing tying them together. Types whose shape makes a high count expected — and which would otherwise dominate this list — are excluded before this row is raised, so this is a genuine split candidate rather than a metric reading. It is still a shape, not a defect: confirm the groups match responsibilities you can name before splitting.
  • Low cohesion: MetricConfig (LCOM4 6) clients/src/main/java/org/apache/kafka/common/metrics/MetricConfig.java:30 — MetricConfig's methods fall into 6 groups that share no field and call none of each other, against a bar of more than 3 for this run (LCOM4, configurable — your repository's bar is the one quoted here). Each group is a set of methods reachable from one another through shared fields or direct calls, so 6 groups means the type has that many internally-connected clusters with nothing tying them together. Types whose shape makes a high count expected — and which would otherwise dominate this list — are excluded before this row is raised, so this is a genuine split candidate rather than a metric reading. It is still a shape, not a defect: confirm the groups match responsibilities you can name before splitting.
  • Low cohesion: GroupCoordinatorMetricsShard (LCOM4 6) group-coordinator/src/main/java/org/apache/kafka/coordinator/group/metrics/GroupCoordinatorMetricsShard.java:41 — GroupCoordinatorMetricsShard's methods fall into 6 groups that share no field and call none of each other, against a bar of more than 3 for this run (LCOM4, configurable — your repository's bar is the one quoted here). Each group is a set of methods reachable from one another through shared fields or direct calls, so 6 groups means the type has that many internally-connected clusters with nothing tying them together. Types whose shape makes a high count expected — and which would otherwise dominate this list — are excluded before this row is raised, so this is a genuine split candidate rather than a metric reading. It is still a shape, not a defect: confirm the groups match responsibilities you can name before splitting.
  • Low cohesion: Materialized (LCOM4 6) streams/src/main/java/org/apache/kafka/streams/kstream/Materialized.java:89 — Materialized's methods fall into 6 groups that share no field and call none of each other, against a bar of more than 3 for this run (LCOM4, configurable — your repository's bar is the one quoted here). Each group is a set of methods reachable from one another through shared fields or direct calls, so 6 groups means the type has that many internally-connected clusters with nothing tying them together. Types whose shape makes a high count expected — and which would otherwise dominate this list — are excluded before this row is raised, so this is a genuine split candidate rather than a metric reading. It is still a shape, not a defect: confirm the groups match responsibilities you can name before splitting.
  • Low cohesion: AbstractHerder (LCOM4 5) connect/runtime/src/main/java/org/apache/kafka/connect/runtime/AbstractHerder.java:133 — AbstractHerder's methods fall into 5 groups that share no field and call none of each other, against a bar of more than 3 for this run (LCOM4, configurable — your repository's bar is the one quoted here). Each group is a set of methods reachable from one another through shared fields or direct calls, so 5 groups means the type has that many internally-connected clusters with nothing tying them together. Types whose shape makes a high count expected — and which would otherwise dominate this list — are excluded before this row is raised, so this is a genuine split candidate rather than a metric reading. It is still a shape, not a defect: confirm the groups match responsibilities you can name before splitting.
  • Low cohesion: StreamTask (LCOM4 5) streams/src/main/java/org/apache/kafka/streams/processor/internals/StreamTask.java:73 — StreamTask's methods fall into 5 groups that share no field and call none of each other, against a bar of more than 3 for this run (LCOM4, configurable — your repository's bar is the one quoted here). Each group is a set of methods reachable from one another through shared fields or direct calls, so 5 groups means the type has that many internally-connected clusters with nothing tying them together. Types whose shape makes a high count expected — and which would otherwise dominate this list — are excluded before this row is raised, so this is a genuine split candidate rather than a metric reading. It is still a shape, not a defect: confirm the groups match responsibilities you can name before splitting.
  • Low cohesion: AbstractRecords (LCOM4 4) clients/src/main/java/org/apache/kafka/common/record/internal/AbstractRecords.java:27 — AbstractRecords's methods fall into 4 groups that share no field and call none of each other, against a bar of more than 3 for this run (LCOM4, configurable — your repository's bar is the one quoted here). Each group is a set of methods reachable from one another through shared fields or direct calls, so 4 groups means the type has that many internally-connected clusters with nothing tying them together. Types whose shape makes a high count expected — and which would otherwise dominate this list — are excluded before this row is raised, so this is a genuine split candidate rather than a metric reading. It is still a shape, not a defect: confirm the groups match responsibilities you can name before splitting.
  • Low cohesion: DistributedHerder (LCOM4 4) connect/runtime/src/main/java/org/apache/kafka/connect/runtime/distributed/DistributedHerder.java:154 — DistributedHerder's methods fall into 4 groups that share no field and call none of each other, against a bar of more than 3 for this run (LCOM4, configurable — your repository's bar is the one quoted here). Each group is a set of methods reachable from one another through shared fields or direct calls, so 4 groups means the type has that many internally-connected clusters with nothing tying them together. Types whose shape makes a high count expected — and which would otherwise dominate this list — are excluded before this row is raised, so this is a genuine split candidate rather than a metric reading. It is still a shape, not a defect: confirm the groups match responsibilities you can name before splitting.
  • Low cohesion: Builder (LCOM4 4) group-coordinator/src/main/java/org/apache/kafka/coordinator/group/streams/StreamsGroupMember.java:85 — Builder's methods fall into 4 groups that share no field and call none of each other, against a bar of more than 3 for this run (LCOM4, configurable — your repository's bar is the one quoted here). Each group is a set of methods reachable from one another through shared fields or direct calls, so 4 groups means the type has that many internally-connected clusters with nothing tying them together. Types whose shape makes a high count expected — and which would otherwise dominate this list — are excluded before this row is raised, so this is a genuine split candidate rather than a metric reading. It is still a shape, not a defect: confirm the groups match responsibilities you can name before splitting.
  • Low cohesion: AbstractProcessorContext (LCOM4 4) streams/src/main/java/org/apache/kafka/streams/processor/internals/AbstractProcessorContext.java:38 — AbstractProcessorContext's methods fall into 4 groups that share no field and call none of each other, against a bar of more than 3 for this run (LCOM4, configurable — your repository's bar is the one quoted here). Each group is a set of methods reachable from one another through shared fields or direct calls, so 4 groups means the type has that many internally-connected clusters with nothing tying them together. Types whose shape makes a high count expected — and which would otherwise dominate this list — are excluded before this row is raised, so this is a genuine split candidate rather than a metric reading. It is still a shape, not a defect: confirm the groups match responsibilities you can name before splitting.
  • Low cohesion: ProcessorTopology (LCOM4 4) streams/src/main/java/org/apache/kafka/streams/processor/internals/ProcessorTopology.java:33 — ProcessorTopology's methods fall into 4 groups that share no field and call none of each other, against a bar of more than 3 for this run (LCOM4, configurable — your repository's bar is the one quoted here). Each group is a set of methods reachable from one another through shared fields or direct calls, so 4 groups means the type has that many internally-connected clusters with nothing tying them together. Types whose shape makes a high count expected — and which would otherwise dominate this list — are excluded before this row is raised, so this is a genuine split candidate rather than a metric reading. It is still a shape, not a defect: confirm the groups match responsibilities you can name before splitting.
  • Low cohesion: ConsoleShareConsumerOptions (LCOM4 4) tools/src/main/java/org/apache/kafka/tools/consumer/ConsoleShareConsumerOptions.java:37 — ConsoleShareConsumerOptions's methods fall into 4 groups that share no field and call none of each other, against a bar of more than 3 for this run (LCOM4, configurable — your repository's bar is the one quoted here). Each group is a set of methods reachable from one another through shared fields or direct calls, so 4 groups means the type has that many internally-connected clusters with nothing tying them together. Types whose shape makes a high count expected — and which would otherwise dominate this list — are excluded before this row is raised, so this is a genuine split candidate rather than a metric reading. It is still a shape, not a defect: confirm the groups match responsibilities you can name before splitting.
D4 · Code Duplication · Members sharing a duplicated core (4 members, 50+ identical tokens) · ×15
  • Members sharing a duplicated core (4 members, 50+ identical tokens) clients/src/main/java/org/apache/kafka/clients/admin/KafkaAdminClient.java:1935 — clients/src/main/java/org/apache/kafka/clients/admin/KafkaAdminClient.java:1935-1993 | clients/src/main/java/org/apache/kafka/clients/admin/KafkaAdminClient.java:2096-2138 | clients/src/main/java/org/apache/kafka/clients/admin/KafkaAdminClient.java:2169-2211 | clients/src/main/java/org/apache/kafka/clients/admin/KafkaAdminClient.java:3328-3370 — These 4 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
  • Members sharing a duplicated core (4 members, 50+ identical tokens) clients/src/main/java/org/apache/kafka/clients/admin/KafkaAdminClient.java:2031 — clients/src/main/java/org/apache/kafka/clients/admin/KafkaAdminClient.java:2031-2053 | clients/src/main/java/org/apache/kafka/clients/admin/KafkaAdminClient.java:2056-2078 | clients/src/main/java/org/apache/kafka/clients/admin/KafkaAdminClient.java:2441-2478 | clients/src/main/java/org/apache/kafka/clients/admin/KafkaAdminClient.java:2480-2543 — These 4 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
  • Members sharing a duplicated core (4 members, 50+ identical tokens) metadata/src/main/java/org/apache/kafka/image/AclsDelta.java:92 — metadata/src/main/java/org/apache/kafka/image/AclsDelta.java:92-110 | metadata/src/main/java/org/apache/kafka/image/ClientQuotaDelta.java:58-76 | metadata/src/main/java/org/apache/kafka/image/ConfigurationDelta.java:69-87 | metadata/src/main/java/org/apache/kafka/image/DelegationTokenDelta.java:74-98 — These 4 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
  • Members sharing a duplicated core (4 members, 50+ identical tokens) metadata/src/main/java/org/apache/kafka/metadata/ListenerInfo.java:88 — metadata/src/main/java/org/apache/kafka/metadata/ListenerInfo.java:88-102 | metadata/src/main/java/org/apache/kafka/metadata/ListenerInfo.java:113-127 | metadata/src/main/java/org/apache/kafka/metadata/ListenerInfo.java:138-152 | metadata/src/main/java/org/apache/kafka/metadata/ListenerInfo.java:163-177 — These 4 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
  • Members sharing a duplicated core (4 members, 50+ identical tokens) share-coordinator/src/main/java/org/apache/kafka/coordinator/share/ShareCoordinatorService.java:589 — share-coordinator/src/main/java/org/apache/kafka/coordinator/share/ShareCoordinatorService.java:589-704 | share-coordinator/src/main/java/org/apache/kafka/coordinator/share/ShareCoordinatorService.java:707-813 | share-coordinator/src/main/java/org/apache/kafka/coordinator/share/ShareCoordinatorService.java:816-922 | share-coordinator/src/main/java/org/apache/kafka/coordinator/share/ShareCoordinatorService.java:925-1015 — These 4 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
  • Members sharing a duplicated core (4 members, 50+ identical tokens) streams/src/main/java/org/apache/kafka/streams/kstream/SessionWindowedDeserializer.java:55 — streams/src/main/java/org/apache/kafka/streams/kstream/SessionWindowedDeserializer.java:55-90 | streams/src/main/java/org/apache/kafka/streams/kstream/SessionWindowedSerializer.java:58-92 | streams/src/main/java/org/apache/kafka/streams/kstream/TimeWindowedDeserializer.java:132-167 | streams/src/main/java/org/apache/kafka/streams/kstream/TimeWindowedSerializer.java:59-93 — These 4 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
  • Members sharing a duplicated core (4 members, 50+ identical tokens) streams/src/main/java/org/apache/kafka/streams/kstream/internals/KGroupedStreamImpl.java:84 — streams/src/main/java/org/apache/kafka/streams/kstream/internals/KGroupedStreamImpl.java:84-107 | streams/src/main/java/org/apache/kafka/streams/kstream/internals/SessionWindowedKStreamImpl.java:145-179 | streams/src/main/java/org/apache/kafka/streams/kstream/internals/SlidingWindowedKStreamImpl.java:126-153 | streams/src/main/java/org/apache/kafka/streams/kstream/internals/TimeWindowedKStreamImpl.java:143-175 — These 4 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
  • Members sharing a duplicated core (4 members, 50+ identical tokens) streams/src/main/java/org/apache/kafka/streams/kstream/internals/KStreamAggregate.java:102 — streams/src/main/java/org/apache/kafka/streams/kstream/internals/KStreamAggregate.java:102-144 | streams/src/main/java/org/apache/kafka/streams/kstream/internals/KStreamReduce.java:99-139 | streams/src/main/java/org/apache/kafka/streams/kstream/internals/KTableAggregate.java:98-143 | streams/src/main/java/org/apache/kafka/streams/kstream/internals/KTableReduce.java:94-135 — These 4 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
  • Members sharing a duplicated core (4 members, 50+ identical tokens) streams/src/main/java/org/apache/kafka/streams/state/internals/CachingKeyValueStore.java:207 — streams/src/main/java/org/apache/kafka/streams/state/internals/CachingKeyValueStore.java:207-239 | streams/src/main/java/org/apache/kafka/streams/state/internals/CachingSessionStore.java:165-201 | streams/src/main/java/org/apache/kafka/streams/state/internals/CachingWindowStore.java:100-138 | streams/src/main/java/org/apache/kafka/streams/state/internals/TimeOrderedCachingWindowStore.java:204-240 — These 4 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
  • Members sharing a duplicated core (4 members, 50+ identical tokens) streams/src/main/java/org/apache/kafka/streams/state/internals/CachingKeyValueStore.java:266 — streams/src/main/java/org/apache/kafka/streams/state/internals/CachingKeyValueStore.java:266-286 | streams/src/main/java/org/apache/kafka/streams/state/internals/CachingSessionStore.java:213-231 | streams/src/main/java/org/apache/kafka/streams/state/internals/CachingWindowStore.java:153-174 | streams/src/main/java/org/apache/kafka/streams/state/internals/TimeOrderedCachingWindowStore.java:261-305 — These 4 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
  • Members sharing a duplicated core (4 members, 50+ identical tokens) streams/src/main/java/org/apache/kafka/streams/state/internals/CachingKeyValueStore.java:546 — streams/src/main/java/org/apache/kafka/streams/state/internals/CachingKeyValueStore.java:546-561 | streams/src/main/java/org/apache/kafka/streams/state/internals/CachingSessionStore.java:447-457 | streams/src/main/java/org/apache/kafka/streams/state/internals/CachingWindowStore.java:390-400 | streams/src/main/java/org/apache/kafka/streams/state/internals/TimeOrderedCachingWindowStore.java:503-513 — These 4 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
  • Members sharing a duplicated core (4 members, 50+ identical tokens) streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredKeyValueStore.java:286 — streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredKeyValueStore.java:286-321 | streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredTimestampedKeyValueStore.java:193-230 | streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredTimestampedKeyValueStore.java:262-298 | streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredTimestampedKeyValueStoreWithHeaders.java:486-514 — These 4 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
  • Members sharing a duplicated core (4 members, 50+ identical tokens) streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredSessionStoreWithHeaders.java:337 — streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredSessionStoreWithHeaders.java:337-374 | streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredSessionStoreWithHeaders.java:389-415 | streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredTimestampedWindowStoreWithHeaders.java:248-283 | streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredTimestampedWindowStoreWithHeaders.java:372-399 — These 4 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
  • Members sharing a duplicated core (4 members, 50+ identical tokens) trogdor/src/main/java/org/apache/kafka/trogdor/agent/Agent.java:201 — trogdor/src/main/java/org/apache/kafka/trogdor/agent/Agent.java:201-272 | trogdor/src/main/java/org/apache/kafka/trogdor/agent/AgentClient.java:200-324 | trogdor/src/main/java/org/apache/kafka/trogdor/coordinator/Coordinator.java:130-183 | trogdor/src/main/java/org/apache/kafka/trogdor/coordinator/CoordinatorClient.java:225-467 — These 4 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
  • Members sharing a duplicated core (4 members, 50+ identical tokens) core/src/main/scala/kafka/server/KafkaApis.scala:1316 — core/src/main/scala/kafka/server/KafkaApis.scala:1316-1362 | core/src/main/scala/kafka/server/KafkaApis.scala:2720-2804 | core/src/main/scala/kafka/server/KafkaApis.scala:2974-3073 | core/src/main/scala/kafka/server/KafkaApis.scala:3195-3275 — These 4 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
D4 · Code Duplication · Duplicated block (16 lines × 2) · ×14
  • Duplicated block (16 lines × 2) clients/src/main/java/org/apache/kafka/clients/admin/KafkaAdminClient.java:3653 — clients/src/main/java/org/apache/kafka/clients/admin/KafkaAdminClient.java:3653-3668 | clients/src/main/java/org/apache/kafka/clients/admin/KafkaAdminClient.java:3811-3826 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `clients/src/main/java/org/apache/kafka/clients/admin/KafkaAdminClient.java:3653` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (16 lines × 2) connect/runtime/src/main/java/org/apache/kafka/connect/runtime/distributed/EagerAssignor.java:74 — connect/runtime/src/main/java/org/apache/kafka/connect/runtime/distributed/EagerAssignor.java:74-89 | connect/runtime/src/main/java/org/apache/kafka/connect/runtime/distributed/IncrementalCooperativeAssignor.java:133-148 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
  • Duplicated block (16 lines × 2) group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java:5577 — group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java:5577-5592 | group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java:5620-5635 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java:5577` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (16 lines × 2) group-coordinator/src/main/java/org/apache/kafka/coordinator/group/streams/CurrentAssignmentBuilder.java:288 — group-coordinator/src/main/java/org/apache/kafka/coordinator/group/streams/CurrentAssignmentBuilder.java:288-303 | group-coordinator/src/main/java/org/apache/kafka/coordinator/group/streams/CurrentAssignmentBuilder.java:383-398 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `group-coordinator/src/main/java/org/apache/kafka/coordinator/group/streams/CurrentAssignmentBuilder.java:288` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (16 lines × 2) jmh-benchmarks/src/main/java/org/apache/kafka/jmh/streams/RawBytesExtractionBenchmark.java:283 — jmh-benchmarks/src/main/java/org/apache/kafka/jmh/streams/RawBytesExtractionBenchmark.java:283-298 | streams/src/main/java/org/apache/kafka/streams/state/internals/Utils.java:214-229 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `jmh-benchmarks/src/main/java/org/apache/kafka/jmh/streams/RawBytesExtractionBenchmark.java:283` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (16 lines × 2) raft/src/main/java/org/apache/kafka/raft/KafkaRaftClient.java:2897 — raft/src/main/java/org/apache/kafka/raft/KafkaRaftClient.java:2897-2912 | raft/src/main/java/org/apache/kafka/raft/internals/DefaultRequestSender.java:72-87 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
  • Duplicated block (16 lines × 2) streams/src/main/java/org/apache/kafka/streams/kstream/internals/KStreamAggregate.java:104 — streams/src/main/java/org/apache/kafka/streams/kstream/internals/KStreamAggregate.java:104-119 | streams/src/main/java/org/apache/kafka/streams/kstream/internals/KStreamReduce.java:101-116 — before extracting anything, compare `streams/src/main/java/org/apache/kafka/streams/kstream/internals/KStreamAggregate.java` and `streams/src/main/java/org/apache/kafka/streams/kstream/internals/KStreamReduce.java` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 50 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. Note first that the copies are not typed on the same thing: the declarations holding them bind `record` to `Record<KIn, VIn>` in one and `Record<K, V>` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
  • Duplicated block (16 lines × 2) streams/src/main/java/org/apache/kafka/streams/kstream/internals/KStreamImpl.java:266 — streams/src/main/java/org/apache/kafka/streams/kstream/internals/KStreamImpl.java:266-281 | streams/src/main/java/org/apache/kafka/streams/kstream/internals/KStreamImpl.java:363-378 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `streams/src/main/java/org/apache/kafka/streams/kstream/internals/KStreamImpl.java:266` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (16 lines × 2) streams/src/main/java/org/apache/kafka/streams/state/internals/CachingWindowStore.java:510 — streams/src/main/java/org/apache/kafka/streams/state/internals/CachingWindowStore.java:510-525 | streams/src/main/java/org/apache/kafka/streams/state/internals/TimeOrderedCachingWindowStore.java:652-667 — before extracting anything, compare `streams/src/main/java/org/apache/kafka/streams/state/internals/CachingWindowStore.java` and `streams/src/main/java/org/apache/kafka/streams/state/internals/TimeOrderedCachingWindowStore.java` as WHOLE FILES: this scan already matched 9 separate duplicated blocks between them, totalling at least 121 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `streams/src/main/java/org/apache/kafka/streams/state/internals/CachingWindowStore.java:510` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (16 lines × 2) tools/src/main/java/org/apache/kafka/tools/consumer/ConsoleConsumer.java:106 — tools/src/main/java/org/apache/kafka/tools/consumer/ConsoleConsumer.java:106-121 | tools/src/main/java/org/apache/kafka/tools/consumer/ConsoleShareConsumer.java:108-123 — before extracting anything, compare `tools/src/main/java/org/apache/kafka/tools/consumer/ConsoleConsumer.java` and `tools/src/main/java/org/apache/kafka/tools/consumer/ConsoleShareConsumer.java` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 36 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `tools/src/main/java/org/apache/kafka/tools/consumer/ConsoleConsumer.java:106` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (16 lines × 2) metadata/src/main/java/org/apache/kafka/metadata/BrokerRegistrationFencingChange.java:40 — metadata/src/main/java/org/apache/kafka/metadata/BrokerRegistrationFencingChange.java:40-55 | metadata/src/main/java/org/apache/kafka/metadata/BrokerRegistrationInControlledShutdownChange.java:41-56 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (16 lines × 2) core/src/main/scala/kafka/coordinator/transaction/TransactionCoordinator.scala:624 — core/src/main/scala/kafka/coordinator/transaction/TransactionCoordinator.scala:624-639 | core/src/main/scala/kafka/coordinator/transaction/TransactionCoordinator.scala:949-964 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `core/src/main/scala/kafka/coordinator/transaction/TransactionCoordinator.scala:624` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (16 lines × 2) core/src/main/scala/kafka/server/ConfigAdminManager.scala:106 — core/src/main/scala/kafka/server/ConfigAdminManager.scala:106-121 | core/src/main/scala/kafka/server/ConfigAdminManager.scala:220-235 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `core/src/main/scala/kafka/server/ConfigAdminManager.scala:106` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (16 lines × 2) release/templates.py:169 — release/templates.py:169-184 | release/templates.py:196-236 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `release/templates.py:196` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (6 lines × 3) · ×14
  • Duplicated block (6 lines × 3) clients/src/main/java/org/apache/kafka/common/requests/FetchResponse.java:294 — clients/src/main/java/org/apache/kafka/common/requests/FetchResponse.java:294-299 | clients/src/main/java/org/apache/kafka/common/requests/ShareAcknowledgeResponse.java:137-142 | clients/src/main/java/org/apache/kafka/common/requests/ShareFetchResponse.java:195-200 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 3 call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `clients/src/main/java/org/apache/kafka/common/requests/FetchResponse.java:294` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (6 lines × 3) metadata/src/main/java/org/apache/kafka/image/AclsDelta.java:103 — metadata/src/main/java/org/apache/kafka/image/AclsDelta.java:103-108 | metadata/src/main/java/org/apache/kafka/image/ConfigurationDelta.java:80-85 | metadata/src/main/java/org/apache/kafka/image/DelegationTokenDelta.java:91-96 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 3 call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `metadata/src/main/java/org/apache/kafka/image/AclsDelta.java:103` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (6 lines × 3) streams/src/main/java/org/apache/kafka/streams/kstream/internals/KGroupedStreamImpl.java:180 — streams/src/main/java/org/apache/kafka/streams/kstream/internals/KGroupedStreamImpl.java:180-185 | streams/src/main/java/org/apache/kafka/streams/kstream/internals/KGroupedTableImpl.java:141-146 | streams/src/main/java/org/apache/kafka/streams/kstream/internals/KGroupedTableImpl.java:171-176 — there are 3 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 3 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `streams/src/main/java/org/apache/kafka/streams/kstream/internals/KGroupedStreamImpl.java:180` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note first that the copies are not typed on the same thing: the declarations holding them bind `materialized` to `Materialized<K, Long, KeyValueStore<Bytes, byte[]>>` in one and `Materialized<K, V, KeyValueStore<Bytes, byte[]>>` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
  • Duplicated block (6 lines × 3) streams/src/main/java/org/apache/kafka/streams/kstream/internals/KStreamSlidingWindowAggregate.java:181 — streams/src/main/java/org/apache/kafka/streams/kstream/internals/KStreamSlidingWindowAggregate.java:181-186 | streams/src/main/java/org/apache/kafka/streams/kstream/internals/KStreamSlidingWindowAggregate.java:243-248 | streams/src/main/java/org/apache/kafka/streams/kstream/internals/KStreamSlidingWindowAggregate.java:310-315 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `streams/src/main/java/org/apache/kafka/streams/kstream/internals/KStreamSlidingWindowAggregate.java:181` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (6 lines × 3) streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredKeyValueStore.java:228 — streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredKeyValueStore.java:228-233 | streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredSessionStore.java:181-186 | streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredWindowStore.java:198-203 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 3 call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredKeyValueStore.java:228` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately. Note first that the copies are not typed on the same thing: the declarations holding them bind `listener` to `CacheFlushListener<K, V>` in one and `CacheFlushListener<Windowed<K>, V>` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
  • Duplicated block (6 lines × 3) clients/src/main/java/org/apache/kafka/clients/admin/internals/DeleteConsumerGroupOffsetsHandler.java:76 — clients/src/main/java/org/apache/kafka/clients/admin/internals/DeleteConsumerGroupOffsetsHandler.java:76-81 | clients/src/main/java/org/apache/kafka/clients/admin/internals/DeleteShareGroupOffsetsHandler.java:75-80 | clients/src/main/java/org/apache/kafka/clients/admin/internals/RemoveMembersFromConsumerGroupHandler.java:75-80 — before extracting anything, compare `clients/src/main/java/org/apache/kafka/clients/admin/internals/DeleteConsumerGroupOffsetsHandler.java` and `clients/src/main/java/org/apache/kafka/clients/admin/internals/RemoveMembersFromConsumerGroupHandler.java` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 61 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `clients/src/main/java/org/apache/kafka/clients/admin/internals/RemoveMembersFromConsumerGroupHandler.java:75` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (6 lines × 3) streams/src/main/java/org/apache/kafka/streams/processor/internals/AbstractProcessorContext.java:198 — streams/src/main/java/org/apache/kafka/streams/processor/internals/AbstractProcessorContext.java:198-203 | streams/test-utils/src/main/java/org/apache/kafka/streams/processor/MockProcessorContext.java:271-276 | streams/test-utils/src/main/java/org/apache/kafka/streams/processor/api/MockProcessorContext.java:301-306 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (6 lines × 3) streams/src/main/java/org/apache/kafka/streams/state/internals/KeyValueStoreBuilder.java:34 — streams/src/main/java/org/apache/kafka/streams/state/internals/KeyValueStoreBuilder.java:34-39 | streams/src/main/java/org/apache/kafka/streams/state/internals/ListValueStoreBuilder.java:33-38 | streams/src/main/java/org/apache/kafka/streams/state/internals/VersionedKeyValueStoreBuilder.java:38-47 — before extracting anything, compare `streams/src/main/java/org/apache/kafka/streams/state/internals/KeyValueStoreBuilder.java` and `streams/src/main/java/org/apache/kafka/streams/state/internals/ListValueStoreBuilder.java` as WHOLE FILES: 89% of the shorter file's lines also appear in the other, so this reads as one file having been copied from the other rather than as a helper waiting to be extracted. The 1 duplicated block(s) this scan matched between them are fragments of that copy, not the extent of it — treat the file pair as the unit. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `streams/src/main/java/org/apache/kafka/streams/state/internals/KeyValueStoreBuilder.java:34` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. Note first that the copies are not typed on the same thing: the declarations holding them bind `storeSupplier` to `KeyValueBytesStoreSupplier` in one and `VersionedBytesStoreSupplier` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
  • Duplicated block (6 lines × 3) clients/src/main/java/org/apache/kafka/clients/admin/internals/AlterConsumerGroupOffsetsHandler.java:56 — clients/src/main/java/org/apache/kafka/clients/admin/internals/AlterConsumerGroupOffsetsHandler.java:56-61 | clients/src/main/java/org/apache/kafka/clients/admin/internals/DeleteConsumerGroupOffsetsHandler.java:53-58 | clients/src/main/java/org/apache/kafka/clients/admin/internals/RemoveMembersFromConsumerGroupHandler.java:50-55 — before extracting anything, compare `clients/src/main/java/org/apache/kafka/clients/admin/internals/DeleteConsumerGroupOffsetsHandler.java` and `clients/src/main/java/org/apache/kafka/clients/admin/internals/RemoveMembersFromConsumerGroupHandler.java` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 61 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `clients/src/main/java/org/apache/kafka/clients/admin/internals/AlterConsumerGroupOffsetsHandler.java:56` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (6 lines × 3) clients/src/main/java/org/apache/kafka/common/requests/BrokerHeartbeatRequest.java:59 — clients/src/main/java/org/apache/kafka/common/requests/BrokerHeartbeatRequest.java:59-64 | clients/src/main/java/org/apache/kafka/common/requests/BrokerRegistrationRequest.java:76-81 | clients/src/main/java/org/apache/kafka/common/requests/ShareAcknowledgeRequest.java:108-113 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 3 call sites, so a change lands once. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (6 lines × 3) clients/src/main/java/org/apache/kafka/common/requests/HeartbeatRequest.java:37 — clients/src/main/java/org/apache/kafka/common/requests/HeartbeatRequest.java:37-42 | clients/src/main/java/org/apache/kafka/common/requests/JoinGroupRequest.java:43-48 | clients/src/main/java/org/apache/kafka/common/requests/SyncGroupRequest.java:42-47 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 3 call sites, so a change lands once. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (6 lines × 3) streams/src/main/java/org/apache/kafka/streams/state/internals/AggregationWithHeadersSerde.java:34 — streams/src/main/java/org/apache/kafka/streams/state/internals/AggregationWithHeadersSerde.java:34-39 | streams/src/main/java/org/apache/kafka/streams/state/internals/ValueAndTimestampSerde.java:26-31 | streams/src/main/java/org/apache/kafka/streams/state/internals/ValueTimestampHeadersSerde.java:34-39 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 3 call sites, so a change lands once.
  • Duplicated block (6 lines × 3) streams/src/main/java/org/apache/kafka/streams/state/internals/KeyValueToTimestampedKeyValueByteStoreAdapter.java:83 — streams/src/main/java/org/apache/kafka/streams/state/internals/KeyValueToTimestampedKeyValueByteStoreAdapter.java:83-88 | streams/src/main/java/org/apache/kafka/streams/state/internals/PlainToHeadersStoreAdapter.java:86-91 | streams/src/main/java/org/apache/kafka/streams/state/internals/TimestampedToHeadersStoreAdapter.java:88-93 — before extracting anything, compare `streams/src/main/java/org/apache/kafka/streams/state/internals/PlainToHeadersStoreAdapter.java` and `streams/src/main/java/org/apache/kafka/streams/state/internals/TimestampedToHeadersStoreAdapter.java` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 44 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (6 lines × 3) .github/scripts/develocity_reports.py:1068 — .github/scripts/develocity_reports.py:1068-1073 | .github/scripts/develocity_reports.py:1129-1134 | .github/scripts/develocity_reports.py:1199-1204 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `.github/scripts/develocity_reports.py:1126` calls `sorted`, `items` and `.github/scripts/develocity_reports.py:1198` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (18 lines × 2) · ×13
  • Duplicated block (18 lines × 2) clients/src/main/java/org/apache/kafka/clients/admin/KafkaAdminClient.java:3593 — clients/src/main/java/org/apache/kafka/clients/admin/KafkaAdminClient.java:3593-3610 | clients/src/main/java/org/apache/kafka/clients/admin/KafkaAdminClient.java:3757-3774 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `clients/src/main/java/org/apache/kafka/clients/admin/KafkaAdminClient.java:3593` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note first that the copies are not typed on the same thing: the declarations holding them bind `options` to `ListGroupsOptions` in one and `ListConsumerGroupsOptions` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
  • Duplicated block (18 lines × 2) clients/src/main/java/org/apache/kafka/clients/consumer/internals/AsyncKafkaConsumer.java:2396 — clients/src/main/java/org/apache/kafka/clients/consumer/internals/AsyncKafkaConsumer.java:2396-2413 | clients/src/main/java/org/apache/kafka/clients/consumer/internals/ShareConsumerImpl.java:1298-1315 — before extracting anything, compare `clients/src/main/java/org/apache/kafka/clients/consumer/internals/AsyncKafkaConsumer.java` and `clients/src/main/java/org/apache/kafka/clients/consumer/internals/ShareConsumerImpl.java` as WHOLE FILES: this scan already matched 13 separate duplicated blocks between them, totalling at least 131 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `clients/src/main/java/org/apache/kafka/clients/consumer/internals/AsyncKafkaConsumer.java:2396` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (18 lines × 2) clients/src/main/java/org/apache/kafka/clients/consumer/internals/TopicMetadataFetcher.java:116 — clients/src/main/java/org/apache/kafka/clients/consumer/internals/TopicMetadataFetcher.java:116-133 | clients/src/main/java/org/apache/kafka/clients/consumer/internals/TopicMetadataRequestManager.java:248-265 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `clients/src/main/java/org/apache/kafka/clients/consumer/internals/TopicMetadataFetcher.java:116` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (18 lines × 2) clients/src/main/java/org/apache/kafka/common/config/provider/FileConfigProvider.java:63 — clients/src/main/java/org/apache/kafka/common/config/provider/FileConfigProvider.java:63-80 | clients/src/main/java/org/apache/kafka/common/config/provider/FileConfigProvider.java:104-121 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `clients/src/main/java/org/apache/kafka/common/config/provider/FileConfigProvider.java:63` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (18 lines × 2) jmh-benchmarks/src/main/java/org/apache/kafka/jmh/fetcher/ReplicaFetcherThreadBenchmark.java:133 — jmh-benchmarks/src/main/java/org/apache/kafka/jmh/fetcher/ReplicaFetcherThreadBenchmark.java:133-150 | jmh-benchmarks/src/main/java/org/apache/kafka/jmh/partition/PartitionMakeFollowerBenchmark.java:105-122 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `jmh-benchmarks/src/main/java/org/apache/kafka/jmh/fetcher/ReplicaFetcherThreadBenchmark.java:133` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (18 lines × 2) streams/src/main/java/org/apache/kafka/streams/processor/internals/ProcessorStateManager.java:596 — streams/src/main/java/org/apache/kafka/streams/processor/internals/ProcessorStateManager.java:596-613 | streams/src/main/java/org/apache/kafka/streams/processor/internals/ProcessorStateManager.java:696-713 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `streams/src/main/java/org/apache/kafka/streams/processor/internals/ProcessorStateManager.java:596` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `streams/src/main/java/org/apache/kafka/streams/processor/internals/ProcessorStateManager.java:717` calls `put` and `streams/src/main/java/org/apache/kafka/streams/processor/internals/ProcessorStateManager.java:614` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (18 lines × 2) streams/src/main/java/org/apache/kafka/streams/processor/internals/StandbyTask.java:281 — streams/src/main/java/org/apache/kafka/streams/processor/internals/StandbyTask.java:281-298 | streams/src/main/java/org/apache/kafka/streams/processor/internals/StreamTask.java:693-710 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `streams/src/main/java/org/apache/kafka/streams/processor/internals/StandbyTask.java:281` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (18 lines × 2) streams/src/main/java/org/apache/kafka/streams/state/internals/RocksDBMigratingSessionStoreWithHeaders.java:73 — streams/src/main/java/org/apache/kafka/streams/state/internals/RocksDBMigratingSessionStoreWithHeaders.java:73-90 | streams/src/main/java/org/apache/kafka/streams/state/internals/RocksDBMigratingWindowStoreWithHeaders.java:81-98 — before extracting anything, compare `streams/src/main/java/org/apache/kafka/streams/state/internals/RocksDBMigratingSessionStoreWithHeaders.java` and `streams/src/main/java/org/apache/kafka/streams/state/internals/RocksDBMigratingWindowStoreWithHeaders.java` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 48 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `streams/src/main/java/org/apache/kafka/streams/state/internals/RocksDBMigratingSessionStoreWithHeaders.java:73` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (18 lines × 2) tools/src/main/java/org/apache/kafka/tools/consumer/group/ConsumerGroupCommand.java:735 — tools/src/main/java/org/apache/kafka/tools/consumer/group/ConsumerGroupCommand.java:735-752 | tools/src/main/java/org/apache/kafka/tools/streams/StreamsGroupCommand.java:675-692 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `tools/src/main/java/org/apache/kafka/tools/consumer/group/ConsumerGroupCommand.java:735` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (18 lines × 2) trogdor/src/main/java/org/apache/kafka/trogdor/agent/Agent.java:223 — trogdor/src/main/java/org/apache/kafka/trogdor/agent/Agent.java:223-240 | trogdor/src/main/java/org/apache/kafka/trogdor/coordinator/Coordinator.java:146-163 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `trogdor/src/main/java/org/apache/kafka/trogdor/agent/Agent.java:223` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `trogdor/src/main/java/org/apache/kafka/trogdor/coordinator/Coordinator.java:145` calls `required` and `trogdor/src/main/java/org/apache/kafka/trogdor/agent/Agent.java:222` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (18 lines × 2) trogdor/src/main/java/org/apache/kafka/trogdor/workload/ConsumeBenchWorker.java:239 — trogdor/src/main/java/org/apache/kafka/trogdor/workload/ConsumeBenchWorker.java:239-256 | trogdor/src/main/java/org/apache/kafka/trogdor/workload/ShareConsumeBenchWorker.java:268-285 — before extracting anything, compare `trogdor/src/main/java/org/apache/kafka/trogdor/workload/ConsumeBenchWorker.java` and `trogdor/src/main/java/org/apache/kafka/trogdor/workload/ShareConsumeBenchWorker.java` as WHOLE FILES: this scan already matched 12 separate duplicated blocks between them, totalling at least 137 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `trogdor/src/main/java/org/apache/kafka/trogdor/workload/ConsumeBenchWorker.java:239` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `trogdor/src/main/java/org/apache/kafka/trogdor/workload/ShareConsumeBenchWorker.java:287` calls `acknowledgeTypeFor`, `ifPresent`, `acknowledge` and `trogdor/src/main/java/org/apache/kafka/trogdor/workload/ConsumeBenchWorker.java:257` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (18 lines × 2) trogdor/src/main/java/org/apache/kafka/trogdor/workload/ConsumeBenchWorker.java:257 — trogdor/src/main/java/org/apache/kafka/trogdor/workload/ConsumeBenchWorker.java:257-274 | trogdor/src/main/java/org/apache/kafka/trogdor/workload/ShareConsumeBenchWorker.java:288-305 — before extracting anything, compare `trogdor/src/main/java/org/apache/kafka/trogdor/workload/ConsumeBenchWorker.java` and `trogdor/src/main/java/org/apache/kafka/trogdor/workload/ShareConsumeBenchWorker.java` as WHOLE FILES: this scan already matched 12 separate duplicated blocks between them, totalling at least 137 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `trogdor/src/main/java/org/apache/kafka/trogdor/workload/ConsumeBenchWorker.java:257` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (18 lines × 2) core/src/main/scala/kafka/server/ConfigAdminManager.scala:138 — core/src/main/scala/kafka/server/ConfigAdminManager.scala:138-155 | core/src/main/scala/kafka/server/ConfigAdminManager.scala:245-262 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `core/src/main/scala/kafka/server/ConfigAdminManager.scala:138` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (9 lines × 3) · ×13
  • Duplicated block (9 lines × 3) clients/src/main/java/org/apache/kafka/common/utils/internals/ByteUtils.java:229 — clients/src/main/java/org/apache/kafka/common/utils/internals/ByteUtils.java:229-237 | jmh-benchmarks/src/main/java/org/apache/kafka/jmh/util/ByteUtilsBenchmark.java:388-396 | jmh-benchmarks/src/main/java/org/apache/kafka/jmh/util/ByteUtilsBenchmark.java:421-429 — there are 3 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 3 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `clients/src/main/java/org/apache/kafka/common/utils/internals/ByteUtils.java:229` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (9 lines × 3) generator/src/main/java/org/apache/kafka/message/JsonConverterGenerator.java:92 — generator/src/main/java/org/apache/kafka/message/JsonConverterGenerator.java:92-100 | generator/src/main/java/org/apache/kafka/message/MessageDataGenerator.java:426-434 | generator/src/main/java/org/apache/kafka/message/MessageDataGenerator.java:1074-1082 — there are 3 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 3 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `generator/src/main/java/org/apache/kafka/message/JsonConverterGenerator.java:92` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `generator/src/main/java/org/apache/kafka/message/MessageDataGenerator.java:1072` calls `printf` and `generator/src/main/java/org/apache/kafka/message/MessageDataGenerator.java:424` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (9 lines × 3) group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupCoordinatorService.java:1342 — group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupCoordinatorService.java:1342-1350 | group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupCoordinatorService.java:1395-1403 | group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupCoordinatorService.java:1450-1458 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupCoordinatorService.java:1342` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (9 lines × 3) metadata/src/main/java/org/apache/kafka/controller/BrokersToElrs.java:123 — metadata/src/main/java/org/apache/kafka/controller/BrokersToElrs.java:123-131 | metadata/src/main/java/org/apache/kafka/controller/BrokersToIsrs.java:212-220 | metadata/src/main/java/org/apache/kafka/controller/BrokersToIsrs.java:239-247 — before extracting anything, compare `metadata/src/main/java/org/apache/kafka/controller/BrokersToElrs.java` and `metadata/src/main/java/org/apache/kafka/controller/BrokersToIsrs.java` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 62 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (9 lines × 3) metadata/src/main/java/org/apache/kafka/controller/DelegationTokenControlManager.java:180 — metadata/src/main/java/org/apache/kafka/controller/DelegationTokenControlManager.java:180-188 | metadata/src/main/java/org/apache/kafka/controller/DelegationTokenControlManager.java:242-250 | metadata/src/main/java/org/apache/kafka/controller/DelegationTokenControlManager.java:293-301 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (9 lines × 3) streams/src/main/java/org/apache/kafka/streams/state/internals/AbstractDualSchemaRocksDBSegmentedBytesStore.java:141 — streams/src/main/java/org/apache/kafka/streams/state/internals/AbstractDualSchemaRocksDBSegmentedBytesStore.java:141-149 | streams/src/main/java/org/apache/kafka/streams/state/internals/AbstractDualSchemaRocksDBSegmentedBytesStore.java:155-163 | streams/src/main/java/org/apache/kafka/streams/state/internals/AbstractDualSchemaRocksDBSegmentedBytesStore.java:170-178 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `streams/src/main/java/org/apache/kafka/streams/state/internals/AbstractDualSchemaRocksDBSegmentedBytesStore.java:141` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (9 lines × 3) tools/src/main/java/org/apache/kafka/tools/ClientMetricsCommand.java:228 — tools/src/main/java/org/apache/kafka/tools/ClientMetricsCommand.java:228-236 | tools/src/main/java/org/apache/kafka/tools/LogDirsCommand.java:167-176 | tools/src/main/java/org/apache/kafka/tools/TopicCommand.java:719-727 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 3 call sites, so a change lands once. Note first that the copies are not typed on the same thing: the declarations holding them bind `args` to `String[]` in one and `String...` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
  • Duplicated block (9 lines × 3) tools/src/main/java/org/apache/kafka/tools/ConsumerPerformance.java:288 — tools/src/main/java/org/apache/kafka/tools/ConsumerPerformance.java:288-296 | tools/src/main/java/org/apache/kafka/tools/EndToEndLatency.java:374-383 | tools/src/main/java/org/apache/kafka/tools/ShareConsumerPerformance.java:332-340 — before extracting anything, compare `tools/src/main/java/org/apache/kafka/tools/ConsumerPerformance.java` and `tools/src/main/java/org/apache/kafka/tools/ShareConsumerPerformance.java` as WHOLE FILES: this scan already matched 10 separate duplicated blocks between them, totalling at least 119 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (9 lines × 3) tools/src/main/java/org/apache/kafka/tools/consumer/group/ConsumerGroupCommandOptions.java:142 — tools/src/main/java/org/apache/kafka/tools/consumer/group/ConsumerGroupCommandOptions.java:142-150 | tools/src/main/java/org/apache/kafka/tools/consumer/group/ShareGroupCommandOptions.java:123-131 | tools/src/main/java/org/apache/kafka/tools/streams/StreamsGroupCommandOptions.java:146-154 — before extracting anything, compare `tools/src/main/java/org/apache/kafka/tools/consumer/group/ConsumerGroupCommandOptions.java` and `tools/src/main/java/org/apache/kafka/tools/consumer/group/ShareGroupCommandOptions.java` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 85 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (9 lines × 3) trogdor/src/main/java/org/apache/kafka/trogdor/coordinator/CoordinatorClient.java:281 — trogdor/src/main/java/org/apache/kafka/trogdor/coordinator/CoordinatorClient.java:281-289 | trogdor/src/main/java/org/apache/kafka/trogdor/coordinator/CoordinatorClient.java:298-306 | trogdor/src/main/java/org/apache/kafka/trogdor/coordinator/CoordinatorClient.java:308-316 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `trogdor/src/main/java/org/apache/kafka/trogdor/coordinator/CoordinatorClient.java:281` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `trogdor/src/main/java/org/apache/kafka/trogdor/coordinator/CoordinatorClient.java:295` calls `action`, `store`, `required` and `trogdor/src/main/java/org/apache/kafka/trogdor/coordinator/CoordinatorClient.java:279` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (9 lines × 3) clients/src/main/java/org/apache/kafka/clients/consumer/internals/AutoOffsetResetStrategy.java:160 — clients/src/main/java/org/apache/kafka/clients/consumer/internals/AutoOffsetResetStrategy.java:160-168 | clients/src/main/java/org/apache/kafka/clients/consumer/internals/ShareAcknowledgementMode.java:99-107 | group-coordinator/src/main/java/org/apache/kafka/coordinator/group/ShareGroupAutoOffsetResetStrategy.java:139-147 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times.
  • Duplicated block (9 lines × 3) connect/transforms/src/main/java/org/apache/kafka/connect/transforms/Flatten.java:72 — connect/transforms/src/main/java/org/apache/kafka/connect/transforms/Flatten.java:72-80 | connect/transforms/src/main/java/org/apache/kafka/connect/transforms/InsertField.java:140-148 | connect/transforms/src/main/java/org/apache/kafka/connect/transforms/ReplaceField.java:144-152 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 3 call sites, so a change lands once.
  • Duplicated block (9 lines × 3) clients/src/main/java/org/apache/kafka/common/requests/DeleteShareGroupStateResponse.java:72 — clients/src/main/java/org/apache/kafka/common/requests/DeleteShareGroupStateResponse.java:72-80 | clients/src/main/java/org/apache/kafka/common/requests/InitializeShareGroupStateResponse.java:119-128 | clients/src/main/java/org/apache/kafka/common/requests/WriteShareGroupStateResponse.java:72-80 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 3 call sites, so a change lands once. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (7 lines × 3) · ×13
  • Duplicated block (7 lines × 3) group-coordinator/src/main/java/org/apache/kafka/coordinator/group/streams/StreamsCoordinatorRecordHelpers.java:164 — group-coordinator/src/main/java/org/apache/kafka/coordinator/group/streams/StreamsCoordinatorRecordHelpers.java:164-170 | group-coordinator/src/main/java/org/apache/kafka/coordinator/group/streams/StreamsCoordinatorRecordHelpers.java:173-179 | group-coordinator/src/main/java/org/apache/kafka/coordinator/group/streams/StreamsCoordinatorRecordHelpers.java:182-188 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `group-coordinator/src/main/java/org/apache/kafka/coordinator/group/streams/StreamsCoordinatorRecordHelpers.java:164` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (7 lines × 3) trogdor/src/main/java/org/apache/kafka/trogdor/workload/ConfigurableProducerWorker.java:110 — trogdor/src/main/java/org/apache/kafka/trogdor/workload/ConfigurableProducerWorker.java:110-116 | trogdor/src/main/java/org/apache/kafka/trogdor/workload/ProduceBenchWorker.java:106-112 | trogdor/src/main/java/org/apache/kafka/trogdor/workload/RoundTripWorkerBase.java:140-146 — before extracting anything, compare `trogdor/src/main/java/org/apache/kafka/trogdor/workload/ConfigurableProducerWorker.java` and `trogdor/src/main/java/org/apache/kafka/trogdor/workload/ProduceBenchWorker.java` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 53 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `trogdor/src/main/java/org/apache/kafka/trogdor/workload/RoundTripWorkerBase.java:147` calls `isEmpty`, `RuntimeException` and `trogdor/src/main/java/org/apache/kafka/trogdor/workload/ConfigurableProducerWorker.java:117` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (7 lines × 3) clients/src/main/java/org/apache/kafka/clients/consumer/internals/AsyncKafkaConsumer.java:1858 — clients/src/main/java/org/apache/kafka/clients/consumer/internals/AsyncKafkaConsumer.java:1858-1864 | clients/src/main/java/org/apache/kafka/clients/consumer/internals/ClassicKafkaConsumer.java:943-950 | clients/src/main/java/org/apache/kafka/clients/consumer/internals/ShareConsumerImpl.java:934-940 — before extracting anything, compare `clients/src/main/java/org/apache/kafka/clients/consumer/internals/AsyncKafkaConsumer.java` and `clients/src/main/java/org/apache/kafka/clients/consumer/internals/ClassicKafkaConsumer.java` as WHOLE FILES: this scan already matched 11 separate duplicated blocks between them, totalling at least 102 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (7 lines × 3) clients/src/main/java/org/apache/kafka/common/requests/AddRaftVoterResponse.java:51 — clients/src/main/java/org/apache/kafka/common/requests/AddRaftVoterResponse.java:51-57 | clients/src/main/java/org/apache/kafka/common/requests/RemoveRaftVoterResponse.java:51-57 | clients/src/main/java/org/apache/kafka/common/requests/UpdateRaftVoterResponse.java:51-57 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 3 call sites, so a change lands once. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `clients/src/main/java/org/apache/kafka/common/requests/AddRaftVoterResponse.java:47` calls `setThrottleTimeMs` and `clients/src/main/java/org/apache/kafka/common/requests/UpdateRaftVoterResponse.java:46` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (7 lines × 3) clients/src/main/java/org/apache/kafka/common/requests/ConsumerGroupDescribeResponse.java:54 — clients/src/main/java/org/apache/kafka/common/requests/ConsumerGroupDescribeResponse.java:54-60 | clients/src/main/java/org/apache/kafka/common/requests/ShareGroupDescribeResponse.java:54-60 | clients/src/main/java/org/apache/kafka/common/requests/StreamsGroupDescribeResponse.java:60-66 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 3 call sites, so a change lands once.
  • Duplicated block (7 lines × 3) connect/mirror-client/src/main/java/org/apache/kafka/connect/mirror/Checkpoint.java:122 — connect/mirror-client/src/main/java/org/apache/kafka/connect/mirror/Checkpoint.java:122-128 | connect/mirror-client/src/main/java/org/apache/kafka/connect/mirror/Heartbeat.java:95-101 | connect/mirror/src/main/java/org/apache/kafka/connect/mirror/OffsetSync.java:64-70 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (7 lines × 3) streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredKeyValueStore.java:526 — streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredKeyValueStore.java:526-532 | streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredSessionStore.java:427-433 | streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredWindowStore.java:429-435 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 3 call sites, so a change lands once.
  • Duplicated block (7 lines × 3) streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredKeyValueStore.java:558 — streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredKeyValueStore.java:558-564 | streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredSessionStore.java:526-534 | streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredWindowStore.java:586-594 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 3 call sites, so a change lands once.
  • Duplicated block (7 lines × 3) clients/src/main/java/org/apache/kafka/common/acl/AclOperation.java:143 — clients/src/main/java/org/apache/kafka/common/acl/AclOperation.java:143-149 | clients/src/main/java/org/apache/kafka/common/acl/AclPermissionType.java:66-72 | clients/src/main/java/org/apache/kafka/common/resource/ResourceType.java:86-92 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times.
  • Duplicated block (7 lines × 3) clients/src/main/java/org/apache/kafka/common/requests/ConsumerGroupDescribeRequest.java:91 — clients/src/main/java/org/apache/kafka/common/requests/ConsumerGroupDescribeRequest.java:91-97 | clients/src/main/java/org/apache/kafka/common/requests/DescribeGroupsRequest.java:83-90 | clients/src/main/java/org/apache/kafka/common/requests/StreamsGroupDescribeRequest.java:87-93 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 3 call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `clients/src/main/java/org/apache/kafka/common/requests/ConsumerGroupDescribeRequest.java:91` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (7 lines × 3) clients/src/main/java/org/apache/kafka/common/requests/ControllerRegistrationRequest.java:58 — clients/src/main/java/org/apache/kafka/common/requests/ControllerRegistrationRequest.java:58-64 | clients/src/main/java/org/apache/kafka/common/requests/UnregisterBrokerRequest.java:54-60 | clients/src/main/java/org/apache/kafka/common/requests/UnregisterControllerRequest.java:54-60 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 3 call sites, so a change lands once. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (7 lines × 3) streams/src/main/java/org/apache/kafka/streams/state/internals/CompositeReadOnlyKeyValueStore.java:177 — streams/src/main/java/org/apache/kafka/streams/state/internals/CompositeReadOnlyKeyValueStore.java:177-183 | streams/src/main/java/org/apache/kafka/streams/state/internals/CompositeReadOnlySessionStore.java:62-68 | streams/src/main/java/org/apache/kafka/streams/state/internals/CompositeReadOnlyWindowStore.java:65-71 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 3 call sites, so a change lands once.
  • Duplicated block (7 lines × 3) .github/scripts/junit.py:48 — .github/scripts/junit.py:48-54 | .github/scripts/pr-format.py:39-45 | .github/scripts/pr-reviewers-trailer.py:46-52 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 3 call sites, so a change lands once.
D35 · Change Coupling · Change coupling · ×12
  • Change coupling: ActiveTaskCreator.java ↔ StandbyTaskCreator.java streams/src/main/java/org/apache/kafka/streams/processor/internals/ActiveTaskCreator.java:1 — `streams/src/main/java/org/apache/kafka/streams/processor/internals/ActiveTaskCreator.java` and `streams/src/main/java/org/apache/kafka/streams/processor/internals/StandbyTaskCreator.java` change together 94% of the time (16 of the 17 commits that touched whichever of the two files changed less often, counting a file under its earlier names as well, and counted over this repository's 10,000 most recent commits rather than its whole history — a repo-wide or module-wide sweep is evidence about the sweep rather than about any pair inside it and is left out of BOTH sides of this ratio, while a dependency bump, a formatter/rename sweep, or a commit whose edit to one of the two files was a tool directive such as //go:generate or whitespace only is left out of the shared count ONLY, so the two sides are not taken over identical commit sets). They sit in the same directory, and in this ecosystem sibling files there normally share one namespace/package — so a direct reference between them needs no import and this pass cannot see whether one exists. Read the pair before acting: if one file only DECLARES what the other consumes (a constants/types file beside its user), the co-change is definitional and the question is whether the split earns its keep; if they duplicate structure, extract the common part into a shared function or type they both call; if neither holds, the coupling is hidden and worth breaking. You can check this without leaving the row: of the 16 shared commits counted here, the most recent 3 are `65d65546` KAFKA-20805: Refresh task directory mtime on state manager close (#22…; `6c83a29a` KAFKA-20489: Add enable.transactional.statestores (#22141); `599d55cd` KAFKA-19710: Write legacy .checkpoint on close for downgrade support … — run `git show` on any of them.
  • Change coupling: PartitionMakeFollowerBenchmark.java ↔ UpdateFollowerFetchStateBenchmark.java jmh-benchmarks/src/main/java/org/apache/kafka/jmh/partition/PartitionMakeFollowerBenchmark.java:1 — `jmh-benchmarks/src/main/java/org/apache/kafka/jmh/partition/PartitionMakeFollowerBenchmark.java` and `jmh-benchmarks/src/main/java/org/apache/kafka/jmh/partition/UpdateFollowerFetchStateBenchmark.java` change together 83% of the time (19 of the 23 commits that touched whichever of the two files changed less often, counting a file under its earlier names as well, and counted over this repository's 10,000 most recent commits rather than its whole history — a repo-wide or module-wide sweep is evidence about the sweep rather than about any pair inside it and is left out of BOTH sides of this ratio, while a dependency bump, a formatter/rename sweep, or a commit whose edit to one of the two files was a tool directive such as //go:generate or whitespace only is left out of the shared count ONLY, so the two sides are not taken over identical commit sets). They sit in the same directory, and in this ecosystem sibling files there normally share one namespace/package — so a direct reference between them needs no import and this pass cannot see whether one exists. Read the pair before acting: if one file only DECLARES what the other consumes (a constants/types file beside its user), the co-change is definitional and the question is whether the split earns its keep; if they duplicate structure, extract the common part into a shared function or type they both call; if neither holds, the coupling is hidden and worth breaking. You can check this without leaving the row: of the 19 shared commits counted here, the most recent 3 are `ad038ef3` KAFKA-21038 Replace LogManagerBuilder with direct LogManager construc…; `cae98481` KAFKA-19447 Replace PartitionState with PartitionRegistration in make…; `bd14ed21` KAFKA-18486 Remove ReplicaManager#becomeLeaderOrFollower (#20037) — run `git show` on any of them.
  • Change coupling: KafkaApisBuilder.java ↔ BrokerServer.scala core/src/main/java/kafka/server/builders/KafkaApisBuilder.java:1 — `core/src/main/java/kafka/server/builders/KafkaApisBuilder.java` and `core/src/main/scala/kafka/server/BrokerServer.scala` change together 79% of the time (19 of the 24 commits that touched whichever of the two files changed less often, counting a file under its earlier names as well, and counted over this repository's 10,000 most recent commits rather than its whole history — a repo-wide or module-wide sweep is evidence about the sweep rather than about any pair inside it and is left out of BOTH sides of this ratio, while a dependency bump, a formatter/rename sweep, or a commit whose edit to one of the two files was a tool directive such as //go:generate or whitespace only is left out of the shared count ONLY, so the two sides are not taken over identical commit sets) with no explicit dependency — the edge is real but nothing declares it. Read the pair before acting: if one registers itself into the other through a hook or an initialiser, the missing dependency is DELIBERATE — the registration is the link, and it is meant not to be an import — and the thing to add is a comment on each side naming the other, not a merge; if they simply belong together, co-locate them; if neither holds, the coupling is hidden and worth breaking. You can check this without leaving the row: of the 19 shared commits counted here, the most recent 3 are `74ebbae8` KAFKA-19132: Move FetchSession and related classes to server module (…; `29ce9615` MINOR; Revert "KAFKA-18681: Created GetReplicaLogInfo RPCs (#19664)" …; `d86ba7f5` KAFKA-18681: Created GetReplicaLogInfo RPCs (#19664) — run `git show` on any of them.
  • Change coupling: KafkaApis.scala ↔ ShareSessionContext.java core/src/main/scala/kafka/server/KafkaApis.scala:1 — `core/src/main/scala/kafka/server/KafkaApis.scala` and `server/src/main/java/org/apache/kafka/server/share/context/ShareSessionContext.java` change together 70% of the time (7 of the 10 commits that touched whichever of the two files changed less often, counting a file under its earlier names as well, and counted over this repository's 10,000 most recent commits rather than its whole history — a repo-wide or module-wide sweep is evidence about the sweep rather than about any pair inside it and is left out of BOTH sides of this ratio, while a dependency bump, a formatter/rename sweep, or a commit whose edit to one of the two files was a tool directive such as //go:generate or whitespace only is left out of the shared count ONLY, so the two sides are not taken over identical commit sets) with no explicit dependency — the edge is real but nothing declares it. Read the pair before acting: if one registers itself into the other through a hook or an initialiser, the missing dependency is DELIBERATE — the registration is the link, and it is meant not to be an import — and the thing to add is a comment on each side naming the other, not a merge; if they simply belong together, co-locate them; if neither holds, the coupling is hidden and worth breaking. You can check this without leaving the row: of the 7 shared commits counted here, the most recent 3 are `bd8ea36a` KAFKA-19846: Remove uuid to string conversion and vice-versa for memb…; `4aa81204` KAFKA-19018,KAFKA-19063: Implement maxRecords and acquisition lock ti…; `c07c59ad` KAFKA-18932: Removed usage of partition max bytes from share fetch re… — run `git show` on any of them.
  • Change coupling: ReplicaManagerBuilder.java ↔ BrokerServer.scala core/src/main/java/kafka/server/builders/ReplicaManagerBuilder.java:1 — `core/src/main/java/kafka/server/builders/ReplicaManagerBuilder.java` and `core/src/main/scala/kafka/server/BrokerServer.scala` change together 67% of the time (14 of the 21 commits that touched whichever of the two files changed less often, counting a file under its earlier names as well, and counted over this repository's 10,000 most recent commits rather than its whole history — a repo-wide or module-wide sweep is evidence about the sweep rather than about any pair inside it and is left out of BOTH sides of this ratio, while a dependency bump, a formatter/rename sweep, or a commit whose edit to one of the two files was a tool directive such as //go:generate or whitespace only is left out of the shared count ONLY, so the two sides are not taken over identical commit sets) with no explicit dependency — the edge is real but nothing declares it. Read the pair before acting: if one registers itself into the other through a hook or an initialiser, the missing dependency is DELIBERATE — the registration is the link, and it is meant not to be an import — and the thing to add is a comment on each side naming the other, not a merge; if they simply belong together, co-locate them; if neither holds, the coupling is hidden and worth breaking. You can check this without leaving the row: of the 14 shared commits counted here, the most recent 3 are `ad934d32` MINOR: Remove threadNamePrefix parameter from ReplicaManager and Repl…; `bd14ed21` KAFKA-18486 Remove ReplicaManager#becomeLeaderOrFollower (#20037); `da0c3bef` KAFKA-18491 Remove zkClient & maybeUpdateMetadataCache from ReplicaMa… — run `git show` on any of them.
  • Change coupling: UpgradeFromValues.java ↔ AssignorConfiguration.java streams/src/main/java/org/apache/kafka/streams/internals/UpgradeFromValues.java:1 — `streams/src/main/java/org/apache/kafka/streams/internals/UpgradeFromValues.java` and `streams/src/main/java/org/apache/kafka/streams/processor/internals/assignment/AssignorConfiguration.java` change together 64% of the time (7 of the 11 commits that touched whichever of the two files changed less often, counting a file under its earlier names as well, and counted over this repository's 10,000 most recent commits rather than its whole history — a repo-wide or module-wide sweep is evidence about the sweep rather than about any pair inside it and is left out of BOTH sides of this ratio, while a dependency bump, a formatter/rename sweep, or a commit whose edit to one of the two files was a tool directive such as //go:generate or whitespace only is left out of the shared count ONLY, so the two sides are not taken over identical commit sets) with no explicit dependency — the edge is real but nothing declares it. Read the pair before acting: if one registers itself into the other through a hook or an initialiser, the missing dependency is DELIBERATE — the registration is the link, and it is meant not to be an import — and the thing to add is a comment on each side naming the other, not a merge; if they simply belong together, co-locate them; if neither holds, the coupling is hidden and worth breaking. You can check this without leaving the row: of the 7 shared commits counted here, the most recent 3 are `7ddd0d7c` KAFKA-19703: Removed versions 2.3 and below from UpgradeFromValues. (…; `84fe6682` KAFKA-18006: Add 3.9.0 to end-to-end test (streams) (#17800); `e299a006` KAFKA-17214: Add 3.8.0 version to streams system tests (#16728) — run `git show` on any of them.
  • Change coupling: OffsetFetcher.java ↔ OffsetsRequestManager.java clients/src/main/java/org/apache/kafka/clients/consumer/internals/OffsetFetcher.java:1 — `clients/src/main/java/org/apache/kafka/clients/consumer/internals/OffsetFetcher.java` and `clients/src/main/java/org/apache/kafka/clients/consumer/internals/OffsetsRequestManager.java` change together 64% of the time (7 of the 11 commits that touched whichever of the two files changed less often, counting a file under its earlier names as well, and counted over this repository's 10,000 most recent commits rather than its whole history — a repo-wide or module-wide sweep is evidence about the sweep rather than about any pair inside it and is left out of BOTH sides of this ratio, while a dependency bump, a formatter/rename sweep, or a commit whose edit to one of the two files was a tool directive such as //go:generate or whitespace only is left out of the shared count ONLY, so the two sides are not taken over identical commit sets). They sit in the same directory, and in this ecosystem sibling files there normally share one namespace/package — so a direct reference between them needs no import and this pass cannot see whether one exists. Read the pair before acting: if one file only DECLARES what the other consumes (a constants/types file beside its user), the co-change is definitional and the question is whether the split earns its keep; if they duplicate structure, extract the common part into a shared function or type they both call; if neither holds, the coupling is hidden and worth breaking. You can check this without leaving the row: of the 7 shared commits counted here, the most recent 3 are `d0e0ec47` KAFKA-20312: Handle null leader during OffsetFetcher regroup safely (…; `51bb0367` KAFKA-19589: Check for ability to skip position validation in applica…; `ae3c5dec` KAFKA-18013: Add support for duration based offset reset strategy to … — run `git show` on any of them.
  • Change coupling: KafkaApis.scala ↔ RequestConvertToJson.java core/src/main/scala/kafka/server/KafkaApis.scala:1 — `core/src/main/scala/kafka/server/KafkaApis.scala` and `server/src/main/java/org/apache/kafka/network/RequestConvertToJson.java` change together 54% of the time (7 of the 13 commits that touched whichever of the two files changed less often, counting a file under its earlier names as well, and counted over this repository's 10,000 most recent commits rather than its whole history — a repo-wide or module-wide sweep is evidence about the sweep rather than about any pair inside it and is left out of BOTH sides of this ratio, while a dependency bump, a formatter/rename sweep, or a commit whose edit to one of the two files was a tool directive such as //go:generate or whitespace only is left out of the shared count ONLY, so the two sides are not taken over identical commit sets) with no explicit dependency — the edge is real but nothing declares it. Read the pair before acting: if one registers itself into the other through a hook or an initialiser, the missing dependency is DELIBERATE — the registration is the link, and it is meant not to be an import — and the thing to add is a comment on each side naming the other, not a merge; if they simply belong together, co-locate them; if neither holds, the coupling is hidden and worth breaking. You can check this without leaving the row: of the 7 shared commits counted here, the most recent 3 are `7997c9eb` KAFKA-20620: Add StreamsGroupTopologyDescriptionUpdate RPC schema and…; `29ce9615` MINOR; Revert "KAFKA-18681: Created GetReplicaLogInfo RPCs (#19664)" …; `d86ba7f5` KAFKA-18681: Created GetReplicaLogInfo RPCs (#19664) — run `git show` on any of them.
  • Change coupling: CheckpointBench.java ↔ PartitionCreationBench.java jmh-benchmarks/src/main/java/org/apache/kafka/jmh/server/CheckpointBench.java:1 — `jmh-benchmarks/src/main/java/org/apache/kafka/jmh/server/CheckpointBench.java` and `jmh-benchmarks/src/main/java/org/apache/kafka/jmh/server/PartitionCreationBench.java` change together 54% of the time (15 of the 28 commits that touched whichever of the two files changed less often, counting a file under its earlier names as well, and counted over this repository's 10,000 most recent commits rather than its whole history — a repo-wide or module-wide sweep is evidence about the sweep rather than about any pair inside it and is left out of BOTH sides of this ratio, while a dependency bump, a formatter/rename sweep, or a commit whose edit to one of the two files was a tool directive such as //go:generate or whitespace only is left out of the shared count ONLY, so the two sides are not taken over identical commit sets). They sit in the same directory, and in this ecosystem sibling files there normally share one namespace/package — so a direct reference between them needs no import and this pass cannot see whether one exists. Read the pair before acting: if one file only DECLARES what the other consumes (a constants/types file beside its user), the co-change is definitional and the question is whether the split earns its keep; if they duplicate structure, extract the common part into a shared function or type they both call; if neither holds, the coupling is hidden and worth breaking. You can check this without leaving the row: of the 15 shared commits counted here, the most recent 3 are `ad038ef3` KAFKA-21038 Replace LogManagerBuilder with direct LogManager construc…; `ed367cf2` KAFKA-20060 Drop core test output dependency in jmh-benchmarks (#21310); `ced56a32` MINOR: Move logDirs config out of KafkaConfig (#19579) — run `git show` on any of them.
  • Change coupling: PartitionMakeFollowerBenchmark.java ↔ PartitionCreationBench.java jmh-benchmarks/src/main/java/org/apache/kafka/jmh/partition/PartitionMakeFollowerBenchmark.java:1 — `jmh-benchmarks/src/main/java/org/apache/kafka/jmh/partition/PartitionMakeFollowerBenchmark.java` and `jmh-benchmarks/src/main/java/org/apache/kafka/jmh/server/PartitionCreationBench.java` change together 52% of the time (12 of the 23 commits that touched whichever of the two files changed less often, counting a file under its earlier names as well, and counted over this repository's 10,000 most recent commits rather than its whole history — a repo-wide or module-wide sweep is evidence about the sweep rather than about any pair inside it and is left out of BOTH sides of this ratio, while a dependency bump, a formatter/rename sweep, or a commit whose edit to one of the two files was a tool directive such as //go:generate or whitespace only is left out of the shared count ONLY, so the two sides are not taken over identical commit sets) with no explicit dependency — the edge is real but nothing declares it. Read the pair before acting: if one registers itself into the other through a hook or an initialiser, the missing dependency is DELIBERATE — the registration is the link, and it is meant not to be an import — and the thing to add is a comment on each side naming the other, not a merge; if they simply belong together, co-locate them; if neither holds, the coupling is hidden and worth breaking. You can check this without leaving the row: of the 12 shared commits counted here, the most recent 3 are `ad038ef3` KAFKA-21038 Replace LogManagerBuilder with direct LogManager construc…; `cae98481` KAFKA-19447 Replace PartitionState with PartitionRegistration in make…; `bd14ed21` KAFKA-18486 Remove ReplicaManager#becomeLeaderOrFollower (#20037) — run `git show` on any of them.
  • Change coupling: OffsetsRequestManager.java ↔ ApplicationEventProcessor.java clients/src/main/java/org/apache/kafka/clients/consumer/internals/OffsetsRequestManager.java:1 — `clients/src/main/java/org/apache/kafka/clients/consumer/internals/OffsetsRequestManager.java` and `clients/src/main/java/org/apache/kafka/clients/consumer/internals/events/ApplicationEventProcessor.java` change together 50% of the time (9 of the 18 commits that touched whichever of the two files changed less often, counting a file under its earlier names as well, and counted over this repository's 10,000 most recent commits rather than its whole history — a repo-wide or module-wide sweep is evidence about the sweep rather than about any pair inside it and is left out of BOTH sides of this ratio, while a dependency bump, a formatter/rename sweep, or a commit whose edit to one of the two files was a tool directive such as //go:generate or whitespace only is left out of the shared count ONLY, so the two sides are not taken over identical commit sets) with no explicit dependency — the edge is real but nothing declares it. Read the pair before acting: if one registers itself into the other through a hook or an initialiser, the missing dependency is DELIBERATE — the registration is the link, and it is meant not to be an import — and the thing to add is a comment on each side naming the other, not a merge; if they simply belong together, co-locate them; if neither holds, the coupling is hidden and worth breaking. You can check this without leaving the row: of the 9 shared commits counted here, the most recent 3 are `e5e26abb` KAFKA-20187: Fix for AsyncKafkaConsumer not clearing endOffsetRequest…; `ada5f22b` KAFKA-20165: Handle retriable partition errors gracefully on OffsetFe…; `51bb0367` KAFKA-19589: Check for ability to skip position validation in applica… — run `git show` on any of them.
  • Change coupling: ShareSessionContext.java ↔ ShareSessionCache.java server/src/main/java/org/apache/kafka/server/share/context/ShareSessionContext.java:1 — `server/src/main/java/org/apache/kafka/server/share/context/ShareSessionContext.java` and `server/src/main/java/org/apache/kafka/server/share/session/ShareSessionCache.java` change together 50% of the time (5 of the 10 commits that touched whichever of the two files changed less often, counting a file under its earlier names as well, and counted over this repository's 10,000 most recent commits rather than its whole history — a repo-wide or module-wide sweep is evidence about the sweep rather than about any pair inside it and is left out of BOTH sides of this ratio, while a dependency bump, a formatter/rename sweep, or a commit whose edit to one of the two files was a tool directive such as //go:generate or whitespace only is left out of the shared count ONLY, so the two sides are not taken over identical commit sets) with no explicit dependency — the edge is real but nothing declares it. Read the pair before acting: if one registers itself into the other through a hook or an initialiser, the missing dependency is DELIBERATE — the registration is the link, and it is meant not to be an import — and the thing to add is a comment on each side naming the other, not a merge; if they simply belong together, co-locate them; if neither holds, the coupling is hidden and worth breaking. You can check this without leaving the row: of the 5 shared commits counted here, the most recent 3 are `bd8ea36a` KAFKA-19846: Remove uuid to string conversion and vice-versa for memb…; `300e825b` MINOR Refactored share module classes (#17178) (at that commit the files were still `share/src/main/java/org/apache/kafka/server/share/context/ShareSessionContext.java` and `share/src/main/java/org/apache/kafka/server/share/session/ShareSessionCache.java`); `3db6e68c` KAFKA-17346: Create :share Gradle module (#16888) (at that commit the files were still `share/src/main/java/org/apache/kafka/server/share/ShareSessionContext.java` and `share/src/main/java/org/apache/kafka/server/share/ShareSessionCache.java`) — run `git show` on any of them.
D4 · Code Duplication · Duplicated block (8 lines × 3) · ×10
  • Duplicated block (8 lines × 3) clients/src/main/java/org/apache/kafka/common/requests/DeleteShareGroupStateResponse.java:47 — clients/src/main/java/org/apache/kafka/common/requests/DeleteShareGroupStateResponse.java:47-54 | clients/src/main/java/org/apache/kafka/common/requests/ReadShareGroupStateSummaryResponse.java:47-54 | clients/src/main/java/org/apache/kafka/common/requests/WriteShareGroupStateResponse.java:47-54 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 3 call sites, so a change lands once. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
  • Duplicated block (8 lines × 3) core/src/main/java/kafka/server/share/SharePartition.java:1482 — core/src/main/java/kafka/server/share/SharePartition.java:1482-1489 | core/src/main/java/kafka/server/share/SharePartition.java:1987-1997 | core/src/main/java/kafka/server/share/SharePartition.java:3100-3110 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `core/src/main/java/kafka/server/share/SharePartition.java:1482` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `core/src/main/java/kafka/server/share/SharePartition.java:1481` calls `trace` and `core/src/main/java/kafka/server/share/SharePartition.java:1986` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (8 lines × 3) generator/src/main/java/org/apache/kafka/message/CoordinatorRecordTypeGenerator.java:164 — generator/src/main/java/org/apache/kafka/message/CoordinatorRecordTypeGenerator.java:164-171 | generator/src/main/java/org/apache/kafka/message/CoordinatorRecordTypeGenerator.java:189-196 | generator/src/main/java/org/apache/kafka/message/CoordinatorRecordTypeGenerator.java:214-221 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `generator/src/main/java/org/apache/kafka/message/CoordinatorRecordTypeGenerator.java:164` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (8 lines × 3) jmh-benchmarks/src/main/java/org/apache/kafka/jmh/assignor/AssignorBenchmarkUtils.java:249 — jmh-benchmarks/src/main/java/org/apache/kafka/jmh/assignor/AssignorBenchmarkUtils.java:249-256 | jmh-benchmarks/src/main/java/org/apache/kafka/jmh/assignor/AssignorBenchmarkUtils.java:333-340 | jmh-benchmarks/src/main/java/org/apache/kafka/jmh/assignor/ClientSideAssignorBenchmark.java:188-195 — there are 3 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 3 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `jmh-benchmarks/src/main/java/org/apache/kafka/jmh/assignor/AssignorBenchmarkUtils.java:249` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (8 lines × 3) streams/src/main/java/org/apache/kafka/streams/kstream/internals/KStreamSessionWindowAggregate.java:415 — streams/src/main/java/org/apache/kafka/streams/kstream/internals/KStreamSessionWindowAggregate.java:415-422 | streams/src/main/java/org/apache/kafka/streams/kstream/internals/KStreamSlidingWindowAggregate.java:515-522 | streams/src/main/java/org/apache/kafka/streams/kstream/internals/KStreamWindowAggregate.java:228-235 — before extracting anything, compare `streams/src/main/java/org/apache/kafka/streams/kstream/internals/KStreamSlidingWindowAggregate.java` and `streams/src/main/java/org/apache/kafka/streams/kstream/internals/KStreamWindowAggregate.java` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 36 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `streams/src/main/java/org/apache/kafka/streams/kstream/internals/KStreamSessionWindowAggregate.java:415` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `streams/src/main/java/org/apache/kafka/streams/kstream/internals/KStreamWindowAggregate.java:237` calls `SuppressWarnings` and `streams/src/main/java/org/apache/kafka/streams/kstream/internals/KStreamSessionWindowAggregate.java:424` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (8 lines × 3) tools/src/main/java/org/apache/kafka/tools/consumer/group/ConsumerGroupCommand.java:1015 — tools/src/main/java/org/apache/kafka/tools/consumer/group/ConsumerGroupCommand.java:1015-1022 | tools/src/main/java/org/apache/kafka/tools/consumer/group/ShareGroupCommand.java:281-288 | tools/src/main/java/org/apache/kafka/tools/streams/StreamsGroupCommand.java:376-383 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. Read the line range as the matched WINDOW rather than a finished unit: at `tools/src/main/java/org/apache/kafka/tools/consumer/group/ConsumerGroupCommand.java:1015` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (8 lines × 3) clients/src/main/java/org/apache/kafka/common/utils/internals/ByteUtils.java:521 — clients/src/main/java/org/apache/kafka/common/utils/internals/ByteUtils.java:521-528 | jmh-benchmarks/src/main/java/org/apache/kafka/jmh/util/ByteUtilsBenchmark.java:478-485 | jmh-benchmarks/src/main/java/org/apache/kafka/jmh/util/ByteUtilsBenchmark.java:490-497 — there are 3 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 3 sites; resolving a subset leaves the remainder to drift apart.
  • Duplicated block (8 lines × 3) generator/src/main/java/org/apache/kafka/message/ApiMessageTypeGenerator.java:337 — generator/src/main/java/org/apache/kafka/message/ApiMessageTypeGenerator.java:337-344 | generator/src/main/java/org/apache/kafka/message/CoordinatorRecordTypeGenerator.java:245-252 | generator/src/main/java/org/apache/kafka/message/MetadataRecordTypeGenerator.java:177-184 — before extracting anything, compare `generator/src/main/java/org/apache/kafka/message/ApiMessageTypeGenerator.java` and `generator/src/main/java/org/apache/kafka/message/MetadataRecordTypeGenerator.java` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 33 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (8 lines × 3) streams/src/main/java/org/apache/kafka/streams/state/internals/InMemoryKeyValueStore.java:399 — streams/src/main/java/org/apache/kafka/streams/state/internals/InMemoryKeyValueStore.java:399-406 | streams/src/main/java/org/apache/kafka/streams/state/internals/InMemorySessionStore.java:594-601 | streams/src/main/java/org/apache/kafka/streams/state/internals/InMemoryWindowStore.java:595-602 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 3 call sites, so a change lands once. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `streams/src/main/java/org/apache/kafka/streams/state/internals/InMemoryKeyValueStore.java:396` calls `commitStagedWrites` and `streams/src/main/java/org/apache/kafka/streams/state/internals/InMemorySessionStore.java:594` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (8 lines × 3) jmh-benchmarks/src/main/java/org/apache/kafka/jmh/cache/LRUCacheBenchmark.java:77 — jmh-benchmarks/src/main/java/org/apache/kafka/jmh/cache/LRUCacheBenchmark.java:77-84 | jmh-benchmarks/src/main/java/org/apache/kafka/jmh/coordinator/GroupCoordinatorShardLoadingBenchmark.java:350-357 | jmh-benchmarks/src/main/java/org/apache/kafka/jmh/util/ByteUtilsBenchmark.java:286-293 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times.
D4 · Code Duplication · Members sharing a duplicated core (5 members, 50+ identical tokens) · ×9
  • Members sharing a duplicated core (5 members, 50+ identical tokens) clients/src/main/java/org/apache/kafka/clients/admin/DescribeClassicGroupsResult.java:50 — clients/src/main/java/org/apache/kafka/clients/admin/DescribeClassicGroupsResult.java:50-65 | clients/src/main/java/org/apache/kafka/clients/admin/DescribeConsumerGroupsResult.java:50-65 | clients/src/main/java/org/apache/kafka/clients/admin/DescribeShareGroupsResult.java:50-65 | clients/src/main/java/org/apache/kafka/clients/admin/DescribeStreamsGroupsResult.java:54-69 | clients/src/main/java/org/apache/kafka/clients/admin/ListConsumerGroupOffsetsResult.java:74-89 — These 5 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 5 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 5 times.
  • Members sharing a duplicated core (5 members, 50+ identical tokens) raft/src/main/java/org/apache/kafka/raft/KafkaRaftClient.java:956 — raft/src/main/java/org/apache/kafka/raft/KafkaRaftClient.java:956-1033 | raft/src/main/java/org/apache/kafka/raft/KafkaRaftClient.java:1173-1229 | raft/src/main/java/org/apache/kafka/raft/KafkaRaftClient.java:1350-1400 | raft/src/main/java/org/apache/kafka/raft/KafkaRaftClient.java:1696-1825 | raft/src/main/java/org/apache/kafka/raft/KafkaRaftClient.java:2563-2605 — These 5 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 5 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 5 times.
  • Members sharing a duplicated core (5 members, 50+ identical tokens) share-coordinator/src/main/java/org/apache/kafka/coordinator/share/ShareCoordinatorShard.java:756 — share-coordinator/src/main/java/org/apache/kafka/coordinator/share/ShareCoordinatorShard.java:756-809 | share-coordinator/src/main/java/org/apache/kafka/coordinator/share/ShareCoordinatorShard.java:811-865 | share-coordinator/src/main/java/org/apache/kafka/coordinator/share/ShareCoordinatorShard.java:867-900 | share-coordinator/src/main/java/org/apache/kafka/coordinator/share/ShareCoordinatorShard.java:904-933 | share-coordinator/src/main/java/org/apache/kafka/coordinator/share/ShareCoordinatorShard.java:939-975 — These 5 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 5 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 5 times.
  • Members sharing a duplicated core (5 members, 50+ identical tokens) streams/src/main/java/org/apache/kafka/streams/kstream/internals/KTableFilter.java:123 — streams/src/main/java/org/apache/kafka/streams/kstream/internals/KTableFilter.java:123-133 | streams/src/main/java/org/apache/kafka/streams/kstream/internals/KTableKTableJoinMerger.java:122-132 | streams/src/main/java/org/apache/kafka/streams/kstream/internals/KTableMapValues.java:136-146 | streams/src/main/java/org/apache/kafka/streams/kstream/internals/KTableSource.java:106-119 | streams/src/main/java/org/apache/kafka/streams/kstream/internals/KTableTransformValues.java:103-115 — These 5 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 5 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 5 times.
  • Members sharing a duplicated core (5 members, 50+ identical tokens) streams/src/main/java/org/apache/kafka/streams/state/internals/CompositeReadOnlyKeyValueStore.java:86 — streams/src/main/java/org/apache/kafka/streams/state/internals/CompositeReadOnlyKeyValueStore.java:86-101 | streams/src/main/java/org/apache/kafka/streams/state/internals/CompositeReadOnlyKeyValueStore.java:104-119 | streams/src/main/java/org/apache/kafka/streams/state/internals/CompositeReadOnlyKeyValueStore.java:122-139 | streams/src/main/java/org/apache/kafka/streams/state/internals/CompositeReadOnlyKeyValueStore.java:142-157 | streams/src/main/java/org/apache/kafka/streams/state/internals/CompositeReadOnlyKeyValueStore.java:160-175 — These 5 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 5 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 5 times.
  • Members sharing a duplicated core (5 members, 50+ identical tokens) streams/src/main/java/org/apache/kafka/streams/state/internals/CompositeReadOnlySessionStore.java:73 — streams/src/main/java/org/apache/kafka/streams/state/internals/CompositeReadOnlySessionStore.java:73-96 | streams/src/main/java/org/apache/kafka/streams/state/internals/CompositeReadOnlySessionStore.java:101-122 | streams/src/main/java/org/apache/kafka/streams/state/internals/CompositeReadOnlySessionStore.java:128-149 | streams/src/main/java/org/apache/kafka/streams/state/internals/CompositeReadOnlySessionStore.java:155-176 | streams/src/main/java/org/apache/kafka/streams/state/internals/CompositeReadOnlySessionStore.java:220-241 — These 5 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 5 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 5 times.
  • Members sharing a duplicated core (5 members, 50+ identical tokens) streams/src/main/java/org/apache/kafka/streams/state/internals/PlainToHeadersStoreAdapter.java:147 — streams/src/main/java/org/apache/kafka/streams/state/internals/PlainToHeadersStoreAdapter.java:147-187 | streams/src/main/java/org/apache/kafka/streams/state/internals/PlainToHeadersWindowStoreAdapter.java:171-212 | streams/src/main/java/org/apache/kafka/streams/state/internals/SessionToHeadersStoreAdapter.java:200-220 | streams/src/main/java/org/apache/kafka/streams/state/internals/TimestampedToHeadersStoreAdapter.java:149-189 | streams/src/main/java/org/apache/kafka/streams/state/internals/TimestampedToHeadersWindowStoreAdapter.java:217-258 — These 5 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 5 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 5 times.
  • Members sharing a duplicated core (5 members, 50+ identical tokens) streams/src/main/java/org/apache/kafka/streams/state/internals/RocksDBMigratingSessionStoreWithHeaders.java:59 — streams/src/main/java/org/apache/kafka/streams/state/internals/RocksDBMigratingSessionStoreWithHeaders.java:59-93 | streams/src/main/java/org/apache/kafka/streams/state/internals/RocksDBMigratingWindowStoreWithHeaders.java:66-101 | streams/src/main/java/org/apache/kafka/streams/state/internals/RocksDBTimestampedStore.java:55-89 | streams/src/main/java/org/apache/kafka/streams/state/internals/RocksDBTimestampedStoreWithHeaders.java:91-128 | streams/src/main/java/org/apache/kafka/streams/state/internals/RocksDBTimestampedStoreWithHeaders.java:131-191 — These 5 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 5 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 5 times.
  • Members sharing a duplicated core (5 members, 50+ identical tokens) tools/src/main/java/org/apache/kafka/tools/ClusterTool.java:57 — tools/src/main/java/org/apache/kafka/tools/ClusterTool.java:57-69 | tools/src/main/java/org/apache/kafka/tools/DelegationTokenCommand.java:54-66 | tools/src/main/java/org/apache/kafka/tools/EndToEndLatency.java:74-86 | tools/src/main/java/org/apache/kafka/tools/LogDirsCommand.java:54-66 | tools/src/main/java/org/apache/kafka/tools/MetadataQuorumCommand.java:81-98 — These 5 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 5 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 5 times.
D15 · Churn × Complexity Hotspots · Hotspot · ×8
  • Hotspot: group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java:2113 — group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java changed 21 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 43 in GroupMetadataManager.streamsGroupHeartbeat at line 2113. 2 of those changes were fix/bug commits, and the other 19 changed it for other reasons — this file is under both repair and feature pressure. Before the next change lands here, make sure the area it touches is under test, then split that area out of the file so the following change is smaller than this one — a file this often edited pays the complexity back every time. Counted over 2026-07-25..2026-10-23, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-25 11:39:11 +09:00' --until='2026-10-23 11:39:11 +09:00' --full-history --no-merges -- group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Hotspot: core/src/main/scala/kafka/server/KafkaConfig.scala core/src/main/scala/kafka/server/KafkaConfig.scala:299 — core/src/main/scala/kafka/server/KafkaConfig.scala changed 8 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 22 in KafkaConfig.validateValues at line 299. Frequent change and high complexity in one file compound: schedule the next change to it to include carving out the part being edited, with the area under test before it moves. Counted over 2026-07-25..2026-10-23, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-25 11:39:11 +09:00' --until='2026-10-23 11:39:11 +09:00' --full-history --no-merges -- core/src/main/scala/kafka/server/KafkaConfig.scala`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Hotspot: streams/src/main/java/org/apache/kafka/streams/processor/internals/StoreChangelogReader.java streams/src/main/java/org/apache/kafka/streams/processor/internals/StoreChangelogReader.java:1098 — streams/src/main/java/org/apache/kafka/streams/processor/internals/StoreChangelogReader.java changed 9 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 16 in StoreChangelogReader.prepareChangelogs at line 1098. Frequent change and high complexity in one file compound: schedule the next change to it to include carving out the part being edited, with the area under test before it moves. Counted over 2026-07-25..2026-10-23, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-25 11:39:11 +09:00' --until='2026-10-23 11:39:11 +09:00' --full-history --no-merges -- streams/src/main/java/org/apache/kafka/streams/processor/internals/StoreChangelogReader.java`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Hotspot: core/src/main/scala/kafka/coordinator/transaction/TransactionCoordinator.scala core/src/main/scala/kafka/coordinator/transaction/TransactionCoordinator.scala:773 — core/src/main/scala/kafka/coordinator/transaction/TransactionCoordinator.scala changed 2 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 65 in TransactionCoordinator.endTransaction at line 773. Frequent change and high complexity in one file compound: schedule the next change to it to include carving out the part being edited, with the area under test before it moves. Counted over 2026-07-25..2026-10-23, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-25 11:39:11 +09:00' --until='2026-10-23 11:39:11 +09:00' --full-history --no-merges -- core/src/main/scala/kafka/coordinator/transaction/TransactionCoordinator.scala`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Hotspot: storage/src/main/java/org/apache/kafka/storage/internals/log/UnifiedLog.java storage/src/main/java/org/apache/kafka/storage/internals/log/UnifiedLog.java:1128 — storage/src/main/java/org/apache/kafka/storage/internals/log/UnifiedLog.java changed 6 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 19 in UnifiedLog.append at line 1128. 2 of those changes were fix/bug commits, and the other 4 changed it for other reasons — this file is under both repair and feature pressure. Before the next change lands here, make sure the area it touches is under test, then split that area out of the file so the following change is smaller than this one — a file this often edited pays the complexity back every time. Counted over 2026-07-25..2026-10-23, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-25 11:39:11 +09:00' --until='2026-10-23 11:39:11 +09:00' --full-history --no-merges -- storage/src/main/java/org/apache/kafka/storage/internals/log/UnifiedLog.java`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Hotspot: clients/src/main/java/org/apache/kafka/clients/consumer/internals/ShareConsumeRequestManager.java clients/src/main/java/org/apache/kafka/clients/consumer/internals/ShareConsumeRequestManager.java:150 — clients/src/main/java/org/apache/kafka/clients/consumer/internals/ShareConsumeRequestManager.java changed 3 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 30 in ShareConsumeRequestManager.poll at line 150. Frequent change and high complexity in one file compound: schedule the next change to it to include carving out the part being edited, with the area under test before it moves. Counted over 2026-07-25..2026-10-23, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-25 11:39:11 +09:00' --until='2026-10-23 11:39:11 +09:00' --full-history --no-merges -- clients/src/main/java/org/apache/kafka/clients/consumer/internals/ShareConsumeRequestManager.java`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Hotspot: core/src/main/scala/kafka/server/ConfigHelper.scala core/src/main/scala/kafka/server/ConfigHelper.scala:82 — core/src/main/scala/kafka/server/ConfigHelper.scala changed 3 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 19 in ConfigHelper.describeConfigs at line 82. Frequent change and high complexity in one file compound: schedule the next change to it to include carving out the part being edited, with the area under test before it moves. Counted over 2026-07-25..2026-10-23, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-25 11:39:11 +09:00' --until='2026-10-23 11:39:11 +09:00' --full-history --no-merges -- core/src/main/scala/kafka/server/ConfigHelper.scala`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Hotspot: clients/src/main/java/org/apache/kafka/clients/producer/internals/ChunkedRecordAccumulator.java clients/src/main/java/org/apache/kafka/clients/producer/internals/ChunkedRecordAccumulator.java:108 — clients/src/main/java/org/apache/kafka/clients/producer/internals/ChunkedRecordAccumulator.java changed 2 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 22 in ChunkedRecordAccumulator.append at line 108. 1 of those changes was a fix/bug commit, and the other 1 changed it for other reasons — this file is under both repair and feature pressure. Before the next change lands here, make sure the area it touches is under test, then split that area out of the file so the following change is smaller than this one — a file this often edited pays the complexity back every time. Counted over 2026-07-25..2026-10-23, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-25 11:39:11 +09:00' --until='2026-10-23 11:39:11 +09:00' --full-history --no-merges -- clients/src/main/java/org/apache/kafka/clients/producer/internals/ChunkedRecordAccumulator.java`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
X3 · Exception handling · Swallowed exception (caught, then discarded) · ×8
  • Swallowed exception (caught, then discarded) clients/src/main/java/org/apache/kafka/common/network/SaslChannelBuilder.java:158 — `catch (Exception)` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
  • Swallowed exception (caught, then discarded) clients/src/main/java/org/apache/kafka/common/security/kerberos/KerberosError.java:73 — `catch (Exception)` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
  • Swallowed exception (caught, then discarded) core/src/main/scala/kafka/server/DynamicBrokerConfig.scala:380 — `case _: Exception` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
  • Swallowed exception (caught, then discarded) metadata/src/main/java/org/apache/kafka/image/node/TopicsImageByIdNode.java:57 — `catch (Exception)` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
  • Swallowed exception (caught, then discarded) metadata/src/main/java/org/apache/kafka/image/node/AclsImageByIdNode.java:57 — `catch (Exception)` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
  • Swallowed exception (caught, then discarded) metadata/src/main/java/org/apache/kafka/metadata/authorizer/StandardAuthorizer.java:179 — `catch (Exception)` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
  • Swallowed exception (caught, then discarded) release/gpg.py:35 — `except Exception` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
  • Swallowed exception (caught, then discarded) tools/src/main/java/org/apache/kafka/tools/FeatureCommand.java:232 — `catch (Throwable)` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
D31 · IaC & Container Security · Medium IaC · ×6
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
D4 · Code Duplication · Duplicated block (21 lines × 2) · ×6
  • Duplicated block (21 lines × 2) clients/src/main/java/org/apache/kafka/clients/admin/KafkaAdminClient.java:3672 — clients/src/main/java/org/apache/kafka/clients/admin/KafkaAdminClient.java:3672-3692 | clients/src/main/java/org/apache/kafka/clients/admin/KafkaAdminClient.java:3830-3850 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `clients/src/main/java/org/apache/kafka/clients/admin/KafkaAdminClient.java:3672` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (21 lines × 2) clients/src/main/java/org/apache/kafka/clients/admin/KafkaAdminClient.java:4931 — clients/src/main/java/org/apache/kafka/clients/admin/KafkaAdminClient.java:4931-4951 | clients/src/main/java/org/apache/kafka/clients/admin/KafkaAdminClient.java:4973-4993 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `clients/src/main/java/org/apache/kafka/clients/admin/KafkaAdminClient.java:4931` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (21 lines × 2) clients/src/main/java/org/apache/kafka/clients/consumer/internals/AbstractMembershipManager.java:460 — clients/src/main/java/org/apache/kafka/clients/consumer/internals/AbstractMembershipManager.java:460-480 | clients/src/main/java/org/apache/kafka/clients/consumer/internals/StreamsMembershipManager.java:863-883 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `clients/src/main/java/org/apache/kafka/clients/consumer/internals/AbstractMembershipManager.java:460` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (21 lines × 2) streams/src/main/java/org/apache/kafka/streams/kstream/internals/SessionStoreMaterializer.java:80 — streams/src/main/java/org/apache/kafka/streams/kstream/internals/SessionStoreMaterializer.java:80-100 | streams/src/main/java/org/apache/kafka/streams/kstream/internals/SlidingWindowStoreMaterializer.java:83-103 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `streams/src/main/java/org/apache/kafka/streams/kstream/internals/SessionStoreMaterializer.java:80` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on. Note first that the copies are not typed on the same thing: the declarations holding them bind `materialized` to `MaterializedInternal<K, V, SessionStore<Bytes, byte[]>>` in one and `MaterializedInternal<K, V, WindowStore<Bytes, byte[]>>` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
  • Duplicated block (21 lines × 2) streams/src/main/java/org/apache/kafka/streams/processor/internals/TaskExecutor.java:104 — streams/src/main/java/org/apache/kafka/streams/processor/internals/TaskExecutor.java:104-124 | streams/src/main/java/org/apache/kafka/streams/processor/internals/tasks/DefaultTaskExecutor.java:165-185 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `streams/src/main/java/org/apache/kafka/streams/processor/internals/TaskExecutor.java:104` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (21 lines × 2) tools/src/main/java/org/apache/kafka/tools/ConsoleProducer.java:241 — tools/src/main/java/org/apache/kafka/tools/ConsoleProducer.java:241-261 | tools/src/main/java/org/apache/kafka/tools/consumer/ConsoleShareConsumerOptions.java:90-110 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `tools/src/main/java/org/apache/kafka/tools/ConsoleProducer.java:241` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
D4 · Code Duplication · Duplicated block (17 lines × 2) · ×6
  • Duplicated block (17 lines × 2) clients/src/main/java/org/apache/kafka/clients/consumer/internals/AsyncKafkaConsumer.java:554 — clients/src/main/java/org/apache/kafka/clients/consumer/internals/AsyncKafkaConsumer.java:554-570 | clients/src/main/java/org/apache/kafka/clients/consumer/internals/ShareConsumerImpl.java:316-333 — before extracting anything, compare `clients/src/main/java/org/apache/kafka/clients/consumer/internals/AsyncKafkaConsumer.java` and `clients/src/main/java/org/apache/kafka/clients/consumer/internals/ShareConsumerImpl.java` as WHOLE FILES: this scan already matched 13 separate duplicated blocks between them, totalling at least 131 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `clients/src/main/java/org/apache/kafka/clients/consumer/internals/AsyncKafkaConsumer.java:554` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (17 lines × 2) server/src/main/java/org/apache/kafka/server/KRaftTopicCreator.java:106 — server/src/main/java/org/apache/kafka/server/KRaftTopicCreator.java:106-122 | server/src/main/java/org/apache/kafka/server/KRaftTopicCreator.java:149-165 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `server/src/main/java/org/apache/kafka/server/KRaftTopicCreator.java:106` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (17 lines × 2) streams/src/main/java/org/apache/kafka/streams/processor/internals/StreamThread.java:1653 — streams/src/main/java/org/apache/kafka/streams/processor/internals/StreamThread.java:1653-1669 | streams/src/main/java/org/apache/kafka/streams/processor/internals/StreamsPartitionAssignor.java:1613-1629 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
  • Duplicated block (17 lines × 2) tools/src/main/java/org/apache/kafka/tools/ProducerPerformance.java:292 — tools/src/main/java/org/apache/kafka/tools/ProducerPerformance.java:292-308 | tools/src/main/java/org/apache/kafka/tools/ProducerPerformance.java:420-436 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `tools/src/main/java/org/apache/kafka/tools/ProducerPerformance.java:292` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (17 lines × 2) tools/src/main/java/org/apache/kafka/tools/VerifiableConsumer.java:270 — tools/src/main/java/org/apache/kafka/tools/VerifiableConsumer.java:270-286 | tools/src/main/java/org/apache/kafka/tools/VerifiableShareConsumer.java:549-565 — before extracting anything, compare `tools/src/main/java/org/apache/kafka/tools/VerifiableConsumer.java` and `tools/src/main/java/org/apache/kafka/tools/VerifiableShareConsumer.java` as WHOLE FILES: this scan already matched 9 separate duplicated blocks between them, totalling at least 130 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
  • Duplicated block (17 lines × 2) streams/src/main/java/org/apache/kafka/streams/state/internals/CachingSessionStore.java:511 — streams/src/main/java/org/apache/kafka/streams/state/internals/CachingSessionStore.java:511-527 | streams/src/main/java/org/apache/kafka/streams/state/internals/CachingWindowStore.java:528-544 — before extracting anything, compare `streams/src/main/java/org/apache/kafka/streams/state/internals/CachingSessionStore.java` and `streams/src/main/java/org/apache/kafka/streams/state/internals/CachingWindowStore.java` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 83 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (14–15 lines × 2) · ×6
  • Duplicated block (14–15 lines × 2) coordinator-common/src/main/java/org/apache/kafka/coordinator/common/runtime/CoordinatorRuntime.java:1333 — coordinator-common/src/main/java/org/apache/kafka/coordinator/common/runtime/CoordinatorRuntime.java:1333-1347 | coordinator-common/src/main/java/org/apache/kafka/coordinator/common/runtime/CoordinatorRuntime.java:1639-1652 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `coordinator-common/src/main/java/org/apache/kafka/coordinator/common/runtime/CoordinatorRuntime.java:1333` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (14–15 lines × 2) metadata/src/main/java/org/apache/kafka/controller/ActivationRecordsGenerator.java:47 — metadata/src/main/java/org/apache/kafka/controller/ActivationRecordsGenerator.java:47-60 | metadata/src/main/java/org/apache/kafka/controller/ActivationRecordsGenerator.java:120-134 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `metadata/src/main/java/org/apache/kafka/controller/ActivationRecordsGenerator.java:47` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (14–15 lines × 2) server/src/main/java/org/apache/kafka/server/BrokerLifecycleManager.java:531 — server/src/main/java/org/apache/kafka/server/BrokerLifecycleManager.java:531-544 | server/src/main/java/org/apache/kafka/server/BrokerLifecycleManager.java:622-636 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `server/src/main/java/org/apache/kafka/server/BrokerLifecycleManager.java:531` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `server/src/main/java/org/apache/kafka/server/BrokerLifecycleManager.java:619` calls `SuppressWarnings` and `server/src/main/java/org/apache/kafka/server/BrokerLifecycleManager.java:527` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (14–15 lines × 2) streams/src/main/java/org/apache/kafka/streams/processor/internals/GlobalStateManagerImpl.java:325 — streams/src/main/java/org/apache/kafka/streams/processor/internals/GlobalStateManagerImpl.java:325-338 | streams/src/main/java/org/apache/kafka/streams/processor/internals/GlobalStateManagerImpl.java:467-481 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `streams/src/main/java/org/apache/kafka/streams/processor/internals/GlobalStateManagerImpl.java:325` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `streams/src/main/java/org/apache/kafka/streams/processor/internals/GlobalStateManagerImpl.java:483` calls `adapt` and `streams/src/main/java/org/apache/kafka/streams/processor/internals/GlobalStateManagerImpl.java:339` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (14–15 lines × 2) streams/src/main/java/org/apache/kafka/streams/processor/internals/TaskManager.java:1669 — streams/src/main/java/org/apache/kafka/streams/processor/internals/TaskManager.java:1669-1683 | streams/src/main/java/org/apache/kafka/streams/processor/internals/TaskManager.java:1699-1712 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `streams/src/main/java/org/apache/kafka/streams/processor/internals/TaskManager.java:1669` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `streams/src/main/java/org/apache/kafka/streams/processor/internals/TaskManager.java:1697` calls `prepareCommit`, `postCommit` and `streams/src/main/java/org/apache/kafka/streams/processor/internals/TaskManager.java:1668` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (14–15 lines × 2) streams/src/main/java/org/apache/kafka/streams/state/internals/Utils.java:60 — streams/src/main/java/org/apache/kafka/streams/state/internals/Utils.java:60-74 | streams/src/main/java/org/apache/kafka/streams/state/internals/Utils.java:202-215 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
D4 · Code Duplication · Duplicated block (11 lines × 3) · ×6
  • Duplicated block (11 lines × 3) group-coordinator/src/main/java/org/apache/kafka/coordinator/group/modern/consumer/CurrentAssignmentBuilder.java:412 — group-coordinator/src/main/java/org/apache/kafka/coordinator/group/modern/consumer/CurrentAssignmentBuilder.java:412-422 | group-coordinator/src/main/java/org/apache/kafka/coordinator/group/streams/CurrentAssignmentBuilder.java:290-300 | group-coordinator/src/main/java/org/apache/kafka/coordinator/group/streams/CurrentAssignmentBuilder.java:385-395 — there are 3 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 3 sites; resolving a subset leaves the remainder to drift apart.
  • Duplicated block (11 lines × 3) raft/src/main/java/org/apache/kafka/raft/KafkaRaftClient.java:977 — raft/src/main/java/org/apache/kafka/raft/KafkaRaftClient.java:977-987 | raft/src/main/java/org/apache/kafka/raft/KafkaRaftClient.java:1186-1196 | raft/src/main/java/org/apache/kafka/raft/KafkaRaftClient.java:1362-1372 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `raft/src/main/java/org/apache/kafka/raft/KafkaRaftClient.java:977` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (11 lines × 3) streams/src/main/java/org/apache/kafka/streams/kstream/internals/SessionWindowedKStreamImpl.java:106 — streams/src/main/java/org/apache/kafka/streams/kstream/internals/SessionWindowedKStreamImpl.java:106-116 | streams/src/main/java/org/apache/kafka/streams/kstream/internals/SessionWindowedKStreamImpl.java:160-170 | streams/src/main/java/org/apache/kafka/streams/kstream/internals/SessionWindowedKStreamImpl.java:230-240 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `streams/src/main/java/org/apache/kafka/streams/kstream/internals/SessionWindowedKStreamImpl.java:106` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (11 lines × 3) streams/src/main/java/org/apache/kafka/streams/kstream/internals/KGroupedStreamImpl.java:166 — streams/src/main/java/org/apache/kafka/streams/kstream/internals/KGroupedStreamImpl.java:166-176 | streams/src/main/java/org/apache/kafka/streams/kstream/internals/SessionWindowedKStreamImpl.java:81-91 | streams/src/main/java/org/apache/kafka/streams/kstream/internals/TimeWindowedKStreamImpl.java:81-91 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 3 call sites, so a change lands once. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. Note first that the copies are not typed on the same thing: the declarations holding them bind `materialized` to `Materialized<K, Long, KeyValueStore<Bytes, byte[]>>` in one and `Materialized<K, Long, SessionStore<Bytes, byte[]>>` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
  • Duplicated block (11 lines × 3) streams/src/main/java/org/apache/kafka/streams/kstream/internals/KTableFilter.java:81 — streams/src/main/java/org/apache/kafka/streams/kstream/internals/KTableFilter.java:81-91 | streams/src/main/java/org/apache/kafka/streams/kstream/internals/KTableMapValues.java:91-102 | streams/src/main/java/org/apache/kafka/streams/kstream/internals/KTableTransformValues.java:81-91 — before extracting anything, compare `streams/src/main/java/org/apache/kafka/streams/kstream/internals/KTableFilter.java` and `streams/src/main/java/org/apache/kafka/streams/kstream/internals/KTableMapValues.java` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 42 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (11 lines × 3) streams/src/main/java/org/apache/kafka/streams/state/internals/AbstractMeteredIterator.java:92 — streams/src/main/java/org/apache/kafka/streams/state/internals/AbstractMeteredIterator.java:92-102 | streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredWindowStoreIterator.java:77-87 | streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredWindowedKeyValueIterator.java:87-97 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 3 call sites, so a change lands once.
D4 · Code Duplication · Duplicated block (8 lines × 4) · ×6
  • Duplicated block (8 lines × 4) clients/src/main/java/org/apache/kafka/clients/admin/KafkaAdminClient.java:2037 — clients/src/main/java/org/apache/kafka/clients/admin/KafkaAdminClient.java:2037-2044 | clients/src/main/java/org/apache/kafka/clients/admin/KafkaAdminClient.java:2062-2069 | clients/src/main/java/org/apache/kafka/clients/admin/KafkaAdminClient.java:2447-2454 | clients/src/main/java/org/apache/kafka/clients/admin/KafkaAdminClient.java:2487-2494 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `clients/src/main/java/org/apache/kafka/clients/admin/KafkaAdminClient.java:2037` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (8 lines × 4) generator/src/main/java/org/apache/kafka/message/CoordinatorRecordJsonConvertersGenerator.java:103 — generator/src/main/java/org/apache/kafka/message/CoordinatorRecordJsonConvertersGenerator.java:103-110 | generator/src/main/java/org/apache/kafka/message/CoordinatorRecordJsonConvertersGenerator.java:130-137 | generator/src/main/java/org/apache/kafka/message/CoordinatorRecordJsonConvertersGenerator.java:157-164 | generator/src/main/java/org/apache/kafka/message/CoordinatorRecordJsonConvertersGenerator.java:184-191 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `generator/src/main/java/org/apache/kafka/message/CoordinatorRecordJsonConvertersGenerator.java:103` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (8 lines × 4) streams/src/main/java/org/apache/kafka/streams/kstream/internals/KStreamAggregate.java:137 — streams/src/main/java/org/apache/kafka/streams/kstream/internals/KStreamAggregate.java:137-144 | streams/src/main/java/org/apache/kafka/streams/kstream/internals/KStreamReduce.java:132-139 | streams/src/main/java/org/apache/kafka/streams/kstream/internals/KTableAggregate.java:136-143 | streams/src/main/java/org/apache/kafka/streams/kstream/internals/KTableReduce.java:128-135 — before extracting anything, compare `streams/src/main/java/org/apache/kafka/streams/kstream/internals/KStreamAggregate.java` and `streams/src/main/java/org/apache/kafka/streams/kstream/internals/KStreamReduce.java` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 50 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `streams/src/main/java/org/apache/kafka/streams/kstream/internals/KStreamAggregate.java:137` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note first that the copies are not typed on the same thing: the declarations holding them bind `record` to `Record<KIn, VIn>` in one and `Record<K, V>` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `streams/src/main/java/org/apache/kafka/streams/kstream/internals/KStreamAggregate.java:135` calls `apply`, `key`, `value` and `streams/src/main/java/org/apache/kafka/streams/kstream/internals/KStreamReduce.java:130` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (8 lines × 4) streams/src/main/java/org/apache/kafka/streams/state/internals/InMemorySessionTransactionBuffer.java:232 — streams/src/main/java/org/apache/kafka/streams/state/internals/InMemorySessionTransactionBuffer.java:232-239 | streams/src/main/java/org/apache/kafka/streams/state/internals/InMemoryTransactionBuffer.java:136-143 | streams/src/main/java/org/apache/kafka/streams/state/internals/InMemoryWindowTransactionBuffer.java:210-217 | streams/src/main/java/org/apache/kafka/streams/state/internals/RocksDBTransactionBuffer.java:308-315 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 4 call sites, so a change lands once.
  • Duplicated block (8 lines × 4) streams/src/main/java/org/apache/kafka/streams/state/internals/InMemorySessionTransactionBuffer.java:241 — streams/src/main/java/org/apache/kafka/streams/state/internals/InMemorySessionTransactionBuffer.java:241-248 | streams/src/main/java/org/apache/kafka/streams/state/internals/InMemoryTransactionBuffer.java:145-152 | streams/src/main/java/org/apache/kafka/streams/state/internals/InMemoryWindowTransactionBuffer.java:219-226 | streams/src/main/java/org/apache/kafka/streams/state/internals/RocksDBTransactionBuffer.java:317-324 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 4 call sites, so a change lands once.
  • Duplicated block (8 lines × 4) streams/src/main/java/org/apache/kafka/streams/state/internals/CompositeReadOnlySessionStore.java:244 — streams/src/main/java/org/apache/kafka/streams/state/internals/CompositeReadOnlySessionStore.java:244-251 | streams/src/main/java/org/apache/kafka/streams/state/internals/CompositeReadOnlySessionStore.java:254-264 | streams/src/main/java/org/apache/kafka/streams/state/internals/CompositeReadOnlyWindowStore.java:190-198 | streams/src/main/java/org/apache/kafka/streams/state/internals/CompositeReadOnlyWindowStore.java:202-210 — there are 4 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 4 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `streams/src/main/java/org/apache/kafka/streams/state/internals/CompositeReadOnlyWindowStore.java:190` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
D4 · Code Duplication · Duplicated block (7 lines × 4) · ×6
  • Duplicated block (7 lines × 4) clients/src/main/java/org/apache/kafka/clients/admin/KafkaAdminClient.java:1946 — clients/src/main/java/org/apache/kafka/clients/admin/KafkaAdminClient.java:1946-1952 | clients/src/main/java/org/apache/kafka/clients/admin/KafkaAdminClient.java:2107-2113 | clients/src/main/java/org/apache/kafka/clients/admin/KafkaAdminClient.java:2180-2186 | clients/src/main/java/org/apache/kafka/clients/admin/KafkaAdminClient.java:3339-3345 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `clients/src/main/java/org/apache/kafka/clients/admin/KafkaAdminClient.java:1946` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (7 lines × 4) clients/src/main/java/org/apache/kafka/clients/consumer/internals/AsyncKafkaConsumer.java:890 — clients/src/main/java/org/apache/kafka/clients/consumer/internals/AsyncKafkaConsumer.java:890-896 | clients/src/main/java/org/apache/kafka/clients/consumer/internals/ClassicKafkaConsumer.java:445-451 | clients/src/main/java/org/apache/kafka/clients/consumer/internals/ShareConsumerImpl.java:967-973 | clients/src/main/java/org/apache/kafka/clients/producer/KafkaProducer.java:1500-1506 — before extracting anything, compare `clients/src/main/java/org/apache/kafka/clients/consumer/internals/AsyncKafkaConsumer.java` and `clients/src/main/java/org/apache/kafka/clients/consumer/internals/ClassicKafkaConsumer.java` as WHOLE FILES: this scan already matched 11 separate duplicated blocks between them, totalling at least 102 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (7 lines × 4) clients/src/main/java/org/apache/kafka/clients/consumer/internals/AsyncKafkaConsumer.java:899 — clients/src/main/java/org/apache/kafka/clients/consumer/internals/AsyncKafkaConsumer.java:899-905 | clients/src/main/java/org/apache/kafka/clients/consumer/internals/ClassicKafkaConsumer.java:454-460 | clients/src/main/java/org/apache/kafka/clients/consumer/internals/ShareConsumerImpl.java:979-985 | clients/src/main/java/org/apache/kafka/clients/producer/KafkaProducer.java:1518-1524 — before extracting anything, compare `clients/src/main/java/org/apache/kafka/clients/consumer/internals/AsyncKafkaConsumer.java` and `clients/src/main/java/org/apache/kafka/clients/consumer/internals/ClassicKafkaConsumer.java` as WHOLE FILES: this scan already matched 11 separate duplicated blocks between them, totalling at least 102 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (7 lines × 4) streams/src/main/java/org/apache/kafka/streams/state/internals/CachingKeyValueStore.java:444 — streams/src/main/java/org/apache/kafka/streams/state/internals/CachingKeyValueStore.java:444-450 | streams/src/main/java/org/apache/kafka/streams/state/internals/CachingSessionStore.java:77-83 | streams/src/main/java/org/apache/kafka/streams/state/internals/CachingWindowStore.java:365-371 | streams/src/main/java/org/apache/kafka/streams/state/internals/TimeOrderedCachingWindowStore.java:516-522 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 4 call sites, so a change lands once. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (7 lines × 4) metadata/src/main/java/org/apache/kafka/image/ClientQuotaDelta.java:41 — metadata/src/main/java/org/apache/kafka/image/ClientQuotaDelta.java:41-48 | metadata/src/main/java/org/apache/kafka/image/ConfigurationDelta.java:44-50 | metadata/src/main/java/org/apache/kafka/image/DelegationTokenDelta.java:44-52 | metadata/src/main/java/org/apache/kafka/image/FeaturesDelta.java:52-58 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 4 call sites, so a change lands once.
  • Duplicated block (7 lines × 4) streams/src/main/java/org/apache/kafka/streams/state/SessionStore.java:84 — streams/src/main/java/org/apache/kafka/streams/state/SessionStore.java:84-92 | streams/src/main/java/org/apache/kafka/streams/state/SessionStore.java:97-105 | streams/src/main/java/org/apache/kafka/streams/state/WindowStore.java:139-145 | streams/src/main/java/org/apache/kafka/streams/state/WindowStore.java:158-164 — there are 4 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 4 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `streams/src/main/java/org/apache/kafka/streams/state/SessionStore.java:84` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
P7 · Outbound HTTP resilience · Outbound HTTP without resilience · ×6
  • Outbound HTTP without resilience REDACTED:82 — `urllib.request.urlopen(` makes an outbound HTTP call, and nothing bounds it: no timeout, deadline, retry or circuit breaker is set for it here, and the client has no process-wide default. A slow or failing dependency will hold this service's request, thread or connection until the call gives up on its own — or never, for a client with no default timeout.
  • Outbound HTTP without resilience connect/runtime/src/main/java/org/apache/kafka/connect/runtime/rest/RestClient.java:75 — `HttpClient(` makes an outbound HTTP call, and nothing bounds it: no timeout, deadline, retry or circuit breaker is set for it here, and the client has no process-wide default. A slow or failing dependency will hold this service's request, thread or connection until the call gives up on its own — or never, for a client with no default timeout.
  • Outbound HTTP without resilience connect/runtime/src/main/java/org/apache/kafka/connect/runtime/rest/RestClient.java:77 — `HttpClient(` makes an outbound HTTP call, and nothing bounds it: no timeout, deadline, retry or circuit breaker is set for it here, and the client has no process-wide default. A slow or failing dependency will hold this service's request, thread or connection until the call gives up on its own — or never, for a client with no default timeout.
  • Outbound HTTP without resilience tools/src/main/java/org/apache/kafka/tools/ManifestWorkspace.java:551 — `.openConnection(` makes an outbound HTTP call, and nothing bounds it: no timeout, deadline, retry or circuit breaker is set for it here, and the client has no process-wide default. A slow or failing dependency will hold this service's request, thread or connection until the call gives up on its own — or never, for a client with no default timeout.
  • Outbound HTTP without resilience tools/src/main/java/org/apache/kafka/tools/PushHttpMetricsReporter.java:233 — `.openConnection(` makes an outbound HTTP call, and nothing bounds it: no timeout, deadline, retry or circuit breaker is set for it here, and the client has no process-wide default. A slow or failing dependency will hold this service's request, thread or connection until the call gives up on its own — or never, for a client with no default timeout.
  • Outbound HTTP without resilience trogdor/src/main/java/org/apache/kafka/trogdor/rest/JsonRestServer.java:183 — `.openConnection(` makes an outbound HTTP call, and nothing bounds it: no timeout, deadline, retry or circuit breaker is set for it here, and the client has no process-wide default. A slow or failing dependency will hold this service's request, thread or connection until the call gives up on its own — or never, for a client with no default timeout.
D17 · Explicit Debt · FixmeComment · ×5
  • FixmeComment connect/runtime/src/main/java/org/apache/kafka/connect/runtime/WorkerSinkTask.java:181 — // FIXME Kafka needs to add a timeout parameter here for us to properly obey the timeout — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `// REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • FixmeComment connect/runtime/src/main/java/org/apache/kafka/connect/runtime/distributed/DistributedHerder.java:572 — // FIXME should not be WakeupException — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `// REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • FixmeComment connect/runtime/src/test/java/org/apache/kafka/connect/runtime/distributed/DistributedHerderTest.java:3761 — // FIXME: if we have inconsistent configs, we need to request forced reconfig + write of the connector's task configs — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `// REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • FixmeComment storage/src/test/java/org/apache/kafka/server/log/remote/storage/LocalTieredStorageTest.java:142 — //FIXME: Fetch at arbitrary index does not work as proper support for records need to be added. — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `// REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • FixmeComment tests/kafkatest/benchmarks/core/benchmark_test.py:139 — # FIXME we should be generating a graph too — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `# REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
D36 · Supply-chain Provenance & Signing · REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
D4 · Code Duplication · Duplicated block (13 lines × 3) · ×5
  • Duplicated block (13 lines × 3) clients/src/main/java/org/apache/kafka/clients/consumer/internals/StreamsMembershipManager.java:1420 — clients/src/main/java/org/apache/kafka/clients/consumer/internals/StreamsMembershipManager.java:1420-1432 | clients/src/main/java/org/apache/kafka/clients/consumer/internals/StreamsMembershipManager.java:1441-1453 | clients/src/main/java/org/apache/kafka/clients/consumer/internals/StreamsMembershipManager.java:1462-1474 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit. Note first that the copies are not typed on the same thing: the declarations holding them bind `event` to `StreamsOnTasksRevokedCallbackCompletedEvent` in one and `StreamsOnTasksAssignedCallbackCompletedEvent` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
  • Duplicated block (13 lines × 3) jmh-benchmarks/src/main/java/org/apache/kafka/jmh/fetcher/ReplicaFetcherThreadBenchmark.java:132 — jmh-benchmarks/src/main/java/org/apache/kafka/jmh/fetcher/ReplicaFetcherThreadBenchmark.java:132-144 | jmh-benchmarks/src/main/java/org/apache/kafka/jmh/partition/PartitionMakeFollowerBenchmark.java:104-116 | jmh-benchmarks/src/main/java/org/apache/kafka/jmh/partition/UpdateFollowerFetchStateBenchmark.java:95-107 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times.
  • Duplicated block (13 lines × 3) streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredSessionStore.java:491 — streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredSessionStore.java:491-503 | streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredWindowStore.java:501-513 | streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredWindowStore.java:552-564 — before extracting anything, compare `streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredSessionStore.java` and `streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredWindowStore.java` as WHOLE FILES: this scan already matched 11 separate duplicated blocks between them, totalling at least 156 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredSessionStore.java:491` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (13 lines × 3) clients/src/main/java/org/apache/kafka/clients/consumer/internals/AsyncKafkaConsumer.java:2211 — clients/src/main/java/org/apache/kafka/clients/consumer/internals/AsyncKafkaConsumer.java:2211-2224 | clients/src/main/java/org/apache/kafka/clients/consumer/internals/ClassicKafkaConsumer.java:1252-1264 | clients/src/main/java/org/apache/kafka/clients/consumer/internals/ShareConsumerImpl.java:1123-1135 — before extracting anything, compare `clients/src/main/java/org/apache/kafka/clients/consumer/internals/AsyncKafkaConsumer.java` and `clients/src/main/java/org/apache/kafka/clients/consumer/internals/ClassicKafkaConsumer.java` as WHOLE FILES: this scan already matched 11 separate duplicated blocks between them, totalling at least 102 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (13 lines × 3) streams/src/main/java/org/apache/kafka/streams/state/internals/InMemoryKeyValueStore.java:131 — streams/src/main/java/org/apache/kafka/streams/state/internals/InMemoryKeyValueStore.java:131-143 | streams/src/main/java/org/apache/kafka/streams/state/internals/InMemorySessionStore.java:183-195 | streams/src/main/java/org/apache/kafka/streams/state/internals/InMemoryWindowStore.java:177-189 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 3 call sites, so a change lands once. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (12–13 lines × 2) · ×5
  • Duplicated block (12–13 lines × 2) clients/src/main/java/org/apache/kafka/clients/consumer/internals/AsyncKafkaConsumer.java:1645 — clients/src/main/java/org/apache/kafka/clients/consumer/internals/AsyncKafkaConsumer.java:1645-1657 | clients/src/main/java/org/apache/kafka/clients/consumer/internals/ShareConsumerImpl.java:1016-1027 — before extracting anything, compare `clients/src/main/java/org/apache/kafka/clients/consumer/internals/AsyncKafkaConsumer.java` and `clients/src/main/java/org/apache/kafka/clients/consumer/internals/ShareConsumerImpl.java` as WHOLE FILES: this scan already matched 13 separate duplicated blocks between them, totalling at least 131 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `clients/src/main/java/org/apache/kafka/clients/consumer/internals/AsyncKafkaConsumer.java:1645` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (12–13 lines × 2) streams/src/main/java/org/apache/kafka/streams/kstream/internals/KStreamAggregate.java:88 — streams/src/main/java/org/apache/kafka/streams/kstream/internals/KStreamAggregate.java:88-99 | streams/src/main/java/org/apache/kafka/streams/kstream/internals/KStreamReduce.java:84-96 — before extracting anything, compare `streams/src/main/java/org/apache/kafka/streams/kstream/internals/KStreamAggregate.java` and `streams/src/main/java/org/apache/kafka/streams/kstream/internals/KStreamReduce.java` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 50 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit. Note first that the copies are not typed on the same thing: the declarations holding them bind `context` to `ProcessorContext<KIn, Change<VAgg>>` in one and `ProcessorContext<K, Change<V>>` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
  • Duplicated block (12–13 lines × 2) streams/src/main/java/org/apache/kafka/streams/processor/assignment/assignors/StickyTaskAssignor.java:96 — streams/src/main/java/org/apache/kafka/streams/processor/assignment/assignors/StickyTaskAssignor.java:96-108 | streams/src/main/java/org/apache/kafka/streams/processor/assignment/assignors/StickyTaskAssignor.java:127-138 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `streams/src/main/java/org/apache/kafka/streams/processor/assignment/assignors/StickyTaskAssignor.java:127` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (12–13 lines × 2) tools/src/main/java/org/apache/kafka/tools/DumpLogSegments.java:717 — tools/src/main/java/org/apache/kafka/tools/DumpLogSegments.java:717-729 | tools/src/main/java/org/apache/kafka/tools/consumer/TransactionLogMessageFormatter.java:46-57 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `tools/src/main/java/org/apache/kafka/tools/DumpLogSegments.java:717` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (12–13 lines × 2) streams/examples/src/main/java/org/apache/kafka/streams/examples/wordcount/WordCountProcessorDemo.java:61 — streams/examples/src/main/java/org/apache/kafka/streams/examples/wordcount/WordCountProcessorDemo.java:61-73 | streams/examples/src/main/java/org/apache/kafka/streams/examples/wordcount/WordCountTransformerDemo.java:74-85 — before extracting anything, compare `streams/examples/src/main/java/org/apache/kafka/streams/examples/wordcount/WordCountProcessorDemo.java` and `streams/examples/src/main/java/org/apache/kafka/streams/examples/wordcount/WordCountTransformerDemo.java` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 61 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
D4 · Code Duplication · Duplicated block (10–11 lines × 2) · ×5
  • Duplicated block (10–11 lines × 2) group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java:4398 — group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java:4398-4408 | group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java:4640-4649 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (10–11 lines × 2) streams/src/main/java/org/apache/kafka/streams/kstream/internals/InternalStreamsBuilder.java:137 — streams/src/main/java/org/apache/kafka/streams/kstream/internals/InternalStreamsBuilder.java:137-146 | streams/src/main/java/org/apache/kafka/streams/kstream/internals/InternalStreamsBuilder.java:182-192 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (10–11 lines × 2) streams/src/main/java/org/apache/kafka/streams/processor/internals/InternalTopicManager.java:305 — streams/src/main/java/org/apache/kafka/streams/processor/internals/InternalTopicManager.java:305-314 | streams/src/main/java/org/apache/kafka/streams/processor/internals/InternalTopicManager.java:350-360 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (10–11 lines × 2) streams/src/main/java/org/apache/kafka/streams/state/internals/AbstractDualSchemaRocksDBSegmentedBytesStore.java:187 — streams/src/main/java/org/apache/kafka/streams/state/internals/AbstractDualSchemaRocksDBSegmentedBytesStore.java:187-197 | streams/src/main/java/org/apache/kafka/streams/state/internals/AbstractRocksDBSegmentedBytesStore.java:253-262 — before extracting anything, compare `streams/src/main/java/org/apache/kafka/streams/state/internals/AbstractDualSchemaRocksDBSegmentedBytesStore.java` and `streams/src/main/java/org/apache/kafka/streams/state/internals/AbstractRocksDBSegmentedBytesStore.java` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 80 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `streams/src/main/java/org/apache/kafka/streams/state/internals/AbstractDualSchemaRocksDBSegmentedBytesStore.java:187` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (10–11 lines × 2) streams/src/main/java/org/apache/kafka/streams/state/internals/InMemoryWindowStore.java:118 — streams/src/main/java/org/apache/kafka/streams/state/internals/InMemoryWindowStore.java:118-127 | streams/src/main/java/org/apache/kafka/streams/state/internals/RocksDBVersionedStore.java:471-481 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
D4 · Code Duplication · Duplicated block (9 lines × 4) · ×5
  • Duplicated block (9 lines × 4) share-coordinator/src/main/java/org/apache/kafka/coordinator/share/ShareCoordinatorService.java:689 — share-coordinator/src/main/java/org/apache/kafka/coordinator/share/ShareCoordinatorService.java:689-697 | share-coordinator/src/main/java/org/apache/kafka/coordinator/share/ShareCoordinatorService.java:798-806 | share-coordinator/src/main/java/org/apache/kafka/coordinator/share/ShareCoordinatorService.java:907-915 | share-coordinator/src/main/java/org/apache/kafka/coordinator/share/ShareCoordinatorService.java:1000-1008 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
  • Duplicated block (9 lines × 4) streams/src/main/java/org/apache/kafka/streams/kstream/internals/KTableKTableInnerJoin.java:77 — streams/src/main/java/org/apache/kafka/streams/kstream/internals/KTableKTableInnerJoin.java:77-85 | streams/src/main/java/org/apache/kafka/streams/kstream/internals/KTableKTableLeftJoin.java:79-87 | streams/src/main/java/org/apache/kafka/streams/kstream/internals/KTableKTableOuterJoin.java:78-86 | streams/src/main/java/org/apache/kafka/streams/kstream/internals/KTableKTableRightJoin.java:77-85 — before extracting anything, compare `streams/src/main/java/org/apache/kafka/streams/kstream/internals/KTableKTableInnerJoin.java` and `streams/src/main/java/org/apache/kafka/streams/kstream/internals/KTableKTableLeftJoin.java` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 55 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (9 lines × 4) streams/src/main/java/org/apache/kafka/streams/state/internals/InMemorySessionTransactionBuffer.java:250 — streams/src/main/java/org/apache/kafka/streams/state/internals/InMemorySessionTransactionBuffer.java:250-258 | streams/src/main/java/org/apache/kafka/streams/state/internals/InMemoryTransactionBuffer.java:154-162 | streams/src/main/java/org/apache/kafka/streams/state/internals/InMemoryWindowTransactionBuffer.java:228-236 | streams/src/main/java/org/apache/kafka/streams/state/internals/RocksDBTransactionBuffer.java:326-334 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 4 call sites, so a change lands once.
  • Duplicated block (9 lines × 4) streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredSessionStoreWithHeaders.java:296 — streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredSessionStoreWithHeaders.java:296-305 | streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredSessionStoreWithHeaders.java:313-322 | streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredTimestampedWindowStoreWithHeaders.java:407-415 | streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredTimestampedWindowStoreWithHeaders.java:423-431 — there are 4 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 4 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredSessionStoreWithHeaders.java:296` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (9 lines × 4) streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredSessionStoreWithHeaders.java:489 — streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredSessionStoreWithHeaders.java:489-497 | streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredSessionStoreWithHeaders.java:501-509 | streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredTimestampedWindowStoreWithHeaders.java:520-528 | streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredTimestampedWindowStoreWithHeaders.java:532-540 — there are 4 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 4 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredSessionStoreWithHeaders.java:489` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D36 · Supply-chain Provenance & Signing · REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
D4 · Code Duplication · Duplicated block (22 lines × 2) · ×4
  • Duplicated block (22 lines × 2) streams/src/main/java/org/apache/kafka/streams/kstream/internals/CogroupedStreamAggregateBuilder.java:105 — streams/src/main/java/org/apache/kafka/streams/kstream/internals/CogroupedStreamAggregateBuilder.java:105-126 | streams/src/main/java/org/apache/kafka/streams/kstream/internals/CogroupedStreamAggregateBuilder.java:185-206 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `streams/src/main/java/org/apache/kafka/streams/kstream/internals/CogroupedStreamAggregateBuilder.java:105` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (22 lines × 2) tools/src/main/java/org/apache/kafka/tools/consumer/group/ConsumerGroupCommand.java:1000 — tools/src/main/java/org/apache/kafka/tools/consumer/group/ConsumerGroupCommand.java:1000-1021 | tools/src/main/java/org/apache/kafka/tools/streams/StreamsGroupCommand.java:361-382 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
  • Duplicated block (22 lines × 2) clients/src/main/java/org/apache/kafka/common/requests/OffsetCommitResponse.java:64 — clients/src/main/java/org/apache/kafka/common/requests/OffsetCommitResponse.java:64-85 | clients/src/main/java/org/apache/kafka/common/requests/TxnOffsetCommitResponse.java:222-243 — before extracting anything, compare `clients/src/main/java/org/apache/kafka/common/requests/OffsetCommitResponse.java` and `clients/src/main/java/org/apache/kafka/common/requests/TxnOffsetCommitResponse.java` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 48 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `clients/src/main/java/org/apache/kafka/common/requests/OffsetCommitResponse.java:87` calls `OffsetCommitResponse`, `this` and `clients/src/main/java/org/apache/kafka/common/requests/TxnOffsetCommitResponse.java:245` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (22 lines × 2) trogdor/src/main/java/org/apache/kafka/trogdor/rest/WorkerRunning.java:46 — trogdor/src/main/java/org/apache/kafka/trogdor/rest/WorkerRunning.java:46-67 | trogdor/src/main/java/org/apache/kafka/trogdor/rest/WorkerStopping.java:46-72 — before extracting anything, compare `trogdor/src/main/java/org/apache/kafka/trogdor/rest/WorkerRunning.java` and `trogdor/src/main/java/org/apache/kafka/trogdor/rest/WorkerStopping.java` as WHOLE FILES: 88% of the shorter file's lines also appear in the other, so this reads as one file having been copied from the other rather than as a helper waiting to be extracted. The 1 duplicated block(s) this scan matched between them are fragments of that copy, not the extent of it — treat the file pair as the unit. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `trogdor/src/main/java/org/apache/kafka/trogdor/rest/WorkerRunning.java:46` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (20 lines × 2) · ×4
  • Duplicated block (20 lines × 2) group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java:4411 — group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java:4411-4430 | group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java:4506-4525 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java:4411` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (20 lines × 2) trogdor/src/main/java/org/apache/kafka/trogdor/agent/AgentClient.java:249 — trogdor/src/main/java/org/apache/kafka/trogdor/agent/AgentClient.java:249-268 | trogdor/src/main/java/org/apache/kafka/trogdor/coordinator/CoordinatorClient.java:328-347 — before extracting anything, compare `trogdor/src/main/java/org/apache/kafka/trogdor/agent/AgentClient.java` and `trogdor/src/main/java/org/apache/kafka/trogdor/coordinator/CoordinatorClient.java` as WHOLE FILES: this scan already matched 9 separate duplicated blocks between them, totalling at least 91 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `trogdor/src/main/java/org/apache/kafka/trogdor/agent/AgentClient.java:249` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (20 lines × 2) clients/src/main/java/org/apache/kafka/clients/admin/DeleteConsumerGroupsResult.java:35 — clients/src/main/java/org/apache/kafka/clients/admin/DeleteConsumerGroupsResult.java:35-54 | clients/src/main/java/org/apache/kafka/clients/admin/DeleteShareGroupsResult.java:34-53 — before extracting anything, compare `clients/src/main/java/org/apache/kafka/clients/admin/DeleteConsumerGroupsResult.java` and `clients/src/main/java/org/apache/kafka/clients/admin/DeleteShareGroupsResult.java` as WHOLE FILES: 83% of the shorter file's lines also appear in the other, so this reads as one file having been copied from the other rather than as a helper waiting to be extracted. The 1 duplicated block(s) this scan matched between them are fragments of that copy, not the extent of it — treat the file pair as the unit. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (20 lines × 2) clients/src/main/java/org/apache/kafka/clients/consumer/internals/events/CompletableApplicationEvent.java:35 — clients/src/main/java/org/apache/kafka/clients/consumer/internals/events/CompletableApplicationEvent.java:35-54 | clients/src/main/java/org/apache/kafka/clients/consumer/internals/events/CompletableBackgroundEvent.java:35-54 — before extracting anything, compare `clients/src/main/java/org/apache/kafka/clients/consumer/internals/events/CompletableApplicationEvent.java` and `clients/src/main/java/org/apache/kafka/clients/consumer/internals/events/CompletableBackgroundEvent.java` as WHOLE FILES: 93% of the shorter file's lines also appear in the other, so this reads as one file having been copied from the other rather than as a helper waiting to be extracted. The 1 duplicated block(s) this scan matched between them are fragments of that copy, not the extent of it — treat the file pair as the unit. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (17–18 lines × 2) · ×4
  • Duplicated block (17–18 lines × 2) streams/src/main/java/org/apache/kafka/streams/processor/internals/GlobalStateManagerImpl.java:339 — streams/src/main/java/org/apache/kafka/streams/processor/internals/GlobalStateManagerImpl.java:339-356 | streams/src/main/java/org/apache/kafka/streams/processor/internals/GlobalStateManagerImpl.java:485-501 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `streams/src/main/java/org/apache/kafka/streams/processor/internals/GlobalStateManagerImpl.java:339` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `streams/src/main/java/org/apache/kafka/streams/processor/internals/GlobalStateManagerImpl.java:483` calls `adapt` and `streams/src/main/java/org/apache/kafka/streams/processor/internals/GlobalStateManagerImpl.java:338` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (17–18 lines × 2) streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredTimestampedKeyValueStore.java:214 — streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredTimestampedKeyValueStore.java:214-230 | streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredTimestampedKeyValueStoreWithHeaders.java:533-550 — before extracting anything, compare `streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredTimestampedKeyValueStore.java` and `streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredTimestampedKeyValueStoreWithHeaders.java` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 78 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredTimestampedKeyValueStore.java:214` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (17–18 lines × 2) streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredTimestampedKeyValueStore.java:282 — streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredTimestampedKeyValueStore.java:282-298 | streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredTimestampedKeyValueStoreWithHeaders.java:497-514 — before extracting anything, compare `streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredTimestampedKeyValueStore.java` and `streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredTimestampedKeyValueStoreWithHeaders.java` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 78 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredTimestampedKeyValueStore.java:282` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (17–18 lines × 2) streams/src/main/java/org/apache/kafka/streams/state/internals/RecordConverters.java:155 — streams/src/main/java/org/apache/kafka/streams/state/internals/RecordConverters.java:155-171 | streams/src/main/java/org/apache/kafka/streams/state/internals/ValueTimestampHeadersSerializer.java:81-98 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `streams/src/main/java/org/apache/kafka/streams/state/internals/ValueTimestampHeadersSerializer.java:81` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (16–17 lines × 2) · ×4
  • Duplicated block (16–17 lines × 2) clients/src/main/java/org/apache/kafka/clients/consumer/internals/CommitRequestManager.java:1331 — clients/src/main/java/org/apache/kafka/clients/consumer/internals/CommitRequestManager.java:1331-1347 | clients/src/main/java/org/apache/kafka/clients/consumer/internals/ConsumerCoordinator.java:1568-1583 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `clients/src/main/java/org/apache/kafka/clients/consumer/internals/CommitRequestManager.java:1331` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (16–17 lines × 2) group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java:6178 — group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java:6178-6194 | group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java:6496-6511 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java:6178` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (16–17 lines × 2) streams/src/main/java/org/apache/kafka/streams/processor/assignment/TaskAssignmentUtils.java:473 — streams/src/main/java/org/apache/kafka/streams/processor/assignment/TaskAssignmentUtils.java:473-488 | streams/src/main/java/org/apache/kafka/streams/processor/internals/assignment/RackAwareTaskAssignor.java:454-470 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
  • Duplicated block (16–17 lines × 2) streams/src/main/java/org/apache/kafka/streams/state/internals/AggregationWithHeadersSerializer.java:80 — streams/src/main/java/org/apache/kafka/streams/state/internals/AggregationWithHeadersSerializer.java:80-96 | streams/src/main/java/org/apache/kafka/streams/state/internals/RecordConverters.java:128-143 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `streams/src/main/java/org/apache/kafka/streams/state/internals/AggregationWithHeadersSerializer.java:80` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (10 lines × 4) · ×4
  • Duplicated block (10 lines × 4) streams/src/main/java/org/apache/kafka/streams/kstream/internals/KGroupedStreamImpl.java:180 — streams/src/main/java/org/apache/kafka/streams/kstream/internals/KGroupedStreamImpl.java:180-189 | streams/src/main/java/org/apache/kafka/streams/kstream/internals/SessionWindowedKStreamImpl.java:96-105 | streams/src/main/java/org/apache/kafka/streams/kstream/internals/SlidingWindowedKStreamImpl.java:84-93 | streams/src/main/java/org/apache/kafka/streams/kstream/internals/TimeWindowedKStreamImpl.java:96-105 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 4 call sites, so a change lands once. Note first that the copies are not typed on the same thing: the declarations holding them bind `materialized` to `Materialized<K, Long, KeyValueStore<Bytes, byte[]>>` in one and `Materialized<K, Long, SessionStore<Bytes, byte[]>>` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `streams/src/main/java/org/apache/kafka/streams/kstream/internals/SessionWindowedKStreamImpl.java:107` calls `gracePeriodMs`, `inactivityGap` and `streams/src/main/java/org/apache/kafka/streams/kstream/internals/SlidingWindowedKStreamImpl.java:96` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (10 lines × 4) trogdor/src/main/java/org/apache/kafka/trogdor/agent/AgentClient.java:227 — trogdor/src/main/java/org/apache/kafka/trogdor/agent/AgentClient.java:227-236 | trogdor/src/main/java/org/apache/kafka/trogdor/coordinator/CoordinatorClient.java:294-303 | trogdor/src/main/java/org/apache/kafka/trogdor/coordinator/CoordinatorClient.java:304-313 | trogdor/src/main/java/org/apache/kafka/trogdor/coordinator/CoordinatorClient.java:314-323 — before extracting anything, compare `trogdor/src/main/java/org/apache/kafka/trogdor/agent/AgentClient.java` and `trogdor/src/main/java/org/apache/kafka/trogdor/coordinator/CoordinatorClient.java` as WHOLE FILES: this scan already matched 9 separate duplicated blocks between them, totalling at least 91 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `trogdor/src/main/java/org/apache/kafka/trogdor/coordinator/CoordinatorClient.java:301` calls `addParser`, `help`, `addTargetArgument` and `trogdor/src/main/java/org/apache/kafka/trogdor/agent/AgentClient.java:226` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (10 lines × 4) tools/src/main/java/org/apache/kafka/tools/BrokerApiVersionsCommand.java:73 — tools/src/main/java/org/apache/kafka/tools/BrokerApiVersionsCommand.java:73-82 | tools/src/main/java/org/apache/kafka/tools/ClientMetricsCommand.java:64-73 | tools/src/main/java/org/apache/kafka/tools/GroupsCommand.java:55-64 | tools/src/main/java/org/apache/kafka/tools/TopicCommand.java:88-97 — before extracting anything, compare `tools/src/main/java/org/apache/kafka/tools/ClientMetricsCommand.java` and `tools/src/main/java/org/apache/kafka/tools/GroupsCommand.java` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 35 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (10 lines × 4) .github/scripts/develocity_reports.py:997 — .github/scripts/develocity_reports.py:997-1006 | .github/scripts/develocity_reports.py:1056-1065 | .github/scripts/develocity_reports.py:1112-1121 | .github/scripts/develocity_reports.py:1180-1189 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Note first that the copies are not typed on the same thing: the declarations holding them bind `test_name` to `"<tr><td>Class</td><td>Test Case</td><td>Failure Rate</td><td>Build Scans</td><td>Link</td></tr>") for` in one and `"<tr><td>Test Class</td><td>Recent Flaky Rate</td><td>Historical Rate</td><td>Recent Executions</td><td>Link</td></tr>") for` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `.github/scripts/develocity_reports.py:1053` calls `sorted`, `strftime` and `.github/scripts/develocity_reports.py:1179` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (10 lines × 3) · ×4
  • Duplicated block (10 lines × 3) tools/src/main/java/org/apache/kafka/tools/consumer/group/ConsumerGroupCommand.java:1037 — tools/src/main/java/org/apache/kafka/tools/consumer/group/ConsumerGroupCommand.java:1037-1046 | tools/src/main/java/org/apache/kafka/tools/consumer/group/ShareGroupCommand.java:325-334 | tools/src/main/java/org/apache/kafka/tools/streams/StreamsGroupCommand.java:782-791 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times.
  • Duplicated block (10 lines × 3) tools/src/main/java/org/apache/kafka/tools/consumer/group/ConsumerGroupCommandOptions.java:123 — tools/src/main/java/org/apache/kafka/tools/consumer/group/ConsumerGroupCommandOptions.java:123-132 | tools/src/main/java/org/apache/kafka/tools/consumer/group/ShareGroupCommandOptions.java:104-113 | tools/src/main/java/org/apache/kafka/tools/streams/StreamsGroupCommandOptions.java:126-135 — before extracting anything, compare `tools/src/main/java/org/apache/kafka/tools/consumer/group/ConsumerGroupCommandOptions.java` and `tools/src/main/java/org/apache/kafka/tools/consumer/group/ShareGroupCommandOptions.java` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 85 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (10 lines × 3) streams/src/main/java/org/apache/kafka/streams/state/internals/InMemorySessionStore.java:729 — streams/src/main/java/org/apache/kafka/streams/state/internals/InMemorySessionStore.java:729-738 | streams/src/main/java/org/apache/kafka/streams/state/internals/InMemoryWindowStore.java:769-778 | streams/src/main/java/org/apache/kafka/streams/state/internals/InMemoryWindowStore.java:859-868 — there are 3 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 3 sites; resolving a subset leaves the remainder to drift apart. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (10 lines × 3) streams/src/main/java/org/apache/kafka/streams/state/internals/RocksDbIndexedTimeOrderedWindowBytesStoreSupplier.java:193 — streams/src/main/java/org/apache/kafka/streams/state/internals/RocksDbIndexedTimeOrderedWindowBytesStoreSupplier.java:193-202 | streams/src/main/java/org/apache/kafka/streams/state/internals/RocksDbIndexedTimeOrderedWindowBytesStoreWithHeadersSupplier.java:90-99 | streams/src/main/java/org/apache/kafka/streams/state/internals/RocksDbWindowBytesStoreSupplier.java:112-121 — before extracting anything, compare `streams/src/main/java/org/apache/kafka/streams/state/internals/RocksDbIndexedTimeOrderedWindowBytesStoreSupplier.java` and `streams/src/main/java/org/apache/kafka/streams/state/internals/RocksDbIndexedTimeOrderedWindowBytesStoreWithHeadersSupplier.java` as WHOLE FILES: 82% of the shorter file's lines also appear in the other, so this reads as one file having been copied from the other rather than as a helper waiting to be extracted. The 2 duplicated block(s) this scan matched between them are fragments of that copy, not the extent of it — treat the file pair as the unit. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (9–10 lines × 2) · ×4
  • Duplicated block (9–10 lines × 2) connect/runtime/src/main/java/org/apache/kafka/connect/storage/KafkaStatusBackingStore.java:422 — connect/runtime/src/main/java/org/apache/kafka/connect/storage/KafkaStatusBackingStore.java:422-431 | connect/runtime/src/main/java/org/apache/kafka/connect/storage/KafkaStatusBackingStore.java:444-452 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `connect/runtime/src/main/java/org/apache/kafka/connect/storage/KafkaStatusBackingStore.java:422` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (9–10 lines × 2) group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupConfig.java:986 — group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupConfig.java:986-994 | group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupConfig.java:1045-1054 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupConfig.java:986` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (9–10 lines × 2) streams/src/main/java/org/apache/kafka/streams/kstream/internals/SlidingWindowedKStreamImpl.java:184 — streams/src/main/java/org/apache/kafka/streams/kstream/internals/SlidingWindowedKStreamImpl.java:184-192 | streams/src/main/java/org/apache/kafka/streams/kstream/internals/TimeWindowedKStreamImpl.java:207-216 — before extracting anything, compare `streams/src/main/java/org/apache/kafka/streams/kstream/internals/SlidingWindowedKStreamImpl.java` and `streams/src/main/java/org/apache/kafka/streams/kstream/internals/TimeWindowedKStreamImpl.java` as WHOLE FILES: this scan already matched 7 separate duplicated blocks between them, totalling at least 61 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (9–10 lines × 2) core/src/main/scala/kafka/server/KafkaApis.scala:711 — core/src/main/scala/kafka/server/KafkaApis.scala:711-719 | core/src/main/scala/kafka/server/KafkaApis.scala:4313-4322 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `core/src/main/scala/kafka/server/KafkaApis.scala:4313` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (7–8 lines × 2) · ×4
  • Duplicated block (7–8 lines × 2) clients/src/main/java/org/apache/kafka/clients/NetworkClient.java:1134 — clients/src/main/java/org/apache/kafka/clients/NetworkClient.java:1134-1140 | clients/src/main/java/org/apache/kafka/clients/NetworkClient.java:1246-1253 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `clients/src/main/java/org/apache/kafka/clients/NetworkClient.java:1134` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (7–8 lines × 2) group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java:7536 — group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java:7536-7542 | group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java:7581-7588 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java:7536` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (7–8 lines × 2) metadata/src/main/java/org/apache/kafka/controller/ScramControlManager.java:204 — metadata/src/main/java/org/apache/kafka/controller/ScramControlManager.java:204-210 | metadata/src/main/java/org/apache/kafka/controller/ScramControlManager.java:224-231 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `metadata/src/main/java/org/apache/kafka/controller/ScramControlManager.java:204` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (7–8 lines × 2) streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredSessionStore.java:114 — streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredSessionStore.java:114-120 | streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredWindowStore.java:127-134 — before extracting anything, compare `streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredSessionStore.java` and `streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredWindowStore.java` as WHOLE FILES: this scan already matched 11 separate duplicated blocks between them, totalling at least 156 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
D4 · Code Duplication · Duplicated block (5 lines × 4) · ×4
  • Duplicated block (5 lines × 4) streams/src/main/java/org/apache/kafka/streams/kstream/internals/KGroupedStreamImpl.java:127 — streams/src/main/java/org/apache/kafka/streams/kstream/internals/KGroupedStreamImpl.java:127-133 | streams/src/main/java/org/apache/kafka/streams/kstream/internals/SessionWindowedKStreamImpl.java:223-229 | streams/src/main/java/org/apache/kafka/streams/kstream/internals/SlidingWindowedKStreamImpl.java:188-192 | streams/src/main/java/org/apache/kafka/streams/kstream/internals/TimeWindowedKStreamImpl.java:211-216 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 4 call sites, so a change lands once. Note first that the copies are not typed on the same thing: the declarations holding them bind `materialized` to `Materialized<K, VOut, KeyValueStore<Bytes, byte[]>>` in one and `Materialized<K, VOut, SessionStore<Bytes, byte[]>>` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `streams/src/main/java/org/apache/kafka/streams/kstream/internals/SessionWindowedKStreamImpl.java:231` calls `gracePeriodMs`, `inactivityGap` and `streams/src/main/java/org/apache/kafka/streams/kstream/internals/SlidingWindowedKStreamImpl.java:195` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (5 lines × 4) trogdor/src/main/java/org/apache/kafka/trogdor/agent/AgentClient.java:256 — trogdor/src/main/java/org/apache/kafka/trogdor/agent/AgentClient.java:256-261 | trogdor/src/main/java/org/apache/kafka/trogdor/agent/AgentClient.java:271-276 | trogdor/src/main/java/org/apache/kafka/trogdor/coordinator/CoordinatorClient.java:335-340 | trogdor/src/main/java/org/apache/kafka/trogdor/coordinator/CoordinatorClient.java:350-354 — before extracting anything, compare `trogdor/src/main/java/org/apache/kafka/trogdor/agent/AgentClient.java` and `trogdor/src/main/java/org/apache/kafka/trogdor/coordinator/CoordinatorClient.java` as WHOLE FILES: this scan already matched 9 separate duplicated blocks between them, totalling at least 91 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `trogdor/src/main/java/org/apache/kafka/trogdor/agent/AgentClient.java:256` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (5 lines × 4) clients/src/main/java/org/apache/kafka/common/requests/AddOffsetsToTxnRequest.java:59 — clients/src/main/java/org/apache/kafka/common/requests/AddOffsetsToTxnRequest.java:59-63 | clients/src/main/java/org/apache/kafka/common/requests/EndTxnRequest.java:75-80 | clients/src/main/java/org/apache/kafka/common/requests/ExpireDelegationTokenRequest.java:47-52 | clients/src/main/java/org/apache/kafka/common/requests/UpdateRaftVoterRequest.java:60-64 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 4 call sites, so a change lands once. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (5 lines × 4) .github/scripts/develocity_reports.py:1025 — .github/scripts/develocity_reports.py:1025-1029 | .github/scripts/develocity_reports.py:1073-1077 | .github/scripts/develocity_reports.py:1134-1138 | .github/scripts/develocity_reports.py:1204-1208 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
D36 · Supply-chain Provenance & Signing · REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
D4 · Code Duplication · Duplicated block (26 lines × 2) · ×3
  • Duplicated block (26 lines × 2) clients/src/main/java/org/apache/kafka/clients/admin/internals/DeleteRecordsHandler.java:120 — clients/src/main/java/org/apache/kafka/clients/admin/internals/DeleteRecordsHandler.java:120-145 | clients/src/main/java/org/apache/kafka/clients/admin/internals/ListOffsetsHandler.java:143-168 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `clients/src/main/java/org/apache/kafka/clients/admin/internals/DeleteRecordsHandler.java:120` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (26 lines × 2) clients/src/main/java/org/apache/kafka/clients/consumer/internals/metrics/KafkaConsumerMetrics.java:48 — clients/src/main/java/org/apache/kafka/clients/consumer/internals/metrics/KafkaConsumerMetrics.java:48-73 | clients/src/main/java/org/apache/kafka/clients/consumer/internals/metrics/KafkaShareConsumerMetrics.java:45-70 — before extracting anything, compare `clients/src/main/java/org/apache/kafka/clients/consumer/internals/metrics/KafkaConsumerMetrics.java` and `clients/src/main/java/org/apache/kafka/clients/consumer/internals/metrics/KafkaShareConsumerMetrics.java` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 38 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (26 lines × 2) core/src/main/scala/kafka/server/KafkaApis.scala:4094 — core/src/main/scala/kafka/server/KafkaApis.scala:4094-4119 | core/src/main/scala/kafka/server/KafkaApis.scala:4131-4156 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `core/src/main/scala/kafka/server/KafkaApis.scala:4094` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (24 lines × 2) · ×3
  • Duplicated block (24 lines × 2) jmh-benchmarks/src/main/java/org/apache/kafka/jmh/coordinator/GroupCoordinatorShardLoadingBenchmark.java:125 — jmh-benchmarks/src/main/java/org/apache/kafka/jmh/coordinator/GroupCoordinatorShardLoadingBenchmark.java:125-148 | jmh-benchmarks/src/main/java/org/apache/kafka/jmh/coordinator/GroupCoordinatorShardLoadingBenchmark.java:196-219 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `jmh-benchmarks/src/main/java/org/apache/kafka/jmh/coordinator/GroupCoordinatorShardLoadingBenchmark.java:125` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (24 lines × 2) streams/src/main/java/org/apache/kafka/streams/kstream/internals/SlidingWindowStoreMaterializer.java:70 — streams/src/main/java/org/apache/kafka/streams/kstream/internals/SlidingWindowStoreMaterializer.java:70-93 | streams/src/main/java/org/apache/kafka/streams/kstream/internals/WindowStoreMaterializer.java:69-92 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `streams/src/main/java/org/apache/kafka/streams/kstream/internals/SlidingWindowStoreMaterializer.java:70` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (24 lines × 2) tools/src/main/java/org/apache/kafka/tools/consumer/group/ConsumerGroupCommand.java:1038 — tools/src/main/java/org/apache/kafka/tools/consumer/group/ConsumerGroupCommand.java:1038-1061 | tools/src/main/java/org/apache/kafka/tools/consumer/group/ShareGroupCommand.java:326-349 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `tools/src/main/java/org/apache/kafka/tools/consumer/group/ConsumerGroupCommand.java:1038` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (19 lines × 2) · ×3
  • Duplicated block (19 lines × 2) group-coordinator/src/main/java/org/apache/kafka/coordinator/group/streams/assignor/BalancedTaskAssignor.java:337 — group-coordinator/src/main/java/org/apache/kafka/coordinator/group/streams/assignor/BalancedTaskAssignor.java:337-355 | streams/src/main/java/org/apache/kafka/streams/processor/internals/assignment/HighAvailabilityTaskAssignor.java:212-230 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
  • Duplicated block (19 lines × 2) streams/src/main/java/org/apache/kafka/streams/state/internals/TimestampedWindowStoreBuilder.java:83 — streams/src/main/java/org/apache/kafka/streams/state/internals/TimestampedWindowStoreBuilder.java:83-101 | streams/src/main/java/org/apache/kafka/streams/state/internals/TimestampedWindowStoreWithHeadersBuilder.java:96-114 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
  • Duplicated block (19 lines × 2) tools/src/main/java/org/apache/kafka/tools/consumer/group/ConsumerGroupCommandOptions.java:160 — tools/src/main/java/org/apache/kafka/tools/consumer/group/ConsumerGroupCommandOptions.java:160-178 | tools/src/main/java/org/apache/kafka/tools/streams/StreamsGroupCommandOptions.java:171-189 — before extracting anything, compare `tools/src/main/java/org/apache/kafka/tools/consumer/group/ConsumerGroupCommandOptions.java` and `tools/src/main/java/org/apache/kafka/tools/streams/StreamsGroupCommandOptions.java` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 59 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
D4 · Code Duplication · Duplicated block (15–16 lines × 2) · ×3
  • Duplicated block (15–16 lines × 2) clients/src/main/java/org/apache/kafka/clients/consumer/internals/AsyncKafkaConsumer.java:1565 — clients/src/main/java/org/apache/kafka/clients/consumer/internals/AsyncKafkaConsumer.java:1565-1580 | clients/src/main/java/org/apache/kafka/clients/consumer/internals/ClassicKafkaConsumer.java:1139-1153 — before extracting anything, compare `clients/src/main/java/org/apache/kafka/clients/consumer/internals/AsyncKafkaConsumer.java` and `clients/src/main/java/org/apache/kafka/clients/consumer/internals/ClassicKafkaConsumer.java` as WHOLE FILES: this scan already matched 11 separate duplicated blocks between them, totalling at least 102 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
  • Duplicated block (15–16 lines × 2) group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java:6433 — group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java:6433-6447 | group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java:6747-6762 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. Note first that the copies are not typed on the same thing: the declarations holding them bind `key` to `ShareGroupMemberMetadataKey` in one and `ShareGroupCurrentMemberAssignmentKey` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
  • Duplicated block (15–16 lines × 2) tools/src/main/java/org/apache/kafka/tools/consumer/group/ConsumerGroupCommand.java:982 — tools/src/main/java/org/apache/kafka/tools/consumer/group/ConsumerGroupCommand.java:982-996 | tools/src/main/java/org/apache/kafka/tools/streams/StreamsGroupCommand.java:1013-1028 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `tools/src/main/java/org/apache/kafka/tools/consumer/group/ConsumerGroupCommand.java:982` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (14 lines × 4) · ×3
  • Duplicated block (14 lines × 4) metadata/src/main/java/org/apache/kafka/metadata/ListenerInfo.java:89 — metadata/src/main/java/org/apache/kafka/metadata/ListenerInfo.java:89-102 | metadata/src/main/java/org/apache/kafka/metadata/ListenerInfo.java:114-127 | metadata/src/main/java/org/apache/kafka/metadata/ListenerInfo.java:139-152 | metadata/src/main/java/org/apache/kafka/metadata/ListenerInfo.java:164-177 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit. Note first that the copies are not typed on the same thing: the declarations holding them bind `collection` to `ControllerRegistrationRequestData.ListenerCollection` in one and `RegisterControllerRecord.ControllerEndpointCollection` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
  • Duplicated block (14 lines × 4) raft/src/main/java/org/apache/kafka/raft/KafkaRaftClient.java:994 — raft/src/main/java/org/apache/kafka/raft/KafkaRaftClient.java:994-1007 | raft/src/main/java/org/apache/kafka/raft/KafkaRaftClient.java:1203-1216 | raft/src/main/java/org/apache/kafka/raft/KafkaRaftClient.java:1379-1392 | raft/src/main/java/org/apache/kafka/raft/KafkaRaftClient.java:2581-2594 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `raft/src/main/java/org/apache/kafka/raft/KafkaRaftClient.java:994` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (14 lines × 4) streams/src/main/java/org/apache/kafka/streams/state/internals/RocksDBSessionStore.java:56 — streams/src/main/java/org/apache/kafka/streams/state/internals/RocksDBSessionStore.java:56-69 | streams/src/main/java/org/apache/kafka/streams/state/internals/RocksDBTimeOrderedSessionStore.java:57-70 | streams/src/main/java/org/apache/kafka/streams/state/internals/RocksDBTimeOrderedWindowStore.java:234-247 | streams/src/main/java/org/apache/kafka/streams/state/internals/RocksDBWindowStore.java:197-210 — before extracting anything, compare `streams/src/main/java/org/apache/kafka/streams/state/internals/RocksDBSessionStore.java` and `streams/src/main/java/org/apache/kafka/streams/state/internals/RocksDBTimeOrderedSessionStore.java` as WHOLE FILES: 83% of the shorter file's lines also appear in the other, so this reads as one file having been copied from the other rather than as a helper waiting to be extracted. The 1 duplicated block(s) this scan matched between them are fragments of that copy, not the extent of it — treat the file pair as the unit. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `streams/src/main/java/org/apache/kafka/streams/state/internals/RocksDBSessionStore.java:56` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (12 lines × 3) · ×3
  • Duplicated block (12 lines × 3) connect/mirror/src/main/java/org/apache/kafka/connect/mirror/MirrorCheckpointConnector.java:172 — connect/mirror/src/main/java/org/apache/kafka/connect/mirror/MirrorCheckpointConnector.java:172-183 | connect/mirror/src/main/java/org/apache/kafka/connect/mirror/MirrorHeartbeatConnector.java:93-104 | connect/mirror/src/main/java/org/apache/kafka/connect/mirror/MirrorSourceConnector.java:292-303 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 3 call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `connect/mirror/src/main/java/org/apache/kafka/connect/mirror/MirrorCheckpointConnector.java:172` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `connect/mirror/src/main/java/org/apache/kafka/connect/mirror/MirrorCheckpointConnector.java:187` calls `validateSourcePartitionPartition` and `connect/mirror/src/main/java/org/apache/kafka/connect/mirror/MirrorHeartbeatConnector.java:109` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (12 lines × 3) streams/src/main/java/org/apache/kafka/streams/state/internals/CachingSessionStore.java:216 — streams/src/main/java/org/apache/kafka/streams/state/internals/CachingSessionStore.java:216-227 | streams/src/main/java/org/apache/kafka/streams/state/internals/CachingWindowStore.java:159-170 | streams/src/main/java/org/apache/kafka/streams/state/internals/TimeOrderedCachingWindowStore.java:267-278 — before extracting anything, compare `streams/src/main/java/org/apache/kafka/streams/state/internals/CachingSessionStore.java` and `streams/src/main/java/org/apache/kafka/streams/state/internals/CachingWindowStore.java` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 83 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (12 lines × 3) tools/src/main/java/org/apache/kafka/tools/consumer/group/ConsumerGroupCommandOptions.java:156 — tools/src/main/java/org/apache/kafka/tools/consumer/group/ConsumerGroupCommandOptions.java:156-167 | tools/src/main/java/org/apache/kafka/tools/consumer/group/ShareGroupCommandOptions.java:137-148 | tools/src/main/java/org/apache/kafka/tools/streams/StreamsGroupCommandOptions.java:167-178 — before extracting anything, compare `tools/src/main/java/org/apache/kafka/tools/consumer/group/ConsumerGroupCommandOptions.java` and `tools/src/main/java/org/apache/kafka/tools/consumer/group/ShareGroupCommandOptions.java` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 85 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
D4 · Code Duplication · Duplicated block (11 lines × 4) · ×3
  • Duplicated block (11 lines × 4) server-common/src/main/java/org/apache/kafka/server/share/persister/PersisterStateManager.java:676 — server-common/src/main/java/org/apache/kafka/server/share/persister/PersisterStateManager.java:676-686 | server-common/src/main/java/org/apache/kafka/server/share/persister/PersisterStateManager.java:1059-1069 | server-common/src/main/java/org/apache/kafka/server/share/persister/PersisterStateManager.java:1240-1250 | server-common/src/main/java/org/apache/kafka/server/share/persister/PersisterStateManager.java:1418-1428 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `server-common/src/main/java/org/apache/kafka/server/share/persister/PersisterStateManager.java:676` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (11 lines × 4) share-coordinator/src/main/java/org/apache/kafka/coordinator/share/ShareCoordinatorService.java:674 — share-coordinator/src/main/java/org/apache/kafka/coordinator/share/ShareCoordinatorService.java:674-684 | share-coordinator/src/main/java/org/apache/kafka/coordinator/share/ShareCoordinatorService.java:783-793 | share-coordinator/src/main/java/org/apache/kafka/coordinator/share/ShareCoordinatorService.java:892-902 | share-coordinator/src/main/java/org/apache/kafka/coordinator/share/ShareCoordinatorService.java:985-995 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `share-coordinator/src/main/java/org/apache/kafka/coordinator/share/ShareCoordinatorService.java:674` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (11 lines × 4) streams/src/main/java/org/apache/kafka/streams/kstream/SessionWindowedDeserializer.java:68 — streams/src/main/java/org/apache/kafka/streams/kstream/SessionWindowedDeserializer.java:68-78 | streams/src/main/java/org/apache/kafka/streams/kstream/SessionWindowedSerializer.java:70-80 | streams/src/main/java/org/apache/kafka/streams/kstream/TimeWindowedDeserializer.java:145-155 | streams/src/main/java/org/apache/kafka/streams/kstream/TimeWindowedSerializer.java:71-81 — before extracting anything, compare `streams/src/main/java/org/apache/kafka/streams/kstream/SessionWindowedDeserializer.java` and `streams/src/main/java/org/apache/kafka/streams/kstream/TimeWindowedDeserializer.java` as WHOLE FILES: 84% of the shorter file's lines also appear in the other, so this reads as one file having been copied from the other rather than as a helper waiting to be extracted. The 2 duplicated block(s) this scan matched between them are fragments of that copy, not the extent of it — treat the file pair as the unit. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `streams/src/main/java/org/apache/kafka/streams/kstream/SessionWindowedDeserializer.java:68` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (10–11 lines × 3) · ×3
  • Duplicated block (10–11 lines × 3) jmh-benchmarks/src/main/java/org/apache/kafka/jmh/fetcher/ReplicaFetcherThreadBenchmark.java:171 — jmh-benchmarks/src/main/java/org/apache/kafka/jmh/fetcher/ReplicaFetcherThreadBenchmark.java:171-180 | jmh-benchmarks/src/main/java/org/apache/kafka/jmh/partition/UpdateFollowerFetchStateBenchmark.java:119-128 | jmh-benchmarks/src/main/java/org/apache/kafka/jmh/server/PartitionCreationBench.java:196-206 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times.
  • Duplicated block (10–11 lines × 3) streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredKeyValueStore.java:236 — streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredKeyValueStore.java:236-246 | streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredSessionStore.java:189-198 | streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredWindowStore.java:212-222 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 3 call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredKeyValueStore.java:236` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (10–11 lines × 3) streams/src/main/java/org/apache/kafka/streams/state/internals/PrefixedWindowKeySchemas.java:134 — streams/src/main/java/org/apache/kafka/streams/state/internals/PrefixedWindowKeySchemas.java:134-143 | streams/src/main/java/org/apache/kafka/streams/state/internals/PrefixedWindowKeySchemas.java:292-302 | streams/src/main/java/org/apache/kafka/streams/state/internals/WindowKeySchema.java:91-101 — there are 3 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 3 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `streams/src/main/java/org/apache/kafka/streams/state/internals/PrefixedWindowKeySchemas.java:134` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (10 lines × 5) · ×3
  • Duplicated block (10 lines × 5) streams/src/main/java/org/apache/kafka/streams/state/internals/CompositeReadOnlyKeyValueStore.java:92 — streams/src/main/java/org/apache/kafka/streams/state/internals/CompositeReadOnlyKeyValueStore.java:92-101 | streams/src/main/java/org/apache/kafka/streams/state/internals/CompositeReadOnlyKeyValueStore.java:110-119 | streams/src/main/java/org/apache/kafka/streams/state/internals/CompositeReadOnlyKeyValueStore.java:130-139 | streams/src/main/java/org/apache/kafka/streams/state/internals/CompositeReadOnlyKeyValueStore.java:148-157 | streams/src/main/java/org/apache/kafka/streams/state/internals/CompositeReadOnlyKeyValueStore.java:166-175 — all 5 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `streams/src/main/java/org/apache/kafka/streams/state/internals/CompositeReadOnlyKeyValueStore.java:92` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (10 lines × 5) tools/src/main/java/org/apache/kafka/tools/ClusterTool.java:60 — tools/src/main/java/org/apache/kafka/tools/ClusterTool.java:60-69 | tools/src/main/java/org/apache/kafka/tools/DelegationTokenCommand.java:57-66 | tools/src/main/java/org/apache/kafka/tools/EndToEndLatency.java:77-86 | tools/src/main/java/org/apache/kafka/tools/LogDirsCommand.java:57-66 | tools/src/main/java/org/apache/kafka/tools/MetadataQuorumCommand.java:89-98 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 5 call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `tools/src/main/java/org/apache/kafka/tools/ClusterTool.java:60` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (10 lines × 5) clients/src/main/java/org/apache/kafka/common/serialization/DoubleDeserializer.java:45 — clients/src/main/java/org/apache/kafka/common/serialization/DoubleDeserializer.java:45-54 | clients/src/main/java/org/apache/kafka/common/serialization/FloatDeserializer.java:44-53 | clients/src/main/java/org/apache/kafka/common/serialization/IntegerDeserializer.java:44-53 | clients/src/main/java/org/apache/kafka/common/serialization/LongDeserializer.java:44-53 | clients/src/main/java/org/apache/kafka/common/serialization/ShortDeserializer.java:45-54 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 5 call sites, so a change lands once. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
X3 · Exception handling · Swallowed exception (empty catch) · ×3
  • Swallowed exception (empty catch) clients/src/main/java/org/apache/kafka/common/security/ssl/SslFactory.java:531 — An empty catch block silently discards the error — failures vanish with no log and no rethrow. On a teardown path letting it propagate is not an option (throwing out of `close()` masks the failure already in flight and abandons the rest of the cleanup), so make the swallow deliberate instead: narrow the catch to the exception this release can actually raise, and record it through whatever this codebase already uses to report problems — or, if it truly cannot matter, say why in a comment on the catch.
  • Swallowed exception (empty catch) jmh-benchmarks/src/main/java/org/apache/kafka/jmh/connect/ValuesBenchmark.java:140 — An empty catch block silently discards the error — failures vanish with no log and no rethrow. Log it, handle it, or don't catch it.
  • Swallowed exception (empty catch) jmh-benchmarks/src/main/java/org/apache/kafka/jmh/connect/ValuesBenchmark.java:153 — An empty catch block silently discards the error — failures vanish with no log and no rethrow. Log it, handle it, or don't catch it.
D17 · Explicit Debt · HackComment · ×2
  • HackComment connect/runtime/src/test/java/org/apache/kafka/connect/integration/StandaloneWorkerIntegrationTest.java:330 — // Hack: if a connector blocks in its taskConfigs method, then the worker gets blocked — a workaround marked in source: record what it is compensating for and what would allow its removal (the upstream fix, the API it is waiting on, the invariant it restores), so the next reader can judge whether it is still needed rather than rediscovering why it is there.
  • HackComment connect/runtime/src/test/java/org/apache/kafka/connect/integration/ExactlyOnceSourceIntegrationTest.java:707 — // Hack: There is a small chance that our recent ACL updates for the connector have — a workaround marked in source: record what it is compensating for and what would allow its removal (the upstream fix, the API it is waiting on, the invariant it restores), so the next reader can judge whether it is still needed rather than rediscovering why it is there.
D2 · Cognitive Complexity · ByteUtils.readUnsignedVarint (cognitive 19) · ×2
  • ByteUtils.readUnsignedVarint (cognitive 19) clients/src/main/java/org/apache/kafka/common/utils/internals/ByteUtils.java:266 — ByteUtils.readUnsignedVarint has cognitive complexity 19 (threshold 15). Drivers by points: if/else 9 (19 pts) (nesting depth added 10). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function. This shape REPEATS in the file: one other method here (ByteUtils.readUnsignedVarint) has the same decision points, in the same order, at the same nesting depths — so this is one pattern written twice rather than two separate problems. Splitting this body alone leaves the other exactly as it is. Where these are variations on one operation, the change that clears both is the shared one: lift the common shape into a single routine the variants call, parameterised by whatever genuinely differs between them, and keep in each method only the part that is not shared.
  • ByteUtils.readUnsignedVarint (cognitive 19) clients/src/main/java/org/apache/kafka/common/utils/internals/ByteUtils.java:223 — ByteUtils.readUnsignedVarint has cognitive complexity 19 (threshold 15). Drivers by points: if/else 9 (19 pts) (nesting depth added 10). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function. This shape REPEATS in the file: one other method here (ByteUtils.readUnsignedVarint) has the same decision points, in the same order, at the same nesting depths — so this is one pattern written twice rather than two separate problems. Splitting this body alone leaves the other exactly as it is. Where these are variations on one operation, the change that clears both is the shared one: lift the common shape into a single routine the variants call, parameterised by whatever genuinely differs between them, and keep in each method only the part that is not shared.
D36 · Supply-chain Provenance & Signing · REDACTED
  • REDACTED
  • REDACTED
D4 · Code Duplication · Edited copy of a member (21 corresponding lines) · ×2
  • Edited copy of a member (21 corresponding lines) clients/src/main/java/org/apache/kafka/common/utils/internals/ByteUtils.java:223 — clients/src/main/java/org/apache/kafka/common/utils/internals/ByteUtils.java:223-250 | jmh-benchmarks/src/main/java/org/apache/kafka/jmh/util/ByteUtilsBenchmark.java:382-409 — These two members are one piece of code written twice and then edited apart: 21 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (21 corresponding lines) server/src/main/java/org/apache/kafka/server/share/dlq/ShareGroupDLQRecordFetcher.java:327 — server/src/main/java/org/apache/kafka/server/share/dlq/ShareGroupDLQRecordFetcher.java:327-355 | server/src/main/java/org/apache/kafka/server/share/dlq/ShareGroupDLQRecordFetcher.java:467-498 — These two members are one piece of code written twice and then edited apart: 21 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Members sharing a duplicated core (7 members, 50+ identical tokens) · ×2
  • Members sharing a duplicated core (7 members, 50+ identical tokens) clients/src/main/java/org/apache/kafka/clients/admin/internals/DeleteConsumerGroupOffsetsHandler.java:142 — clients/src/main/java/org/apache/kafka/clients/admin/internals/DeleteConsumerGroupOffsetsHandler.java:142-172 | clients/src/main/java/org/apache/kafka/clients/admin/internals/DescribeClassicGroupsHandler.java:166-192 | clients/src/main/java/org/apache/kafka/clients/admin/internals/DescribeShareGroupsHandler.java:161-195 | clients/src/main/java/org/apache/kafka/clients/admin/internals/DescribeStreamsGroupsHandler.java:353-386 | clients/src/main/java/org/apache/kafka/clients/admin/internals/ListConsumerGroupOffsetsHandler.java:196-223 | clients/src/main/java/org/apache/kafka/clients/admin/internals/ListShareGroupOffsetsHandler.java:173-202 | clients/src/main/java/org/apache/kafka/clients/admin/internals/RemoveMembersFromConsumerGroupHandler.java:123-147 — These 7 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 7 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 7 times.
  • Members sharing a duplicated core (7 members, 50+ identical tokens) raft/src/main/java/org/apache/kafka/raft/RaftUtil.java:726 — raft/src/main/java/org/apache/kafka/raft/RaftUtil.java:726-731 | raft/src/main/java/org/apache/kafka/raft/RaftUtil.java:733-738 | raft/src/main/java/org/apache/kafka/raft/RaftUtil.java:740-745 | raft/src/main/java/org/apache/kafka/raft/RaftUtil.java:747-752 | raft/src/main/java/org/apache/kafka/raft/RaftUtil.java:754-759 | raft/src/main/java/org/apache/kafka/raft/RaftUtil.java:761-766 | raft/src/main/java/org/apache/kafka/raft/RaftUtil.java:768-773 — These 7 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 7 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 7 times.
D4 · Code Duplication · Members sharing a duplicated core (6 members, 50+ identical tokens) · ×2
  • Members sharing a duplicated core (6 members, 50+ identical tokens) streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredKeyValueStore.java:254 — streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredKeyValueStore.java:254-276 | streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredSessionStore.java:441-463 | streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredTimestampedKeyValueStore.java:141-163 | streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredTimestampedKeyValueStoreWithHeaders.java:319-341 | streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredVersionedKeyValueStore.java:193-215 | streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredWindowStore.java:443-465 — These 6 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 6 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 6 times.
  • Members sharing a duplicated core (6 members, 50+ identical tokens) streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredSessionStoreWithHeaders.java:86 — streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredSessionStoreWithHeaders.java:86-140 | streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredSessionStoreWithHeaders.java:143-181 | streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredTimestampedKeyValueStoreWithHeaders.java:155-197 | streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredTimestampedKeyValueStoreWithHeaders.java:201-241 | streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredTimestampedKeyValueStoreWithHeaders.java:268-303 | streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredTimestampedWindowStoreWithHeaders.java:97-139 — These 6 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 6 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 6 times.
D4 · Code Duplication · Duplicated block (25 lines × 2) · ×2
  • Duplicated block (25 lines × 2) tools/src/main/java/org/apache/kafka/tools/VerifiableConsumer.java:526 — tools/src/main/java/org/apache/kafka/tools/VerifiableConsumer.java:526-550 | tools/src/main/java/org/apache/kafka/tools/VerifiableShareConsumer.java:585-609 — before extracting anything, compare `tools/src/main/java/org/apache/kafka/tools/VerifiableConsumer.java` and `tools/src/main/java/org/apache/kafka/tools/VerifiableShareConsumer.java` as WHOLE FILES: this scan already matched 9 separate duplicated blocks between them, totalling at least 130 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `tools/src/main/java/org/apache/kafka/tools/VerifiableConsumer.java:553` calls `setDefault` and `tools/src/main/java/org/apache/kafka/tools/VerifiableShareConsumer.java:612` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (25 lines × 2) tools/src/main/java/org/apache/kafka/tools/consumer/ConsoleConsumerOptions.java:371 — tools/src/main/java/org/apache/kafka/tools/consumer/ConsoleConsumerOptions.java:371-395 | tools/src/main/java/org/apache/kafka/tools/consumer/ConsoleShareConsumerOptions.java:254-278 — before extracting anything, compare `tools/src/main/java/org/apache/kafka/tools/consumer/ConsoleConsumerOptions.java` and `tools/src/main/java/org/apache/kafka/tools/consumer/ConsoleShareConsumerOptions.java` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 157 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
D4 · Code Duplication · Duplicated block (23 lines × 2) · ×2
  • Duplicated block (23 lines × 2) clients/src/main/java/org/apache/kafka/clients/consumer/internals/ShareSessionHandler.java:290 — clients/src/main/java/org/apache/kafka/clients/consumer/internals/ShareSessionHandler.java:290-312 | clients/src/main/java/org/apache/kafka/clients/consumer/internals/ShareSessionHandler.java:327-349 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `clients/src/main/java/org/apache/kafka/clients/consumer/internals/ShareSessionHandler.java:290` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. Note first that the copies are not typed on the same thing: the declarations holding them bind `response` to `ShareFetchResponse` in one and `ShareAcknowledgeResponse` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `clients/src/main/java/org/apache/kafka/clients/consumer/internals/ShareSessionHandler.java:284` calls `error` and `clients/src/main/java/org/apache/kafka/clients/consumer/internals/ShareSessionHandler.java:323` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (23 lines × 2) jmh-benchmarks/src/main/java/org/apache/kafka/jmh/assignor/AssignorBenchmarkUtils.java:241 — jmh-benchmarks/src/main/java/org/apache/kafka/jmh/assignor/AssignorBenchmarkUtils.java:241-263 | jmh-benchmarks/src/main/java/org/apache/kafka/jmh/assignor/AssignorBenchmarkUtils.java:325-347 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `jmh-benchmarks/src/main/java/org/apache/kafka/jmh/assignor/AssignorBenchmarkUtils.java:241` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (22–23 lines × 2) · ×2
  • Duplicated block (22–23 lines × 2) streams/src/main/java/org/apache/kafka/streams/kstream/internals/graph/OptimizableRepartitionNode.java:68 — streams/src/main/java/org/apache/kafka/streams/kstream/internals/graph/OptimizableRepartitionNode.java:68-90 | streams/src/main/java/org/apache/kafka/streams/kstream/internals/graph/UnoptimizableRepartitionNode.java:54-75 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
  • Duplicated block (22–23 lines × 2) streams/src/main/java/org/apache/kafka/streams/state/internals/RocksDBVersionedStore.java:997 — streams/src/main/java/org/apache/kafka/streams/state/internals/RocksDBVersionedStore.java:997-1018 | streams/src/main/java/org/apache/kafka/streams/state/internals/RocksDBVersionedStore.java:1039-1061 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `streams/src/main/java/org/apache/kafka/streams/state/internals/RocksDBVersionedStore.java:997` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (13–17 lines × 2) · ×2
  • Duplicated block (13–17 lines × 2) connect/runtime/src/main/java/org/apache/kafka/connect/runtime/distributed/DistributedHerder.java:1790 — connect/runtime/src/main/java/org/apache/kafka/connect/runtime/distributed/DistributedHerder.java:1790-1806 | connect/runtime/src/main/java/org/apache/kafka/connect/runtime/standalone/StandaloneHerder.java:500-512 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `connect/runtime/src/main/java/org/apache/kafka/connect/runtime/distributed/DistributedHerder.java:1790` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (13–17 lines × 2) streams/src/main/java/org/apache/kafka/streams/kstream/internals/KStreamSlidingWindowAggregate.java:204 — streams/src/main/java/org/apache/kafka/streams/kstream/internals/KStreamSlidingWindowAggregate.java:204-220 | streams/src/main/java/org/apache/kafka/streams/kstream/internals/KStreamSlidingWindowAggregate.java:328-340 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `streams/src/main/java/org/apache/kafka/streams/kstream/internals/KStreamSlidingWindowAggregate.java:204` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (11–14 lines × 2) · ×2
  • Duplicated block (11–14 lines × 2) core/src/main/java/kafka/server/share/SharePartition.java:1168 — core/src/main/java/kafka/server/share/SharePartition.java:1168-1178 | core/src/main/java/kafka/server/share/SharePartition.java:2387-2400 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `core/src/main/java/kafka/server/share/SharePartition.java:1168` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (11–14 lines × 2) jmh-benchmarks/src/main/java/org/apache/kafka/jmh/server/CheckpointBench.java:139 — jmh-benchmarks/src/main/java/org/apache/kafka/jmh/server/CheckpointBench.java:139-152 | jmh-benchmarks/src/main/java/org/apache/kafka/jmh/server/PartitionCreationBench.java:147-157 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
D4 · Code Duplication · Duplicated block (11–13 lines × 2) · ×2
  • Duplicated block (11–13 lines × 2) streams/src/main/java/org/apache/kafka/streams/state/Stores.java:220 — streams/src/main/java/org/apache/kafka/streams/state/Stores.java:220-230 | streams/src/main/java/org/apache/kafka/streams/state/Stores.java:441-453 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (11–13 lines × 2) tools/src/main/java/org/apache/kafka/tools/TransactionalMessageCopier.java:79 — tools/src/main/java/org/apache/kafka/tools/TransactionalMessageCopier.java:79-91 | tools/src/main/java/org/apache/kafka/tools/TransactionalMessageCopier.java:97-107 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `tools/src/main/java/org/apache/kafka/tools/TransactionalMessageCopier.java:79` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (11–12 lines × 2) · ×2
  • Duplicated block (11–12 lines × 2) connect/mirror/src/main/java/org/apache/kafka/connect/mirror/MirrorUtils.java:306 — connect/mirror/src/main/java/org/apache/kafka/connect/mirror/MirrorUtils.java:306-317 | connect/runtime/src/main/java/org/apache/kafka/connect/util/TopicAdmin.java:443-453 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `connect/mirror/src/main/java/org/apache/kafka/connect/mirror/MirrorUtils.java:306` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (11–12 lines × 2) streams/src/main/java/org/apache/kafka/streams/state/internals/AbstractRocksDBTimeOrderedSegmentedBytesStore.java:263 — streams/src/main/java/org/apache/kafka/streams/state/internals/AbstractRocksDBTimeOrderedSegmentedBytesStore.java:263-274 | streams/src/main/java/org/apache/kafka/streams/state/internals/AbstractRocksDBTimeOrderedSegmentedBytesStore.java:339-349 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `streams/src/main/java/org/apache/kafka/streams/state/internals/AbstractRocksDBTimeOrderedSegmentedBytesStore.java:263` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (9–10 lines × 4) · ×2
  • Duplicated block (9–10 lines × 4) streams/src/main/java/org/apache/kafka/streams/kstream/internals/KGroupedStreamImpl.java:90 — streams/src/main/java/org/apache/kafka/streams/kstream/internals/KGroupedStreamImpl.java:90-99 | streams/src/main/java/org/apache/kafka/streams/kstream/internals/SessionWindowedKStreamImpl.java:151-159 | streams/src/main/java/org/apache/kafka/streams/kstream/internals/SlidingWindowedKStreamImpl.java:132-141 | streams/src/main/java/org/apache/kafka/streams/kstream/internals/TimeWindowedKStreamImpl.java:149-158 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 4 call sites, so a change lands once. Note first that the copies are not typed on the same thing: the declarations holding them bind `materialized` to `Materialized<K, V, KeyValueStore<Bytes, byte[]>>` in one and `Materialized<K, V, SessionStore<Bytes, byte[]>>` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `streams/src/main/java/org/apache/kafka/streams/kstream/internals/SessionWindowedKStreamImpl.java:149` calls `aggregatorFromReducer` and `streams/src/main/java/org/apache/kafka/streams/kstream/internals/KGroupedStreamImpl.java:87` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (9–10 lines × 4) streams/src/main/java/org/apache/kafka/streams/state/internals/CachingKeyValueStore.java:549 — streams/src/main/java/org/apache/kafka/streams/state/internals/CachingKeyValueStore.java:549-557 | streams/src/main/java/org/apache/kafka/streams/state/internals/CachingSessionStore.java:448-457 | streams/src/main/java/org/apache/kafka/streams/state/internals/CachingWindowStore.java:391-400 | streams/src/main/java/org/apache/kafka/streams/state/internals/TimeOrderedCachingWindowStore.java:504-513 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 4 call sites, so a change lands once.
D4 · Code Duplication · Duplicated block (7–10 lines × 3) · ×2
  • Duplicated block (7–10 lines × 3) group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java:1680 — group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java:1680-1686 | group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java:1711-1717 | group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java:1914-1923 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java:1680` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately. Note first that the copies are not typed on the same thing: the declarations holding them bind `member` to `ConsumerGroupMember` in one and `ShareGroupMember` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
  • Duplicated block (7–10 lines × 3) tools/src/main/java/org/apache/kafka/tools/GroupOffsetsResetter.java:310 — tools/src/main/java/org/apache/kafka/tools/GroupOffsetsResetter.java:310-319 | tools/src/main/java/org/apache/kafka/tools/GroupOffsetsResetter.java:323-332 | tools/src/main/java/org/apache/kafka/tools/GroupOffsetsResetter.java:357-363 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `tools/src/main/java/org/apache/kafka/tools/GroupOffsetsResetter.java:310` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (7–9 lines × 2) · ×2
  • Duplicated block (7–9 lines × 2) connect/runtime/src/main/java/org/apache/kafka/connect/storage/KafkaConfigBackingStore.java:950 — connect/runtime/src/main/java/org/apache/kafka/connect/storage/KafkaConfigBackingStore.java:950-956 | connect/runtime/src/main/java/org/apache/kafka/connect/storage/KafkaConfigBackingStore.java:1237-1245 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (7–9 lines × 2) storage/src/main/java/org/apache/kafka/storage/internals/log/LogValidator.java:200 — storage/src/main/java/org/apache/kafka/storage/internals/log/LogValidator.java:200-206 | storage/src/main/java/org/apache/kafka/storage/internals/log/LogValidator.java:242-250 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `storage/src/main/java/org/apache/kafka/storage/internals/log/LogValidator.java:200` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (6–8 lines × 2) · ×2
  • Duplicated block (6–8 lines × 2) server-common/src/main/java/org/apache/kafka/server/share/persister/DefaultStatePersister.java:348 — server-common/src/main/java/org/apache/kafka/server/share/persister/DefaultStatePersister.java:348-353 | server-common/src/main/java/org/apache/kafka/server/share/persister/ReadShareGroupStateResult.java:44-51 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `server-common/src/main/java/org/apache/kafka/server/share/persister/DefaultStatePersister.java:348` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (6–8 lines × 2) trogdor/src/main/java/org/apache/kafka/trogdor/workload/ConnectionStressWorker.java:114 — trogdor/src/main/java/org/apache/kafka/trogdor/workload/ConnectionStressWorker.java:114-119 | trogdor/src/main/java/org/apache/kafka/trogdor/workload/SustainedConnectionWorker.java:127-134 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
D4 · Code Duplication · Duplicated block (4–5 lines × 3) · ×2
  • Duplicated block (4–5 lines × 3) clients/src/main/java/org/apache/kafka/clients/consumer/internals/AsyncKafkaConsumer.java:485 — clients/src/main/java/org/apache/kafka/clients/consumer/internals/AsyncKafkaConsumer.java:485-489 | clients/src/main/java/org/apache/kafka/clients/consumer/internals/ClassicKafkaConsumer.java:177-180 | clients/src/main/java/org/apache/kafka/clients/consumer/internals/ShareConsumerImpl.java:259-263 — before extracting anything, compare `clients/src/main/java/org/apache/kafka/clients/consumer/internals/AsyncKafkaConsumer.java` and `clients/src/main/java/org/apache/kafka/clients/consumer/internals/ClassicKafkaConsumer.java` as WHOLE FILES: this scan already matched 11 separate duplicated blocks between them, totalling at least 102 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (4–5 lines × 3) tools/src/main/java/org/apache/kafka/tools/DeleteRecordsCommand.java:95 — tools/src/main/java/org/apache/kafka/tools/DeleteRecordsCommand.java:95-100 | tools/src/main/java/org/apache/kafka/tools/LeaderElectionCommand.java:227-231 | tools/src/main/java/org/apache/kafka/tools/reassign/ReassignPartitionsCommand.java:1411-1414 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. Read the line range as the matched WINDOW rather than a finished unit: at `tools/src/main/java/org/apache/kafka/tools/DeleteRecordsCommand.java:95` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
X18 · Disposal-pattern correctness · Owned disposable field is never released · ×2
  • Owned disposable field is never released clients/src/main/java/org/apache/kafka/clients/consumer/internals/AbstractCoordinator.java:197 — `AbstractCoordinator` declares `close()` — so it has told every caller, and every try-with-resources, that it holds something worth releasing — and it creates `sensors` itself (line 197, `new GroupCoordinatorMetrics(…)`), which makes that instance its own. But `sensors` is named in none of the methods the disposal search covered: `close` (line 1120), `close` (line 1127), `closeHeartbeatThread` (line 433), `onLeavePrepare` (line 263), `maybeLeaveGroup` (line 1168), `checkAndGetCoordinator` (line 981), `shouldSendLeaveGroupRequest` (line 1188), `resetGenerationOnLeaveGroup` (line 1083), `markCoordinatorUnknown` (line 994), `markCoordinatorUnknown` (line 998), `markCoordinatorUnknown` (line 1002), `coordinatorUnknown` (line 971), `isDynamicMember` (line 1196), `resetStateAndRejoin` (line 1072), `resetStateAndGeneration` (line 1059), `requestRejoin` (line 1094), `requestRejoin` (line 1105) — that is `close()` plus every method it calls on `this` BY NAME, so a release reached through a superclass, a callback or a registry is not followed and is worth checking before acting. The field is released nowhere else in the class and is never handed to anything else, so no other owner can be releasing it. On what was read, closing this object releases everything except the one thing it owns: whatever `new GroupCoordinatorMetrics(…)` holds — a file descriptor, a socket, a pool's live threads — outlives it, and a long-running process runs out of them one closed instance at a time. Release it in `close()` (`sensors.close()`), or, if it truly does not need releasing, drop the `close()` so the claim and the behaviour agree.
  • Owned disposable field is never released streams/src/main/java/org/apache/kafka/streams/kstream/internals/KTableTransformValues.java:108 — `KTableTransformValuesProcessor` declares `close()` — so it has told every caller, and every try-with-resources, that it holds something worth releasing — and it creates `store` itself (line 108, `new KeyValueStoreWrapper(…)`), which makes that instance its own. But `store` is named in none of the methods the disposal search covered: `close` (line 135) — that is `close()` plus every method it calls on `this` BY NAME, so a release reached through a superclass, a callback or a registry is not followed and is worth checking before acting. The field is released nowhere else in the class and is never handed to anything else, so no other owner can be releasing it. On what was read, closing this object releases everything except the one thing it owns: whatever `new KeyValueStoreWrapper(…)` holds — a file descriptor, a socket, a pool's live threads — outlives it, and a long-running process runs out of them one closed instance at a time. Release it in `close()` (`store.close()`), or, if it truly does not need releasing, drop the `close()` so the claim and the behaviour agree.
D1 · Cyclomatic Complexity · TransactionCoordinator.endTransaction (cyclomatic 65) · ×1
  • TransactionCoordinator.endTransaction (cyclomatic 65) core/src/main/scala/kafka/coordinator/transaction/TransactionCoordinator.scala:773 — TransactionCoordinator.endTransaction has cyclomatic complexity 65 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · TransactionCoordinator.endTransactionWithTV1 (cyclomatic 46) · ×1
  • TransactionCoordinator.endTransactionWithTV1 (cyclomatic 46) core/src/main/scala/kafka/coordinator/transaction/TransactionCoordinator.scala:544 — TransactionCoordinator.endTransactionWithTV1 has cyclomatic complexity 46 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · GroupMetadataManager.streamsGroupHeartbeat (cyclomatic 43) · ×1
  • GroupMetadataManager.streamsGroupHeartbeat (cyclomatic 43) group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java:2113 — GroupMetadataManager.streamsGroupHeartbeat has cyclomatic complexity 43 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · JsonConverter.convertToJson (cyclomatic 40) · ×1
  • JsonConverter.convertToJson (cyclomatic 40) connect/json/src/main/java/org/apache/kafka/connect/json/JsonConverter.java:586 — JsonConverter.convertToJson has cyclomatic complexity 40 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · ConnectHeaders.checkSchemaMatches (cyclomatic 39) · ×1
  • ConnectHeaders.checkSchemaMatches (cyclomatic 39) connect/api/src/main/java/org/apache/kafka/connect/header/ConnectHeaders.java:399 — ConnectHeaders.checkSchemaMatches has cyclomatic complexity 39 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · JsonConverter.asConnectSchema (cyclomatic 39) · ×1
  • JsonConverter.asConnectSchema (cyclomatic 39) connect/json/src/main/java/org/apache/kafka/connect/json/JsonConverter.java:455 — JsonConverter.asConnectSchema has cyclomatic complexity 39 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · SchemaGenerator.fieldTypeToSchemaType (cyclomatic 38) · ×1
  • SchemaGenerator.fieldTypeToSchemaType (cyclomatic 38) generator/src/main/java/org/apache/kafka/message/SchemaGenerator.java:221 — SchemaGenerator.fieldTypeToSchemaType has cyclomatic complexity 38 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · ConfigCommandOptions.checkArgs (cyclomatic 37) · ×1
  • ConfigCommandOptions.checkArgs (cyclomatic 37) tools/src/main/java/org/apache/kafka/tools/ConfigCommand.java:965 — ConfigCommandOptions.checkArgs has cyclomatic complexity 37 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · ConfigDef.parseType (cyclomatic 35) · ×1
  • ConfigDef.parseType (cyclomatic 35) clients/src/main/java/org/apache/kafka/common/config/ConfigDef.java:703 — ConfigDef.parseType has cyclomatic complexity 35 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · ConfigCommand.alterConfig (cyclomatic 34) · ×1
  • ConfigCommand.alterConfig (cyclomatic 34) tools/src/main/java/org/apache/kafka/tools/ConfigCommand.java:224 — ConfigCommand.alterConfig has cyclomatic complexity 34 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · KafkaApis.handleShareFetchRequest (cyclomatic 33) · ×1
  • KafkaApis.handleShareFetchRequest (cyclomatic 33) core/src/main/scala/kafka/server/KafkaApis.scala:3280 — KafkaApis.handleShareFetchRequest has cyclomatic complexity 33 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages. This is NOT this file's highest cyclomatic complexity: KafkaApis.handle (cyclomatic 84) is higher and carries no row of its own — it was excluded as a flat dispatcher (a long switch/match over independent cases: many branches, almost no nesting), which this dimension does not treat as a refactor obligation. It is named here so the ranking you see in this file is not mistaken for the whole of it; the excluded method is counted neither in this dimension's figures nor in its score.
D1 · Cyclomatic Complexity · Selector.pollSelectionKeys (cyclomatic 32) · ×1
  • Selector.pollSelectionKeys (cyclomatic 32) clients/src/main/java/org/apache/kafka/common/network/Selector.java:514 — Selector.pollSelectionKeys has cyclomatic complexity 32 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · SharePartition.acquire (cyclomatic 32) · ×1
  • SharePartition.acquire (cyclomatic 32) core/src/main/java/kafka/server/share/SharePartition.java:756 — SharePartition.acquire has cyclomatic complexity 32 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · BrokerServer.shutdown (cyclomatic 32) · ×1
  • BrokerServer.shutdown (cyclomatic 32) core/src/main/scala/kafka/server/BrokerServer.scala:830 — BrokerServer.shutdown has cyclomatic complexity 32 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · ShareConsumeRequestManager.poll (cyclomatic 30) · ×1
  • ShareConsumeRequestManager.poll (cyclomatic 30) clients/src/main/java/org/apache/kafka/clients/consumer/internals/ShareConsumeRequestManager.java:150 — ShareConsumeRequestManager.poll has cyclomatic complexity 30 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · AbstractFetcherThread.processFetchRequest (cyclomatic 30) · ×1
  • AbstractFetcherThread.processFetchRequest (cyclomatic 30) core/src/main/scala/kafka/server/AbstractFetcherThread.scala:244 — AbstractFetcherThread.processFetchRequest has cyclomatic complexity 30 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · DistributedHerder.tick (cyclomatic 29) · ×1
  • DistributedHerder.tick (cyclomatic 29) connect/runtime/src/main/java/org/apache/kafka/connect/runtime/distributed/DistributedHerder.java:409 — DistributedHerder.tick has cyclomatic complexity 29 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · CoordinatorClient.main (cyclomatic 29) · ×1
  • CoordinatorClient.main (cyclomatic 29) trogdor/src/main/java/org/apache/kafka/trogdor/coordinator/CoordinatorClient.java:225 — CoordinatorClient.main has cyclomatic complexity 29 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · SslTransportLayer.read (cyclomatic 28) · ×1
  • SslTransportLayer.read (cyclomatic 28) clients/src/main/java/org/apache/kafka/common/network/SslTransportLayer.java:560 — SslTransportLayer.read has cyclomatic complexity 28 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · RLMExpirationTask.cleanupExpiredRemoteLogSegments (cyclomatic 28) · ×1
  • RLMExpirationTask.cleanupExpiredRemoteLogSegments (cyclomatic 28) storage/src/main/java/org/apache/kafka/server/log/remote/storage/RemoteLogManager.java:1448 — RLMExpirationTask.cleanupExpiredRemoteLogSegments has cyclomatic complexity 28 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · ShareGroupCommandOptions.checkArgs (cyclomatic 28) · ×1
  • ShareGroupCommandOptions.checkArgs (cyclomatic 28) tools/src/main/java/org/apache/kafka/tools/consumer/group/ShareGroupCommandOptions.java:175 — ShareGroupCommandOptions.checkArgs has cyclomatic complexity 28 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · MessageDataGenerator.generateVariableLengthFieldSize (cyclomatic 27) · ×1
  • MessageDataGenerator.generateVariableLengthFieldSize (cyclomatic 27) generator/src/main/java/org/apache/kafka/message/MessageDataGenerator.java:1183 — MessageDataGenerator.generateVariableLengthFieldSize has cyclomatic complexity 27 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · ConfigPostProcessor.<init> (cyclomatic 27) · ×1
  • ConfigPostProcessor.<init> (cyclomatic 27) tools/src/main/java/org/apache/kafka/tools/ProducerPerformance.java:641 — ConfigPostProcessor.<init> has cyclomatic complexity 27 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · ConfigCommand.describeResourceConfig (cyclomatic 26) · ×1
  • ConfigCommand.describeResourceConfig (cyclomatic 26) tools/src/main/java/org/apache/kafka/tools/ConfigCommand.java:489 — ConfigCommand.describeResourceConfig has cyclomatic complexity 26 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · SharePartition.maybeInitialize (cyclomatic 26) · ×1
  • SharePartition.maybeInitialize (cyclomatic 26) core/src/main/java/kafka/server/share/SharePartition.java:427 — SharePartition.maybeInitialize has cyclomatic complexity 26 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · ShareConsumeRequestManager.handleShareFetchSuccess (cyclomatic 25) · ×1
  • ShareConsumeRequestManager.handleShareFetchSuccess (cyclomatic 25) clients/src/main/java/org/apache/kafka/clients/consumer/internals/ShareConsumeRequestManager.java:905 — ShareConsumeRequestManager.handleShareFetchSuccess has cyclomatic complexity 25 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · KerberosLogin.login (cyclomatic 25) · ×1
  • KerberosLogin.login (cyclomatic 25) clients/src/main/java/org/apache/kafka/common/security/kerberos/KerberosLogin.java:101 — KerberosLogin.login has cyclomatic complexity 25 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · Authorizer.authorizeByResourceType (cyclomatic 25) · ×1
  • Authorizer.authorizeByResourceType (cyclomatic 25) clients/src/main/java/org/apache/kafka/server/authorizer/Authorizer.java:187 — Authorizer.authorizeByResourceType has cyclomatic complexity 25 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · TargetAssignmentRecordsBuilder.build (cyclomatic 25) · ×1
  • TargetAssignmentRecordsBuilder.build (cyclomatic 25) group-coordinator/src/main/java/org/apache/kafka/coordinator/group/TargetAssignmentRecordsBuilder.java:200 — TargetAssignmentRecordsBuilder.build has cyclomatic complexity 25 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · ReplicationControlManager.createTopic (cyclomatic 25) · ×1
  • ReplicationControlManager.createTopic (cyclomatic 25) metadata/src/main/java/org/apache/kafka/controller/ReplicationControlManager.java:728 — ReplicationControlManager.createTopic has cyclomatic complexity 25 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · TaskManager.handleRevocation (cyclomatic 25) · ×1
  • TaskManager.handleRevocation (cyclomatic 25) streams/src/main/java/org/apache/kafka/streams/processor/internals/TaskManager.java:1055 — TaskManager.handleRevocation has cyclomatic complexity 25 (threshold 15). To reduce it, separate the branches: extract each independent case into its own named function so the top-level body reads as a short sequence of named decisions.
D1 · Cyclomatic Complexity · TransactionMarkerRequestCompletionHandler.onComplete (cyclomatic 25) · ×1
  • TransactionMarkerRequestCompletionHandler.onComplete (cyclomatic 25) core/src/main/scala/kafka/coordinator/transaction/TransactionMarkerRequestCompletionHandler.scala:37 — TransactionMarkerRequestCompletionHandler.onComplete has cyclomatic complexity 25 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · SaslClientAuthenticator.authenticate (cyclomatic 24) · ×1
  • SaslClientAuthenticator.authenticate (cyclomatic 24) clients/src/main/java/org/apache/kafka/common/security/authenticator/SaslClientAuthenticator.java:240 — SaslClientAuthenticator.authenticate has cyclomatic complexity 24 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · DelayedFetch.tryComplete (cyclomatic 24) · ×1
  • DelayedFetch.tryComplete (cyclomatic 24) server/src/main/java/org/apache/kafka/server/purgatory/DelayedFetch.java:116 — DelayedFetch.tryComplete has cyclomatic complexity 24 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · FieldSpecPairIterator.hasNext (cyclomatic 24) · ×1
  • FieldSpecPairIterator.hasNext (cyclomatic 24) generator/src/main/java/org/apache/kafka/message/checker/FieldSpecPairIterator.java:47 — FieldSpecPairIterator.hasNext has cyclomatic complexity 24 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · TestAnalyzer.get_build_info (cyclomatic 24) · ×1
  • TestAnalyzer.get_build_info (cyclomatic 24) .github/scripts/develocity_reports.py:313 — TestAnalyzer.get_build_info has cyclomatic complexity 24 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · TxnOffsetCommitHandler.handleResponse (cyclomatic 23) · ×1
  • TxnOffsetCommitHandler.handleResponse (cyclomatic 23) clients/src/main/java/org/apache/kafka/clients/producer/internals/TransactionManager.java:1959 — TxnOffsetCommitHandler.handleResponse has cyclomatic complexity 23 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · ClusterControlManager.registerBroker (cyclomatic 23) · ×1
  • ClusterControlManager.registerBroker (cyclomatic 23) metadata/src/main/java/org/apache/kafka/controller/ClusterControlManager.java:351 — ClusterControlManager.registerBroker has cyclomatic complexity 23 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · ConsumerGroupCommandOptions.checkArgs (cyclomatic 23) · ×1
  • ConsumerGroupCommandOptions.checkArgs (cyclomatic 23) tools/src/main/java/org/apache/kafka/tools/consumer/group/ConsumerGroupCommandOptions.java:208 — ConsumerGroupCommandOptions.checkArgs has cyclomatic complexity 23 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · KafkaApis.handleTopicMetadataRequest (cyclomatic 23) · ×1
  • KafkaApis.handleTopicMetadataRequest (cyclomatic 23) core/src/main/scala/kafka/server/KafkaApis.scala:891 — KafkaApis.handleTopicMetadataRequest has cyclomatic complexity 23 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top. This is NOT this file's highest cyclomatic complexity: KafkaApis.handle (cyclomatic 84) is higher and carries no row of its own — it was excluded as a flat dispatcher (a long switch/match over independent cases: many branches, almost no nesting), which this dimension does not treat as a refactor obligation. It is named here so the ranking you see in this file is not mistaken for the whole of it; the excluded method is counted neither in this dimension's figures nor in its score.
D1 · Cyclomatic Complexity · OffsetCommitResponseHandler.handle (cyclomatic 22) · ×1
  • OffsetCommitResponseHandler.handle (cyclomatic 22) clients/src/main/java/org/apache/kafka/clients/consumer/internals/ConsumerCoordinator.java:1361 — OffsetCommitResponseHandler.handle has cyclomatic complexity 22 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · ChunkedRecordAccumulator.append (cyclomatic 22) · ×1
  • ChunkedRecordAccumulator.append (cyclomatic 22) clients/src/main/java/org/apache/kafka/clients/producer/internals/ChunkedRecordAccumulator.java:108 — ChunkedRecordAccumulator.append has cyclomatic complexity 22 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · SslTransportLayer.doHandshake (cyclomatic 22) · ×1
  • SslTransportLayer.doHandshake (cyclomatic 22) clients/src/main/java/org/apache/kafka/common/network/SslTransportLayer.java:335 — SslTransportLayer.doHandshake has cyclomatic complexity 22 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · FileStreamSourceTask.poll (cyclomatic 22) · ×1
  • FileStreamSourceTask.poll (cyclomatic 22) connect/file/src/main/java/org/apache/kafka/connect/file/FileStreamSourceTask.java:89 — FileStreamSourceTask.poll has cyclomatic complexity 22 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · JsonConverter.asJsonSchema (cyclomatic 22) · ×1
  • JsonConverter.asJsonSchema (cyclomatic 22) connect/json/src/main/java/org/apache/kafka/connect/json/JsonConverter.java:374 — JsonConverter.asJsonSchema has cyclomatic complexity 22 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
D1 · Cyclomatic Complexity · TransactionMetadata.completeTransitionTo (cyclomatic 22) · ×1
  • TransactionMetadata.completeTransitionTo (cyclomatic 22) transaction-coordinator/src/main/java/org/apache/kafka/coordinator/transaction/TransactionMetadata.java:349 — TransactionMetadata.completeTransitionTo has cyclomatic complexity 22 (threshold 15). To reduce it, separate the branches: extract each independent case into its own named function so the top-level body reads as a short sequence of named decisions.
D1 · Cyclomatic Complexity · TransactionStateManager.appendTransactionToLog (cyclomatic 22) · ×1
  • TransactionStateManager.appendTransactionToLog (cyclomatic 22) core/src/main/scala/kafka/coordinator/transaction/TransactionStateManager.scala:660 — TransactionStateManager.appendTransactionToLog has cyclomatic complexity 22 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · KafkaConfig.validateValues (cyclomatic 22) · ×1
  • KafkaConfig.validateValues (cyclomatic 22) core/src/main/scala/kafka/server/KafkaConfig.scala:299 — KafkaConfig.validateValues has cyclomatic complexity 22 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · ConsumerCoordinator.onJoinPrepare (cyclomatic 21) · ×1
  • ConsumerCoordinator.onJoinPrepare (cyclomatic 21) clients/src/main/java/org/apache/kafka/clients/consumer/internals/ConsumerCoordinator.java:754 — ConsumerCoordinator.onJoinPrepare has cyclomatic complexity 21 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · ShareSessionHandler.newShareFetchBuilder (cyclomatic 21) · ×1
  • ShareSessionHandler.newShareFetchBuilder (cyclomatic 21) clients/src/main/java/org/apache/kafka/clients/consumer/internals/ShareSessionHandler.java:115 — ShareSessionHandler.newShareFetchBuilder has cyclomatic complexity 21 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · UnifiedLog.fetchOffsetByTimestamp (cyclomatic 21) · ×1
  • UnifiedLog.fetchOffsetByTimestamp (cyclomatic 21) storage/src/main/java/org/apache/kafka/storage/internals/log/UnifiedLog.java:1696 — UnifiedLog.fetchOffsetByTimestamp has cyclomatic complexity 21 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · JsonConverter.convertToConnect (cyclomatic 21) · ×1
  • JsonConverter.convertToConnect (cyclomatic 21) connect/json/src/main/java/org/apache/kafka/connect/json/JsonConverter.java:701 — JsonConverter.convertToConnect has cyclomatic complexity 21 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · MetaPropertiesEnsemble.verify (cyclomatic 21) · ×1
  • MetaPropertiesEnsemble.verify (cyclomatic 21) server-common/src/main/java/org/apache/kafka/metadata/properties/MetaPropertiesEnsemble.java:472 — MetaPropertiesEnsemble.verify has cyclomatic complexity 21 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · StreamThread.resetOffsets (cyclomatic 21) · ×1
  • StreamThread.resetOffsets (cyclomatic 21) streams/src/main/java/org/apache/kafka/streams/processor/internals/StreamThread.java:1671 — StreamThread.resetOffsets has cyclomatic complexity 21 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · KafkaStreams.query (cyclomatic 21) · ×1
  • KafkaStreams.query (cyclomatic 21) streams/src/main/java/org/apache/kafka/streams/KafkaStreams.java:2266 — KafkaStreams.query has cyclomatic complexity 21 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · KafkaApis.handleFetchRequest (cyclomatic 21) · ×1
  • KafkaApis.handleFetchRequest (cyclomatic 21) core/src/main/scala/kafka/server/KafkaApis.scala:568 — KafkaApis.handleFetchRequest has cyclomatic complexity 21 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages. This is NOT this file's highest cyclomatic complexity: KafkaApis.handle (cyclomatic 84) is higher and carries no row of its own — it was excluded as a flat dispatcher (a long switch/match over independent cases: many branches, almost no nesting), which this dimension does not treat as a refactor obligation. It is named here so the ranking you see in this file is not mistaken for the whole of it; the excluded method is counted neither in this dimension's figures nor in its score.
D1 · Cyclomatic Complexity · TestAnalyzer.process_chunk (cyclomatic 21) · ×1
  • TestAnalyzer.process_chunk (cyclomatic 21) .github/scripts/develocity_reports.py:226 — TestAnalyzer.process_chunk has cyclomatic complexity 21 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · OffsetCommitRequestState.onResponse (cyclomatic 20) · ×1
  • OffsetCommitRequestState.onResponse (cyclomatic 20) clients/src/main/java/org/apache/kafka/clients/consumer/internals/CommitRequestManager.java:863 — OffsetCommitRequestState.onResponse has cyclomatic complexity 20 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · MessageDataGenerator.generateClassWriter (cyclomatic 20) · ×1
  • MessageDataGenerator.generateClassWriter (cyclomatic 20) generator/src/main/java/org/apache/kafka/message/MessageDataGenerator.java:731 — MessageDataGenerator.generateClassWriter has cyclomatic complexity 20 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · StreamsPartitionAssignor.assignTasksToThreads (cyclomatic 20) · ×1
  • StreamsPartitionAssignor.assignTasksToThreads (cyclomatic 20) streams/src/main/java/org/apache/kafka/streams/processor/internals/StreamsPartitionAssignor.java:1292 — StreamsPartitionAssignor.assignTasksToThreads has cyclomatic complexity 20 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · KafkaStreams.removeStreamThread (cyclomatic 20) · ×1
  • KafkaStreams.removeStreamThread (cyclomatic 20) streams/src/main/java/org/apache/kafka/streams/KafkaStreams.java:1232 — KafkaStreams.removeStreamThread has cyclomatic complexity 20 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · DefaultMessageFormatter.writeTo (cyclomatic 20) · ×1
  • DefaultMessageFormatter.writeTo (cyclomatic 20) tools/src/main/java/org/apache/kafka/tools/consumer/DefaultMessageFormatter.java:129 — DefaultMessageFormatter.writeTo has cyclomatic complexity 20 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · StreamsResetter.maybeResetInputAndSeekToEndIntermediateTopicOffsets (cyclomatic 20) · ×1
  • StreamsResetter.maybeResetInputAndSeekToEndIntermediateTopicOffsets (cyclomatic 20) tools/src/main/java/org/apache/kafka/tools/StreamsResetter.java:225 — StreamsResetter.maybeResetInputAndSeekToEndIntermediateTopicOffsets has cyclomatic complexity 20 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · ControllerApis.deleteTopics (cyclomatic 20) · ×1
  • ControllerApis.deleteTopics (cyclomatic 20) core/src/main/scala/kafka/server/ControllerApis.scala:223 — ControllerApis.deleteTopics has cyclomatic complexity 20 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages. This is NOT this file's highest cyclomatic complexity: ControllerApis.handle (cyclomatic 45) is higher and carries no row of its own — it was excluded as a flat dispatcher (a long switch/match over independent cases: many branches, almost no nesting), which this dimension does not treat as a refactor obligation. It is named here so the ranking you see in this file is not mistaken for the whole of it; the excluded method is counted neither in this dimension's figures nor in its score.
D1 · Cyclomatic Complexity · ReplicaManager.fetchOffset (cyclomatic 20) · ×1
  • ReplicaManager.fetchOffset (cyclomatic 20) core/src/main/scala/kafka/server/ReplicaManager.scala:1459 — ReplicaManager.fetchOffset has cyclomatic complexity 20 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · JoinGroupResponseHandler.handle (cyclomatic 19) · ×1
  • JoinGroupResponseHandler.handle (cyclomatic 19) clients/src/main/java/org/apache/kafka/clients/consumer/internals/AbstractCoordinator.java:646 — JoinGroupResponseHandler.handle has cyclomatic complexity 19 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · LogManager.loadLogs (cyclomatic 19) · ×1
  • LogManager.loadLogs (cyclomatic 19) storage/src/main/java/org/apache/kafka/storage/internals/log/LogManager.java:608 — LogManager.loadLogs has cyclomatic complexity 19 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · LogValidator.validateMessagesAndAssignOffsetsCompressed (cyclomatic 19) · ×1
  • LogValidator.validateMessagesAndAssignOffsetsCompressed (cyclomatic 19) storage/src/main/java/org/apache/kafka/storage/internals/log/LogValidator.java:300 — LogValidator.validateMessagesAndAssignOffsetsCompressed has cyclomatic complexity 19 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · UnifiedLog.analyzeAndValidateRecords (cyclomatic 19) · ×1
  • UnifiedLog.analyzeAndValidateRecords (cyclomatic 19) storage/src/main/java/org/apache/kafka/storage/internals/log/UnifiedLog.java:1503 — UnifiedLog.analyzeAndValidateRecords has cyclomatic complexity 19 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · UnifiedLog.append (cyclomatic 19) · ×1
  • UnifiedLog.append (cyclomatic 19) storage/src/main/java/org/apache/kafka/storage/internals/log/UnifiedLog.java:1128 — UnifiedLog.append has cyclomatic complexity 19 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · StreamThread.runLoop (cyclomatic 19) · ×1
  • StreamThread.runLoop (cyclomatic 19) streams/src/main/java/org/apache/kafka/streams/processor/internals/StreamThread.java:975 — StreamThread.runLoop has cyclomatic complexity 19 (threshold 15). To reduce it, separate the branches: extract each independent case into its own named function so the top-level body reads as a short sequence of named decisions.
D1 · Cyclomatic Complexity · ProducerPerformance.start (cyclomatic 19) · ×1
  • ProducerPerformance.start (cyclomatic 19) tools/src/main/java/org/apache/kafka/tools/ProducerPerformance.java:70 — ProducerPerformance.start has cyclomatic complexity 19 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · KafkaApisBuilder.build (cyclomatic 19) · ×1
  • KafkaApisBuilder.build (cyclomatic 19) core/src/main/java/kafka/server/builders/KafkaApisBuilder.java:191 — KafkaApisBuilder.build has cyclomatic complexity 19 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · ConfigHelper.describeConfigs (cyclomatic 19) · ×1
  • ConfigHelper.describeConfigs (cyclomatic 19) core/src/main/scala/kafka/server/ConfigHelper.scala:82 — ConfigHelper.describeConfigs has cyclomatic complexity 19 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · KafkaApis.handleProduceRequest (cyclomatic 19) · ×1
  • KafkaApis.handleProduceRequest (cyclomatic 19) core/src/main/scala/kafka/server/KafkaApis.scala:401 — KafkaApis.handleProduceRequest has cyclomatic complexity 19 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages. This is NOT this file's highest cyclomatic complexity: KafkaApis.handle (cyclomatic 84) is higher and carries no row of its own — it was excluded as a flat dispatcher (a long switch/match over independent cases: many branches, almost no nesting), which this dimension does not treat as a refactor obligation. It is named here so the ranking you see in this file is not mistaken for the whole of it; the excluded method is counted neither in this dimension's figures nor in its score.
D1 · Cyclomatic Complexity · KafkaApis.handleStreamsGroupHeartbeat (cyclomatic 19) · ×1
  • KafkaApis.handleStreamsGroupHeartbeat (cyclomatic 19) core/src/main/scala/kafka/server/KafkaApis.scala:2815 — KafkaApis.handleStreamsGroupHeartbeat has cyclomatic complexity 19 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top. This is NOT this file's highest cyclomatic complexity: KafkaApis.handle (cyclomatic 84) is higher and carries no row of its own — it was excluded as a flat dispatcher (a long switch/match over independent cases: many branches, almost no nesting), which this dimension does not treat as a refactor obligation. It is named here so the ranking you see in this file is not mistaken for the whole of it; the excluded method is counted neither in this dimension's figures nor in its score.
D1 · Cyclomatic Complexity · BufferPool.allocateChunks (cyclomatic 18) · ×1
  • BufferPool.allocateChunks (cyclomatic 18) clients/src/main/java/org/apache/kafka/clients/producer/internals/BufferPool.java:277 — BufferPool.allocateChunks has cyclomatic complexity 18 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · LogLoader.load (cyclomatic 18) · ×1
  • LogLoader.load (cyclomatic 18) storage/src/main/java/org/apache/kafka/storage/internals/log/LogLoader.java:128 — LogLoader.load has cyclomatic complexity 18 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · SaslServerAuthenticator.authenticate (cyclomatic 18) · ×1
  • SaslServerAuthenticator.authenticate (cyclomatic 18) clients/src/main/java/org/apache/kafka/common/security/authenticator/SaslServerAuthenticator.java:254 — SaslServerAuthenticator.authenticate has cyclomatic complexity 18 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · Builder.build (cyclomatic 18) · ×1
  • Builder.build (cyclomatic 18) coordinator-common/src/main/java/org/apache/kafka/coordinator/common/runtime/CoordinatorRuntime.java:207 — Builder.build has cyclomatic complexity 18 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · ConfigurationControlManager.validateAlterConfig (cyclomatic 18) · ×1
  • ConfigurationControlManager.validateAlterConfig (cyclomatic 18) metadata/src/main/java/org/apache/kafka/controller/ConfigurationControlManager.java:355 — ConfigurationControlManager.validateAlterConfig has cyclomatic complexity 18 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · EventHandler.handleEvents (cyclomatic 18) · ×1
  • EventHandler.handleEvents (cyclomatic 18) server-common/src/main/java/org/apache/kafka/queue/KafkaEventQueue.java:211 — EventHandler.handleEvents has cyclomatic complexity 18 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · StreamThread.runOnceWithoutProcessingThreads (cyclomatic 18) · ×1
  • StreamThread.runOnceWithoutProcessingThreads (cyclomatic 18) streams/src/main/java/org/apache/kafka/streams/processor/internals/StreamThread.java:1241 — StreamThread.runOnceWithoutProcessingThreads has cyclomatic complexity 18 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · SharePartition.acquireSubsetBatchRecords (cyclomatic 18) · ×1
  • SharePartition.acquireSubsetBatchRecords (cyclomatic 18) core/src/main/java/kafka/server/share/SharePartition.java:1970 — SharePartition.acquireSubsetBatchRecords has cyclomatic complexity 18 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · SharePartition.nextFetchOffset (cyclomatic 18) · ×1
  • SharePartition.nextFetchOffset (cyclomatic 18) core/src/main/java/kafka/server/share/SharePartition.java:609 — SharePartition.nextFetchOffset has cyclomatic complexity 18 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · KafkaApis.handleWriteTxnMarkersRequest (cyclomatic 18) · ×1
  • KafkaApis.handleWriteTxnMarkersRequest (cyclomatic 18) core/src/main/scala/kafka/server/KafkaApis.scala:1755 — KafkaApis.handleWriteTxnMarkersRequest has cyclomatic complexity 18 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top. This is NOT this file's highest cyclomatic complexity: KafkaApis.handle (cyclomatic 84) is higher and carries no row of its own — it was excluded as a flat dispatcher (a long switch/match over independent cases: many branches, almost no nesting), which this dimension does not treat as a refactor obligation. It is named here so the ranking you see in this file is not mistaken for the whole of it; the excluded method is counted neither in this dimension's figures nor in its score.
D1 · Cyclomatic Complexity · GeneralAssignmentBuilder.performReassignments (cyclomatic 17) · ×1
  • GeneralAssignmentBuilder.performReassignments (cyclomatic 17) clients/src/main/java/org/apache/kafka/clients/consumer/internals/AbstractStickyAssignor.java:1388 — GeneralAssignmentBuilder.performReassignments has cyclomatic complexity 17 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · OffsetFetcherUtils.handleListOffsetResponse (cyclomatic 17) · ×1
  • OffsetFetcherUtils.handleListOffsetResponse (cyclomatic 17) clients/src/main/java/org/apache/kafka/clients/consumer/internals/OffsetFetcherUtils.java:107 — OffsetFetcherUtils.handleListOffsetResponse has cyclomatic complexity 17 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
D1 · Cyclomatic Complexity · RecordAccumulator.partitionReady (cyclomatic 17) · ×1
  • RecordAccumulator.partitionReady (cyclomatic 17) clients/src/main/java/org/apache/kafka/clients/producer/internals/RecordAccumulator.java:752 — RecordAccumulator.partitionReady has cyclomatic complexity 17 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · AddPartitionsToTxnHandler.handleResponse (cyclomatic 17) · ×1
  • AddPartitionsToTxnHandler.handleResponse (cyclomatic 17) clients/src/main/java/org/apache/kafka/clients/producer/internals/TransactionManager.java:1620 — AddPartitionsToTxnHandler.handleResponse has cyclomatic complexity 17 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · FetchSessionHandler.handleResponse (cyclomatic 17) · ×1
  • FetchSessionHandler.handleResponse (cyclomatic 17) clients/src/main/java/org/apache/kafka/clients/FetchSessionHandler.java:527 — FetchSessionHandler.handleResponse has cyclomatic complexity 17 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · SaslClientCallbackHandler.handle (cyclomatic 17) · ×1
  • SaslClientCallbackHandler.handle (cyclomatic 17) clients/src/main/java/org/apache/kafka/common/security/authenticator/SaslClientCallbackHandler.java:57 — SaslClientCallbackHandler.handle has cyclomatic complexity 17 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · RemoteLogManager.read (cyclomatic 17) · ×1
  • RemoteLogManager.read (cyclomatic 17) storage/src/main/java/org/apache/kafka/server/log/remote/storage/RemoteLogManager.java:1876 — RemoteLogManager.read has cyclomatic complexity 17 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · UniformHomogeneousAssignmentBuilder.maybeRevokePartitions (cyclomatic 17) · ×1
  • UniformHomogeneousAssignmentBuilder.maybeRevokePartitions (cyclomatic 17) group-coordinator/src/main/java/org/apache/kafka/coordinator/group/assignor/UniformHomogeneousAssignmentBuilder.java:156 — UniformHomogeneousAssignmentBuilder.maybeRevokePartitions has cyclomatic complexity 17 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · FieldType.parse (cyclomatic 17) · ×1
  • FieldType.parse (cyclomatic 17) generator/src/main/java/org/apache/kafka/message/FieldType.java:386 — FieldType.parse has cyclomatic complexity 17 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
D1 · Cyclomatic Complexity · FeatureControlManager.updateFeature (cyclomatic 17) · ×1
  • FeatureControlManager.updateFeature (cyclomatic 17) metadata/src/main/java/org/apache/kafka/controller/FeatureControlManager.java:243 — FeatureControlManager.updateFeature has cyclomatic complexity 17 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · ClientQuotasImage.describe (cyclomatic 17) · ×1
  • ClientQuotasImage.describe (cyclomatic 17) metadata/src/main/java/org/apache/kafka/image/ClientQuotasImage.java:109 — ClientQuotasImage.describe has cyclomatic complexity 17 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · GlobComponent.toRegularExpression (cyclomatic 17) · ×1
  • GlobComponent.toRegularExpression (cyclomatic 17) shell/src/main/java/org/apache/kafka/shell/glob/GlobComponent.java:56 — GlobComponent.toRegularExpression has cyclomatic complexity 17 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · AclCommandOptions.checkArgs (cyclomatic 17) · ×1
  • AclCommandOptions.checkArgs (cyclomatic 17) tools/src/main/java/org/apache/kafka/tools/AclCommand.java:544 — AclCommandOptions.checkArgs has cyclomatic complexity 17 (threshold 15). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
D1 · Cyclomatic Complexity · SharePartition.acknowledgePerOffsetBatchRecords (cyclomatic 17) · ×1
  • SharePartition.acknowledgePerOffsetBatchRecords (cyclomatic 17) core/src/main/java/kafka/server/share/SharePartition.java:2308 — SharePartition.acknowledgePerOffsetBatchRecords has cyclomatic complexity 17 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · TransactionCoordinator.handleInitProducerId (cyclomatic 17) · ×1
  • TransactionCoordinator.handleInitProducerId (cyclomatic 17) core/src/main/scala/kafka/coordinator/transaction/TransactionCoordinator.scala:118 — TransactionCoordinator.handleInitProducerId has cyclomatic complexity 17 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · KafkaApis.handleAddPartitionsToTxnRequest (cyclomatic 17) · ×1
  • KafkaApis.handleAddPartitionsToTxnRequest (cyclomatic 17) core/src/main/scala/kafka/server/KafkaApis.scala:1900 — KafkaApis.handleAddPartitionsToTxnRequest has cyclomatic complexity 17 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top. This is NOT this file's highest cyclomatic complexity: KafkaApis.handle (cyclomatic 84) is higher and carries no row of its own — it was excluded as a flat dispatcher (a long switch/match over independent cases: many branches, almost no nesting), which this dimension does not treat as a refactor obligation. It is named here so the ranking you see in this file is not mistaken for the whole of it; the excluded method is counted neither in this dimension's figures nor in its score.
D1 · Cyclomatic Complexity · ReplicaManager.readFromLog (cyclomatic 17) · ×1
  • ReplicaManager.readFromLog (cyclomatic 17) core/src/main/scala/kafka/server/ReplicaManager.scala:1771 — ReplicaManager.readFromLog has cyclomatic complexity 17 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · TestAnalyzer.get_test_results (cyclomatic 17) · ×1
  • TestAnalyzer.get_test_results (cyclomatic 17) .github/scripts/develocity_reports.py:415 — TestAnalyzer.get_test_results has cyclomatic complexity 17 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · HeartbeatThread.run (cyclomatic 16) · ×1
  • HeartbeatThread.run (cyclomatic 16) clients/src/main/java/org/apache/kafka/clients/consumer/internals/AbstractCoordinator.java:1489 — HeartbeatThread.run has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · MockConsumer.poll (cyclomatic 16) · ×1
  • MockConsumer.poll (cyclomatic 16) clients/src/main/java/org/apache/kafka/clients/consumer/MockConsumer.java:299 — MockConsumer.poll has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · Builder.build (cyclomatic 16) · ×1
  • Builder.build (cyclomatic 16) clients/src/main/java/org/apache/kafka/clients/FetchSessionHandler.java:275 — Builder.build has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · SaslServerAuthenticator.handleSaslToken (cyclomatic 16) · ×1
  • SaslServerAuthenticator.handleSaslToken (cyclomatic 16) clients/src/main/java/org/apache/kafka/common/security/authenticator/SaslServerAuthenticator.java:429 — SaslServerAuthenticator.handleSaslToken has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · DefaultSslEngineFactory.createKeystore (cyclomatic 16) · ×1
  • DefaultSslEngineFactory.createKeystore (cyclomatic 16) clients/src/main/java/org/apache/kafka/common/security/ssl/DefaultSslEngineFactory.java:279 — DefaultSslEngineFactory.createKeystore has cyclomatic complexity 16 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · ClientQuotaManager.updateQuotaTypes (cyclomatic 16) · ×1
  • ClientQuotaManager.updateQuotaTypes (cyclomatic 16) server/src/main/java/org/apache/kafka/server/quota/ClientQuotaManager.java:572 — ClientQuotaManager.updateQuotaTypes has cyclomatic complexity 16 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · DelayedRemoteListOffsets.tryComplete (cyclomatic 16) · ×1
  • DelayedRemoteListOffsets.tryComplete (cyclomatic 16) storage/src/main/java/org/apache/kafka/server/purgatory/DelayedRemoteListOffsets.java:114 — DelayedRemoteListOffsets.tryComplete has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · InitializeStateHandler.handleRequestResponse (cyclomatic 16) · ×1
  • InitializeStateHandler.handleRequestResponse (cyclomatic 16) server-common/src/main/java/org/apache/kafka/server/share/persister/PersisterStateManager.java:660 — InitializeStateHandler.handleRequestResponse has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top. This shape REPEATS in the file: 3 other methods here (ReadStateHandler.handleRequestResponse, ReadStateSummaryHandler.handleRequestResponse, DeleteStateHandler.handleRequestResponse) have the same decision points, in the same order, at the same nesting depths — so this is one pattern written 4 times rather than 4 independent problems. Splitting this body alone leaves the other 3 exactly as they are. Where these are variations on one operation, the change that clears all 4 is the shared one: lift the common shape into a single routine the variants call, parameterised by whatever genuinely differs between them, and keep in each method only the part that is not shared.
D1 · Cyclomatic Complexity · ReadStateHandler.handleRequestResponse (cyclomatic 16) · ×1
  • ReadStateHandler.handleRequestResponse (cyclomatic 16) server-common/src/main/java/org/apache/kafka/server/share/persister/PersisterStateManager.java:1046 — ReadStateHandler.handleRequestResponse has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top. This shape REPEATS in the file: 3 other methods here (InitializeStateHandler.handleRequestResponse, ReadStateSummaryHandler.handleRequestResponse, DeleteStateHandler.handleRequestResponse) have the same decision points, in the same order, at the same nesting depths — so this is one pattern written 4 times rather than 4 independent problems. Splitting this body alone leaves the other 3 exactly as they are. Where these are variations on one operation, the change that clears all 4 is the shared one: lift the common shape into a single routine the variants call, parameterised by whatever genuinely differs between them, and keep in each method only the part that is not shared.
D1 · Cyclomatic Complexity · ReadStateSummaryHandler.handleRequestResponse (cyclomatic 16) · ×1
  • ReadStateSummaryHandler.handleRequestResponse (cyclomatic 16) server-common/src/main/java/org/apache/kafka/server/share/persister/PersisterStateManager.java:1227 — ReadStateSummaryHandler.handleRequestResponse has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top. This shape REPEATS in the file: 3 other methods here (InitializeStateHandler.handleRequestResponse, ReadStateHandler.handleRequestResponse, DeleteStateHandler.handleRequestResponse) have the same decision points, in the same order, at the same nesting depths — so this is one pattern written 4 times rather than 4 independent problems. Splitting this body alone leaves the other 3 exactly as they are. Where these are variations on one operation, the change that clears all 4 is the shared one: lift the common shape into a single routine the variants call, parameterised by whatever genuinely differs between them, and keep in each method only the part that is not shared.
D1 · Cyclomatic Complexity · DeleteStateHandler.handleRequestResponse (cyclomatic 16) · ×1
  • DeleteStateHandler.handleRequestResponse (cyclomatic 16) server-common/src/main/java/org/apache/kafka/server/share/persister/PersisterStateManager.java:1401 — DeleteStateHandler.handleRequestResponse has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top. This shape REPEATS in the file: 3 other methods here (InitializeStateHandler.handleRequestResponse, ReadStateHandler.handleRequestResponse, ReadStateSummaryHandler.handleRequestResponse) have the same decision points, in the same order, at the same nesting depths — so this is one pattern written 4 times rather than 4 independent problems. Splitting this body alone leaves the other 3 exactly as they are. Where these are variations on one operation, the change that clears all 4 is the shared one: lift the common shape into a single routine the variants call, parameterised by whatever genuinely differs between them, and keep in each method only the part that is not shared.
D1 · Cyclomatic Complexity · BrokerHeartbeatResponseEvent.run (cyclomatic 16) · ×1
  • BrokerHeartbeatResponseEvent.run (cyclomatic 16) server/src/main/java/org/apache/kafka/server/BrokerLifecycleManager.java:621 — BrokerHeartbeatResponseEvent.run has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · Values.append (cyclomatic 16) · ×1
  • Values.append (cyclomatic 16) connect/api/src/main/java/org/apache/kafka/connect/data/Values.java:697 — Values.append has cyclomatic complexity 16 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · CoordinatorLoaderImpl.processMemoryRecords (cyclomatic 16) · ×1
  • CoordinatorLoaderImpl.processMemoryRecords (cyclomatic 16) coordinator-common/src/main/java/org/apache/kafka/coordinator/common/runtime/CoordinatorLoaderImpl.java:220 — CoordinatorLoaderImpl.processMemoryRecords has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · GroupMetadataManager.maybeUpdateRegularExpressions (cyclomatic 16) · ×1
  • GroupMetadataManager.maybeUpdateRegularExpressions (cyclomatic 16) group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java:3756 — GroupMetadataManager.maybeUpdateRegularExpressions has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · MessageDataGenerator.generateVariableLengthWriter (cyclomatic 16) · ×1
  • MessageDataGenerator.generateVariableLengthWriter (cyclomatic 16) generator/src/main/java/org/apache/kafka/message/MessageDataGenerator.java:960 — MessageDataGenerator.generateVariableLengthWriter has cyclomatic complexity 16 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · ScramControlManager.alterCredentials (cyclomatic 16) · ×1
  • ScramControlManager.alterCredentials (cyclomatic 16) metadata/src/main/java/org/apache/kafka/controller/ScramControlManager.java:192 — ScramControlManager.alterCredentials has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · EventHandler.enqueue (cyclomatic 16) · ×1
  • EventHandler.enqueue (cyclomatic 16) server-common/src/main/java/org/apache/kafka/queue/KafkaEventQueue.java:306 — EventHandler.enqueue has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · StoreChangelogReader.prepareChangelogs (cyclomatic 16) · ×1
  • StoreChangelogReader.prepareChangelogs (cyclomatic 16) streams/src/main/java/org/apache/kafka/streams/processor/internals/StoreChangelogReader.java:1098 — StoreChangelogReader.prepareChangelogs has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · TaskManager.tryCloseCleanActiveTasks (cyclomatic 16) · ×1
  • TaskManager.tryCloseCleanActiveTasks (cyclomatic 16) streams/src/main/java/org/apache/kafka/streams/processor/internals/TaskManager.java:1593 — TaskManager.tryCloseCleanActiveTasks has cyclomatic complexity 16 (threshold 15). To reduce it, separate the branches: extract each independent case into its own named function so the top-level body reads as a short sequence of named decisions.
D1 · Cyclomatic Complexity · GlobalStateStoreProvider.stores (cyclomatic 16) · ×1
  • GlobalStateStoreProvider.stores (cyclomatic 16) streams/src/main/java/org/apache/kafka/streams/state/internals/GlobalStateStoreProvider.java:41 — GlobalStateStoreProvider.stores has cyclomatic complexity 16 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · StreamThreadStateStoreProvider.validateAndCastStores (cyclomatic 16) · ×1
  • StreamThreadStateStoreProvider.validateAndCastStores (cyclomatic 16) streams/src/main/java/org/apache/kafka/streams/state/internals/StreamThreadStateStoreProvider.java:95 — StreamThreadStateStoreProvider.validateAndCastStores has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · TopologyConfig.<init> (cyclomatic 16) · ×1
  • TopologyConfig.<init> (cyclomatic 16) streams/src/main/java/org/apache/kafka/streams/TopologyConfig.java:206 — TopologyConfig.<init> has cyclomatic complexity 16 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · ConsumerGroupService.printMembers (cyclomatic 16) · ×1
  • ConsumerGroupService.printMembers (cyclomatic 16) tools/src/main/java/org/apache/kafka/tools/consumer/group/ConsumerGroupCommand.java:397 — ConsumerGroupService.printMembers has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · LineMessageReader.configure (cyclomatic 16) · ×1
  • LineMessageReader.configure (cyclomatic 16) tools/src/main/java/org/apache/kafka/tools/LineMessageReader.java:68 — LineMessageReader.configure has cyclomatic complexity 16 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · TransactionStateManager.loadTransactionMetadata (cyclomatic 16) · ×1
  • TransactionStateManager.loadTransactionMetadata (cyclomatic 16) core/src/main/scala/kafka/coordinator/transaction/TransactionStateManager.scala:453 — TransactionStateManager.loadTransactionMetadata has cyclomatic complexity 16 (threshold 15). To reduce it, separate the branches: extract each independent case into its own named function so the top-level body reads as a short sequence of named decisions.
D1 · Cyclomatic Complexity · KafkaApis.handleTxnOffsetCommitRequest (cyclomatic 16) · ×1
  • KafkaApis.handleTxnOffsetCommitRequest (cyclomatic 16) core/src/main/scala/kafka/server/KafkaApis.scala:2062 — KafkaApis.handleTxnOffsetCommitRequest has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top. This is NOT this file's highest cyclomatic complexity: KafkaApis.handle (cyclomatic 84) is higher and carries no row of its own — it was excluded as a flat dispatcher (a long switch/match over independent cases: many branches, almost no nesting), which this dimension does not treat as a refactor obligation. It is named here so the ranking you see in this file is not mistaken for the whole of it; the excluded method is counted neither in this dimension's figures nor in its score.
D1 · Cyclomatic Complexity · BrokerMetadataPublisher.onMetadataUpdate (cyclomatic 16) · ×1
  • BrokerMetadataPublisher.onMetadataUpdate (cyclomatic 16) core/src/main/scala/kafka/server/metadata/BrokerMetadataPublisher.scala:112 — BrokerMetadataPublisher.onMetadataUpdate has cyclomatic complexity 16 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · StorageTool.infoCommand (cyclomatic 16) · ×1
  • StorageTool.infoCommand (cyclomatic 16) REDACTED:414 — StorageTool.infoCommand has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · pr-reviewers-trailer.resolve_reviewer (cyclomatic 16) · ×1
  • pr-reviewers-trailer.resolve_reviewer (cyclomatic 16) .github/scripts/pr-reviewers-trailer.py:78 — pr-reviewers-trailer.resolve_reviewer has cyclomatic complexity 16 (threshold 15). To reduce it, separate the branches: extract each independent case into its own named function so the top-level body reads as a short sequence of named decisions.
D17 · Explicit Debt · TodoComment repeated across 22 files · ×1
  • TodoComment repeated across 22 files streams/src/testFixtures/java/org/apache/kafka/streams/tests/SmokeTestDriver.java:112 — The identical TodoComment appears in 22 files (22 occurrences) — almost certainly one boilerplate line from a single migration or decision, not 22 independent debts. Fix the systemic cause once rather than file-by-file. Text: "// However, values are also use as a timestamp of the record. (TODO: separate data and timestamp)". Source code is not a task system: track the cleanup where tasks live. (Every occurrence still counts toward the score and metrics.)
D2 · Cognitive Complexity · TransactionCoordinator.endTransaction (cognitive 182) · ×1
  • TransactionCoordinator.endTransaction (cognitive 182) core/src/main/scala/kafka/coordinator/transaction/TransactionCoordinator.scala:773 — TransactionCoordinator.endTransaction has cognitive complexity 182 (threshold 15). Drivers by points: if/else 48 (135 pts), match/switch 8 (32 pts), boolean chains 11, error handling 1 (4 pts) (nesting depth added 114). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
D2 · Cognitive Complexity · TransactionCoordinator.endTransactionWithTV1 (cognitive 123) · ×1
  • TransactionCoordinator.endTransactionWithTV1 (cognitive 123) core/src/main/scala/kafka/coordinator/transaction/TransactionCoordinator.scala:544 — TransactionCoordinator.endTransactionWithTV1 has cognitive complexity 123 (threshold 15). Drivers by points: if/else 31 (90 pts), match/switch 7 (28 pts), boolean chains 5 (nesting depth added 80). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
D2 · Cognitive Complexity · ConnectHeaders.checkSchemaMatches (cognitive 83) · ×1
  • ConnectHeaders.checkSchemaMatches (cognitive 83) connect/api/src/main/java/org/apache/kafka/connect/header/ConnectHeaders.java:399 — ConnectHeaders.checkSchemaMatches has cognitive complexity 83 (threshold 15). Drivers by points: if/else 21 (75 pts), boolean chains 5, match/switch 1 (3 pts) (nesting depth added 56). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · Selector.pollSelectionKeys (cognitive 82) · ×1
  • Selector.pollSelectionKeys (cognitive 82) clients/src/main/java/org/apache/kafka/common/network/Selector.java:514 — Selector.pollSelectionKeys has cognitive complexity 82 (threshold 15). Drivers by points: if/else 23 (55 pts), ternaries 5 (16 pts), boolean chains 6, error handling 2 (4 pts), loops 1 (nesting depth added 45). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
D2 · Cognitive Complexity · KerberosLogin.login (cognitive 73) · ×1
  • KerberosLogin.login (cognitive 73) clients/src/main/java/org/apache/kafka/common/security/kerberos/KerberosLogin.java:101 — KerberosLogin.login has cognitive complexity 73 (threshold 15). Drivers by points: if/else 21 (42 pts), error handling 6 (23 pts), loops 3 (6 pts), boolean chains 2 (nesting depth added 41). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · SchemaGenerator.fieldTypeToSchemaType (cognitive 73) · ×1
  • SchemaGenerator.fieldTypeToSchemaType (cognitive 73) generator/src/main/java/org/apache/kafka/message/SchemaGenerator.java:221 — SchemaGenerator.fieldTypeToSchemaType has cognitive complexity 73 (threshold 15). Drivers by points: if/else 33 (47 pts), ternaries 9 (26 pts) (nesting depth added 31). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · KafkaApis.handleStreamsGroupHeartbeat (cognitive 73) · ×1
  • KafkaApis.handleStreamsGroupHeartbeat (cognitive 73) core/src/main/scala/kafka/server/KafkaApis.scala:2815 — KafkaApis.handleStreamsGroupHeartbeat has cognitive complexity 73 (threshold 15). Drivers by points: if/else 23 (72 pts), boolean chains 1 (nesting depth added 49). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
D2 · Cognitive Complexity · AbstractFetcherThread.processFetchRequest (cognitive 68) · ×1
  • AbstractFetcherThread.processFetchRequest (cognitive 68) core/src/main/scala/kafka/server/AbstractFetcherThread.scala:244 — AbstractFetcherThread.processFetchRequest has cognitive complexity 68 (threshold 15). Drivers by points: if/else 17 (49 pts), error handling 4 (13 pts), boolean chains 3, match/switch 1 (3 pts) (nesting depth added 43). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
D2 · Cognitive Complexity · ConfigCommand.alterConfig (cognitive 66) · ×1
  • ConfigCommand.alterConfig (cognitive 66) tools/src/main/java/org/apache/kafka/tools/ConfigCommand.java:224 — ConfigCommand.alterConfig has cognitive complexity 66 (threshold 15). Drivers by points: if/else 27 (54 pts), boolean chains 10, error handling 1 (2 pts) (nesting depth added 28). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · JsonConverter.convertToJson (cognitive 60) · ×1
  • JsonConverter.convertToJson (cognitive 60) connect/json/src/main/java/org/apache/kafka/connect/json/JsonConverter.java:586 — JsonConverter.convertToJson has cognitive complexity 60 (threshold 15). Drivers by points: if/else 20 (34 pts), ternaries 5 (13 pts), loops 4 (9 pts), boolean chains 2, error handling 1, match/switch 1 (nesting depth added 27). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · SslTransportLayer.read (cognitive 59) · ×1
  • SslTransportLayer.read (cognitive 59) clients/src/main/java/org/apache/kafka/common/network/SslTransportLayer.java:560 — SslTransportLayer.read has cognitive complexity 59 (threshold 15). Drivers by points: if/else 21 (47 pts), boolean chains 6, error handling 1 (3 pts), loops 2 (3 pts) (nesting depth added 29). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · RLMExpirationTask.cleanupExpiredRemoteLogSegments (cognitive 59) · ×1
  • RLMExpirationTask.cleanupExpiredRemoteLogSegments (cognitive 59) storage/src/main/java/org/apache/kafka/server/log/remote/storage/RemoteLogManager.java:1448 — RLMExpirationTask.cleanupExpiredRemoteLogSegments has cognitive complexity 59 (threshold 15). Drivers by points: if/else 18 (44 pts), loops 6 (11 pts), boolean chains 4 (nesting depth added 31). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · StreamsPartitionAssignor.assignTasksToThreads (cognitive 57) · ×1
  • StreamsPartitionAssignor.assignTasksToThreads (cognitive 57) streams/src/main/java/org/apache/kafka/streams/processor/internals/StreamsPartitionAssignor.java:1292 — StreamsPartitionAssignor.assignTasksToThreads has cognitive complexity 57 (threshold 15). Drivers by points: if/else 12 (37 pts), loops 8 (19 pts), boolean chains 1 (nesting depth added 36). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
D2 · Cognitive Complexity · KafkaStreams.query (cognitive 57) · ×1
  • KafkaStreams.query (cognitive 57) streams/src/main/java/org/apache/kafka/streams/KafkaStreams.java:2266 — KafkaStreams.query has cognitive complexity 57 (threshold 15). Drivers by points: if/else 12 (31 pts), ternaries 2 (14 pts), loops 3 (7 pts), boolean chains 5 (nesting depth added 35). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
D2 · Cognitive Complexity · TestAnalyzer.process_chunk (cognitive 57) · ×1
  • TestAnalyzer.process_chunk (cognitive 57) .github/scripts/develocity_reports.py:226 — TestAnalyzer.process_chunk has cognitive complexity 57 (threshold 15). Drivers by points: if/else 11 (41 pts), error handling 2 (6 pts), boolean chains 5, loops 3 (5 pts) (nesting depth added 36). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
D2 · Cognitive Complexity · UniformHomogeneousAssignmentBuilder.maybeRevokePartitions (cognitive 56) · ×1
  • UniformHomogeneousAssignmentBuilder.maybeRevokePartitions (cognitive 56) group-coordinator/src/main/java/org/apache/kafka/coordinator/group/assignor/UniformHomogeneousAssignmentBuilder.java:156 — UniformHomogeneousAssignmentBuilder.maybeRevokePartitions has cognitive complexity 56 (threshold 15). Drivers by points: if/else 16 (47 pts), loops 3 (8 pts), boolean chains 1 (nesting depth added 36). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
D2 · Cognitive Complexity · GroupMetadataManager.streamsGroupHeartbeat (cognitive 56) · ×1
  • GroupMetadataManager.streamsGroupHeartbeat (cognitive 56) group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java:2113 — GroupMetadataManager.streamsGroupHeartbeat has cognitive complexity 56 (threshold 15). Drivers by points: if/else 33 (40 pts), boolean chains 12, ternaries 3 (4 pts) (nesting depth added 8). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
D2 · Cognitive Complexity · GlobalStateManagerImpl.reprocessState (cognitive 55) · ×1
  • GlobalStateManagerImpl.reprocessState (cognitive 55) streams/src/main/java/org/apache/kafka/streams/processor/internals/GlobalStateManagerImpl.java:320 — GlobalStateManagerImpl.reprocessState has cognitive complexity 55 (threshold 15). Drivers by points: if/else 9 (32 pts), error handling 3 (17 pts), loops 3 (6 pts) (nesting depth added 40). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ShareConsumeRequestManager.poll (cognitive 54) · ×1
  • ShareConsumeRequestManager.poll (cognitive 54) clients/src/main/java/org/apache/kafka/clients/consumer/internals/ShareConsumeRequestManager.java:150 — ShareConsumeRequestManager.poll has cognitive complexity 54 (threshold 15). Drivers by points: if/else 25 (47 pts), boolean chains 5, loops 2 (nesting depth added 22). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · FileStreamSourceTask.poll (cognitive 54) · ×1
  • FileStreamSourceTask.poll (cognitive 54) connect/file/src/main/java/org/apache/kafka/connect/file/FileStreamSourceTask.java:89 — FileStreamSourceTask.poll has cognitive complexity 54 (threshold 15). Drivers by points: if/else 12 (31 pts), error handling 4 (10 pts), loops 3 (8 pts), ternaries 1 (3 pts), boolean chains 2 (nesting depth added 32). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · CoordinatorClient.main (cognitive 52) · ×1
  • CoordinatorClient.main (cognitive 52) trogdor/src/main/java/org/apache/kafka/trogdor/coordinator/CoordinatorClient.java:225 — CoordinatorClient.main has cognitive complexity 52 (threshold 15). Drivers by points: if/else 17 (36 pts), error handling 3 (7 pts), loops 2 (6 pts), boolean chains 2, match/switch 1 (nesting depth added 27). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
D2 · Cognitive Complexity · ConfigDef.parseType (cognitive 51) · ×1
  • ConfigDef.parseType (cognitive 51) clients/src/main/java/org/apache/kafka/common/config/ConfigDef.java:703 — ConfigDef.parseType has cognitive complexity 51 (threshold 15). Drivers by points: if/else 34 (48 pts), error handling 2, match/switch 1 (nesting depth added 14). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · TargetAssignmentRecordsBuilder.build (cognitive 51) · ×1
  • TargetAssignmentRecordsBuilder.build (cognitive 51) group-coordinator/src/main/java/org/apache/kafka/coordinator/group/TargetAssignmentRecordsBuilder.java:200 — TargetAssignmentRecordsBuilder.build has cognitive complexity 51 (threshold 15). Drivers by points: if/else 20 (42 pts), loops 4 (8 pts), boolean chains 1 (nesting depth added 26). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · OffsetCommitResponseHandler.handle (cognitive 50) · ×1
  • OffsetCommitResponseHandler.handle (cognitive 50) clients/src/main/java/org/apache/kafka/clients/consumer/internals/ConsumerCoordinator.java:1361 — OffsetCommitResponseHandler.handle has cognitive complexity 50 (threshold 15). Drivers by points: if/else 21 (42 pts), boolean chains 5, loops 2 (3 pts) (nesting depth added 22). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · SharePartition.acquire (cognitive 49) · ×1
  • SharePartition.acquire (cognitive 49) core/src/main/java/kafka/server/share/SharePartition.java:756 — SharePartition.acquire has cognitive complexity 49 (threshold 15). Drivers by points: if/else 21 (39 pts), boolean chains 9, loops 1 (nesting depth added 18). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ConfigCommand.describeResourceConfig (cognitive 48) · ×1
  • ConfigCommand.describeResourceConfig (cognitive 48) tools/src/main/java/org/apache/kafka/tools/ConfigCommand.java:489 — ConfigCommand.describeResourceConfig has cognitive complexity 48 (threshold 15). Drivers by points: if/else 22 (38 pts), ternaries 2 (5 pts), boolean chains 3, loops 2 (nesting depth added 19). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · DistributedHerder.tick (cognitive 47) · ×1
  • DistributedHerder.tick (cognitive 47) connect/runtime/src/main/java/org/apache/kafka/connect/runtime/distributed/DistributedHerder.java:409 — DistributedHerder.tick has cognitive complexity 47 (threshold 15). Drivers by points: if/else 22 (32 pts), error handling 4 (7 pts), ternaries 4 (6 pts), boolean chains 1, loops 1 (nesting depth added 15). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ReplicationControlManager.createTopic (cognitive 47) · ×1
  • ReplicationControlManager.createTopic (cognitive 47) metadata/src/main/java/org/apache/kafka/controller/ReplicationControlManager.java:728 — ReplicationControlManager.createTopic has cognitive complexity 47 (threshold 15). Drivers by points: if/else 14 (26 pts), loops 5 (9 pts), ternaries 3 (7 pts), error handling 2 (3 pts), boolean chains 2 (nesting depth added 21). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · TransactionMarkerRequestCompletionHandler.onComplete (cognitive 47) · ×1
  • TransactionMarkerRequestCompletionHandler.onComplete (cognitive 47) core/src/main/scala/kafka/coordinator/transaction/TransactionMarkerRequestCompletionHandler.scala:37 — TransactionMarkerRequestCompletionHandler.onComplete has cognitive complexity 47 (threshold 15). Drivers by points: if/else 11 (26 pts), match/switch 3 (12 pts), loops 3 (9 pts) (nesting depth added 30). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · TestAnalyzer.get_build_info (cognitive 47) · ×1
  • TestAnalyzer.get_build_info (cognitive 47) .github/scripts/develocity_reports.py:313 — TestAnalyzer.get_build_info has cognitive complexity 47 (threshold 15). Drivers by points: if/else 13 (31 pts), loops 4 (8 pts), boolean chains 3, ternaries 3, error handling 1 (2 pts) (nesting depth added 23). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
D2 · Cognitive Complexity · StreamThread.resetOffsets (cognitive 46) · ×1
  • StreamThread.resetOffsets (cognitive 46) streams/src/main/java/org/apache/kafka/streams/processor/internals/StreamThread.java:1671 — StreamThread.resetOffsets has cognitive complexity 46 (threshold 15). Drivers by points: if/else 23 (39 pts), loops 2 (4 pts), error handling 1 (3 pts) (nesting depth added 20). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · GeneralAssignmentBuilder.performReassignments (cognitive 45) · ×1
  • GeneralAssignmentBuilder.performReassignments (cognitive 45) clients/src/main/java/org/apache/kafka/clients/consumer/internals/AbstractStickyAssignor.java:1388 — GeneralAssignmentBuilder.performReassignments has cognitive complexity 45 (threshold 15). Drivers by points: if/else 8 (30 pts), loops 4 (11 pts), boolean chains 4 (nesting depth added 29). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · Authorizer.authorizeByResourceType (cognitive 45) · ×1
  • Authorizer.authorizeByResourceType (cognitive 45) clients/src/main/java/org/apache/kafka/server/authorizer/Authorizer.java:187 — Authorizer.authorizeByResourceType has cognitive complexity 45 (threshold 15). Drivers by points: if/else 12 (29 pts), loops 4 (7 pts), match/switch 2 (5 pts), boolean chains 4 (nesting depth added 23). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · InternalTopologyBuilder.subtopologyToTopicsInfo (cognitive 45) · ×1
  • InternalTopologyBuilder.subtopologyToTopicsInfo (cognitive 45) streams/src/main/java/org/apache/kafka/streams/processor/internals/InternalTopologyBuilder.java:1196 — InternalTopologyBuilder.subtopologyToTopicsInfo has cognitive complexity 45 (threshold 15). Drivers by points: if/else 11 (34 pts), loops 4 (10 pts), boolean chains 1 (nesting depth added 29). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · KafkaApis.handleFetchRequest (cognitive 45) · ×1
  • KafkaApis.handleFetchRequest (cognitive 45) core/src/main/scala/kafka/server/KafkaApis.scala:568 — KafkaApis.handleFetchRequest has cognitive complexity 45 (threshold 15). Drivers by points: if/else 32 (42 pts), match/switch 1 (2 pts), boolean chains 1 (nesting depth added 11). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
D2 · Cognitive Complexity · TestAnalyzer.get_test_results (cognitive 45) · ×1
  • TestAnalyzer.get_test_results (cognitive 45) .github/scripts/develocity_reports.py:415 — TestAnalyzer.get_test_results has cognitive complexity 45 (threshold 15). Drivers by points: if/else 10 (27 pts), loops 7 (18 pts) (nesting depth added 28). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ShareSessionHandler.newShareFetchBuilder (cognitive 44) · ×1
  • ShareSessionHandler.newShareFetchBuilder (cognitive 44) clients/src/main/java/org/apache/kafka/clients/consumer/internals/ShareSessionHandler.java:115 — ShareSessionHandler.newShareFetchBuilder has cognitive complexity 44 (threshold 15). Drivers by points: if/else 16 (31 pts), loops 5 (11 pts), boolean chains 2 (nesting depth added 21). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ConfigCommandOptions.checkArgs (cognitive 44) · ×1
  • ConfigCommandOptions.checkArgs (cognitive 44) tools/src/main/java/org/apache/kafka/tools/ConfigCommand.java:965 — ConfigCommandOptions.checkArgs has cognitive complexity 44 (threshold 15). Drivers by points: if/else 20 (27 pts), boolean chains 14, ternaries 2, error handling 1 (nesting depth added 7). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
D2 · Cognitive Complexity · VerifiableShareConsumer.onComplete (cognitive 44) · ×1
  • VerifiableShareConsumer.onComplete (cognitive 44) tools/src/main/java/org/apache/kafka/tools/VerifiableShareConsumer.java:445 — VerifiableShareConsumer.onComplete has cognitive complexity 44 (threshold 15). Drivers by points: if/else 9 (37 pts), loops 2 (5 pts), boolean chains 1, ternaries 1 (nesting depth added 31). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
D2 · Cognitive Complexity · DelayedFetch.tryComplete (cognitive 43) · ×1
  • DelayedFetch.tryComplete (cognitive 43) server/src/main/java/org/apache/kafka/server/purgatory/DelayedFetch.java:116 — DelayedFetch.tryComplete has cognitive complexity 43 (threshold 15). Drivers by points: if/else 11 (30 pts), error handling 4 (8 pts), boolean chains 4, loops 1 (nesting depth added 23). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
D2 · Cognitive Complexity · ChunkedRecordAccumulator.append (cognitive 42) · ×1
  • ChunkedRecordAccumulator.append (cognitive 42) clients/src/main/java/org/apache/kafka/clients/producer/internals/ChunkedRecordAccumulator.java:108 — ChunkedRecordAccumulator.append has cognitive complexity 42 (threshold 15). Drivers by points: if/else 18 (36 pts), error handling 1 (3 pts), boolean chains 2, loops 1 (nesting depth added 20). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ReplicationControlManager.handleAssignReplicasToDirs (cognitive 42) · ×1
  • ReplicationControlManager.handleAssignReplicasToDirs (cognitive 42) metadata/src/main/java/org/apache/kafka/controller/ReplicationControlManager.java:2376 — ReplicationControlManager.handleAssignReplicasToDirs has cognitive complexity 42 (threshold 15). Drivers by points: if/else 10 (29 pts), ternaries 1 (7 pts), loops 3 (6 pts) (nesting depth added 28). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
D2 · Cognitive Complexity · StoreChangelogReader.unregister (cognitive 42) · ×1
  • StoreChangelogReader.unregister (cognitive 42) streams/src/main/java/org/apache/kafka/streams/processor/internals/StoreChangelogReader.java:1483 — StoreChangelogReader.unregister has cognitive complexity 42 (threshold 15). Drivers by points: if/else 7 (17 pts), error handling 2 (12 pts), ternaries 2 (12 pts), loops 1 (nesting depth added 30). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
D2 · Cognitive Complexity · ReplicaBuffer.verifyCheckSum (cognitive 42) · ×1
  • ReplicaBuffer.verifyCheckSum (cognitive 42) tools/src/main/java/org/apache/kafka/tools/ReplicaVerificationTool.java:417 — ReplicaBuffer.verifyCheckSum has cognitive complexity 42 (threshold 15). Drivers by points: if/else 10 (30 pts), loops 4 (8 pts), error handling 1 (4 pts) (nesting depth added 27). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · KafkaApis.handleShareFetchRequest (cognitive 42) · ×1
  • KafkaApis.handleShareFetchRequest (cognitive 42) core/src/main/scala/kafka/server/KafkaApis.scala:3280 — KafkaApis.handleShareFetchRequest has cognitive complexity 42 (threshold 15). Drivers by points: if/else 24 (31 pts), match/switch 3 (5 pts), boolean chains 4, error handling 2 (nesting depth added 9). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
D2 · Cognitive Complexity · CoordinatorLoaderImpl.processMemoryRecords (cognitive 41) · ×1
  • CoordinatorLoaderImpl.processMemoryRecords (cognitive 41) coordinator-common/src/main/java/org/apache/kafka/coordinator/common/runtime/CoordinatorLoaderImpl.java:220 — CoordinatorLoaderImpl.processMemoryRecords has cognitive complexity 41 (threshold 15). Drivers by points: if/else 10 (25 pts), error handling 3 (9 pts), loops 3 (7 pts) (nesting depth added 25). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · MessageDataGenerator.generateVariableLengthFieldSize (cognitive 41) · ×1
  • MessageDataGenerator.generateVariableLengthFieldSize (cognitive 41) generator/src/main/java/org/apache/kafka/message/MessageDataGenerator.java:1183 — MessageDataGenerator.generateVariableLengthFieldSize has cognitive complexity 41 (threshold 15). Drivers by points: if/else 31 (39 pts), boolean chains 2 (nesting depth added 8). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
D2 · Cognitive Complexity · ReplicaManager.fetchOffset (cognitive 41) · ×1
  • ReplicaManager.fetchOffset (cognitive 41) core/src/main/scala/kafka/server/ReplicaManager.scala:1459 — ReplicaManager.fetchOffset has cognitive complexity 41 (threshold 15). Drivers by points: if/else 20 (31 pts), error handling 3 (6 pts), boolean chains 4 (nesting depth added 14). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · RecordAccumulator.partitionReady (cognitive 40) · ×1
  • RecordAccumulator.partitionReady (cognitive 40) clients/src/main/java/org/apache/kafka/clients/producer/internals/RecordAccumulator.java:752 — RecordAccumulator.partitionReady has cognitive complexity 40 (threshold 15). Drivers by points: if/else 13 (36 pts), boolean chains 3, loops 1 (nesting depth added 23). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
D2 · Cognitive Complexity · EventHandler.handleEvents (cognitive 40) · ×1
  • EventHandler.handleEvents (cognitive 40) server-common/src/main/java/org/apache/kafka/queue/KafkaEventQueue.java:211 — EventHandler.handleEvents has cognitive complexity 40 (threshold 15). Drivers by points: if/else 16 (32 pts), ternaries 1 (3 pts), boolean chains 2, error handling 1 (2 pts), loops 1 (nesting depth added 19). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · StreamThread.maybeGetClientInstanceIds (cognitive 40) · ×1
  • StreamThread.maybeGetClientInstanceIds (cognitive 40) streams/src/main/java/org/apache/kafka/streams/processor/internals/StreamThread.java:1060 — StreamThread.maybeGetClientInstanceIds has cognitive complexity 40 (threshold 15). Drivers by points: error handling 6 (24 pts), if/else 8 (15 pts), boolean chains 1 (nesting depth added 25). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ShareConsumeRequestManager.handleShareFetchSuccess (cognitive 39) · ×1
  • ShareConsumeRequestManager.handleShareFetchSuccess (cognitive 39) clients/src/main/java/org/apache/kafka/clients/consumer/internals/ShareConsumeRequestManager.java:905 — ShareConsumeRequestManager.handleShareFetchSuccess has cognitive complexity 39 (threshold 15). Drivers by points: if/else 19 (32 pts), boolean chains 5, loops 1, ternaries 1 (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · Cleaner.buildOffsetMapForSegment (cognitive 39) · ×1
  • Cleaner.buildOffsetMapForSegment (cognitive 39) storage/src/main/java/org/apache/kafka/storage/internals/log/Cleaner.java:779 — Cleaner.buildOffsetMapForSegment has cognitive complexity 39 (threshold 15). Drivers by points: if/else 9 (28 pts), loops 3 (8 pts), error handling 1 (2 pts), boolean chains 1 (nesting depth added 25). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
D2 · Cognitive Complexity · AddPartitionsToTxnHandler.onComplete (cognitive 39) · ×1
  • AddPartitionsToTxnHandler.onComplete (cognitive 39) server/src/main/java/org/apache/kafka/server/transaction/AddPartitionsToTxnManager.java:139 — AddPartitionsToTxnHandler.onComplete has cognitive complexity 39 (threshold 15). Drivers by points: if/else 10 (22 pts), loops 3 (12 pts), ternaries 1 (3 pts), boolean chains 2 (nesting depth added 23). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
D2 · Cognitive Complexity · ShareGroupCommandOptions.checkArgs (cognitive 39) · ×1
  • ShareGroupCommandOptions.checkArgs (cognitive 39) tools/src/main/java/org/apache/kafka/tools/consumer/group/ShareGroupCommandOptions.java:175 — ShareGroupCommandOptions.checkArgs has cognitive complexity 39 (threshold 15). Drivers by points: if/else 16 (28 pts), boolean chains 10, ternaries 1 (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · BrokerServer.shutdown (cognitive 39) · ×1
  • BrokerServer.shutdown (cognitive 39) core/src/main/scala/kafka/server/BrokerServer.scala:830 — BrokerServer.shutdown has cognitive complexity 39 (threshold 15). Drivers by points: if/else 29 (32 pts), error handling 3 (7 pts) (nesting depth added 7). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
D2 · Cognitive Complexity · KafkaApis.handleTxnOffsetCommitRequest (cognitive 39) · ×1
  • KafkaApis.handleTxnOffsetCommitRequest (cognitive 39) core/src/main/scala/kafka/server/KafkaApis.scala:2062 — KafkaApis.handleTxnOffsetCommitRequest has cognitive complexity 39 (threshold 15). Drivers by points: if/else 20 (38 pts), boolean chains 1 (nesting depth added 18). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · StorageTool.infoCommand (cognitive 39) · ×1
  • StorageTool.infoCommand (cognitive 39) REDACTED:414 — StorageTool.infoCommand has cognitive complexity 39 (threshold 15). Drivers by points: if/else 22 (36 pts), error handling 1 (3 pts) (nesting depth added 16). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · FetchSessionHandler.handleResponse (cognitive 38) · ×1
  • FetchSessionHandler.handleResponse (cognitive 38) clients/src/main/java/org/apache/kafka/clients/FetchSessionHandler.java:527 — FetchSessionHandler.handleResponse has cognitive complexity 38 (threshold 15). Drivers by points: if/else 19 (37 pts), boolean chains 1 (nesting depth added 18). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · LogValidator.validateMessagesAndAssignOffsetsCompressed (cognitive 38) · ×1
  • LogValidator.validateMessagesAndAssignOffsetsCompressed (cognitive 38) storage/src/main/java/org/apache/kafka/storage/internals/log/LogValidator.java:300 — LogValidator.validateMessagesAndAssignOffsetsCompressed has cognitive complexity 38 (threshold 15). Drivers by points: if/else 15 (31 pts), boolean chains 4, loops 2 (3 pts) (nesting depth added 17). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · UnifiedLog.analyzeAndValidateRecords (cognitive 38) · ×1
  • UnifiedLog.analyzeAndValidateRecords (cognitive 38) storage/src/main/java/org/apache/kafka/storage/internals/log/UnifiedLog.java:1503 — UnifiedLog.analyzeAndValidateRecords has cognitive complexity 38 (threshold 15). Drivers by points: if/else 12 (31 pts), boolean chains 5, loops 1, ternaries 1 (nesting depth added 19). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · JsonConverter.asConnectSchema (cognitive 38) · ×1
  • JsonConverter.asConnectSchema (cognitive 38) connect/json/src/main/java/org/apache/kafka/connect/json/JsonConverter.java:455 — JsonConverter.asConnectSchema has cognitive complexity 38 (threshold 15). Drivers by points: if/else 16 (24 pts), boolean chains 9, loops 2 (4 pts), match/switch 1 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · OffsetCommitRequestState.onResponse (cognitive 37) · ×1
  • OffsetCommitRequestState.onResponse (cognitive 37) clients/src/main/java/org/apache/kafka/clients/consumer/internals/CommitRequestManager.java:863 — OffsetCommitRequestState.onResponse has cognitive complexity 37 (threshold 15). Drivers by points: if/else 14 (23 pts), ternaries 2 (7 pts), boolean chains 4, loops 2 (3 pts) (nesting depth added 15). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · MetaPropertiesEnsemble.verify (cognitive 37) · ×1
  • MetaPropertiesEnsemble.verify (cognitive 37) server-common/src/main/java/org/apache/kafka/metadata/properties/MetaPropertiesEnsemble.java:472 — MetaPropertiesEnsemble.verify has cognitive complexity 37 (threshold 15). Drivers by points: if/else 19 (36 pts), loops 1 (nesting depth added 17). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · StoreChangelogReader.prepareChangelogs (cognitive 37) · ×1
  • StoreChangelogReader.prepareChangelogs (cognitive 37) streams/src/main/java/org/apache/kafka/streams/processor/internals/StoreChangelogReader.java:1098 — StoreChangelogReader.prepareChangelogs has cognitive complexity 37 (threshold 15). Drivers by points: if/else 11 (23 pts), error handling 4 (10 pts), boolean chains 2, loops 2 (nesting depth added 18). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · StreamThread.runOnceWithoutProcessingThreads (cognitive 37) · ×1
  • StreamThread.runOnceWithoutProcessingThreads (cognitive 37) streams/src/main/java/org/apache/kafka/streams/processor/internals/StreamThread.java:1241 — StreamThread.runOnceWithoutProcessingThreads has cognitive complexity 37 (threshold 15). Drivers by points: if/else 13 (25 pts), ternaries 2 (8 pts), boolean chains 2, loops 1 (2 pts) (nesting depth added 19). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · InMemoryTimeOrderedKeyValueChangeBuffer.restoreBatch (cognitive 37) · ×1
  • InMemoryTimeOrderedKeyValueChangeBuffer.restoreBatch (cognitive 37) streams/src/main/java/org/apache/kafka/streams/state/internals/InMemoryTimeOrderedKeyValueChangeBuffer.java:355 — InMemoryTimeOrderedKeyValueChangeBuffer.restoreBatch has cognitive complexity 37 (threshold 15). Drivers by points: if/else 11 (23 pts), ternaries 3 (13 pts), loops 1 (nesting depth added 22). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
D2 · Cognitive Complexity · KafkaApis.handleWriteTxnMarkersRequest (cognitive 37) · ×1
  • KafkaApis.handleWriteTxnMarkersRequest (cognitive 37) core/src/main/scala/kafka/server/KafkaApis.scala:1755 — KafkaApis.handleWriteTxnMarkersRequest has cognitive complexity 37 (threshold 15). Drivers by points: if/else 15 (26 pts), match/switch 3 (10 pts), loops 1 (nesting depth added 18). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · InternalTopicManager.cleanUpCreatedTopics (cognitive 36) · ×1
  • InternalTopicManager.cleanUpCreatedTopics (cognitive 36) streams/src/main/java/org/apache/kafka/streams/processor/internals/InternalTopicManager.java:824 — InternalTopicManager.cleanUpCreatedTopics has cognitive complexity 36 (threshold 15). Drivers by points: if/else 7 (20 pts), error handling 2 (10 pts), loops 3 (6 pts) (nesting depth added 24). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · TaskManager.handleRevocation (cognitive 36) · ×1
  • TaskManager.handleRevocation (cognitive 36) streams/src/main/java/org/apache/kafka/streams/processor/internals/TaskManager.java:1055 — TaskManager.handleRevocation has cognitive complexity 36 (threshold 15). Drivers by points: error handling 8 (15 pts), if/else 9 (13 pts), loops 4 (5 pts), boolean chains 3 (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · SharePartition.acknowledgePerOffsetBatchRecords (cognitive 36) · ×1
  • SharePartition.acknowledgePerOffsetBatchRecords (cognitive 36) core/src/main/java/kafka/server/share/SharePartition.java:2308 — SharePartition.acknowledgePerOffsetBatchRecords has cognitive complexity 36 (threshold 15). Drivers by points: if/else 12 (28 pts), ternaries 2 (5 pts), boolean chains 2, loops 1 (nesting depth added 19). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · KafkaApis.handleTopicMetadataRequest (cognitive 36) · ×1
  • KafkaApis.handleTopicMetadataRequest (cognitive 36) core/src/main/scala/kafka/server/KafkaApis.scala:891 — KafkaApis.handleTopicMetadataRequest has cognitive complexity 36 (threshold 15). Drivers by points: if/else 18 (29 pts), boolean chains 7 (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · TestAnalyzer.get_cleared_tests (cognitive 36) · ×1
  • TestAnalyzer.get_cleared_tests (cognitive 36) .github/scripts/develocity_reports.py:740 — TestAnalyzer.get_cleared_tests has cognitive complexity 36 (threshold 15). Drivers by points: if/else 8 (25 pts), loops 2 (5 pts), error handling 1 (4 pts), boolean chains 2 (nesting depth added 23). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
D2 · Cognitive Complexity · SingleFieldPath.buildFieldPathV2 (cognitive 35) · ×1
  • SingleFieldPath.buildFieldPathV2 (cognitive 35) connect/transforms/src/main/java/org/apache/kafka/connect/transforms/field/SingleFieldPath.java:65 — SingleFieldPath.buildFieldPathV2 has cognitive complexity 35 (threshold 15). Drivers by points: if/else 10 (29 pts), loops 2 (4 pts), boolean chains 2 (nesting depth added 21). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ClusterControlManager.registerBroker (cognitive 35) · ×1
  • ClusterControlManager.registerBroker (cognitive 35) metadata/src/main/java/org/apache/kafka/controller/ClusterControlManager.java:351 — ClusterControlManager.registerBroker has cognitive complexity 35 (threshold 15). Drivers by points: if/else 19 (28 pts), loops 2 (3 pts), boolean chains 2, ternaries 1 (2 pts) (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · SharePartition.maybeInitialize (cognitive 35) · ×1
  • SharePartition.maybeInitialize (cognitive 35) core/src/main/java/kafka/server/share/SharePartition.java:427 — SharePartition.maybeInitialize has cognitive complexity 35 (threshold 15). Drivers by points: if/else 20 (28 pts), boolean chains 3, error handling 3, loops 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · StorageTool.runFeatureDependenciesCommand (cognitive 35) · ×1
  • StorageTool.runFeatureDependenciesCommand (cognitive 35) REDACTED:209 — StorageTool.runFeatureDependenciesCommand has cognitive complexity 35 (threshold 15). Drivers by points: if/else 7 (17 pts), error handling 3 (9 pts), loops 2 (6 pts), match/switch 1 (3 pts) (nesting depth added 22). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · JoinGroupResponseHandler.handle (cognitive 34) · ×1
  • JoinGroupResponseHandler.handle (cognitive 34) clients/src/main/java/org/apache/kafka/clients/consumer/internals/AbstractCoordinator.java:646 — JoinGroupResponseHandler.handle has cognitive complexity 34 (threshold 15). Drivers by points: if/else 21 (32 pts), boolean chains 2 (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · UnifiedLog.fetchOffsetByTimestamp (cognitive 34) · ×1
  • UnifiedLog.fetchOffsetByTimestamp (cognitive 34) storage/src/main/java/org/apache/kafka/storage/internals/log/UnifiedLog.java:1696 — UnifiedLog.fetchOffsetByTimestamp has cognitive complexity 34 (threshold 15). Drivers by points: if/else 13 (17 pts), ternaries 4 (11 pts), boolean chains 4, loops 1 (2 pts) (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · BalanceSubtopologyGraphConstructor.constructEdges (cognitive 34) · ×1
  • BalanceSubtopologyGraphConstructor.constructEdges (cognitive 34) streams/src/main/java/org/apache/kafka/streams/processor/internals/assignment/BalanceSubtopologyGraphConstructor.java:165 — BalanceSubtopologyGraphConstructor.constructEdges has cognitive complexity 34 (threshold 15). Drivers by points: if/else 5 (19 pts), loops 6 (10 pts), ternaries 1 (4 pts), boolean chains 1 (nesting depth added 21). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · PartitionGroup.readyToProcess (cognitive 34) · ×1
  • PartitionGroup.readyToProcess (cognitive 34) streams/src/main/java/org/apache/kafka/streams/processor/internals/PartitionGroup.java:96 — PartitionGroup.readyToProcess has cognitive complexity 34 (threshold 15). Drivers by points: if/else 15 (29 pts), loops 2 (4 pts), boolean chains 1 (nesting depth added 16). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · StreamThread.runLoop (cognitive 34) · ×1
  • StreamThread.runLoop (cognitive 34) streams/src/main/java/org/apache/kafka/streams/processor/internals/StreamThread.java:975 — StreamThread.runLoop has cognitive complexity 34 (threshold 15). Drivers by points: if/else 7 (15 pts), error handling 6 (13 pts), boolean chains 5, loops 1 (nesting depth added 15). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · KafkaApis.handleProduceRequest (cognitive 34) · ×1
  • KafkaApis.handleProduceRequest (cognitive 34) core/src/main/scala/kafka/server/KafkaApis.scala:401 — KafkaApis.handleProduceRequest has cognitive complexity 34 (threshold 15). Drivers by points: if/else 23 (27 pts), match/switch 1 (3 pts), boolean chains 2, error handling 1 (2 pts) (nesting depth added 7). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
D2 · Cognitive Complexity · TopicMetadataFetcher.getTopicMetadata (cognitive 33) · ×1
  • TopicMetadataFetcher.getTopicMetadata (cognitive 33) clients/src/main/java/org/apache/kafka/clients/consumer/internals/TopicMetadataFetcher.java:94 — TopicMetadataFetcher.getTopicMetadata has cognitive complexity 33 (threshold 15). Drivers by points: if/else 10 (22 pts), loops 3 (9 pts), boolean chains 2 (nesting depth added 18). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · TxnOffsetCommitHandler.handleResponse (cognitive 33) · ×1
  • TxnOffsetCommitHandler.handleResponse (cognitive 33) clients/src/main/java/org/apache/kafka/clients/producer/internals/TransactionManager.java:1959 — TxnOffsetCommitHandler.handleResponse has cognitive complexity 33 (threshold 15). Drivers by points: if/else 15 (22 pts), boolean chains 6, loops 2 (3 pts), ternaries 1 (2 pts) (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · UnifiedLog.analyzeAndValidateProducerState (cognitive 33) · ×1
  • UnifiedLog.analyzeAndValidateProducerState (cognitive 33) storage/src/main/java/org/apache/kafka/storage/internals/log/UnifiedLog.java:1402 — UnifiedLog.analyzeAndValidateProducerState has cognitive complexity 33 (threshold 15). Drivers by points: if/else 7 (26 pts), boolean chains 3, ternaries 1 (3 pts), loops 1 (nesting depth added 21). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
D2 · Cognitive Complexity · SslTransportLayer.doHandshake (cognitive 33) · ×1
  • SslTransportLayer.doHandshake (cognitive 33) clients/src/main/java/org/apache/kafka/common/network/SslTransportLayer.java:335 — SslTransportLayer.doHandshake has cognitive complexity 33 (threshold 15). Drivers by points: if/else 14 (29 pts), loops 1 (2 pts), boolean chains 1, match/switch 1 (nesting depth added 16). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · DelayedRemoteListOffsets.tryComplete (cognitive 33) · ×1
  • DelayedRemoteListOffsets.tryComplete (cognitive 33) storage/src/main/java/org/apache/kafka/server/purgatory/DelayedRemoteListOffsets.java:114 — DelayedRemoteListOffsets.tryComplete has cognitive complexity 33 (threshold 15). Drivers by points: if/else 11 (20 pts), ternaries 2 (6 pts), error handling 2 (4 pts), boolean chains 3 (nesting depth added 15). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · BrokerHeartbeatResponseEvent.run (cognitive 33) · ×1
  • BrokerHeartbeatResponseEvent.run (cognitive 33) server/src/main/java/org/apache/kafka/server/BrokerLifecycleManager.java:621 — BrokerHeartbeatResponseEvent.run has cognitive complexity 33 (threshold 15). Drivers by points: if/else 16 (30 pts), match/switch 1 (3 pts) (nesting depth added 16). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · TopicAssignmentPartialBuilder.assignRemainingPartitions (cognitive 33) · ×1
  • TopicAssignmentPartialBuilder.assignRemainingPartitions (cognitive 33) group-coordinator/src/main/java/org/apache/kafka/coordinator/group/assignor/SimpleHeterogeneousAssignmentBuilder.java:412 — TopicAssignmentPartialBuilder.assignRemainingPartitions has cognitive complexity 33 (threshold 15). Drivers by points: if/else 8 (28 pts), loops 2 (4 pts), ternaries 1 (nesting depth added 22). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · FieldSpecPairIterator.hasNext (cognitive 33) · ×1
  • FieldSpecPairIterator.hasNext (cognitive 33) generator/src/main/java/org/apache/kafka/message/checker/FieldSpecPairIterator.java:47 — FieldSpecPairIterator.hasNext has cognitive complexity 33 (threshold 15). Drivers by points: ternaries 7 (19 pts), match/switch 3 (8 pts), loops 3 (5 pts), if/else 1 (nesting depth added 19). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ScramControlManager.alterCredentials (cognitive 33) · ×1
  • ScramControlManager.alterCredentials (cognitive 33) metadata/src/main/java/org/apache/kafka/controller/ScramControlManager.java:192 — ScramControlManager.alterCredentials has cognitive complexity 33 (threshold 15). Drivers by points: if/else 14 (27 pts), loops 5, boolean chains 1 (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · SharePartition.nextFetchOffset (cognitive 33) · ×1
  • SharePartition.nextFetchOffset (cognitive 33) core/src/main/java/kafka/server/share/SharePartition.java:609 — SharePartition.nextFetchOffset has cognitive complexity 33 (threshold 15). Drivers by points: if/else 12 (24 pts), boolean chains 4, loops 2 (4 pts), ternaries 1 (nesting depth added 14). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · TransactionCoordinator.handleInitProducerId (cognitive 33) · ×1
  • TransactionCoordinator.handleInitProducerId (cognitive 33) core/src/main/scala/kafka/coordinator/transaction/TransactionCoordinator.scala:118 — TransactionCoordinator.handleInitProducerId has cognitive complexity 33 (threshold 15). Drivers by points: if/else 14 (23 pts), error handling 2 (5 pts), match/switch 2 (4 pts), boolean chains 1 (nesting depth added 14). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ControllerApis.deleteTopics (cognitive 33) · ×1
  • ControllerApis.deleteTopics (cognitive 33) core/src/main/scala/kafka/server/ControllerApis.scala:223 — ControllerApis.deleteTopics has cognitive complexity 33 (threshold 15). Drivers by points: if/else 22 (29 pts), boolean chains 3, loops 1 (nesting depth added 7). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
D2 · Cognitive Complexity · KafkaApis.handleAddPartitionsToTxnRequest (cognitive 33) · ×1
  • KafkaApis.handleAddPartitionsToTxnRequest (cognitive 33) core/src/main/scala/kafka/server/KafkaApis.scala:1900 — KafkaApis.handleAddPartitionsToTxnRequest has cognitive complexity 33 (threshold 15). Drivers by points: if/else 20 (28 pts), boolean chains 3, loops 1 (2 pts) (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · TestAnalyzer.get_persistent_failing_tests (cognitive 33) · ×1
  • TestAnalyzer.get_persistent_failing_tests (cognitive 33) .github/scripts/develocity_reports.py:845 — TestAnalyzer.get_persistent_failing_tests has cognitive complexity 33 (threshold 15). Drivers by points: if/else 6 (18 pts), ternaries 2 (7 pts), loops 3 (5 pts), error handling 1 (3 pts) (nesting depth added 21). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ShareConsumeRequestManager.processAcknowledgements (cognitive 32) · ×1
  • ShareConsumeRequestManager.processAcknowledgements (cognitive 32) clients/src/main/java/org/apache/kafka/clients/consumer/internals/ShareConsumeRequestManager.java:484 — ShareConsumeRequestManager.processAcknowledgements has cognitive complexity 32 (threshold 15). Drivers by points: if/else 11 (26 pts), loops 2 (6 pts) (nesting depth added 19). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
D2 · Cognitive Complexity · TopicAdmin.createOrFindTopics (cognitive 32) · ×1
  • TopicAdmin.createOrFindTopics (cognitive 32) connect/runtime/src/main/java/org/apache/kafka/connect/util/TopicAdmin.java:393 — TopicAdmin.createOrFindTopics has cognitive complexity 32 (threshold 15). Drivers by points: if/else 10 (25 pts), error handling 2 (4 pts), loops 2 (3 pts) (nesting depth added 18). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · SimpleHomogeneousAssignmentBuilder.assignRemainingPartitions (cognitive 32) · ×1
  • SimpleHomogeneousAssignmentBuilder.assignRemainingPartitions (cognitive 32) group-coordinator/src/main/java/org/apache/kafka/coordinator/group/assignor/SimpleHomogeneousAssignmentBuilder.java:344 — SimpleHomogeneousAssignmentBuilder.assignRemainingPartitions has cognitive complexity 32 (threshold 15). Drivers by points: if/else 8 (28 pts), loops 2 (4 pts) (nesting depth added 22). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ProcessorStateManager.commit (cognitive 32) · ×1
  • ProcessorStateManager.commit (cognitive 32) streams/src/main/java/org/apache/kafka/streams/processor/internals/ProcessorStateManager.java:569 — ProcessorStateManager.commit has cognitive complexity 32 (threshold 15). Drivers by points: if/else 10 (21 pts), error handling 2 (7 pts), boolean chains 2, loops 1 (2 pts) (nesting depth added 17). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · TransactionStateManager.appendTransactionToLog (cognitive 32) · ×1
  • TransactionStateManager.appendTransactionToLog (cognitive 32) core/src/main/scala/kafka/coordinator/transaction/TransactionStateManager.scala:660 — TransactionStateManager.appendTransactionToLog has cognitive complexity 32 (threshold 15). Drivers by points: if/else 15 (24 pts), match/switch 4 (7 pts), boolean chains 1 (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · KafkaApis.handleOffsetCommitRequest (cognitive 32) · ×1
  • KafkaApis.handleOffsetCommitRequest (cognitive 32) core/src/main/scala/kafka/server/KafkaApis.scala:280 — KafkaApis.handleOffsetCommitRequest has cognitive complexity 32 (threshold 15). Drivers by points: if/else 16 (31 pts), boolean chains 1 (nesting depth added 15). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · KafkaApis.handleStreamsGroupDescribe (cognitive 32) · ×1
  • KafkaApis.handleStreamsGroupDescribe (cognitive 32) core/src/main/scala/kafka/server/KafkaApis.scala:2974 — KafkaApis.handleStreamsGroupDescribe has cognitive complexity 32 (threshold 15). Drivers by points: if/else 15 (32 pts) (nesting depth added 17). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
D2 · Cognitive Complexity · ConstrainedAssignmentBuilder.assignRackAwareRoundRobin (cognitive 31) · ×1
  • ConstrainedAssignmentBuilder.assignRackAwareRoundRobin (cognitive 31) clients/src/main/java/org/apache/kafka/clients/consumer/internals/AbstractStickyAssignor.java:734 — ConstrainedAssignmentBuilder.assignRackAwareRoundRobin has cognitive complexity 31 (threshold 15). Drivers by points: if/else 10 (26 pts), ternaries 1 (3 pts), boolean chains 1, loops 1 (nesting depth added 18). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
D2 · Cognitive Complexity · ShareFetchCollector.collect (cognitive 31) · ×1
  • ShareFetchCollector.collect (cognitive 31) clients/src/main/java/org/apache/kafka/clients/consumer/internals/ShareFetchCollector.java:65 — ShareFetchCollector.collect has cognitive complexity 31 (threshold 15). Drivers by points: if/else 10 (24 pts), error handling 2 (5 pts), boolean chains 1, loops 1 (nesting depth added 17). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · BufferPool.allocateChunks (cognitive 31) · ×1
  • BufferPool.allocateChunks (cognitive 31) clients/src/main/java/org/apache/kafka/clients/producer/internals/BufferPool.java:277 — BufferPool.allocateChunks has cognitive complexity 31 (threshold 15). Drivers by points: if/else 9 (14 pts), loops 6 (14 pts), boolean chains 3 (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · SaslServerAuthenticator.handleSaslToken (cognitive 31) · ×1
  • SaslServerAuthenticator.handleSaslToken (cognitive 31) clients/src/main/java/org/apache/kafka/common/security/authenticator/SaslServerAuthenticator.java:429 — SaslServerAuthenticator.handleSaslToken has cognitive complexity 31 (threshold 15). Drivers by points: if/else 11 (21 pts), error handling 2 (4 pts), ternaries 2 (4 pts), boolean chains 2 (nesting depth added 14). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · SimpleHomogeneousAssignmentBuilder.revokeUnassignablePartitions (cognitive 31) · ×1
  • SimpleHomogeneousAssignmentBuilder.revokeUnassignablePartitions (cognitive 31) group-coordinator/src/main/java/org/apache/kafka/coordinator/group/assignor/SimpleHomogeneousAssignmentBuilder.java:225 — SimpleHomogeneousAssignmentBuilder.revokeUnassignablePartitions has cognitive complexity 31 (threshold 15). Drivers by points: if/else 8 (24 pts), loops 3 (7 pts) (nesting depth added 20). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ReplicationControlManager.alterPartition (cognitive 31) · ×1
  • ReplicationControlManager.alterPartition (cognitive 31) metadata/src/main/java/org/apache/kafka/controller/ReplicationControlManager.java:1093 — ReplicationControlManager.alterPartition has cognitive complexity 31 (threshold 15). Drivers by points: if/else 8 (23 pts), loops 3 (6 pts), boolean chains 2 (nesting depth added 18). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · RepartitionTopics.computePartitionCount (cognitive 31) · ×1
  • RepartitionTopics.computePartitionCount (cognitive 31) streams/src/main/java/org/apache/kafka/streams/processor/internals/RepartitionTopics.java:250 — RepartitionTopics.computePartitionCount has cognitive complexity 31 (threshold 15). Drivers by points: if/else 7 (26 pts), loops 2 (4 pts), boolean chains 1 (nesting depth added 21). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ConsumerGroupCommandOptions.checkArgs (cognitive 31) · ×1
  • ConsumerGroupCommandOptions.checkArgs (cognitive 31) tools/src/main/java/org/apache/kafka/tools/consumer/group/ConsumerGroupCommandOptions.java:208 — ConsumerGroupCommandOptions.checkArgs has cognitive complexity 31 (threshold 15). Drivers by points: if/else 14 (23 pts), boolean chains 7, ternaries 1 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · MockConsumer.poll (cognitive 30) · ×1
  • MockConsumer.poll (cognitive 30) clients/src/main/java/org/apache/kafka/clients/consumer/MockConsumer.java:299 — MockConsumer.poll has cognitive complexity 30 (threshold 15). Drivers by points: if/else 9 (22 pts), loops 3 (5 pts), boolean chains 3 (nesting depth added 15). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · UnifiedLog.rebuildProducerState (cognitive 30) · ×1
  • UnifiedLog.rebuildProducerState (cognitive 30) storage/src/main/java/org/apache/kafka/storage/internals/log/UnifiedLog.java:2553 — UnifiedLog.rebuildProducerState has cognitive complexity 30 (threshold 15). Drivers by points: if/else 6 (16 pts), loops 2 (5 pts), ternaries 1 (5 pts), boolean chains 4 (nesting depth added 17). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
D2 · Cognitive Complexity · SaslClientCallbackHandler.handle (cognitive 30) · ×1
  • SaslClientCallbackHandler.handle (cognitive 30) clients/src/main/java/org/apache/kafka/common/security/authenticator/SaslClientCallbackHandler.java:57 — SaslClientCallbackHandler.handle has cognitive complexity 30 (threshold 15). Drivers by points: if/else 14 (25 pts), boolean chains 4, loops 1 (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · FetchManager.newContext (cognitive 30) · ×1
  • FetchManager.newContext (cognitive 30) server/src/main/java/org/apache/kafka/server/FetchManager.java:58 — FetchManager.newContext has cognitive complexity 30 (threshold 15). Drivers by points: if/else 13 (23 pts), ternaries 1 (4 pts), boolean chains 3 (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · IncrementalCooperativeAssignor.handleLostAssignments (cognitive 30) · ×1
  • IncrementalCooperativeAssignor.handleLostAssignments (cognitive 30) connect/runtime/src/main/java/org/apache/kafka/connect/runtime/distributed/IncrementalCooperativeAssignor.java:439 — IncrementalCooperativeAssignor.handleLostAssignments has cognitive complexity 30 (threshold 15). Drivers by points: if/else 12 (21 pts), loops 2 (6 pts), boolean chains 3 (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · StickyTaskAssignor.assignStandby (cognitive 30) · ×1
  • StickyTaskAssignor.assignStandby (cognitive 30) group-coordinator/src/main/java/org/apache/kafka/coordinator/group/streams/assignor/StickyTaskAssignor.java:471 — StickyTaskAssignor.assignStandby has cognitive complexity 30 (threshold 15). Drivers by points: if/else 6 (22 pts), loops 4 (6 pts), boolean chains 2 (nesting depth added 18). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · TaskManager.tryCloseCleanActiveTasks (cognitive 30) · ×1
  • TaskManager.tryCloseCleanActiveTasks (cognitive 30) streams/src/main/java/org/apache/kafka/streams/processor/internals/TaskManager.java:1593 — TaskManager.tryCloseCleanActiveTasks has cognitive complexity 30 (threshold 15). Drivers by points: error handling 6 (13 pts), if/else 7 (12 pts), loops 3 (4 pts), boolean chains 1 (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · StreamThreadStateStoreProvider.stores (cognitive 30) · ×1
  • StreamThreadStateStoreProvider.stores (cognitive 30) streams/src/main/java/org/apache/kafka/streams/state/internals/StreamThreadStateStoreProvider.java:47 — StreamThreadStateStoreProvider.stores has cognitive complexity 30 (threshold 15). Drivers by points: if/else 8 (15 pts), ternaries 4 (7 pts), loops 2 (6 pts), boolean chains 2 (nesting depth added 14). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · KafkaStreams.removeStreamThread (cognitive 30) · ×1
  • KafkaStreams.removeStreamThread (cognitive 30) streams/src/main/java/org/apache/kafka/streams/KafkaStreams.java:1232 — KafkaStreams.removeStreamThread has cognitive complexity 30 (threshold 15). Drivers by points: if/else 15 (22 pts), boolean chains 7, loops 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · AbstractCoordinator.joinGroupIfNeeded (cognitive 29) · ×1
  • AbstractCoordinator.joinGroupIfNeeded (cognitive 29) clients/src/main/java/org/apache/kafka/clients/consumer/internals/AbstractCoordinator.java:465 — AbstractCoordinator.joinGroupIfNeeded has cognitive complexity 29 (threshold 15). Drivers by points: if/else 12 (26 pts), boolean chains 2, loops 1 (nesting depth added 14). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · CompletedFetch.nextFetchedRecord (cognitive 29) · ×1
  • CompletedFetch.nextFetchedRecord (cognitive 29) clients/src/main/java/org/apache/kafka/clients/consumer/internals/CompletedFetch.java:187 — CompletedFetch.nextFetchedRecord has cognitive complexity 29 (threshold 15). Drivers by points: if/else 10 (26 pts), boolean chains 2, loops 1 (nesting depth added 16). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ConsumerCoordinator.onJoinPrepare (cognitive 29) · ×1
  • ConsumerCoordinator.onJoinPrepare (cognitive 29) clients/src/main/java/org/apache/kafka/clients/consumer/internals/ConsumerCoordinator.java:754 — ConsumerCoordinator.onJoinPrepare has cognitive complexity 29 (threshold 15). Drivers by points: if/else 15 (21 pts), boolean chains 4, match/switch 1 (2 pts), ternaries 1 (2 pts) (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ConsumerCoordinator.poll (cognitive 29) · ×1
  • ConsumerCoordinator.poll (cognitive 29) clients/src/main/java/org/apache/kafka/clients/consumer/internals/ConsumerCoordinator.java:513 — ConsumerCoordinator.poll has cognitive complexity 29 (threshold 15). Drivers by points: if/else 10 (24 pts), ternaries 1 (4 pts), boolean chains 1 (nesting depth added 17). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
D2 · Cognitive Complexity · UnifiedLog.append (cognitive 29) · ×1
  • UnifiedLog.append (cognitive 29) storage/src/main/java/org/apache/kafka/storage/internals/log/UnifiedLog.java:1128 — UnifiedLog.append has cognitive complexity 29 (threshold 15). Drivers by points: if/else 14 (19 pts), loops 2 (4 pts), ternaries 2 (4 pts), boolean chains 2 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · InitializeStateHandler.handleRequestResponse (cognitive 29) · ×1
  • InitializeStateHandler.handleRequestResponse (cognitive 29) server-common/src/main/java/org/apache/kafka/server/share/persister/PersisterStateManager.java:660 — InitializeStateHandler.handleRequestResponse has cognitive complexity 29 (threshold 15). Drivers by points: if/else 5 (20 pts), match/switch 2 (6 pts), loops 1 (2 pts), boolean chains 1 (nesting depth added 20). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident. This shape REPEATS in the file: 3 other methods here (ReadStateHandler.handleRequestResponse, ReadStateSummaryHandler.handleRequestResponse, DeleteStateHandler.handleRequestResponse) have the same decision points, in the same order, at the same nesting depths — so this is one pattern written 4 times rather than 4 independent problems. Splitting this body alone leaves the other 3 exactly as they are. Where these are variations on one operation, the change that clears all 4 is the shared one: lift the common shape into a single routine the variants call, parameterised by whatever genuinely differs between them, and keep in each method only the part that is not shared.
D2 · Cognitive Complexity · ReadStateHandler.handleRequestResponse (cognitive 29) · ×1
  • ReadStateHandler.handleRequestResponse (cognitive 29) server-common/src/main/java/org/apache/kafka/server/share/persister/PersisterStateManager.java:1046 — ReadStateHandler.handleRequestResponse has cognitive complexity 29 (threshold 15). Drivers by points: if/else 5 (20 pts), match/switch 2 (6 pts), loops 1 (2 pts), boolean chains 1 (nesting depth added 20). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident. This shape REPEATS in the file: 3 other methods here (InitializeStateHandler.handleRequestResponse, ReadStateSummaryHandler.handleRequestResponse, DeleteStateHandler.handleRequestResponse) have the same decision points, in the same order, at the same nesting depths — so this is one pattern written 4 times rather than 4 independent problems. Splitting this body alone leaves the other 3 exactly as they are. Where these are variations on one operation, the change that clears all 4 is the shared one: lift the common shape into a single routine the variants call, parameterised by whatever genuinely differs between them, and keep in each method only the part that is not shared.
D2 · Cognitive Complexity · ReadStateSummaryHandler.handleRequestResponse (cognitive 29) · ×1
  • ReadStateSummaryHandler.handleRequestResponse (cognitive 29) server-common/src/main/java/org/apache/kafka/server/share/persister/PersisterStateManager.java:1227 — ReadStateSummaryHandler.handleRequestResponse has cognitive complexity 29 (threshold 15). Drivers by points: if/else 5 (20 pts), match/switch 2 (6 pts), loops 1 (2 pts), boolean chains 1 (nesting depth added 20). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident. This shape REPEATS in the file: 3 other methods here (InitializeStateHandler.handleRequestResponse, ReadStateHandler.handleRequestResponse, DeleteStateHandler.handleRequestResponse) have the same decision points, in the same order, at the same nesting depths — so this is one pattern written 4 times rather than 4 independent problems. Splitting this body alone leaves the other 3 exactly as they are. Where these are variations on one operation, the change that clears all 4 is the shared one: lift the common shape into a single routine the variants call, parameterised by whatever genuinely differs between them, and keep in each method only the part that is not shared.
D2 · Cognitive Complexity · DeleteStateHandler.handleRequestResponse (cognitive 29) · ×1
  • DeleteStateHandler.handleRequestResponse (cognitive 29) server-common/src/main/java/org/apache/kafka/server/share/persister/PersisterStateManager.java:1401 — DeleteStateHandler.handleRequestResponse has cognitive complexity 29 (threshold 15). Drivers by points: if/else 5 (20 pts), match/switch 2 (6 pts), loops 1 (2 pts), boolean chains 1 (nesting depth added 20). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident. This shape REPEATS in the file: 3 other methods here (InitializeStateHandler.handleRequestResponse, ReadStateHandler.handleRequestResponse, ReadStateSummaryHandler.handleRequestResponse) have the same decision points, in the same order, at the same nesting depths — so this is one pattern written 4 times rather than 4 independent problems. Splitting this body alone leaves the other 3 exactly as they are. Where these are variations on one operation, the change that clears all 4 is the shared one: lift the common shape into a single routine the variants call, parameterised by whatever genuinely differs between them, and keep in each method only the part that is not shared.
D2 · Cognitive Complexity · ConfigurationControlManager.incrementalAlterConfigResource (cognitive 29) · ×1
  • ConfigurationControlManager.incrementalAlterConfigResource (cognitive 29) metadata/src/main/java/org/apache/kafka/controller/ConfigurationControlManager.java:290 — ConfigurationControlManager.incrementalAlterConfigResource has cognitive complexity 29 (threshold 15). Drivers by points: if/else 7 (17 pts), loops 3 (9 pts), match/switch 1 (2 pts), boolean chains 1 (nesting depth added 17). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ClientQuotasImage.matches (cognitive 29) · ×1
  • ClientQuotasImage.matches (cognitive 29) metadata/src/main/java/org/apache/kafka/image/ClientQuotasImage.java:163 — ClientQuotasImage.matches has cognitive complexity 29 (threshold 15). Drivers by points: if/else 10 (18 pts), loops 5 (10 pts), boolean chains 1 (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ScramImage.describe (cognitive 29) · ×1
  • ScramImage.describe (cognitive 29) metadata/src/main/java/org/apache/kafka/image/ScramImage.java:82 — ScramImage.describe has cognitive complexity 29 (threshold 15). Drivers by points: if/else 9 (17 pts), loops 5 (11 pts), boolean chains 1 (nesting depth added 14). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · KafkaRaftClient.handleFetchResponse (cognitive 29) · ×1
  • KafkaRaftClient.handleFetchResponse (cognitive 29) raft/src/main/java/org/apache/kafka/raft/KafkaRaftClient.java:1693 — KafkaRaftClient.handleFetchResponse has cognitive complexity 29 (threshold 15). Drivers by points: if/else 18 (25 pts), ternaries 1 (3 pts), boolean chains 1 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · HistoricalIterator.hasNext (cognitive 29) · ×1
  • HistoricalIterator.hasNext (cognitive 29) server-common/src/main/java/org/apache/kafka/timeline/SnapshottableHashTable.java:208 — HistoricalIterator.hasNext has cognitive complexity 29 (threshold 15). Drivers by points: if/else 5 (19 pts), loops 4 (9 pts), boolean chains 1 (nesting depth added 19). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · InMemoryTimeOrderedKeyValueChangeBuffer.evictWhile (cognitive 29) · ×1
  • InMemoryTimeOrderedKeyValueChangeBuffer.evictWhile (cognitive 29) streams/src/main/java/org/apache/kafka/streams/state/internals/InMemoryTimeOrderedKeyValueChangeBuffer.java:442 — InMemoryTimeOrderedKeyValueChangeBuffer.evictWhile has cognitive complexity 29 (threshold 15). Drivers by points: if/else 9 (18 pts), ternaries 2 (8 pts), loops 1 (2 pts), boolean chains 1 (nesting depth added 16). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · Metadata.handleMetadataResponse (cognitive 28) · ×1
  • Metadata.handleMetadataResponse (cognitive 28) clients/src/main/java/org/apache/kafka/clients/Metadata.java:487 — Metadata.handleMetadataResponse has cognitive complexity 28 (threshold 15). Drivers by points: if/else 12 (23 pts), loops 2 (4 pts), boolean chains 1 (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · CoordinatorContext.append (cognitive 28) · ×1
  • CoordinatorContext.append (cognitive 28) coordinator-common/src/main/java/org/apache/kafka/coordinator/common/runtime/CoordinatorRuntime.java:906 — CoordinatorContext.append has cognitive complexity 28 (threshold 15). Drivers by points: if/else 9 (20 pts), loops 2 (4 pts), error handling 1 (3 pts), boolean chains 1 (nesting depth added 15). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ClientQuotasImageNode.decodeEntity (cognitive 28) · ×1
  • ClientQuotasImageNode.decodeEntity (cognitive 28) metadata/src/main/java/org/apache/kafka/image/node/ClientQuotasImageNode.java:102 — ClientQuotasImageNode.decodeEntity has cognitive complexity 28 (threshold 15). Drivers by points: if/else 12 (23 pts), match/switch 1 (4 pts), loops 1 (nesting depth added 14). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · GlobComponent.toRegularExpression (cognitive 28) · ×1
  • GlobComponent.toRegularExpression (cognitive 28) shell/src/main/java/org/apache/kafka/shell/glob/GlobComponent.java:56 — GlobComponent.toRegularExpression has cognitive complexity 28 (threshold 15). Drivers by points: if/else 11 (24 pts), match/switch 1 (2 pts), boolean chains 1, loops 1 (nesting depth added 14). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · GlobalStreamThread.run (cognitive 28) · ×1
  • GlobalStreamThread.run (cognitive 28) streams/src/main/java/org/apache/kafka/streams/processor/internals/GlobalStreamThread.java:290 — GlobalStreamThread.run has cognitive complexity 28 (threshold 15). Drivers by points: error handling 6 (15 pts), if/else 6 (11 pts), boolean chains 1, loops 1 (nesting depth added 14). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · InternalStreamsBuilder.mergeDuplicateSourceNodes (cognitive 28) · ×1
  • InternalStreamsBuilder.mergeDuplicateSourceNodes (cognitive 28) streams/src/main/java/org/apache/kafka/streams/kstream/internals/InternalStreamsBuilder.java:379 — InternalStreamsBuilder.mergeDuplicateSourceNodes has cognitive complexity 28 (threshold 15). Drivers by points: if/else 8 (23 pts), loops 2 (5 pts) (nesting depth added 18). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
D2 · Cognitive Complexity · DefaultMessageFormatter.writeTo (cognitive 28) · ×1
  • DefaultMessageFormatter.writeTo (cognitive 28) tools/src/main/java/org/apache/kafka/tools/consumer/DefaultMessageFormatter.java:129 — DefaultMessageFormatter.writeTo has cognitive complexity 28 (threshold 15). Drivers by points: if/else 13 (18 pts), boolean chains 6, loops 1 (3 pts), error handling 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · StreamsResetter.maybeResetInputAndSeekToEndIntermediateTopicOffsets (cognitive 28) · ×1
  • StreamsResetter.maybeResetInputAndSeekToEndIntermediateTopicOffsets (cognitive 28) tools/src/main/java/org/apache/kafka/tools/StreamsResetter.java:225 — StreamsResetter.maybeResetInputAndSeekToEndIntermediateTopicOffsets has cognitive complexity 28 (threshold 15). Drivers by points: if/else 14 (17 pts), loops 6 (9 pts), boolean chains 1, error handling 1 (nesting depth added 6). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
D2 · Cognitive Complexity · 1.handleResponse (cognitive 27) · ×1
  • 1.handleResponse (cognitive 27) clients/src/main/java/org/apache/kafka/clients/admin/KafkaAdminClient.java:1935 — 1.handleResponse has cognitive complexity 27 (threshold 15). Drivers by points: if/else 13 (26 pts), loops 1 (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ConstrainedAssignmentBuilder.assignOwnedPartitions (cognitive 27) · ×1
  • ConstrainedAssignmentBuilder.assignOwnedPartitions (cognitive 27) clients/src/main/java/org/apache/kafka/clients/consumer/internals/AbstractStickyAssignor.java:666 — ConstrainedAssignmentBuilder.assignOwnedPartitions has cognitive complexity 27 (threshold 15). Drivers by points: if/else 8 (17 pts), loops 4 (9 pts), boolean chains 1 (nesting depth added 14). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · OffsetFetchRequestState.onSuccess (cognitive 27) · ×1
  • OffsetFetchRequestState.onSuccess (cognitive 27) clients/src/main/java/org/apache/kafka/clients/consumer/internals/CommitRequestManager.java:1293 — OffsetFetchRequestState.onSuccess has cognitive complexity 27 (threshold 15). Drivers by points: if/else 12 (21 pts), loops 2 (3 pts), ternaries 1 (2 pts), boolean chains 1 (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · Sender.completeBatch (cognitive 27) · ×1
  • Sender.completeBatch (cognitive 27) clients/src/main/java/org/apache/kafka/clients/producer/internals/Sender.java:671 — Sender.completeBatch has cognitive complexity 27 (threshold 15). Drivers by points: if/else 13 (23 pts), boolean chains 4 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · LogLoader.load (cognitive 27) · ×1
  • LogLoader.load (cognitive 27) storage/src/main/java/org/apache/kafka/storage/internals/log/LogLoader.java:128 — LogLoader.load has cognitive complexity 27 (threshold 15). Drivers by points: if/else 12 (20 pts), loops 3, error handling 1 (2 pts), boolean chains 1, ternaries 1 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · LogManager.loadLogs (cognitive 27) · ×1
  • LogManager.loadLogs (cognitive 27) storage/src/main/java/org/apache/kafka/storage/internals/log/LogManager.java:608 — LogManager.loadLogs has cognitive complexity 27 (threshold 15). Drivers by points: if/else 10 (13 pts), error handling 6 (9 pts), loops 3 (4 pts), ternaries 1 (nesting depth added 7). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
D2 · Cognitive Complexity · RLMExpirationTask.buildRetentionSizeData (cognitive 27) · ×1
  • RLMExpirationTask.buildRetentionSizeData (cognitive 27) storage/src/main/java/org/apache/kafka/server/log/remote/storage/RemoteLogManager.java:1636 — RLMExpirationTask.buildRetentionSizeData has cognitive complexity 27 (threshold 15). Drivers by points: if/else 9 (21 pts), loops 2 (5 pts), boolean chains 1 (nesting depth added 15). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
D2 · Cognitive Complexity · PluginUtils.pluginUrls (cognitive 27) · ×1
  • PluginUtils.pluginUrls (cognitive 27) connect/runtime/src/main/java/org/apache/kafka/connect/runtime/isolation/PluginUtils.java:260 — PluginUtils.pluginUrls has cognitive complexity 27 (threshold 15). Drivers by points: if/else 12 (22 pts), error handling 1 (3 pts), loops 2 (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · MessageGenerator.processDirectories (cognitive 27) · ×1
  • MessageGenerator.processDirectories (cognitive 27) generator/src/main/java/org/apache/kafka/message/MessageGenerator.java:239 — MessageGenerator.processDirectories has cognitive complexity 27 (threshold 15). Drivers by points: if/else 7 (19 pts), error handling 2 (4 pts), loops 4 (nesting depth added 14). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · BrokerHeartbeatManager.calculateNextBrokerState (cognitive 27) · ×1
  • BrokerHeartbeatManager.calculateNextBrokerState (cognitive 27) metadata/src/main/java/org/apache/kafka/controller/BrokerHeartbeatManager.java:402 — BrokerHeartbeatManager.calculateNextBrokerState has cognitive complexity 27 (threshold 15). Drivers by points: if/else 13 (26 pts), match/switch 1 (nesting depth added 13). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
D2 · Cognitive Complexity · BrokersToIsrs.update (cognitive 27) · ×1
  • BrokersToIsrs.update (cognitive 27) metadata/src/main/java/org/apache/kafka/controller/BrokersToIsrs.java:122 — BrokersToIsrs.update has cognitive complexity 27 (threshold 15). Drivers by points: if/else 16 (26 pts), loops 1 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · FeatureControlManager.updateFeature (cognitive 27) · ×1
  • FeatureControlManager.updateFeature (cognitive 27) metadata/src/main/java/org/apache/kafka/controller/FeatureControlManager.java:243 — FeatureControlManager.updateFeature has cognitive complexity 27 (threshold 15). Drivers by points: if/else 16 (19 pts), error handling 3 (8 pts) (nesting depth added 8). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
D2 · Cognitive Complexity · TopicDelta.localChanges (cognitive 27) · ×1
  • TopicDelta.localChanges (cognitive 27) metadata/src/main/java/org/apache/kafka/image/TopicDelta.java:176 — TopicDelta.localChanges has cognitive complexity 27 (threshold 15). Drivers by points: if/else 8 (19 pts), boolean chains 5, error handling 1 (2 pts), loops 1 (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ProcessorNode.process (cognitive 27) · ×1
  • ProcessorNode.process (cognitive 27) streams/src/main/java/org/apache/kafka/streams/processor/internals/ProcessorNode.java:174 — ProcessorNode.process has cognitive complexity 27 (threshold 15). Drivers by points: if/else 9 (14 pts), error handling 4 (5 pts), loops 1 (4 pts), ternaries 2 (4 pts) (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · TopologyConfig.<init> (cognitive 27) · ×1
  • TopologyConfig.<init> (cognitive 27) streams/src/main/java/org/apache/kafka/streams/TopologyConfig.java:206 — TopologyConfig.<init> has cognitive complexity 27 (threshold 15). Drivers by points: if/else 21 (23 pts), boolean chains 3, ternaries 1 (nesting depth added 2). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
D2 · Cognitive Complexity · ConsumerGroupService.printMembers (cognitive 27) · ×1
  • ConsumerGroupService.printMembers (cognitive 27) tools/src/main/java/org/apache/kafka/tools/consumer/group/ConsumerGroupCommand.java:397 — ConsumerGroupService.printMembers has cognitive complexity 27 (threshold 15). Drivers by points: if/else 8 (10 pts), ternaries 2 (8 pts), boolean chains 6, loops 1 (3 pts) (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · 1.hasNext (cognitive 27) · ×1
  • 1.hasNext (cognitive 27) tools/src/main/java/org/apache/kafka/tools/LineMessageReader.java:110 — 1.hasNext has cognitive complexity 27 (threshold 15). Drivers by points: ternaries 4 (12 pts), if/else 6 (10 pts), boolean chains 3, error handling 1 (2 pts) (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ProducerPerformance.start (cognitive 27) · ×1
  • ProducerPerformance.start (cognitive 27) tools/src/main/java/org/apache/kafka/tools/ProducerPerformance.java:70 — ProducerPerformance.start has cognitive complexity 27 (threshold 15). Drivers by points: if/else 14 (21 pts), boolean chains 4, error handling 1, loops 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ConfigPostProcessor.<init> (cognitive 27) · ×1
  • ConfigPostProcessor.<init> (cognitive 27) tools/src/main/java/org/apache/kafka/tools/ProducerPerformance.java:641 — ConfigPostProcessor.<init> has cognitive complexity 27 (threshold 15). Drivers by points: if/else 16 (17 pts), boolean chains 9, ternaries 1 (nesting depth added 1). To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D2 · Cognitive Complexity · TransactionalMessageCopier.runEventLoop (cognitive 27) · ×1
  • TransactionalMessageCopier.runEventLoop (cognitive 27) tools/src/main/java/org/apache/kafka/tools/TransactionalMessageCopier.java:307 — TransactionalMessageCopier.runEventLoop has cognitive complexity 27 (threshold 15). Drivers by points: if/else 6 (10 pts), error handling 3 (7 pts), loops 2 (4 pts), ternaries 2 (4 pts), boolean chains 2 (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · TransactionStateManager.loadTransactionMetadata (cognitive 27) · ×1
  • TransactionStateManager.loadTransactionMetadata (cognitive 27) core/src/main/scala/kafka/coordinator/transaction/TransactionStateManager.scala:453 — TransactionStateManager.loadTransactionMetadata has cognitive complexity 27 (threshold 15). Drivers by points: if/else 3 (10 pts), match/switch 3 (8 pts), loops 2 (5 pts), boolean chains 2, error handling 1 (2 pts) (nesting depth added 16). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
D2 · Cognitive Complexity · ConfigHelper.describeConfigs (cognitive 27) · ×1
  • ConfigHelper.describeConfigs (cognitive 27) core/src/main/scala/kafka/server/ConfigHelper.scala:82 — ConfigHelper.describeConfigs has cognitive complexity 27 (threshold 15). Drivers by points: if/else 15 (21 pts), boolean chains 4, error handling 1, match/switch 1 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · KafkaApis.handleConsumerGroupDescribe (cognitive 27) · ×1
  • KafkaApis.handleConsumerGroupDescribe (cognitive 27) core/src/main/scala/kafka/server/KafkaApis.scala:2720 — KafkaApis.handleConsumerGroupDescribe has cognitive complexity 27 (threshold 15). Drivers by points: if/else 13 (27 pts) (nesting depth added 14). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function. This shape REPEATS in the file: one other method here (KafkaApis.handleShareGroupDescribe) has the same decision points, in the same order, at the same nesting depths — so this is one pattern written twice rather than two separate problems. Splitting this body alone leaves the other exactly as it is. Where these are variations on one operation, the change that clears both is the shared one: lift the common shape into a single routine the variants call, parameterised by whatever genuinely differs between them, and keep in each method only the part that is not shared.
D2 · Cognitive Complexity · KafkaApis.handleShareGroupDescribe (cognitive 27) · ×1
  • KafkaApis.handleShareGroupDescribe (cognitive 27) core/src/main/scala/kafka/server/KafkaApis.scala:3195 — KafkaApis.handleShareGroupDescribe has cognitive complexity 27 (threshold 15). Drivers by points: if/else 13 (27 pts) (nesting depth added 14). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function. This shape REPEATS in the file: one other method here (KafkaApis.handleConsumerGroupDescribe) has the same decision points, in the same order, at the same nesting depths — so this is one pattern written twice rather than two separate problems. Splitting this body alone leaves the other exactly as it is. Where these are variations on one operation, the change that clears both is the shared one: lift the common shape into a single routine the variants call, parameterised by whatever genuinely differs between them, and keep in each method only the part that is not shared.
D2 · Cognitive Complexity · FetchCollector.collectFetch (cognitive 26) · ×1
  • FetchCollector.collectFetch (cognitive 26) clients/src/main/java/org/apache/kafka/clients/consumer/internals/FetchCollector.java:91 — FetchCollector.collectFetch has cognitive complexity 26 (threshold 15). Drivers by points: if/else 8 (18 pts), error handling 2 (5 pts), boolean chains 2, loops 1 (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · Sender.handleProduceResponse (cognitive 26) · ×1
  • Sender.handleProduceResponse (cognitive 26) clients/src/main/java/org/apache/kafka/clients/producer/internals/Sender.java:580 — Sender.handleProduceResponse has cognitive complexity 26 (threshold 15). Drivers by points: if/else 9 (15 pts), loops 4 (9 pts), boolean chains 1, ternaries 1 (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · KafkaProducer.close (cognitive 26) · ×1
  • KafkaProducer.close (cognitive 26) clients/src/main/java/org/apache/kafka/clients/producer/KafkaProducer.java:1602 — KafkaProducer.close has cognitive complexity 26 (threshold 15). Drivers by points: if/else 10 (17 pts), error handling 2 (7 pts), boolean chains 2 (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · Builder.build (cognitive 26) · ×1
  • Builder.build (cognitive 26) clients/src/main/java/org/apache/kafka/clients/FetchSessionHandler.java:275 — Builder.build has cognitive complexity 26 (threshold 15). Drivers by points: if/else 13 (21 pts), boolean chains 2, loops 2, ternaries 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · RemoteLogManager.findOffsetByTimestamp (cognitive 26) · ×1
  • RemoteLogManager.findOffsetByTimestamp (cognitive 26) storage/src/main/java/org/apache/kafka/server/log/remote/storage/RemoteLogManager.java:721 — RemoteLogManager.findOffsetByTimestamp has cognitive complexity 26 (threshold 15). Drivers by points: if/else 6 (16 pts), loops 3 (8 pts), boolean chains 2 (nesting depth added 15). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · GroupMetadataManager.classicGroupJoinExistingMember (cognitive 26) · ×1
  • GroupMetadataManager.classicGroupJoinExistingMember (cognitive 26) group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java:7461 — GroupMetadataManager.classicGroupJoinExistingMember has cognitive complexity 26 (threshold 15). Drivers by points: if/else 14 (20 pts), ternaries 1 (4 pts), error handling 1 (2 pts) (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · RackAwareTaskAssignor.validateTopicPartitionRack (cognitive 26) · ×1
  • RackAwareTaskAssignor.validateTopicPartitionRack (cognitive 26) streams/src/main/java/org/apache/kafka/streams/processor/internals/assignment/RackAwareTaskAssignor.java:179 — RackAwareTaskAssignor.validateTopicPartitionRack has cognitive complexity 26 (threshold 15). Drivers by points: if/else 6 (14 pts), loops 3 (9 pts), error handling 1 (2 pts), boolean chains 1 (nesting depth added 15). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ChangelogTopics.setup (cognitive 26) · ×1
  • ChangelogTopics.setup (cognitive 26) streams/src/main/java/org/apache/kafka/streams/processor/internals/ChangelogTopics.java:59 — ChangelogTopics.setup has cognitive complexity 26 (threshold 15). Drivers by points: if/else 6 (15 pts), loops 6 (11 pts) (nesting depth added 14). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · InternalTopicManager.processCreateTopicResults (cognitive 26) · ×1
  • InternalTopicManager.processCreateTopicResults (cognitive 26) streams/src/main/java/org/apache/kafka/streams/processor/internals/InternalTopicManager.java:760 — InternalTopicManager.processCreateTopicResults has cognitive complexity 26 (threshold 15). Drivers by points: if/else 6 (15 pts), error handling 2 (8 pts), loops 2 (3 pts) (nesting depth added 16). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ProcessorStateManager.close (cognitive 26) · ×1
  • ProcessorStateManager.close (cognitive 26) streams/src/main/java/org/apache/kafka/streams/processor/internals/ProcessorStateManager.java:682 — ProcessorStateManager.close has cognitive complexity 26 (threshold 15). Drivers by points: if/else 9 (19 pts), error handling 1 (3 pts), boolean chains 2, loops 1 (2 pts) (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · SharePartition.acquireSubsetBatchRecords (cognitive 26) · ×1
  • SharePartition.acquireSubsetBatchRecords (cognitive 26) core/src/main/java/kafka/server/share/SharePartition.java:1970 — SharePartition.acquireSubsetBatchRecords has cognitive complexity 26 (threshold 15). Drivers by points: if/else 9 (18 pts), boolean chains 7, loops 1 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · KafkaApis.getCoordinator (cognitive 26) · ×1
  • KafkaApis.getCoordinator (cognitive 26) core/src/main/scala/kafka/server/KafkaApis.scala:1257 — KafkaApis.getCoordinator has cognitive complexity 26 (threshold 15). Drivers by points: if/else 11 (18 pts), boolean chains 3, error handling 1 (3 pts), match/switch 1 (2 pts) (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ReplicaManager.readFromLog (cognitive 26) · ×1
  • ReplicaManager.readFromLog (cognitive 26) core/src/main/scala/kafka/server/ReplicaManager.scala:1771 — ReplicaManager.readFromLog has cognitive complexity 26 (threshold 15). Drivers by points: if/else 18 (21 pts), error handling 3, boolean chains 2 (nesting depth added 3). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
D2 · Cognitive Complexity · ClientQuotaMetadataManager.update (cognitive 26) · ×1
  • ClientQuotaMetadataManager.update (cognitive 26) core/src/main/scala/kafka/server/metadata/ClientQuotaMetadataManager.scala:63 — ClientQuotaMetadataManager.update has cognitive complexity 26 (threshold 15). Drivers by points: if/else 14 (21 pts), boolean chains 3, match/switch 1 (2 pts) (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · SyncGroupResponseHandler.handle (cognitive 25) · ×1
  • SyncGroupResponseHandler.handle (cognitive 25) clients/src/main/java/org/apache/kafka/clients/consumer/internals/AbstractCoordinator.java:826 — SyncGroupResponseHandler.handle has cognitive complexity 25 (threshold 15). Drivers by points: if/else 14 (21 pts), boolean chains 4 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · HeartbeatThread.run (cognitive 25) · ×1
  • HeartbeatThread.run (cognitive 25) clients/src/main/java/org/apache/kafka/clients/consumer/internals/AbstractCoordinator.java:1489 — HeartbeatThread.run has cognitive complexity 25 (threshold 15). Drivers by points: if/else 12 (19 pts), error handling 4, boolean chains 1, loops 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · OffsetFetchResponseHandler.handle (cognitive 25) · ×1
  • OffsetFetchResponseHandler.handle (cognitive 25) clients/src/main/java/org/apache/kafka/clients/consumer/internals/ConsumerCoordinator.java:1520 — OffsetFetchResponseHandler.handle has cognitive complexity 25 (threshold 15). Drivers by points: if/else 15 (21 pts), loops 2 (3 pts), boolean chains 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ShareCompletedFetch.fetchRecords (cognitive 25) · ×1
  • ShareCompletedFetch.fetchRecords (cognitive 25) clients/src/main/java/org/apache/kafka/clients/consumer/internals/ShareCompletedFetch.java:192 — ShareCompletedFetch.fetchRecords has cognitive complexity 25 (threshold 15). Drivers by points: if/else 11 (16 pts), loops 3 (6 pts), error handling 2, boolean chains 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ScramSaslServer.evaluateResponse (cognitive 25) · ×1
  • ScramSaslServer.evaluateResponse (cognitive 25) clients/src/main/java/org/apache/kafka/common/security/scram/internals/ScramSaslServer.java:96 — ScramSaslServer.evaluateResponse has cognitive complexity 25 (threshold 15). Drivers by points: if/else 8 (16 pts), error handling 4 (7 pts), boolean chains 1, match/switch 1 (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · DistributedHerder.doFenceZombieSourceTasks (cognitive 25) · ×1
  • DistributedHerder.doFenceZombieSourceTasks (cognitive 25) connect/runtime/src/main/java/org/apache/kafka/connect/runtime/distributed/DistributedHerder.java:1437 — DistributedHerder.doFenceZombieSourceTasks has cognitive complexity 25 (threshold 15). Drivers by points: if/else 13 (23 pts), boolean chains 2 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · RepartitionTopics.computeRepartitionTopicPartitionCount (cognitive 25) · ×1
  • RepartitionTopics.computeRepartitionTopicPartitionCount (cognitive 25) group-coordinator/src/main/java/org/apache/kafka/coordinator/group/streams/topics/RepartitionTopics.java:106 — RepartitionTopics.computeRepartitionTopicPartitionCount has cognitive complexity 25 (threshold 15). Drivers by points: if/else 5 (15 pts), loops 5 (9 pts), boolean chains 1 (nesting depth added 14). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · MessageDataGenerator.generateClassWriter (cognitive 25) · ×1
  • MessageDataGenerator.generateClassWriter (cognitive 25) generator/src/main/java/org/apache/kafka/message/MessageDataGenerator.java:731 — MessageDataGenerator.generateClassWriter has cognitive complexity 25 (threshold 15). Drivers by points: if/else 18 (21 pts), boolean chains 2, loops 2 (nesting depth added 3). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
D2 · Cognitive Complexity · GlobalStateManagerImpl.initialize (cognitive 25) · ×1
  • GlobalStateManagerImpl.initialize (cognitive 25) streams/src/main/java/org/apache/kafka/streams/processor/internals/GlobalStateManagerImpl.java:176 — GlobalStateManagerImpl.initialize has cognitive complexity 25 (threshold 15). Drivers by points: if/else 5 (12 pts), loops 4 (7 pts), error handling 2 (6 pts) (nesting depth added 14). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · InternalTopologyBuilder.buildProcessorNode (cognitive 25) · ×1
  • InternalTopologyBuilder.buildProcessorNode (cognitive 25) streams/src/main/java/org/apache/kafka/streams/processor/internals/InternalTopologyBuilder.java:1121 — InternalTopologyBuilder.buildProcessorNode has cognitive complexity 25 (threshold 15). Drivers by points: if/else 6 (17 pts), ternaries 1 (5 pts), loops 2, boolean chains 1 (nesting depth added 15). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
D2 · Cognitive Complexity · RocksDBVersionedStore.finishPut (cognitive 25) · ×1
  • RocksDBVersionedStore.finishPut (cognitive 25) streams/src/main/java/org/apache/kafka/streams/state/internals/RocksDBVersionedStore.java:985 — RocksDBVersionedStore.finishPut has cognitive complexity 25 (threshold 15). Drivers by points: if/else 13 (25 pts) (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · StreamsGroupService.resetOffsets (cognitive 25) · ×1
  • StreamsGroupService.resetOffsets (cognitive 25) tools/src/main/java/org/apache/kafka/tools/streams/StreamsGroupCommand.java:559 — StreamsGroupService.resetOffsets has cognitive complexity 25 (threshold 15). Drivers by points: if/else 8 (16 pts), error handling 3 (6 pts), boolean chains 1, match/switch 1, ternaries 1 (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ControllerApis.handleIncrementalAlterConfigs (cognitive 25) · ×1
  • ControllerApis.handleIncrementalAlterConfigs (cognitive 25) core/src/main/scala/kafka/server/ControllerApis.scala:741 — ControllerApis.handleIncrementalAlterConfigs has cognitive complexity 25 (threshold 15). Drivers by points: if/else 12 (18 pts), loops 2 (3 pts), boolean chains 2, error handling 1 (2 pts) (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · KafkaConfig.validateValues (cognitive 25) · ×1
  • KafkaConfig.validateValues (cognitive 25) core/src/main/scala/kafka/server/KafkaConfig.scala:299 — KafkaConfig.validateValues has cognitive complexity 25 (threshold 15). Drivers by points: if/else 16 (19 pts), boolean chains 6 (nesting depth added 3). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
D2 · Cognitive Complexity · TestAnalyzer.get_test_case_details (cognitive 25) · ×1
  • TestAnalyzer.get_test_case_details (cognitive 25) .github/scripts/develocity_reports.py:603 — TestAnalyzer.get_test_case_details has cognitive complexity 25 (threshold 15). Drivers by points: if/else 5 (12 pts), loops 5 (12 pts), error handling 1 (nesting depth added 14). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ListShareGroupOffsetsHandler.handleResponse (cognitive 24) · ×1
  • ListShareGroupOffsetsHandler.handleResponse (cognitive 24) clients/src/main/java/org/apache/kafka/clients/admin/internals/ListShareGroupOffsetsHandler.java:113 — ListShareGroupOffsetsHandler.handleResponse has cognitive complexity 24 (threshold 15). Drivers by points: if/else 6 (12 pts), ternaries 2 (8 pts), loops 3 (4 pts) (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · AbstractFetch.handleFetchSuccess (cognitive 24) · ×1
  • AbstractFetch.handleFetchSuccess (cognitive 24) clients/src/main/java/org/apache/kafka/clients/consumer/internals/AbstractFetch.java:151 — AbstractFetch.handleFetchSuccess has cognitive complexity 24 (threshold 15). Drivers by points: if/else 10 (19 pts), loops 2 (3 pts), boolean chains 2 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · GeneralAssignmentBuilder.isBalanced (cognitive 24) · ×1
  • GeneralAssignmentBuilder.isBalanced (cognitive 24) clients/src/main/java/org/apache/kafka/clients/consumer/internals/AbstractStickyAssignor.java:1170 — GeneralAssignmentBuilder.isBalanced has cognitive complexity 24 (threshold 15). Drivers by points: if/else 5 (15 pts), loops 5 (9 pts) (nesting depth added 14). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · FetchCollector.handleInitializeErrors (cognitive 24) · ×1
  • FetchCollector.handleInitializeErrors (cognitive 24) clients/src/main/java/org/apache/kafka/clients/consumer/internals/FetchCollector.java:321 — FetchCollector.handleInitializeErrors has cognitive complexity 24 (threshold 15). Drivers by points: if/else 16 (22 pts), boolean chains 2 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ChannelBuilders.create (cognitive 24) · ×1
  • ChannelBuilders.create (cognitive 24) clients/src/main/java/org/apache/kafka/common/network/ChannelBuilders.java:109 — ChannelBuilders.create has cognitive complexity 24 (threshold 15). Drivers by points: if/else 5 (15 pts), loops 1 (3 pts), ternaries 1 (3 pts), boolean chains 2, match/switch 1 (nesting depth added 14). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
D2 · Cognitive Complexity · RLMCopyTask.copyLogSegmentsToRemote (cognitive 24) · ×1
  • RLMCopyTask.copyLogSegmentsToRemote (cognitive 24) storage/src/main/java/org/apache/kafka/server/log/remote/storage/RemoteLogManager.java:1011 — RLMCopyTask.copyLogSegmentsToRemote has cognitive complexity 24 (threshold 15). Drivers by points: if/else 8 (13 pts), loops 2 (7 pts), error handling 3, boolean chains 1 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · Values.append (cognitive 24) · ×1
  • Values.append (cognitive 24) connect/api/src/main/java/org/apache/kafka/connect/data/Values.java:697 — Values.append has cognitive complexity 24 (threshold 15). Drivers by points: if/else 18 (22 pts), loops 1 (2 pts) (nesting depth added 5). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
D2 · Cognitive Complexity · DistributedHerder.validateSourceConnectorExactlyOnceSupport (cognitive 24) · ×1
  • DistributedHerder.validateSourceConnectorExactlyOnceSupport (cognitive 24) connect/runtime/src/main/java/org/apache/kafka/connect/runtime/distributed/DistributedHerder.java:983 — DistributedHerder.validateSourceConnectorExactlyOnceSupport has cognitive complexity 24 (threshold 15). Drivers by points: if/else 9 (20 pts), error handling 1 (3 pts), boolean chains 1 (nesting depth added 13). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
D2 · Cognitive Complexity · MessageDataGenerator.generateVariableLengthWriter (cognitive 24) · ×1
  • MessageDataGenerator.generateVariableLengthWriter (cognitive 24) generator/src/main/java/org/apache/kafka/message/MessageDataGenerator.java:960 — MessageDataGenerator.generateVariableLengthWriter has cognitive complexity 24 (threshold 15). Drivers by points: if/else 20 (23 pts), boolean chains 1 (nesting depth added 3). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
D2 · Cognitive Complexity · ClientQuotasImage.describe (cognitive 24) · ×1
  • ClientQuotasImage.describe (cognitive 24) metadata/src/main/java/org/apache/kafka/image/ClientQuotasImage.java:109 — ClientQuotasImage.describe has cognitive complexity 24 (threshold 15). Drivers by points: if/else 8 (17 pts), boolean chains 4, match/switch 1 (2 pts), loops 1 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · TaskAssignmentUtils.validateTaskAssignment (cognitive 24) · ×1
  • TaskAssignmentUtils.validateTaskAssignment (cognitive 24) streams/src/main/java/org/apache/kafka/streams/processor/assignment/TaskAssignmentUtils.java:167 — TaskAssignmentUtils.validateTaskAssignment has cognitive complexity 24 (threshold 15). Drivers by points: if/else 7 (16 pts), loops 5 (6 pts), boolean chains 2 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · TimeOrderedCachingWindowStore.putAndMaybeForward (cognitive 24) · ×1
  • TimeOrderedCachingWindowStore.putAndMaybeForward (cognitive 24) streams/src/main/java/org/apache/kafka/streams/state/internals/TimeOrderedCachingWindowStore.java:142 — TimeOrderedCachingWindowStore.putAndMaybeForward has cognitive complexity 24 (threshold 15). Drivers by points: if/else 9 (21 pts), boolean chains 2, loops 1 (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ReassignPartitionsCommand.parsePartitionReassignmentData (cognitive 24) · ×1
  • ReassignPartitionsCommand.parsePartitionReassignmentData (cognitive 24) tools/src/main/java/org/apache/kafka/tools/reassign/ReassignPartitionsCommand.java:1401 — ReassignPartitionsCommand.parsePartitionReassignmentData has cognitive complexity 24 (threshold 15). Drivers by points: if/else 6 (17 pts), loops 2 (7 pts) (nesting depth added 16). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · WorkerUtils.createTopics (cognitive 24) · ×1
  • WorkerUtils.createTopics (cognitive 24) trogdor/src/main/java/org/apache/kafka/trogdor/common/WorkerUtils.java:178 — WorkerUtils.createTopics has cognitive complexity 24 (threshold 15). Drivers by points: if/else 5 (10 pts), loops 5 (9 pts), error handling 1 (3 pts), boolean chains 2 (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · SharePartition.acknowledgeBatchRecords (cognitive 24) · ×1
  • SharePartition.acknowledgeBatchRecords (cognitive 24) core/src/main/java/kafka/server/share/SharePartition.java:2205 — SharePartition.acknowledgeBatchRecords has cognitive complexity 24 (threshold 15). Drivers by points: if/else 9 (22 pts), boolean chains 1, loops 1 (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · SharePartition.filterRecordBatchesFromAcquiredRecords (cognitive 24) · ×1
  • SharePartition.filterRecordBatchesFromAcquiredRecords (cognitive 24) core/src/main/java/kafka/server/share/SharePartition.java:3228 — SharePartition.filterRecordBatchesFromAcquiredRecords has cognitive complexity 24 (threshold 15). Drivers by points: if/else 10 (21 pts), boolean chains 2, loops 1 (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · KafkaAdminClient.alterUserScramCredentials (cognitive 23) · ×1
  • KafkaAdminClient.alterUserScramCredentials (cognitive 23) clients/src/main/java/org/apache/kafka/clients/admin/KafkaAdminClient.java:4510 — KafkaAdminClient.alterUserScramCredentials has cognitive complexity 23 (threshold 15). Drivers by points: if/else 9 (13 pts), boolean chains 5, error handling 2 (4 pts), loops 1 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · AdminClientRunnable.handleResponses (cognitive 23) · ×1
  • AdminClientRunnable.handleResponses (cognitive 23) clients/src/main/java/org/apache/kafka/clients/admin/KafkaAdminClient.java:1437 — AdminClientRunnable.handleResponses has cognitive complexity 23 (threshold 15). Drivers by points: if/else 9 (19 pts), error handling 1 (3 pts), loops 1 (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · AdminClientRunnable.sendEligibleCalls (cognitive 23) · ×1
  • AdminClientRunnable.sendEligibleCalls (cognitive 23) clients/src/main/java/org/apache/kafka/clients/admin/KafkaAdminClient.java:1333 — AdminClientRunnable.sendEligibleCalls has cognitive complexity 23 (threshold 15). Drivers by points: if/else 8 (17 pts), error handling 1 (3 pts), loops 2 (3 pts) (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · 32.handleResponse (cognitive 23) · ×1
  • 32.handleResponse (cognitive 23) clients/src/main/java/org/apache/kafka/clients/admin/KafkaAdminClient.java:4761 — 32.handleResponse has cognitive complexity 23 (threshold 15). Drivers by points: if/else 6 (14 pts), loops 3 (8 pts), match/switch 1 (nesting depth added 13). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
D2 · Cognitive Complexity · AbstractStickyAssignor.allSubscriptionsEqual (cognitive 23) · ×1
  • AbstractStickyAssignor.allSubscriptionsEqual (cognitive 23) clients/src/main/java/org/apache/kafka/clients/consumer/internals/AbstractStickyAssignor.java:132 — AbstractStickyAssignor.allSubscriptionsEqual has cognitive complexity 23 (threshold 15). Drivers by points: if/else 8 (18 pts), loops 2 (3 pts), boolean chains 2 (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · MemoryRecords.filterTo (cognitive 23) · ×1
  • MemoryRecords.filterTo (cognitive 23) clients/src/main/java/org/apache/kafka/common/record/internal/MemoryRecords.java:147 — MemoryRecords.filterTo has cognitive complexity 23 (threshold 15). Drivers by points: if/else 9 (19 pts), boolean chains 3, loops 1 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · WorkThread.run (cognitive 23) · ×1
  • WorkThread.run (cognitive 23) connect/runtime/src/main/java/org/apache/kafka/connect/util/KafkaBasedLog.java:543 — WorkThread.run has cognitive complexity 23 (threshold 15). Drivers by points: error handling 5 (13 pts), loops 3 (6 pts), if/else 2 (4 pts) (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · JsonConverter.convertToConnect (cognitive 23) · ×1
  • JsonConverter.convertToConnect (cognitive 23) connect/json/src/main/java/org/apache/kafka/connect/json/JsonConverter.java:701 — JsonConverter.convertToConnect has cognitive complexity 23 (threshold 15). Drivers by points: if/else 10 (18 pts), boolean chains 3, match/switch 1 (2 pts) (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · StreamsAssignorBenchmarkUtils.createMemberTaskOffsets (cognitive 23) · ×1
  • StreamsAssignorBenchmarkUtils.createMemberTaskOffsets (cognitive 23) jmh-benchmarks/src/main/java/org/apache/kafka/jmh/assignor/StreamsAssignorBenchmarkUtils.java:380 — StreamsAssignorBenchmarkUtils.createMemberTaskOffsets has cognitive complexity 23 (threshold 15). Drivers by points: if/else 5 (11 pts), ternaries 2 (7 pts), loops 2 (3 pts), boolean chains 2 (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · StandardAuthorizerData.findResult (cognitive 23) · ×1
  • StandardAuthorizerData.findResult (cognitive 23) metadata/src/main/java/org/apache/kafka/metadata/authorizer/StandardAuthorizerData.java:484 — StandardAuthorizerData.findResult has cognitive complexity 23 (threshold 15). Drivers by points: if/else 8 (18 pts), match/switch 1 (3 pts), boolean chains 1, ternaries 1 (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · MinTrafficGraphConstructor.constructTaskGraph (cognitive 23) · ×1
  • MinTrafficGraphConstructor.constructTaskGraph (cognitive 23) streams/src/main/java/org/apache/kafka/streams/processor/internals/assignment/MinTrafficGraphConstructor.java:54 — MinTrafficGraphConstructor.constructTaskGraph has cognitive complexity 23 (threshold 15). Drivers by points: if/else 4 (12 pts), loops 5 (7 pts), ternaries 1 (3 pts), boolean chains 1 (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · StateUpdaterThread.maybeGetClientInstanceIds (cognitive 23) · ×1
  • StateUpdaterThread.maybeGetClientInstanceIds (cognitive 23) streams/src/main/java/org/apache/kafka/streams/processor/internals/DefaultStateUpdater.java:291 — StateUpdaterThread.maybeGetClientInstanceIds has cognitive complexity 23 (threshold 15). Drivers by points: error handling 3 (12 pts), if/else 4 (7 pts), ternaries 1 (4 pts) (nesting depth added 15). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ProcessorStateManager.flushCache (cognitive 23) · ×1
  • ProcessorStateManager.flushCache (cognitive 23) streams/src/main/java/org/apache/kafka/streams/processor/internals/ProcessorStateManager.java:622 — ProcessorStateManager.flushCache has cognitive complexity 23 (threshold 15). Drivers by points: if/else 9 (18 pts), error handling 1 (3 pts), loops 1 (2 pts) (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · RecordCollectorImpl.send (cognitive 23) · ×1
  • RecordCollectorImpl.send (cognitive 23) streams/src/main/java/org/apache/kafka/streams/processor/internals/RecordCollectorImpl.java:132 — RecordCollectorImpl.send has cognitive complexity 23 (threshold 15). Drivers by points: if/else 8 (14 pts), loops 1 (5 pts), error handling 2 (4 pts) (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · StoreChangelogReader.seekNewPartitions (cognitive 23) · ×1
  • StoreChangelogReader.seekNewPartitions (cognitive 23) streams/src/main/java/org/apache/kafka/streams/processor/internals/StoreChangelogReader.java:1220 — StoreChangelogReader.seekNewPartitions has cognitive complexity 23 (threshold 15). Drivers by points: if/else 6 (11 pts), loops 3 (5 pts), error handling 2 (4 pts), boolean chains 3 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · FeatureCommand.handleUpgradeOrDowngrade (cognitive 23) · ×1
  • FeatureCommand.handleUpgradeOrDowngrade (cognitive 23) tools/src/main/java/org/apache/kafka/tools/FeatureCommand.java:294 — FeatureCommand.handleUpgradeOrDowngrade has cognitive complexity 23 (threshold 15). Drivers by points: if/else 7 (11 pts), error handling 3 (7 pts), boolean chains 3, loops 1 (2 pts) (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · SharePartition.findLastOffsetAcknowledgedAndMetadata (cognitive 23) · ×1
  • SharePartition.findLastOffsetAcknowledgedAndMetadata (cognitive 23) core/src/main/java/kafka/server/share/SharePartition.java:2805 — SharePartition.findLastOffsetAcknowledgedAndMetadata has cognitive complexity 23 (threshold 15). Drivers by points: if/else 6 (16 pts), loops 2 (4 pts), boolean chains 3 (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · AsyncKafkaConsumer.processBackgroundEvents (cognitive 22) · ×1
  • AsyncKafkaConsumer.processBackgroundEvents (cognitive 22) clients/src/main/java/org/apache/kafka/clients/consumer/internals/AsyncKafkaConsumer.java:2372 — AsyncKafkaConsumer.processBackgroundEvents has cognitive complexity 22 (threshold 15). Drivers by points: if/else 6 (16 pts), error handling 1 (3 pts), loops 1 (2 pts), boolean chains 1 (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · TransactionManager.canRetry (cognitive 22) · ×1
  • TransactionManager.canRetry (cognitive 22) clients/src/main/java/org/apache/kafka/clients/producer/internals/TransactionManager.java:1043 — TransactionManager.canRetry has cognitive complexity 22 (threshold 15). Drivers by points: if/else 11 (19 pts), boolean chains 3 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · NetworkClient.leastLoadedNode (cognitive 22) · ×1
  • NetworkClient.leastLoadedNode (cognitive 22) clients/src/main/java/org/apache/kafka/clients/NetworkClient.java:845 — NetworkClient.leastLoadedNode has cognitive complexity 22 (threshold 15). Drivers by points: if/else 13 (19 pts), boolean chains 2, loops 1 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · LogValidator.assignOffsetsNonCompressed (cognitive 22) · ×1
  • LogValidator.assignOffsetsNonCompressed (cognitive 22) storage/src/main/java/org/apache/kafka/storage/internals/log/LogValidator.java:230 — LogValidator.assignOffsetsNonCompressed has cognitive complexity 22 (threshold 15). Drivers by points: if/else 9 (17 pts), loops 2 (3 pts), boolean chains 2 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · LogValidator.validateBatch (cognitive 22) · ×1
  • LogValidator.validateBatch (cognitive 22) storage/src/main/java/org/apache/kafka/storage/internals/log/LogValidator.java:458 — LogValidator.validateBatch has cognitive complexity 22 (threshold 15). Drivers by points: if/else 10 (19 pts), boolean chains 3 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · NetworkReceive.readFrom (cognitive 22) · ×1
  • NetworkReceive.readFrom (cognitive 22) clients/src/main/java/org/apache/kafka/common/network/NetworkReceive.java:82 — NetworkReceive.readFrom has cognitive complexity 22 (threshold 15). Drivers by points: if/else 10 (20 pts), boolean chains 2 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · DeepRecordsIterator.<init> (cognitive 22) · ×1
  • DeepRecordsIterator.<init> (cognitive 22) clients/src/main/java/org/apache/kafka/common/record/internal/AbstractLegacyRecordBatch.java:341 — DeepRecordsIterator.<init> has cognitive complexity 22 (threshold 15). Drivers by points: if/else 12 (18 pts), boolean chains 2, error handling 1, loops 1 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · AssignmentRefinerImpl.analyzeTasks (cognitive 22) · ×1
  • AssignmentRefinerImpl.analyzeTasks (cognitive 22) group-coordinator/src/main/java/org/apache/kafka/coordinator/group/streams/AssignmentRefinerImpl.java:260 — AssignmentRefinerImpl.analyzeTasks has cognitive complexity 22 (threshold 15). Drivers by points: if/else 9 (15 pts), boolean chains 3, ternaries 1 (3 pts), loops 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · GroupCoordinatorConfig.streamsGroupAssignors (cognitive 22) · ×1
  • GroupCoordinatorConfig.streamsGroupAssignors (cognitive 22) group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupCoordinatorConfig.java:936 — GroupCoordinatorConfig.streamsGroupAssignors has cognitive complexity 22 (threshold 15). Drivers by points: error handling 4 (10 pts), if/else 4 (8 pts), loops 2 (3 pts), boolean chains 1 (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · MessageDataGenerator.generateVariableLengthReader (cognitive 22) · ×1
  • MessageDataGenerator.generateVariableLengthReader (cognitive 22) generator/src/main/java/org/apache/kafka/message/MessageDataGenerator.java:621 — MessageDataGenerator.generateVariableLengthReader has cognitive complexity 22 (threshold 15). Drivers by points: if/else 16 (19 pts), boolean chains 2, ternaries 1 (nesting depth added 3). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
D2 · Cognitive Complexity · ConfigurationControlManager.describeConfigs (cognitive 22) · ×1
  • ConfigurationControlManager.describeConfigs (cognitive 22) metadata/src/main/java/org/apache/kafka/controller/ConfigurationControlManager.java:667 — ConfigurationControlManager.describeConfigs has cognitive complexity 22 (threshold 15). Drivers by points: if/else 4 (11 pts), loops 3 (9 pts), error handling 1 (2 pts) (nesting depth added 14). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ConfigurationControlManager.validateAlterConfig (cognitive 22) · ×1
  • ConfigurationControlManager.validateAlterConfig (cognitive 22) metadata/src/main/java/org/apache/kafka/controller/ConfigurationControlManager.java:355 — ConfigurationControlManager.validateAlterConfig has cognitive complexity 22 (threshold 15). Drivers by points: if/else 15 (18 pts), error handling 2, loops 2 (nesting depth added 3). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
D2 · Cognitive Complexity · InternalTopologyBuilder.setRegexMatchedTopicToStateStore (cognitive 22) · ×1
  • InternalTopologyBuilder.setRegexMatchedTopicToStateStore (cognitive 22) streams/src/main/java/org/apache/kafka/streams/processor/internals/InternalTopologyBuilder.java:1298 — InternalTopologyBuilder.setRegexMatchedTopicToStateStore has cognitive complexity 22 (threshold 15). Drivers by points: if/else 4 (13 pts), loops 3 (9 pts) (nesting depth added 15). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · StoreChangelogReader.restoreChangelog (cognitive 22) · ×1
  • StoreChangelogReader.restoreChangelog (cognitive 22) streams/src/main/java/org/apache/kafka/streams/processor/internals/StoreChangelogReader.java:700 — StoreChangelogReader.restoreChangelog has cognitive complexity 22 (threshold 15). Drivers by points: if/else 9 (12 pts), error handling 3 (8 pts), boolean chains 2 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · InMemorySessionTransactionBuffer.flushToBase (cognitive 22) · ×1
  • InMemorySessionTransactionBuffer.flushToBase (cognitive 22) streams/src/main/java/org/apache/kafka/streams/state/internals/InMemorySessionTransactionBuffer.java:261 — InMemorySessionTransactionBuffer.flushToBase has cognitive complexity 22 (threshold 15). Drivers by points: if/else 6 (21 pts), loops 1 (nesting depth added 15). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
D2 · Cognitive Complexity · LogicalSegmentIterator.maybeFillIterator (cognitive 22) · ×1
  • LogicalSegmentIterator.maybeFillIterator (cognitive 22) streams/src/main/java/org/apache/kafka/streams/state/internals/LogicalSegmentIterator.java:87 — LogicalSegmentIterator.maybeFillIterator has cognitive complexity 22 (threshold 15). Drivers by points: if/else 7 (15 pts), loops 2 (5 pts), ternaries 1 (2 pts) (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · RocksDBVersionedStore.get (cognitive 22) · ×1
  • RocksDBVersionedStore.get (cognitive 22) streams/src/main/java/org/apache/kafka/streams/state/internals/RocksDBVersionedStore.java:210 — RocksDBVersionedStore.get has cognitive complexity 22 (threshold 15). Drivers by points: if/else 10 (21 pts), loops 1 (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · StreamThreadStateStoreProvider.validateAndCastStores (cognitive 22) · ×1
  • StreamThreadStateStoreProvider.validateAndCastStores (cognitive 22) streams/src/main/java/org/apache/kafka/streams/state/internals/StreamThreadStateStoreProvider.java:95 — StreamThreadStateStoreProvider.validateAndCastStores has cognitive complexity 22 (threshold 15). Drivers by points: if/else 13 (19 pts), boolean chains 3 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ConsumerPerformance.consume (cognitive 22) · ×1
  • ConsumerPerformance.consume (cognitive 22) tools/src/main/java/org/apache/kafka/tools/ConsumerPerformance.java:126 — ConsumerPerformance.consume has cognitive complexity 22 (threshold 15). Drivers by points: if/else 8 (18 pts), loops 2 (3 pts), boolean chains 1 (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · EndToEndLatency.validateHeaders (cognitive 22) · ×1
  • EndToEndLatency.validateHeaders (cognitive 22) tools/src/main/java/org/apache/kafka/tools/EndToEndLatency.java:177 — EndToEndLatency.validateHeaders has cognitive complexity 22 (threshold 15). Drivers by points: if/else 4 (8 pts), ternaries 2 (8 pts), boolean chains 4, loops 1 (2 pts) (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ConsumerRunnable.run (cognitive 22) · ×1
  • ConsumerRunnable.run (cognitive 22) trogdor/src/main/java/org/apache/kafka/trogdor/workload/RoundTripWorkerBase.java:334 — ConsumerRunnable.run has cognitive complexity 22 (threshold 15). Drivers by points: if/else 3 (9 pts), loops 3 (8 pts), error handling 3 (5 pts) (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · DelayedShareFetch.completeRemoteStorageShareFetchRequest (cognitive 22) · ×1
  • DelayedShareFetch.completeRemoteStorageShareFetchRequest (cognitive 22) core/src/main/java/kafka/server/share/DelayedShareFetch.java:1101 — DelayedShareFetch.completeRemoteStorageShareFetchRequest has cognitive complexity 22 (threshold 15). Drivers by points: if/else 7 (11 pts), ternaries 2 (8 pts), error handling 2, loops 1 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · TransactionStateManager.removeExpiredTransactionalIds (cognitive 22) · ×1
  • TransactionStateManager.removeExpiredTransactionalIds (cognitive 22) core/src/main/scala/kafka/coordinator/transaction/TransactionStateManager.scala:151 — TransactionStateManager.removeExpiredTransactionalIds has cognitive complexity 22 (threshold 15). Drivers by points: if/else 7 (18 pts), loops 1 (2 pts), boolean chains 1, match/switch 1 (nesting depth added 12). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
D2 · Cognitive Complexity · Processor.processCompletedReceives (cognitive 22) · ×1
  • Processor.processCompletedReceives (cognitive 22) core/src/main/scala/kafka/network/SocketServer.scala:982 — Processor.processCompletedReceives has cognitive complexity 22 (threshold 15). Drivers by points: if/else 7 (18 pts), boolean chains 2, error handling 1, match/switch 1 (nesting depth added 11). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
D2 · Cognitive Complexity · KafkaRequestHandler.run (cognitive 22) · ×1
  • KafkaRequestHandler.run (cognitive 22) core/src/main/scala/kafka/server/KafkaRequestHandler.scala:108 — KafkaRequestHandler.run has cognitive complexity 22 (threshold 15). Drivers by points: error handling 4 (12 pts), if/else 3 (7 pts), match/switch 1 (2 pts), loops 1 (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · pr-reviewers-trailer.resolve_reviewer (cognitive 22) · ×1
  • pr-reviewers-trailer.resolve_reviewer (cognitive 22) .github/scripts/pr-reviewers-trailer.py:78 — pr-reviewers-trailer.resolve_reviewer has cognitive complexity 22 (threshold 15). Drivers by points: if/else 3 (7 pts), loops 4 (7 pts), boolean chains 6, ternaries 2 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · 2.handleResponse (cognitive 21) · ×1
  • 2.handleResponse (cognitive 21) clients/src/main/java/org/apache/kafka/clients/admin/KafkaAdminClient.java:2096 — 2.handleResponse has cognitive complexity 21 (threshold 15). Drivers by points: if/else 10 (20 pts), loops 1 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body. This shape REPEATS in the file: 2 other methods here (3.handleResponse, 17.handleResponse) have the same decision points, in the same order, at the same nesting depths — so this is one pattern written 3 times rather than 3 independent problems. Splitting this body alone leaves the other 2 exactly as they are. Where these are variations on one operation, the change that clears all 3 is the shared one: lift the common shape into a single routine the variants call, parameterised by whatever genuinely differs between them, and keep in each method only the part that is not shared.
D2 · Cognitive Complexity · 3.handleResponse (cognitive 21) · ×1
  • 3.handleResponse (cognitive 21) clients/src/main/java/org/apache/kafka/clients/admin/KafkaAdminClient.java:2169 — 3.handleResponse has cognitive complexity 21 (threshold 15). Drivers by points: if/else 10 (20 pts), loops 1 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body. This shape REPEATS in the file: 2 other methods here (2.handleResponse, 17.handleResponse) have the same decision points, in the same order, at the same nesting depths — so this is one pattern written 3 times rather than 3 independent problems. Splitting this body alone leaves the other 2 exactly as they are. Where these are variations on one operation, the change that clears all 3 is the shared one: lift the common shape into a single routine the variants call, parameterised by whatever genuinely differs between them, and keep in each method only the part that is not shared.
D2 · Cognitive Complexity · 17.handleResponse (cognitive 21) · ×1
  • 17.handleResponse (cognitive 21) clients/src/main/java/org/apache/kafka/clients/admin/KafkaAdminClient.java:3328 — 17.handleResponse has cognitive complexity 21 (threshold 15). Drivers by points: if/else 10 (20 pts), loops 1 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body. This shape REPEATS in the file: 2 other methods here (2.handleResponse, 3.handleResponse) have the same decision points, in the same order, at the same nesting depths — so this is one pattern written 3 times rather than 3 independent problems. Splitting this body alone leaves the other 2 exactly as they are. Where these are variations on one operation, the change that clears all 3 is the shared one: lift the common shape into a single routine the variants call, parameterised by whatever genuinely differs between them, and keep in each method only the part that is not shared.
D2 · Cognitive Complexity · Sender.run (cognitive 21) · ×1
  • Sender.run (cognitive 21) clients/src/main/java/org/apache/kafka/clients/producer/internals/Sender.java:241 — Sender.run has cognitive complexity 21 (threshold 15). Drivers by points: error handling 5 (10 pts), if/else 3 (5 pts), boolean chains 3, loops 3 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · KafkaProducer.waitOnMetadata (cognitive 21) · ×1
  • KafkaProducer.waitOnMetadata (cognitive 21) clients/src/main/java/org/apache/kafka/clients/producer/KafkaProducer.java:1299 — KafkaProducer.waitOnMetadata has cognitive complexity 21 (threshold 15). Drivers by points: if/else 7 (13 pts), boolean chains 5, error handling 1 (2 pts), loops 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · Protocol.schemaToBnfHtml (cognitive 21) · ×1
  • Protocol.schemaToBnfHtml (cognitive 21) clients/src/main/java/org/apache/kafka/common/protocol/Protocol.java:39 — Protocol.schemaToBnfHtml has cognitive complexity 21 (threshold 15). Drivers by points: if/else 11 (19 pts), loops 2 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · SaslClientAuthenticator.authenticate (cognitive 21) · ×1
  • SaslClientAuthenticator.authenticate (cognitive 21) clients/src/main/java/org/apache/kafka/common/security/authenticator/SaslClientAuthenticator.java:240 — SaslClientAuthenticator.authenticate has cognitive complexity 21 (threshold 15). Drivers by points: if/else 10 (17 pts), boolean chains 3, match/switch 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ChildFirstClassLoader.classpathToURLs (cognitive 21) · ×1
  • ChildFirstClassLoader.classpathToURLs (cognitive 21) clients/src/main/java/org/apache/kafka/common/utils/internals/ChildFirstClassLoader.java:48 — ChildFirstClassLoader.classpathToURLs has cognitive complexity 21 (threshold 15). Drivers by points: if/else 5 (12 pts), loops 2 (6 pts), error handling 1 (2 pts), boolean chains 1 (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ChunkedBytesStream.skip (cognitive 21) · ×1
  • ChunkedBytesStream.skip (cognitive 21) clients/src/main/java/org/apache/kafka/common/utils/internals/ChunkedBytesStream.java:283 — ChunkedBytesStream.skip has cognitive complexity 21 (threshold 15). Drivers by points: if/else 8 (19 pts), boolean chains 1, loops 1 (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · RemoteLogManager.isRemoteSegmentWithinLeaderEpochs (cognitive 21) · ×1
  • RemoteLogManager.isRemoteSegmentWithinLeaderEpochs (cognitive 21) storage/src/main/java/org/apache/kafka/server/log/remote/storage/RemoteLogManager.java:1770 — RemoteLogManager.isRemoteSegmentWithinLeaderEpochs has cognitive complexity 21 (threshold 15). Drivers by points: if/else 9 (16 pts), boolean chains 4, loops 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · SinkUtils.parseSinkConnectorOffsets (cognitive 21) · ×1
  • SinkUtils.parseSinkConnectorOffsets (cognitive 21) connect/runtime/src/main/java/org/apache/kafka/connect/util/SinkUtils.java:80 — SinkUtils.parseSinkConnectorOffsets has cognitive complexity 21 (threshold 15). Drivers by points: if/else 7 (14 pts), error handling 2 (5 pts), boolean chains 1, loops 1 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · OffsetSyncStore.updateSyncArray (cognitive 21) · ×1
  • OffsetSyncStore.updateSyncArray (cognitive 21) connect/mirror/src/main/java/org/apache/kafka/connect/mirror/OffsetSyncStore.java:223 — OffsetSyncStore.updateSyncArray has cognitive complexity 21 (threshold 15). Drivers by points: if/else 5 (10 pts), boolean chains 8, loops 2 (3 pts) (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · AbstractWorkerSourceTask.execute (cognitive 21) · ×1
  • AbstractWorkerSourceTask.execute (cognitive 21) connect/runtime/src/main/java/org/apache/kafka/connect/runtime/AbstractWorkerSourceTask.java:346 — AbstractWorkerSourceTask.execute has cognitive complexity 21 (threshold 15). Drivers by points: if/else 7 (16 pts), error handling 3 (4 pts), loops 1 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · WorkerSinkTask.commitOffsets (cognitive 21) · ×1
  • WorkerSinkTask.commitOffsets (cognitive 21) connect/runtime/src/main/java/org/apache/kafka/connect/runtime/WorkerSinkTask.java:419 — WorkerSinkTask.commitOffsets has cognitive complexity 21 (threshold 15). Drivers by points: if/else 12 (16 pts), loops 2 (4 pts), error handling 1 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · BalancedTaskAssignor.balanceTasksOverProcesses (cognitive 21) · ×1
  • BalancedTaskAssignor.balanceTasksOverProcesses (cognitive 21) group-coordinator/src/main/java/org/apache/kafka/coordinator/group/streams/assignor/BalancedTaskAssignor.java:305 — BalancedTaskAssignor.balanceTasksOverProcesses has cognitive complexity 21 (threshold 15). Drivers by points: loops 4 (10 pts), if/else 2 (9 pts), boolean chains 2 (nesting depth added 13). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
D2 · Cognitive Complexity · MessageDataGenerator.generateClassReader (cognitive 21) · ×1
  • MessageDataGenerator.generateClassReader (cognitive 21) generator/src/main/java/org/apache/kafka/message/MessageDataGenerator.java:419 — MessageDataGenerator.generateClassReader has cognitive complexity 21 (threshold 15). Drivers by points: if/else 11 (16 pts), boolean chains 3, loops 2 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · AuthorizerBenchmark.prepareAclCache (cognitive 21) · ×1
  • AuthorizerBenchmark.prepareAclCache (cognitive 21) jmh-benchmarks/src/main/java/org/apache/kafka/jmh/acl/AuthorizerBenchmark.java:120 — AuthorizerBenchmark.prepareAclCache has cognitive complexity 21 (threshold 15). Drivers by points: if/else 4 (9 pts), ternaries 3 (7 pts), loops 4 (5 pts) (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ReplicationControlManager.electLeaders (cognitive 21) · ×1
  • ReplicationControlManager.electLeaders (cognitive 21) metadata/src/main/java/org/apache/kafka/controller/ReplicationControlManager.java:1614 — ReplicationControlManager.electLeaders has cognitive complexity 21 (threshold 15). Drivers by points: loops 4 (11 pts), if/else 4 (10 pts) (nesting depth added 13). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
D2 · Cognitive Complexity · ReplicationControlManager.updatePartitionDirectories (cognitive 21) · ×1
  • ReplicationControlManager.updatePartitionDirectories (cognitive 21) metadata/src/main/java/org/apache/kafka/controller/ReplicationControlManager.java:2497 — ReplicationControlManager.updatePartitionDirectories has cognitive complexity 21 (threshold 15). Drivers by points: if/else 6 (17 pts), loops 2 (4 pts) (nesting depth added 13). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
D2 · Cognitive Complexity · Graph.detectNegativeCycles (cognitive 21) · ×1
  • Graph.detectNegativeCycles (cognitive 21) streams/src/main/java/org/apache/kafka/streams/processor/internals/assignment/Graph.java:484 — Graph.detectNegativeCycles has cognitive complexity 21 (threshold 15). Drivers by points: if/else 3 (13 pts), loops 3 (6 pts), boolean chains 2 (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · HighAvailabilityTaskAssignor.balanceTasksOverThreads (cognitive 21) · ×1
  • HighAvailabilityTaskAssignor.balanceTasksOverThreads (cognitive 21) streams/src/main/java/org/apache/kafka/streams/processor/internals/assignment/HighAvailabilityTaskAssignor.java:172 — HighAvailabilityTaskAssignor.balanceTasksOverThreads has cognitive complexity 21 (threshold 15). Drivers by points: loops 4 (10 pts), if/else 2 (9 pts), boolean chains 2 (nesting depth added 13). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
D2 · Cognitive Complexity · TaskExecutorThread.runOnce (cognitive 21) · ×1
  • TaskExecutorThread.runOnce (cognitive 21) streams/src/main/java/org/apache/kafka/streams/processor/internals/tasks/DefaultTaskExecutor.java:110 — TaskExecutorThread.runOnce has cognitive complexity 21 (threshold 15). Drivers by points: if/else 9 (18 pts), error handling 1 (2 pts), boolean chains 1 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · StateUpdaterThread.addTask (cognitive 21) · ×1
  • StateUpdaterThread.addTask (cognitive 21) streams/src/main/java/org/apache/kafka/streams/processor/internals/DefaultStateUpdater.java:566 — StateUpdaterThread.addTask has cognitive complexity 21 (threshold 15). Drivers by points: if/else 8 (11 pts), ternaries 5 (10 pts) (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · InternalTopologyBuilder.checkUnprovidedNames (cognitive 21) · ×1
  • InternalTopologyBuilder.checkUnprovidedNames (cognitive 21) streams/src/main/java/org/apache/kafka/streams/processor/internals/InternalTopologyBuilder.java:2325 — InternalTopologyBuilder.checkUnprovidedNames has cognitive complexity 21 (threshold 15). Drivers by points: if/else 9 (19 pts), loops 1 (2 pts) (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · StateDirectory.listTaskDirectories (cognitive 21) · ×1
  • StateDirectory.listTaskDirectories (cognitive 21) streams/src/main/java/org/apache/kafka/streams/processor/internals/StateDirectory.java:850 — StateDirectory.listTaskDirectories has cognitive complexity 21 (threshold 15). Drivers by points: if/else 6 (15 pts), loops 1 (4 pts), boolean chains 2 (nesting depth added 12). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
D2 · Cognitive Complexity · StoreChangelogReader.initializeChangelogs (cognitive 21) · ×1
  • StoreChangelogReader.initializeChangelogs (cognitive 21) streams/src/main/java/org/apache/kafka/streams/processor/internals/StoreChangelogReader.java:956 — StoreChangelogReader.initializeChangelogs has cognitive complexity 21 (threshold 15). Drivers by points: if/else 9 (16 pts), loops 2, ternaries 1 (2 pts), boolean chains 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · RocksDBVersionedStore.maybePutToLatestValueStore (cognitive 21) · ×1
  • RocksDBVersionedStore.maybePutToLatestValueStore (cognitive 21) streams/src/main/java/org/apache/kafka/streams/state/internals/RocksDBVersionedStore.java:775 — RocksDBVersionedStore.maybePutToLatestValueStore has cognitive complexity 21 (threshold 15). Drivers by points: if/else 9 (21 pts) (nesting depth added 12). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
D2 · Cognitive Complexity · StagedMergeIterator.computeNext (cognitive 21) · ×1
  • StagedMergeIterator.computeNext (cognitive 21) streams/src/main/java/org/apache/kafka/streams/state/internals/StagedMergeIterator.java:125 — StagedMergeIterator.computeNext has cognitive complexity 21 (threshold 15). Drivers by points: if/else 8 (17 pts), ternaries 1 (2 pts), boolean chains 1, loops 1 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · KafkaStreams.clientInstanceIds (cognitive 21) · ×1
  • KafkaStreams.clientInstanceIds (cognitive 21) streams/src/main/java/org/apache/kafka/streams/KafkaStreams.java:2056 — KafkaStreams.clientInstanceIds has cognitive complexity 21 (threshold 15). Drivers by points: if/else 11 (15 pts), error handling 3, loops 2, boolean chains 1 (nesting depth added 4). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · FeatureCommand.update (cognitive 21) · ×1
  • FeatureCommand.update (cognitive 21) tools/src/main/java/org/apache/kafka/tools/FeatureCommand.java:435 — FeatureCommand.update has cognitive complexity 21 (threshold 15). Drivers by points: ternaries 4 (12 pts), if/else 4 (5 pts), error handling 2, boolean chains 1, loops 1 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · NodeHeartbeat.handlePresentWorkers (cognitive 21) · ×1
  • NodeHeartbeat.handlePresentWorkers (cognitive 21) trogdor/src/main/java/org/apache/kafka/trogdor/coordinator/NodeManager.java:231 — NodeHeartbeat.handlePresentWorkers has cognitive complexity 21 (threshold 15). Drivers by points: if/else 7 (18 pts), boolean chains 2, loops 1 (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · SharePartition.countTerminalRecordsUpToNewLSO (cognitive 21) · ×1
  • SharePartition.countTerminalRecordsUpToNewLSO (cognitive 21) core/src/main/java/kafka/server/share/SharePartition.java:1378 — SharePartition.countTerminalRecordsUpToNewLSO has cognitive complexity 21 (threshold 15). Drivers by points: if/else 6 (16 pts), loops 2 (4 pts), boolean chains 1 (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · SharePartitionManager.newContext (cognitive 21) · ×1
  • SharePartitionManager.newContext (cognitive 21) core/src/main/java/kafka/server/share/SharePartitionManager.java:518 — SharePartitionManager.newContext has cognitive complexity 21 (threshold 15). Drivers by points: if/else 10 (21 pts) (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · TransactionStateManager.listTransactionStates (cognitive 21) · ×1
  • TransactionStateManager.listTransactionStates (cognitive 21) core/src/main/scala/kafka/coordinator/transaction/TransactionStateManager.scala:326 — TransactionStateManager.listTransactionStates has cognitive complexity 21 (threshold 15). Drivers by points: if/else 11 (14 pts), boolean chains 4, error handling 1 (3 pts) (nesting depth added 5). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
D2 · Cognitive Complexity · DynamicRemoteLogConfig.validateReconfiguration (cognitive 21) · ×1
  • DynamicRemoteLogConfig.validateReconfiguration (cognitive 21) core/src/main/scala/kafka/server/DynamicBrokerConfig.scala:797 — DynamicRemoteLogConfig.validateReconfiguration has cognitive complexity 21 (threshold 15). Drivers by points: if/else 9 (18 pts), boolean chains 3 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · TestAnalyzer.get_flaky_test_regressions (cognitive 21) · ×1
  • TestAnalyzer.get_flaky_test_regressions (cognitive 21) .github/scripts/develocity_reports.py:692 — TestAnalyzer.get_flaky_test_regressions has cognitive complexity 21 (threshold 15). Drivers by points: if/else 7 (14 pts), ternaries 2 (4 pts), boolean chains 2, loops 1 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · develocity_reports.print_most_problematic_tests (cognitive 21) · ×1
  • develocity_reports.print_most_problematic_tests (cognitive 21) .github/scripts/develocity_reports.py:966 — develocity_reports.print_most_problematic_tests has cognitive complexity 21 (threshold 15). Drivers by points: loops 5 (10 pts), if/else 3 (7 pts), ternaries 1 (4 pts) (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · FetchCollector.fetchRecords (cognitive 20) · ×1
  • FetchCollector.fetchRecords (cognitive 20) clients/src/main/java/org/apache/kafka/clients/consumer/internals/FetchCollector.java:149 — FetchCollector.fetchRecords has cognitive complexity 20 (threshold 15). Drivers by points: if/else 10 (20 pts) (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ConsumerPartitionAssignor.getAssignorInstances (cognitive 20) · ×1
  • ConsumerPartitionAssignor.getAssignorInstances (cognitive 20) clients/src/main/java/org/apache/kafka/clients/consumer/ConsumerPartitionAssignor.java:418 — ConsumerPartitionAssignor.getAssignorInstances has cognitive complexity 20 (threshold 15). Drivers by points: if/else 7 (16 pts), error handling 1 (3 pts), loops 1 (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · RecordAccumulator.drainBatchesForOneNode (cognitive 20) · ×1
  • RecordAccumulator.drainBatchesForOneNode (cognitive 20) clients/src/main/java/org/apache/kafka/clients/producer/internals/RecordAccumulator.java:976 — RecordAccumulator.drainBatchesForOneNode has cognitive complexity 20 (threshold 15). Drivers by points: if/else 8 (14 pts), boolean chains 3, ternaries 1 (2 pts), loops 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · Sender.getExpiredInflightBatches (cognitive 20) · ×1
  • Sender.getExpiredInflightBatches (cognitive 20) clients/src/main/java/org/apache/kafka/clients/producer/internals/Sender.java:185 — Sender.getExpiredInflightBatches has cognitive complexity 20 (threshold 15). Drivers by points: if/else 6 (16 pts), loops 2 (4 pts) (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · LocalLog.read (cognitive 20) · ×1
  • LocalLog.read (cognitive 20) storage/src/main/java/org/apache/kafka/storage/internals/log/LocalLog.java:467 — LocalLog.read has cognitive complexity 20 (threshold 15). Drivers by points: if/else 12 (16 pts), boolean chains 3, loops 1 (nesting depth added 4). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · LogManager.truncateTo (cognitive 20) · ×1
  • LogManager.truncateTo (cognitive 20) storage/src/main/java/org/apache/kafka/storage/internals/log/LogManager.java:932 — LogManager.truncateTo has cognitive complexity 20 (threshold 15). Drivers by points: if/else 5 (14 pts), boolean chains 3, ternaries 1 (2 pts), loops 1 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ProducerAppendInfo.checkSequence (cognitive 20) · ×1
  • ProducerAppendInfo.checkSequence (cognitive 20) storage/src/main/java/org/apache/kafka/storage/internals/log/ProducerAppendInfo.java:162 — ProducerAppendInfo.checkSequence has cognitive complexity 20 (threshold 15). Drivers by points: if/else 11 (16 pts), boolean chains 4 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ConfigDef.toHtml (cognitive 20) · ×1
  • ConfigDef.toHtml (cognitive 20) clients/src/main/java/org/apache/kafka/common/config/ConfigDef.java:1737 — ConfigDef.toHtml has cognitive complexity 20 (threshold 15). Drivers by points: if/else 6 (15 pts), loops 2 (3 pts), boolean chains 2 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · DefaultSslEngineFactory.createKeystore (cognitive 20) · ×1
  • DefaultSslEngineFactory.createKeystore (cognitive 20) clients/src/main/java/org/apache/kafka/common/security/ssl/DefaultSslEngineFactory.java:279 — DefaultSslEngineFactory.createKeystore has cognitive complexity 20 (threshold 15). Drivers by points: if/else 14 (16 pts), boolean chains 4 (nesting depth added 2). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
D2 · Cognitive Complexity · Feature.validateDefaultValueAndLatestProductionValue (cognitive 20) · ×1
  • Feature.validateDefaultValueAndLatestProductionValue (cognitive 20) server-common/src/main/java/org/apache/kafka/server/common/Feature.java:261 — Feature.validateDefaultValueAndLatestProductionValue has cognitive complexity 20 (threshold 15). Drivers by points: if/else 8 (16 pts), loops 3 (4 pts) (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · AbstractHerder.redactResolvedValues (cognitive 20) · ×1
  • AbstractHerder.redactResolvedValues (cognitive 20) connect/runtime/src/main/java/org/apache/kafka/connect/runtime/AbstractHerder.java:905 — AbstractHerder.redactResolvedValues has cognitive complexity 20 (threshold 15). Drivers by points: if/else 7 (16 pts), boolean chains 2, loops 2 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · AbstractWorkerSourceTask.sendRecords (cognitive 20) · ×1
  • AbstractWorkerSourceTask.sendRecords (cognitive 20) connect/runtime/src/main/java/org/apache/kafka/connect/runtime/AbstractWorkerSourceTask.java:408 — AbstractWorkerSourceTask.sendRecords has cognitive complexity 20 (threshold 15). Drivers by points: if/else 7 (11 pts), error handling 3 (6 pts), boolean chains 1, loops 1, ternaries 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · TransactionLog.read (cognitive 20) · ×1
  • TransactionLog.read (cognitive 20) transaction-coordinator/src/main/java/org/apache/kafka/coordinator/transaction/TransactionLog.java:118 — TransactionLog.read has cognitive complexity 20 (threshold 15). Drivers by points: if/else 7 (10 pts), loops 2 (9 pts), boolean chains 1 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ByteUtilsBenchmark.innerWriteUnsignedVarlongUnrolled (cognitive 20) · ×1
  • ByteUtilsBenchmark.innerWriteUnsignedVarlongUnrolled (cognitive 20) jmh-benchmarks/src/main/java/org/apache/kafka/jmh/util/ByteUtilsBenchmark.java:527 — ByteUtilsBenchmark.innerWriteUnsignedVarlongUnrolled has cognitive complexity 20 (threshold 15). Drivers by points: if/else 10 (20 pts) (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body. This shape REPEATS in the file: one other method here (ByteUtilsBenchmark.readUnsignedVarlongNetty) has the same decision points, in the same order, at the same nesting depths — so this is one pattern written twice rather than two separate problems. Splitting this body alone leaves the other exactly as it is. Where these are variations on one operation, the change that clears both is the shared one: lift the common shape into a single routine the variants call, parameterised by whatever genuinely differs between them, and keep in each method only the part that is not shared.
D2 · Cognitive Complexity · ByteUtilsBenchmark.readUnsignedVarlongNetty (cognitive 20) · ×1
  • ByteUtilsBenchmark.readUnsignedVarlongNetty (cognitive 20) jmh-benchmarks/src/main/java/org/apache/kafka/jmh/util/ByteUtilsBenchmark.java:415 — ByteUtilsBenchmark.readUnsignedVarlongNetty has cognitive complexity 20 (threshold 15). Drivers by points: if/else 10 (20 pts) (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body. This shape REPEATS in the file: one other method here (ByteUtilsBenchmark.innerWriteUnsignedVarlongUnrolled) has the same decision points, in the same order, at the same nesting depths — so this is one pattern written twice rather than two separate problems. Splitting this body alone leaves the other exactly as it is. Where these are variations on one operation, the change that clears both is the shared one: lift the common shape into a single routine the variants call, parameterised by whatever genuinely differs between them, and keep in each method only the part that is not shared.
D2 · Cognitive Complexity · ReplicationControlManager.createPartitions (cognitive 20) · ×1
  • ReplicationControlManager.createPartitions (cognitive 20) metadata/src/main/java/org/apache/kafka/controller/ReplicationControlManager.java:1957 — ReplicationControlManager.createPartitions has cognitive complexity 20 (threshold 15). Drivers by points: if/else 12 (16 pts), loops 2 (3 pts), error handling 1 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · KafkaRaftClient.handleVoteResponse (cognitive 20) · ×1
  • KafkaRaftClient.handleVoteResponse (cognitive 20) raft/src/main/java/org/apache/kafka/raft/KafkaRaftClient.java:953 — KafkaRaftClient.handleVoteResponse has cognitive complexity 20 (threshold 15). Drivers by points: if/else 15 (19 pts), boolean chains 1 (nesting depth added 4). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
D2 · Cognitive Complexity · EventHandler.enqueue (cognitive 20) · ×1
  • EventHandler.enqueue (cognitive 20) server-common/src/main/java/org/apache/kafka/queue/KafkaEventQueue.java:306 — EventHandler.enqueue has cognitive complexity 20 (threshold 15). Drivers by points: if/else 10 (15 pts), loops 1 (2 pts), ternaries 1 (2 pts), match/switch 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · RackAwareTaskAssignor.validateClientRack (cognitive 20) · ×1
  • RackAwareTaskAssignor.validateClientRack (cognitive 20) streams/src/main/java/org/apache/kafka/streams/processor/internals/assignment/RackAwareTaskAssignor.java:229 — RackAwareTaskAssignor.validateClientRack has cognitive complexity 20 (threshold 15). Drivers by points: if/else 7 (17 pts), loops 2 (3 pts) (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · StreamTask.maybeFlushTerminalE2ELatency (cognitive 20) · ×1
  • StreamTask.maybeFlushTerminalE2ELatency (cognitive 20) streams/src/main/java/org/apache/kafka/streams/processor/internals/StreamTask.java:1329 — StreamTask.maybeFlushTerminalE2ELatency has cognitive complexity 20 (threshold 15). Drivers by points: if/else 4 (13 pts), loops 2 (6 pts), boolean chains 1 (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · InternalStreamsBuilder.rewriteSingleStoreSelfJoin (cognitive 20) · ×1
  • InternalStreamsBuilder.rewriteSingleStoreSelfJoin (cognitive 20) streams/src/main/java/org/apache/kafka/streams/kstream/internals/InternalStreamsBuilder.java:439 — InternalStreamsBuilder.rewriteSingleStoreSelfJoin has cognitive complexity 20 (threshold 15). Drivers by points: if/else 7 (14 pts), boolean chains 3, loops 2 (3 pts) (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · KStreamImplJoin.join (cognitive 20) · ×1
  • KStreamImplJoin.join (cognitive 20) streams/src/main/java/org/apache/kafka/streams/kstream/internals/KStreamImplJoin.java:95 — KStreamImplJoin.join has cognitive complexity 20 (threshold 15). Drivers by points: ternaries 7 (10 pts), if/else 8 (9 pts), boolean chains 1 (nesting depth added 4). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
D2 · Cognitive Complexity · RocksDBStore.openRocksDB (cognitive 20) · ×1
  • RocksDBStore.openRocksDB (cognitive 20) streams/src/main/java/org/apache/kafka/streams/state/internals/RocksDBStore.java:356 — RocksDBStore.openRocksDB has cognitive complexity 20 (threshold 15). Drivers by points: if/else 5 (13 pts), loops 3 (5 pts), error handling 2 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · DumpLogSegments.dumpTimeIndex (cognitive 20) · ×1
  • DumpLogSegments.dumpTimeIndex (cognitive 20) tools/src/main/java/org/apache/kafka/tools/DumpLogSegments.java:243 — DumpLogSegments.dumpTimeIndex has cognitive complexity 20 (threshold 15). Drivers by points: if/else 8 (15 pts), loops 2 (4 pts), boolean chains 1 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · StreamsResetter.maybeDeleteActiveConsumers (cognitive 20) · ×1
  • StreamsResetter.maybeDeleteActiveConsumers (cognitive 20) tools/src/main/java/org/apache/kafka/tools/StreamsResetter.java:185 — StreamsResetter.maybeDeleteActiveConsumers has cognitive complexity 20 (threshold 15). Drivers by points: if/else 6 (16 pts), error handling 1 (2 pts), boolean chains 1, loops 1 (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · VerifiableShareConsumer.run (cognitive 20) · ×1
  • VerifiableShareConsumer.run (cognitive 20) tools/src/main/java/org/apache/kafka/tools/VerifiableShareConsumer.java:494 — VerifiableShareConsumer.run has cognitive complexity 20 (threshold 15). Drivers by points: if/else 5 (12 pts), loops 2 (5 pts), error handling 2, boolean chains 1 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ConfigAdminManager.preprocess (cognitive 20) · ×1
  • ConfigAdminManager.preprocess (cognitive 20) core/src/main/scala/kafka/server/ConfigAdminManager.scala:99 — ConfigAdminManager.preprocess has cognitive complexity 20 (threshold 15). Drivers by points: if/else 8 (15 pts), error handling 1 (2 pts), match/switch 1 (2 pts), boolean chains 1 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · junit.parse_report (cognitive 20) · ×1
  • junit.parse_report (cognitive 20) .github/scripts/junit.py:144 — junit.parse_report has cognitive complexity 20 (threshold 15). Drivers by points: if/else 7 (18 pts), boolean chains 1, loops 1 (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · RemoveMembersFromConsumerGroupResult.all (cognitive 19) · ×1
  • RemoveMembersFromConsumerGroupResult.all (cognitive 19) clients/src/main/java/org/apache/kafka/clients/admin/RemoveMembersFromConsumerGroupResult.java:51 — RemoveMembersFromConsumerGroupResult.all has cognitive complexity 19 (threshold 15). Drivers by points: if/else 6 (13 pts), loops 2 (6 pts) (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ShareConsumerImpl.collect (cognitive 19) · ×1
  • ShareConsumerImpl.collect (cognitive 19) clients/src/main/java/org/apache/kafka/clients/consumer/internals/ShareConsumerImpl.java:730 — ShareConsumerImpl.collect has cognitive complexity 19 (threshold 15). Drivers by points: if/else 9 (18 pts), boolean chains 1 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · Sender.failBatch (cognitive 19) · ×1
  • Sender.failBatch (cognitive 19) clients/src/main/java/org/apache/kafka/clients/producer/internals/Sender.java:770 — Sender.failBatch has cognitive complexity 19 (threshold 15). Drivers by points: if/else 12 (16 pts), loops 1 (2 pts), boolean chains 1 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · AddPartitionsToTxnHandler.handleResponse (cognitive 19) · ×1
  • AddPartitionsToTxnHandler.handleResponse (cognitive 19) clients/src/main/java/org/apache/kafka/clients/producer/internals/TransactionManager.java:1620 — AddPartitionsToTxnHandler.handleResponse has cognitive complexity 19 (threshold 15). Drivers by points: if/else 14 (15 pts), boolean chains 3, loops 1 (nesting depth added 1). To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D2 · Cognitive Complexity · KafkaProducer.<init> (cognitive 19) · ×1
  • KafkaProducer.<init> (cognitive 19) clients/src/main/java/org/apache/kafka/clients/producer/KafkaProducer.java:359 — KafkaProducer.<init> has cognitive complexity 19 (threshold 15). Drivers by points: if/else 14, boolean chains 4, error handling 1. To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D2 · Cognitive Complexity · Cleaner.cleanSegments (cognitive 19) · ×1
  • Cleaner.cleanSegments (cognitive 19) storage/src/main/java/org/apache/kafka/storage/internals/log/Cleaner.java:228 — Cleaner.cleanSegments has cognitive complexity 19 (threshold 15). Drivers by points: ternaries 4 (10 pts), if/else 2 (4 pts), loops 2 (3 pts), error handling 2 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · LogLoader.loadSegmentFiles (cognitive 19) · ×1
  • LogLoader.loadSegmentFiles (cognitive 19) storage/src/main/java/org/apache/kafka/storage/internals/log/LogLoader.java:357 — LogLoader.loadSegmentFiles has cognitive complexity 19 (threshold 15). Drivers by points: if/else 5 (11 pts), error handling 2 (6 pts), boolean chains 1, loops 1 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ConfigDef.compare (cognitive 19) · ×1
  • ConfigDef.compare (cognitive 19) clients/src/main/java/org/apache/kafka/common/config/ConfigDef.java:1608 — ConfigDef.compare has cognitive complexity 19 (threshold 15). Drivers by points: if/else 6 (12 pts), ternaries 3 (5 pts), boolean chains 2 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ConfigDef.toEnrichedRst (cognitive 19) · ×1
  • ConfigDef.toEnrichedRst (cognitive 19) clients/src/main/java/org/apache/kafka/common/config/ConfigDef.java:1527 — ConfigDef.toEnrichedRst has cognitive complexity 19 (threshold 15). Drivers by points: if/else 6 (14 pts), loops 2 (4 pts), boolean chains 1 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ConfigTransformer.transform (cognitive 19) · ×1
  • ConfigTransformer.transform (cognitive 19) clients/src/main/java/org/apache/kafka/common/config/ConfigTransformer.java:79 — ConfigTransformer.transform has cognitive complexity 19 (threshold 15). Drivers by points: loops 5 (9 pts), if/else 3 (8 pts), boolean chains 2 (nesting depth added 9). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
D2 · Cognitive Complexity · Refresher.run (cognitive 19) · ×1
  • Refresher.run (cognitive 19) clients/src/main/java/org/apache/kafka/common/security/oauthbearer/internals/expiring/ExpiringCredentialRefreshingLogin.java:72 — Refresher.run has cognitive complexity 19 (threshold 15). Drivers by points: if/else 4 (10 pts), error handling 2 (6 pts), loops 2 (3 pts) (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ProduceRequestHandler.handleProduceResponse (cognitive 19) · ×1
  • ProduceRequestHandler.handleProduceResponse (cognitive 19) server/src/main/java/org/apache/kafka/server/share/dlq/ShareGroupDLQStateManager.java:605 — ProduceRequestHandler.handleProduceResponse has cognitive complexity 19 (threshold 15). Drivers by points: if/else 7 (15 pts), match/switch 2 (3 pts), boolean chains 1 (nesting depth added 9). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
D2 · Cognitive Complexity · RemoteLogManager.read (cognitive 19) · ×1
  • RemoteLogManager.read (cognitive 19) storage/src/main/java/org/apache/kafka/server/log/remote/storage/RemoteLogManager.java:1876 — RemoteLogManager.read has cognitive complexity 19 (threshold 15). Drivers by points: if/else 8 (9 pts), ternaries 4 (6 pts), boolean chains 3, loops 1 (nesting depth added 3). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition.
D2 · Cognitive Complexity · Cast.getOrBuildSchema (cognitive 19) · ×1
  • Cast.getOrBuildSchema (cognitive 19) connect/transforms/src/main/java/org/apache/kafka/connect/transforms/Cast.java:196 — Cast.getOrBuildSchema has cognitive complexity 19 (threshold 15). Drivers by points: if/else 9 (17 pts), loops 1 (2 pts) (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · UniformHeterogeneousAssignmentBuilder.maybeRevokePartitions (cognitive 19) · ×1
  • UniformHeterogeneousAssignmentBuilder.maybeRevokePartitions (cognitive 19) group-coordinator/src/main/java/org/apache/kafka/coordinator/group/assignor/UniformHeterogeneousAssignmentBuilder.java:279 — UniformHeterogeneousAssignmentBuilder.maybeRevokePartitions has cognitive complexity 19 (threshold 15). Drivers by points: if/else 5 (12 pts), loops 3 (7 pts) (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · CurrentAssignmentBuilder.computeNextAssignment (cognitive 19) · ×1
  • CurrentAssignmentBuilder.computeNextAssignment (cognitive 19) group-coordinator/src/main/java/org/apache/kafka/coordinator/group/modern/consumer/CurrentAssignmentBuilder.java:368 — CurrentAssignmentBuilder.computeNextAssignment has cognitive complexity 19 (threshold 15). Drivers by points: if/else 8 (12 pts), boolean chains 3, loops 2, ternaries 1 (2 pts) (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · GroupCoordinatorConfig.consumerGroupAssignors (cognitive 19) · ×1
  • GroupCoordinatorConfig.consumerGroupAssignors (cognitive 19) group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupCoordinatorConfig.java:883 — GroupCoordinatorConfig.consumerGroupAssignors has cognitive complexity 19 (threshold 15). Drivers by points: error handling 4 (10 pts), if/else 3 (6 pts), loops 2 (3 pts) (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · GroupMetadataManager.classicGroupLeaveToClassicGroup (cognitive 19) · ×1
  • GroupMetadataManager.classicGroupLeaveToClassicGroup (cognitive 19) group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java:9201 — GroupMetadataManager.classicGroupLeaveToClassicGroup has cognitive complexity 19 (threshold 15). Drivers by points: if/else 7 (10 pts), error handling 1 (3 pts), match/switch 1 (2 pts), ternaries 1 (2 pts), boolean chains 1, loops 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · GroupMetadataManager.maybeUpdateRegularExpressions (cognitive 19) · ×1
  • GroupMetadataManager.maybeUpdateRegularExpressions (cognitive 19) group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java:3756 — GroupMetadataManager.maybeUpdateRegularExpressions has cognitive complexity 19 (threshold 15). Drivers by points: if/else 12 (16 pts), boolean chains 3 (nesting depth added 4). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · MessageDataGenerator.generateFieldToString (cognitive 19) · ×1
  • MessageDataGenerator.generateFieldToString (cognitive 19) generator/src/main/java/org/apache/kafka/message/MessageDataGenerator.java:1596 — MessageDataGenerator.generateFieldToString has cognitive complexity 19 (threshold 15). Drivers by points: if/else 15 (18 pts), boolean chains 1 (nesting depth added 3). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
D2 · Cognitive Complexity · ByteUtilsBenchmark.innerUnsignedReadVarLong (cognitive 19) · ×1
  • ByteUtilsBenchmark.innerUnsignedReadVarLong (cognitive 19) jmh-benchmarks/src/main/java/org/apache/kafka/jmh/util/ByteUtilsBenchmark.java:446 — ByteUtilsBenchmark.innerUnsignedReadVarLong has cognitive complexity 19 (threshold 15). Drivers by points: if/else 9 (19 pts) (nesting depth added 10). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function. This shape REPEATS in the file: one other method here (ByteUtilsBenchmark.readUnsignedVarintNetty) has the same decision points, in the same order, at the same nesting depths — so this is one pattern written twice rather than two separate problems. Splitting this body alone leaves the other exactly as it is. Where these are variations on one operation, the change that clears both is the shared one: lift the common shape into a single routine the variants call, parameterised by whatever genuinely differs between them, and keep in each method only the part that is not shared.
D2 · Cognitive Complexity · ByteUtilsBenchmark.readUnsignedVarintNetty (cognitive 19) · ×1
  • ByteUtilsBenchmark.readUnsignedVarintNetty (cognitive 19) jmh-benchmarks/src/main/java/org/apache/kafka/jmh/util/ByteUtilsBenchmark.java:382 — ByteUtilsBenchmark.readUnsignedVarintNetty has cognitive complexity 19 (threshold 15). Drivers by points: if/else 9 (19 pts) (nesting depth added 10). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function. This shape REPEATS in the file: one other method here (ByteUtilsBenchmark.innerUnsignedReadVarLong) has the same decision points, in the same order, at the same nesting depths — so this is one pattern written twice rather than two separate problems. Splitting this body alone leaves the other exactly as it is. Where these are variations on one operation, the change that clears both is the shared one: lift the common shape into a single routine the variants call, parameterised by whatever genuinely differs between them, and keep in each method only the part that is not shared.
D2 · Cognitive Complexity · FeatureControlManager.reasonNotSupported (cognitive 19) · ×1
  • FeatureControlManager.reasonNotSupported (cognitive 19) metadata/src/main/java/org/apache/kafka/controller/FeatureControlManager.java:336 — FeatureControlManager.reasonNotSupported has cognitive complexity 19 (threshold 15). Drivers by points: if/else 7 (14 pts), loops 3 (5 pts) (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · PartitionReassignmentReplicas.maybeCompleteReassignment (cognitive 19) · ×1
  • PartitionReassignmentReplicas.maybeCompleteReassignment (cognitive 19) metadata/src/main/java/org/apache/kafka/controller/PartitionReassignmentReplicas.java:97 — PartitionReassignmentReplicas.maybeCompleteReassignment has cognitive complexity 19 (threshold 15). Drivers by points: if/else 8 (14 pts), loops 2 (4 pts), boolean chains 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ReplicationControlManager.createTopics (cognitive 19) · ×1
  • ReplicationControlManager.createTopics (cognitive 19) metadata/src/main/java/org/apache/kafka/controller/ReplicationControlManager.java:642 — ReplicationControlManager.createTopics has cognitive complexity 19 (threshold 15). Drivers by points: if/else 9 (15 pts), error handling 1 (2 pts), loops 2 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · BaseHashTable.baseRemove (cognitive 19) · ×1
  • BaseHashTable.baseRemove (cognitive 19) server-common/src/main/java/org/apache/kafka/timeline/BaseHashTable.java:148 — BaseHashTable.baseRemove has cognitive complexity 19 (threshold 15). Drivers by points: if/else 7 (12 pts), ternaries 1 (5 pts), loops 1 (2 pts) (nesting depth added 10). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
D2 · Cognitive Complexity · LegacyStickyTaskAssignor.assignActive (cognitive 19) · ×1
  • LegacyStickyTaskAssignor.assignActive (cognitive 19) streams/src/main/java/org/apache/kafka/streams/processor/internals/assignment/LegacyStickyTaskAssignor.java:143 — LegacyStickyTaskAssignor.assignActive has cognitive complexity 19 (threshold 15). Drivers by points: if/else 5 (12 pts), loops 4 (6 pts), boolean chains 1 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · RackAwareTaskAssignor.populateTopicsToDescribe (cognitive 19) · ×1
  • RackAwareTaskAssignor.populateTopicsToDescribe (cognitive 19) streams/src/main/java/org/apache/kafka/streams/processor/internals/assignment/RackAwareTaskAssignor.java:139 — RackAwareTaskAssignor.populateTopicsToDescribe has cognitive complexity 19 (threshold 15). Drivers by points: if/else 5 (12 pts), loops 3 (6 pts), boolean chains 1 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · GlobalStateManagerImpl.commit (cognitive 19) · ×1
  • GlobalStateManagerImpl.commit (cognitive 19) streams/src/main/java/org/apache/kafka/streams/processor/internals/GlobalStateManagerImpl.java:585 — GlobalStateManagerImpl.commit has cognitive complexity 19 (threshold 15). Drivers by points: if/else 4 (11 pts), loops 2 (5 pts), error handling 1 (3 pts) (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · InternalTopicManager.getTopicPartitionInfo (cognitive 19) · ×1
  • InternalTopicManager.getTopicPartitionInfo (cognitive 19) streams/src/main/java/org/apache/kafka/streams/processor/internals/InternalTopicManager.java:625 — InternalTopicManager.getTopicPartitionInfo has cognitive complexity 19 (threshold 15). Drivers by points: if/else 6 (14 pts), error handling 2 (4 pts), loops 1 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · InternalTopicManager.validate (cognitive 19) · ×1
  • InternalTopicManager.validate (cognitive 19) streams/src/main/java/org/apache/kafka/streams/processor/internals/InternalTopicManager.java:152 — InternalTopicManager.validate has cognitive complexity 19 (threshold 15). Drivers by points: if/else 5 (13 pts), boolean chains 3, loops 2 (3 pts) (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · RepartitionTopics.setRepartitionSourceTopicPartitionCount (cognitive 19) · ×1
  • RepartitionTopics.setRepartitionSourceTopicPartitionCount (cognitive 19) streams/src/main/java/org/apache/kafka/streams/processor/internals/RepartitionTopics.java:207 — RepartitionTopics.setRepartitionSourceTopicPartitionCount has cognitive complexity 19 (threshold 15). Drivers by points: if/else 4 (12 pts), loops 3 (6 pts), boolean chains 1 (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · StateDirectory.clean (cognitive 19) · ×1
  • StateDirectory.clean (cognitive 19) streams/src/main/java/org/apache/kafka/streams/processor/internals/StateDirectory.java:569 — StateDirectory.clean has cognitive complexity 19 (threshold 15). Drivers by points: if/else 7 (11 pts), boolean chains 3, error handling 3, loops 1 (2 pts) (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · StateDirectory.maybeCleanEmptyNamedTopologyDirs (cognitive 19) · ×1
  • StateDirectory.maybeCleanEmptyNamedTopologyDirs (cognitive 19) streams/src/main/java/org/apache/kafka/streams/processor/internals/StateDirectory.java:730 — StateDirectory.maybeCleanEmptyNamedTopologyDirs has cognitive complexity 19 (threshold 15). Drivers by points: if/else 5 (11 pts), error handling 1 (4 pts), boolean chains 2, loops 1 (2 pts) (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · StreamTask.punctuate (cognitive 19) · ×1
  • StreamTask.punctuate (cognitive 19) streams/src/main/java/org/apache/kafka/streams/processor/internals/StreamTask.java:924 — StreamTask.punctuate has cognitive complexity 19 (threshold 15). Drivers by points: if/else 7 (10 pts), error handling 5 (6 pts), loops 1 (3 pts) (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · StreamsPartitionAssignor.assign (cognitive 19) · ×1
  • StreamsPartitionAssignor.assign (cognitive 19) streams/src/main/java/org/apache/kafka/streams/processor/internals/StreamsPartitionAssignor.java:344 — StreamsPartitionAssignor.assign has cognitive complexity 19 (threshold 15). Drivers by points: if/else 9 (15 pts), error handling 2, loops 2 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · TaskManager.closeAndRecycleTasks (cognitive 19) · ×1
  • TaskManager.closeAndRecycleTasks (cognitive 19) streams/src/main/java/org/apache/kafka/streams/processor/internals/TaskManager.java:769 — TaskManager.closeAndRecycleTasks has cognitive complexity 19 (threshold 15). Drivers by points: if/else 5 (9 pts), error handling 3 (6 pts), loops 4 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · TaskAssignmentUtils.optimizeRackAwareStandbyTasks (cognitive 19) · ×1
  • TaskAssignmentUtils.optimizeRackAwareStandbyTasks (cognitive 19) streams/src/main/java/org/apache/kafka/streams/processor/assignment/TaskAssignmentUtils.java:395 — TaskAssignmentUtils.optimizeRackAwareStandbyTasks has cognitive complexity 19 (threshold 15). Drivers by points: if/else 4 (10 pts), loops 3 (6 pts), boolean chains 3 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · KStreamSlidingWindowAggregateProcessor.processEarly (cognitive 19) · ×1
  • KStreamSlidingWindowAggregateProcessor.processEarly (cognitive 19) streams/src/main/java/org/apache/kafka/streams/kstream/internals/KStreamSlidingWindowAggregate.java:287 — KStreamSlidingWindowAggregateProcessor.processEarly has cognitive complexity 19 (threshold 15). Drivers by points: if/else 11 (14 pts), boolean chains 4, loops 1 (nesting depth added 3). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
D2 · Cognitive Complexity · KTableSourceProcessor.process (cognitive 19) · ×1
  • KTableSourceProcessor.process (cognitive 19) streams/src/main/java/org/apache/kafka/streams/kstream/internals/KTableSource.java:122 — KTableSourceProcessor.process has cognitive complexity 19 (threshold 15). Drivers by points: if/else 11 (19 pts) (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ShareConsumerPerformance.consumeRecordsForSingleShareConsumer (cognitive 19) · ×1
  • ShareConsumerPerformance.consumeRecordsForSingleShareConsumer (cognitive 19) tools/src/main/java/org/apache/kafka/tools/ShareConsumerPerformance.java:200 — ShareConsumerPerformance.consumeRecordsForSingleShareConsumer has cognitive complexity 19 (threshold 15). Drivers by points: if/else 5 (15 pts), loops 2 (3 pts), boolean chains 1 (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · SharePartition.releaseAcquiredRecordsForPerOffsetBatch (cognitive 19) · ×1
  • SharePartition.releaseAcquiredRecordsForPerOffsetBatch (cognitive 19) core/src/main/java/kafka/server/share/SharePartition.java:1149 — SharePartition.releaseAcquiredRecordsForPerOffsetBatch has cognitive complexity 19 (threshold 15). Drivers by points: if/else 4 (10 pts), ternaries 2 (6 pts), boolean chains 2, loops 1 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ApiSurfaceScanner.scanJars (cognitive 19) · ×1
  • ApiSurfaceScanner.scanJars (cognitive 19) api-checker/core/src/main/java/org/apache/kafka/apicheck/ApiSurfaceScanner.java:110 — ApiSurfaceScanner.scanJars has cognitive complexity 19 (threshold 15). Drivers by points: if/else 5 (15 pts), loops 2 (3 pts), boolean chains 1 (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · TransactionCoordinator.handleVerifyPartitionsInTransaction (cognitive 19) · ×1
  • TransactionCoordinator.handleVerifyPartitionsInTransaction (cognitive 19) core/src/main/scala/kafka/coordinator/transaction/TransactionCoordinator.scala:362 — TransactionCoordinator.handleVerifyPartitionsInTransaction has cognitive complexity 19 (threshold 15). Drivers by points: if/else 8 (13 pts), match/switch 2 (4 pts), boolean chains 2 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ConfigAdminManager.preprocess (cognitive 19) · ×1
  • ConfigAdminManager.preprocess (cognitive 19) core/src/main/scala/kafka/server/ConfigAdminManager.scala:213 — ConfigAdminManager.preprocess has cognitive complexity 19 (threshold 15). Drivers by points: if/else 8 (15 pts), error handling 1 (2 pts), match/switch 1 (2 pts) (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · DynamicBrokerConfig.processReconfiguration (cognitive 19) · ×1
  • DynamicBrokerConfig.processReconfiguration (cognitive 19) core/src/main/scala/kafka/server/DynamicBrokerConfig.scala:453 — DynamicBrokerConfig.processReconfiguration has cognitive complexity 19 (threshold 15). Drivers by points: if/else 7 (14 pts), error handling 1 (2 pts), match/switch 1 (2 pts), boolean chains 1 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · KafkaApis.validateAcknowledgementBatches (cognitive 19) · ×1
  • KafkaApis.validateAcknowledgementBatches (cognitive 19) core/src/main/scala/kafka/server/KafkaApis.scala:4191 — KafkaApis.validateAcknowledgementBatches has cognitive complexity 19 (threshold 15). Drivers by points: if/else 10 (14 pts), boolean chains 4, match/switch 1 (nesting depth added 4). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
D2 · Cognitive Complexity · AdminClientRunnable.processRequests (cognitive 18) · ×1
  • AdminClientRunnable.processRequests (cognitive 18) clients/src/main/java/org/apache/kafka/clients/admin/KafkaAdminClient.java:1575 — AdminClientRunnable.processRequests has cognitive complexity 18 (threshold 15). Drivers by points: if/else 7 (15 pts), boolean chains 2, loops 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · 6.handleResponse (cognitive 18) · ×1
  • 6.handleResponse (cognitive 18) clients/src/main/java/org/apache/kafka/clients/admin/KafkaAdminClient.java:2364 — 6.handleResponse has cognitive complexity 18 (threshold 15). Drivers by points: if/else 7 (12 pts), boolean chains 5, loops 1 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · Acknowledgements.maybeOptimiseAcknowledgeTypes (cognitive 18) · ×1
  • Acknowledgements.maybeOptimiseAcknowledgeTypes (cognitive 18) clients/src/main/java/org/apache/kafka/clients/consumer/internals/Acknowledgements.java:244 — Acknowledgements.maybeOptimiseAcknowledgeTypes has cognitive complexity 18 (threshold 15). Drivers by points: if/else 7 (13 pts), loops 2 (4 pts), boolean chains 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ProducerConfig.postProcessAndValidateIdempotenceConfigs (cognitive 18) · ×1
  • ProducerConfig.postProcessAndValidateIdempotenceConfigs (cognitive 18) clients/src/main/java/org/apache/kafka/clients/producer/ProducerConfig.java:643 — ProducerConfig.postProcessAndValidateIdempotenceConfigs has cognitive complexity 18 (threshold 15). Drivers by points: if/else 9 (16 pts), boolean chains 2 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · NetworkClientUtils.sendAndReceive (cognitive 18) · ×1
  • NetworkClientUtils.sendAndReceive (cognitive 18) clients/src/main/java/org/apache/kafka/clients/NetworkClientUtils.java:103 — NetworkClientUtils.sendAndReceive has cognitive complexity 18 (threshold 15). Drivers by points: if/else 5 (14 pts), loops 2 (3 pts), error handling 1 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · RemoteIndexCache.init (cognitive 18) · ×1
  • RemoteIndexCache.init (cognitive 18) storage/src/main/java/org/apache/kafka/storage/internals/log/RemoteIndexCache.java:275 — RemoteIndexCache.init has cognitive complexity 18 (threshold 15). Drivers by points: if/else 6 (11 pts), error handling 3 (4 pts), boolean chains 2, loops 1 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ConfigDef.getConfigValue (cognitive 18) · ×1
  • ConfigDef.getConfigValue (cognitive 18) clients/src/main/java/org/apache/kafka/common/config/ConfigDef.java:1369 — ConfigDef.getConfigValue has cognitive complexity 18 (threshold 15). Drivers by points: if/else 7 (15 pts), ternaries 1 (2 pts), match/switch 1 (nesting depth added 9). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
D2 · Cognitive Complexity · Builder.forConsumer (cognitive 18) · ×1
  • Builder.forConsumer (cognitive 18) clients/src/main/java/org/apache/kafka/common/requests/ShareFetchRequest.java:46 — Builder.forConsumer has cognitive complexity 18 (threshold 15). Drivers by points: if/else 8 (15 pts), loops 2 (3 pts) (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · SaslServerAuthenticator.authenticate (cognitive 18) · ×1
  • SaslServerAuthenticator.authenticate (cognitive 18) clients/src/main/java/org/apache/kafka/common/security/authenticator/SaslServerAuthenticator.java:254 — SaslServerAuthenticator.authenticate has cognitive complexity 18 (threshold 15). Drivers by points: if/else 6 (11 pts), error handling 3 (4 pts), boolean chains 2, match/switch 1 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · DynamicThreadPool.validateReconfiguration (cognitive 18) · ×1
  • DynamicThreadPool.validateReconfiguration (cognitive 18) server/src/main/java/org/apache/kafka/server/DynamicThreadPool.java:38 — DynamicThreadPool.validateReconfiguration has cognitive complexity 18 (threshold 15). Drivers by points: if/else 5 (17 pts), loops 1 (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ConnectSchema.validateValue (cognitive 18) · ×1
  • ConnectSchema.validateValue (cognitive 18) connect/api/src/main/java/org/apache/kafka/connect/data/ConnectSchema.java:218 — ConnectSchema.validateValue has cognitive complexity 18 (threshold 15). Drivers by points: if/else 7 (12 pts), loops 3 (5 pts), match/switch 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ValueParser.parseMap (cognitive 18) · ×1
  • ValueParser.parseMap (cognitive 18) connect/api/src/main/java/org/apache/kafka/connect/data/Values.java:941 — ValueParser.parseMap has cognitive complexity 18 (threshold 15). Drivers by points: if/else 8 (13 pts), boolean chains 2, ternaries 1 (2 pts), loops 1 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · KafkaConfigBackingStore.processTargetStateRecord (cognitive 18) · ×1
  • KafkaConfigBackingStore.processTargetStateRecord (cognitive 18) connect/runtime/src/main/java/org/apache/kafka/connect/storage/KafkaConfigBackingStore.java:935 — KafkaConfigBackingStore.processTargetStateRecord has cognitive complexity 18 (threshold 15). Drivers by points: if/else 8 (14 pts), boolean chains 2, error handling 1 (2 pts) (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · TimestampConverter.applyWithSchema (cognitive 18) · ×1
  • TimestampConverter.applyWithSchema (cognitive 18) connect/transforms/src/main/java/org/apache/kafka/connect/transforms/TimestampConverter.java:372 — TimestampConverter.applyWithSchema has cognitive complexity 18 (threshold 15). Drivers by points: if/else 7 (15 pts), loops 1 (3 pts) (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · MirrorCheckpointTask.syncGroupOffset (cognitive 18) · ×1
  • MirrorCheckpointTask.syncGroupOffset (cognitive 18) connect/mirror/src/main/java/org/apache/kafka/connect/mirror/MirrorCheckpointTask.java:337 — MirrorCheckpointTask.syncGroupOffset has cognitive complexity 18 (threshold 15). Drivers by points: if/else 6 (15 pts), loops 2 (3 pts) (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ConsumerGroup.subscriptionType (cognitive 18) · ×1
  • ConsumerGroup.subscriptionType (cognitive 18) group-coordinator/src/main/java/org/apache/kafka/coordinator/group/modern/consumer/ConsumerGroup.java:917 — ConsumerGroup.subscriptionType has cognitive complexity 18 (threshold 15). Drivers by points: if/else 6 (12 pts), loops 2 (5 pts), boolean chains 1 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · StickyTaskAssignor.assignActive (cognitive 18) · ×1
  • StickyTaskAssignor.assignActive (cognitive 18) group-coordinator/src/main/java/org/apache/kafka/coordinator/group/streams/assignor/StickyTaskAssignor.java:290 — StickyTaskAssignor.assignActive has cognitive complexity 18 (threshold 15). Drivers by points: if/else 7 (15 pts), loops 3 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · GroupMetadataManager.shareGroupBuildPartitionDeleteRequest (cognitive 18) · ×1
  • GroupMetadataManager.shareGroupBuildPartitionDeleteRequest (cognitive 18) group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java:9375 — GroupMetadataManager.shareGroupBuildPartitionDeleteRequest has cognitive complexity 18 (threshold 15). Drivers by points: if/else 9 (13 pts), loops 2 (4 pts), boolean chains 1 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · TransactionMetadata.completeTransitionTo (cognitive 18) · ×1
  • TransactionMetadata.completeTransitionTo (cognitive 18) transaction-coordinator/src/main/java/org/apache/kafka/coordinator/transaction/TransactionMetadata.java:349 — TransactionMetadata.completeTransitionTo has cognitive complexity 18 (threshold 15). Drivers by points: if/else 5 (9 pts), boolean chains 8, match/switch 1 (nesting depth added 4). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ClientQuotaControlManager.alterClientQuotaEntity (cognitive 18) · ×1
  • ClientQuotaControlManager.alterClientQuotaEntity (cognitive 18) metadata/src/main/java/org/apache/kafka/controller/ClientQuotaControlManager.java:164 — ClientQuotaControlManager.alterClientQuotaEntity has cognitive complexity 18 (threshold 15). Drivers by points: if/else 8 (16 pts), loops 1, ternaries 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ReplicationControlManager.generateLeaderAndIsrUpdates (cognitive 18) · ×1
  • ReplicationControlManager.generateLeaderAndIsrUpdates (cognitive 18) metadata/src/main/java/org/apache/kafka/controller/ReplicationControlManager.java:2106 — ReplicationControlManager.generateLeaderAndIsrUpdates has cognitive complexity 18 (threshold 15). Drivers by points: if/else 7 (12 pts), loops 2 (4 pts), boolean chains 2 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · MetadataDelta.apply (cognitive 18) · ×1
  • MetadataDelta.apply (cognitive 18) metadata/src/main/java/org/apache/kafka/image/MetadataDelta.java:395 — MetadataDelta.apply has cognitive complexity 18 (threshold 15). Drivers by points: if/else 18. To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D2 · Cognitive Complexity · RackList.place (cognitive 18) · ×1
  • RackList.place (cognitive 18) metadata/src/main/java/org/apache/kafka/metadata/placement/StripedReplicaPlacer.java:337 — RackList.place has cognitive complexity 18 (threshold 15). Drivers by points: if/else 7 (13 pts), loops 3 (4 pts), boolean chains 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · PerMechanismData.<init> (cognitive 18) · ×1
  • PerMechanismData.<init> (cognitive 18) metadata/src/main/java/org/apache/kafka/metadata/storage/ScramParser.java:96 — PerMechanismData.<init> has cognitive complexity 18 (threshold 15). Drivers by points: if/else 10 (11 pts), error handling 3 (6 pts), loops 1 (nesting depth added 4). To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D2 · Cognitive Complexity · InternalTopicManager.doValidateTopic (cognitive 18) · ×1
  • InternalTopicManager.doValidateTopic (cognitive 18) streams/src/main/java/org/apache/kafka/streams/processor/internals/InternalTopicManager.java:227 — InternalTopicManager.doValidateTopic has cognitive complexity 18 (threshold 15). Drivers by points: if/else 6 (11 pts), error handling 2 (6 pts), loops 1 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · TaskManager.maybeThrowTaskExceptions (cognitive 18) · ×1
  • TaskManager.maybeThrowTaskExceptions (cognitive 18) streams/src/main/java/org/apache/kafka/streams/processor/internals/TaskManager.java:428 — TaskManager.maybeThrowTaskExceptions has cognitive complexity 18 (threshold 15). Drivers by points: if/else 10 (16 pts), loops 1 (2 pts) (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · InternalStreamsBuilder.mergeRepartitionTopics (cognitive 18) · ×1
  • InternalStreamsBuilder.mergeRepartitionTopics (cognitive 18) streams/src/main/java/org/apache/kafka/streams/kstream/internals/InternalStreamsBuilder.java:476 — InternalStreamsBuilder.mergeRepartitionTopics has cognitive complexity 18 (threshold 15). Drivers by points: loops 5 (13 pts), if/else 2 (5 pts) (nesting depth added 11). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
D2 · Cognitive Complexity · LegacyCheckpointingStateStore.migrateLegacyOffsets (cognitive 18) · ×1
  • LegacyCheckpointingStateStore.migrateLegacyOffsets (cognitive 18) streams/src/main/java/org/apache/kafka/streams/state/internals/LegacyCheckpointingStateStore.java:142 — LegacyCheckpointingStateStore.migrateLegacyOffsets has cognitive complexity 18 (threshold 15). Drivers by points: if/else 5 (12 pts), loops 2 (4 pts), error handling 1 (2 pts) (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · StreamsGroupService.maybeDeleteInternalTopics (cognitive 18) · ×1
  • StreamsGroupService.maybeDeleteInternalTopics (cognitive 18) tools/src/main/java/org/apache/kafka/tools/streams/StreamsGroupCommand.java:822 — StreamsGroupService.maybeDeleteInternalTopics has cognitive complexity 18 (threshold 15). Drivers by points: if/else 3 (9 pts), error handling 2 (5 pts), boolean chains 2, loops 1 (2 pts) (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ConfigCommand.getAllClientQuotasConfigs (cognitive 18) · ×1
  • ConfigCommand.getAllClientQuotasConfigs (cognitive 18) tools/src/main/java/org/apache/kafka/tools/ConfigCommand.java:747 — ConfigCommand.getAllClientQuotasConfigs has cognitive complexity 18 (threshold 15). Drivers by points: if/else 9 (13 pts), ternaries 2 (4 pts), loops 1 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · FeatureCommand.handleFeatureDependencies (cognitive 18) · ×1
  • FeatureCommand.handleFeatureDependencies (cognitive 18) tools/src/main/java/org/apache/kafka/tools/FeatureCommand.java:387 — FeatureCommand.handleFeatureDependencies has cognitive complexity 18 (threshold 15). Drivers by points: if/else 7 (12 pts), error handling 1 (4 pts), loops 1 (2 pts) (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · KafkaApisBuilder.build (cognitive 18) · ×1
  • KafkaApisBuilder.build (cognitive 18) core/src/main/java/kafka/server/builders/KafkaApisBuilder.java:191 — KafkaApisBuilder.build has cognitive complexity 18 (threshold 15). Drivers by points: if/else 18. To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D2 · Cognitive Complexity · SharePartition.releaseAcquisitionLockOnTimeoutForPerOffsetBatch (cognitive 18) · ×1
  • SharePartition.releaseAcquisitionLockOnTimeoutForPerOffsetBatch (cognitive 18) core/src/main/java/kafka/server/share/SharePartition.java:3094 — SharePartition.releaseAcquisitionLockOnTimeoutForPerOffsetBatch has cognitive complexity 18 (threshold 15). Drivers by points: if/else 7 (14 pts), ternaries 1 (2 pts), boolean chains 1, loops 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · TransactionCoordinator.prepareInitProducerIdTransit (cognitive 18) · ×1
  • TransactionCoordinator.prepareInitProducerIdTransit (cognitive 18) core/src/main/scala/kafka/coordinator/transaction/TransactionCoordinator.scala:229 — TransactionCoordinator.prepareInitProducerIdTransit has cognitive complexity 18 (threshold 15). Drivers by points: if/else 5 (7 pts), match/switch 2 (5 pts), boolean chains 3, error handling 1 (3 pts) (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · SharedServer.start (cognitive 18) · ×1
  • SharedServer.start (cognitive 18) core/src/main/scala/kafka/server/SharedServer.scala:268 — SharedServer.start has cognitive complexity 18 (threshold 15). Drivers by points: if/else 9 (14 pts), error handling 2 (4 pts) (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · BrokerMetadataPublisher.onMetadataUpdate (cognitive 18) · ×1
  • BrokerMetadataPublisher.onMetadataUpdate (cognitive 18) core/src/main/scala/kafka/server/metadata/BrokerMetadataPublisher.scala:112 — BrokerMetadataPublisher.onMetadataUpdate has cognitive complexity 18 (threshold 15). Drivers by points: error handling 8 (9 pts), if/else 8 (9 pts) (nesting depth added 2). To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D2 · Cognitive Complexity · DynamicConfigPublisher.onMetadataUpdate (cognitive 18) · ×1
  • DynamicConfigPublisher.onMetadataUpdate (cognitive 18) core/src/main/scala/kafka/server/metadata/DynamicConfigPublisher.scala:49 — DynamicConfigPublisher.onMetadataUpdate has cognitive complexity 18 (threshold 15). Drivers by points: error handling 6 (13 pts), if/else 3 (4 pts), match/switch 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · checkstyle.parse_report (cognitive 18) · ×1
  • checkstyle.parse_report (cognitive 18) .github/scripts/checkstyle.py:38 — checkstyle.parse_report has cognitive complexity 18 (threshold 15). Drivers by points: if/else 5 (12 pts), loops 2 (5 pts), boolean chains 1 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · kafka-merge-pr.main (cognitive 18) · ×1
  • kafka-merge-pr.main (cognitive 18) REDACTED:387 — kafka-merge-pr.main has cognitive complexity 18 (threshold 15). Drivers by points: if/else 12 (15 pts), boolean chains 2, loops 1 (nesting depth added 3). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
D2 · Cognitive Complexity · AbstractCoordinator.ensureCoordinatorReady (cognitive 17) · ×1
  • AbstractCoordinator.ensureCoordinatorReady (cognitive 17) clients/src/main/java/org/apache/kafka/clients/consumer/internals/AbstractCoordinator.java:286 — AbstractCoordinator.ensureCoordinatorReady has cognitive complexity 17 (threshold 15). Drivers by points: if/else 8 (14 pts), boolean chains 2, loops 1 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ConstrainedAssignmentBuilder.assignRoundRobin (cognitive 17) · ×1
  • ConstrainedAssignmentBuilder.assignRoundRobin (cognitive 17) clients/src/main/java/org/apache/kafka/clients/consumer/internals/AbstractStickyAssignor.java:781 — ConstrainedAssignmentBuilder.assignRoundRobin has cognitive complexity 17 (threshold 15). Drivers by points: if/else 8 (15 pts), boolean chains 1, loops 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · GeneralAssignmentBuilder.assignOwnedPartitions (cognitive 17) · ×1
  • GeneralAssignmentBuilder.assignOwnedPartitions (cognitive 17) clients/src/main/java/org/apache/kafka/clients/consumer/internals/AbstractStickyAssignor.java:1033 — GeneralAssignmentBuilder.assignOwnedPartitions has cognitive complexity 17 (threshold 15). Drivers by points: if/else 5 (9 pts), loops 3 (7 pts), boolean chains 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ClassicKafkaConsumer.subscribeInternal (cognitive 17) · ×1
  • ClassicKafkaConsumer.subscribeInternal (cognitive 17) clients/src/main/java/org/apache/kafka/clients/consumer/internals/ClassicKafkaConsumer.java:495 — ClassicKafkaConsumer.subscribeInternal has cognitive complexity 17 (threshold 15). Drivers by points: if/else 7 (13 pts), loops 2 (4 pts) (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ConsumerCoordinator.fetchCommittedOffsets (cognitive 17) · ×1
  • ConsumerCoordinator.fetchCommittedOffsets (cognitive 17) clients/src/main/java/org/apache/kafka/clients/consumer/internals/ConsumerCoordinator.java:965 — ConsumerCoordinator.fetchCommittedOffsets has cognitive complexity 17 (threshold 15). Drivers by points: if/else 10 (15 pts), boolean chains 1, loops 1 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ConsumerSubscriptionState.maybeCompleteValidation (cognitive 17) · ×1
  • ConsumerSubscriptionState.maybeCompleteValidation (cognitive 17) clients/src/main/java/org/apache/kafka/clients/consumer/internals/ConsumerSubscriptionState.java:594 — ConsumerSubscriptionState.maybeCompleteValidation has cognitive complexity 17 (threshold 15). Drivers by points: if/else 11 (16 pts), boolean chains 1 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · OffsetFetcherUtils.handleListOffsetResponse (cognitive 17) · ×1
  • OffsetFetcherUtils.handleListOffsetResponse (cognitive 17) clients/src/main/java/org/apache/kafka/clients/consumer/internals/OffsetFetcherUtils.java:107 — OffsetFetcherUtils.handleListOffsetResponse has cognitive complexity 17 (threshold 15). Drivers by points: if/else 3 (6 pts), ternaries 1 (5 pts), loops 2 (3 pts), match/switch 1 (3 pts) (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ShareInFlightBatch.renew (cognitive 17) · ×1
  • ShareInFlightBatch.renew (cognitive 17) clients/src/main/java/org/apache/kafka/clients/consumer/internals/ShareInFlightBatch.java:144 — ShareInFlightBatch.renew has cognitive complexity 17 (threshold 15). Drivers by points: if/else 5 (13 pts), loops 1 (3 pts), boolean chains 1 (nesting depth added 10). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
D2 · Cognitive Complexity · KafkaProducer.doSend (cognitive 17) · ×1
  • KafkaProducer.doSend (cognitive 17) clients/src/main/java/org/apache/kafka/clients/producer/KafkaProducer.java:1180 — KafkaProducer.doSend has cognitive complexity 17 (threshold 15). Drivers by points: if/else 5 (8 pts), error handling 7, boolean chains 1, ternaries 1 (nesting depth added 3). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · FetchRequestData.toString (cognitive 17) · ×1
  • FetchRequestData.toString (cognitive 17) clients/src/main/java/org/apache/kafka/clients/FetchSessionHandler.java:179 — FetchRequestData.toString has cognitive complexity 17 (threshold 15). Drivers by points: loops 5 (10 pts), if/else 5 (7 pts) (nesting depth added 7). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
D2 · Cognitive Complexity · NetworkClient.cancelInFlightRequests (cognitive 17) · ×1
  • NetworkClient.cancelInFlightRequests (cognitive 17) clients/src/main/java/org/apache/kafka/clients/NetworkClient.java:473 — NetworkClient.cancelInFlightRequests has cognitive complexity 17 (threshold 15). Drivers by points: if/else 8 (15 pts), boolean chains 1, loops 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · LogLoader.removeTempFilesAndCollectSwapFiles (cognitive 17) · ×1
  • LogLoader.removeTempFilesAndCollectSwapFiles (cognitive 17) storage/src/main/java/org/apache/kafka/storage/internals/log/LogLoader.java:261 — LogLoader.removeTempFilesAndCollectSwapFiles has cognitive complexity 17 (threshold 15). Drivers by points: if/else 8 (12 pts), loops 4, boolean chains 1 (nesting depth added 4). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · LogManager.createLog (cognitive 17) · ×1
  • LogManager.createLog (cognitive 17) storage/src/main/java/org/apache/kafka/storage/internals/log/LogManager.java:1286 — LogManager.createLog has cognitive complexity 17 (threshold 15). Drivers by points: if/else 9 (10 pts), boolean chains 2, error handling 1 (2 pts), ternaries 2, loops 1 (nesting depth added 2). To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D2 · Cognitive Complexity · UnifiedLog.deletableSegments (cognitive 17) · ×1
  • UnifiedLog.deletableSegments (cognitive 17) storage/src/main/java/org/apache/kafka/storage/internals/log/UnifiedLog.java:1893 — UnifiedLog.deletableSegments has cognitive complexity 17 (threshold 15). Drivers by points: if/else 6 (11 pts), boolean chains 4, loops 1 (2 pts) (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · Selector.poll (cognitive 17) · ×1
  • Selector.poll (cognitive 17) clients/src/main/java/org/apache/kafka/common/network/Selector.java:445 — Selector.poll has cognitive complexity 17 (threshold 15). Drivers by points: if/else 7 (10 pts), boolean chains 5, loops 1 (2 pts) (nesting depth added 4). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · KerberosRule.apply (cognitive 17) · ×1
  • KerberosRule.apply (cognitive 17) clients/src/main/java/org/apache/kafka/common/security/kerberos/KerberosRule.java:179 — KerberosRule.apply has cognitive complexity 17 (threshold 15). Drivers by points: if/else 9 (13 pts), boolean chains 4 (nesting depth added 4). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ScramSaslClient.evaluateChallenge (cognitive 17) · ×1
  • ScramSaslClient.evaluateChallenge (cognitive 17) clients/src/main/java/org/apache/kafka/common/security/scram/internals/ScramSaslClient.java:94 — ScramSaslClient.evaluateChallenge has cognitive complexity 17 (threshold 15). Drivers by points: if/else 4 (8 pts), error handling 4 (7 pts), boolean chains 1, match/switch 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · SslEngineValidator.handshake (cognitive 17) · ×1
  • SslEngineValidator.handshake (cognitive 17) clients/src/main/java/org/apache/kafka/common/security/ssl/SslFactory.java:451 — SslEngineValidator.handshake has cognitive complexity 17 (threshold 15). Drivers by points: if/else 4 (11 pts), match/switch 2 (5 pts), loops 1 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · Cluster.<init> (cognitive 17) · ×1
  • Cluster.<init> (cognitive 17) clients/src/main/java/org/apache/kafka/common/Cluster.java:114 — Cluster.<init> has cognitive complexity 17 (threshold 15). Drivers by points: if/else 4 (9 pts), loops 5 (7 pts), boolean chains 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ClientQuotaManager.updateQuotaTypes (cognitive 17) · ×1
  • ClientQuotaManager.updateQuotaTypes (cognitive 17) server/src/main/java/org/apache/kafka/server/quota/ClientQuotaManager.java:572 — ClientQuotaManager.updateQuotaTypes has cognitive complexity 17 (threshold 15). Drivers by points: if/else 8 (9 pts), boolean chains 6, ternaries 2 (nesting depth added 1). To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D2 · Cognitive Complexity · PersisterStateManagerHandler.handleFindCoordinatorResponse (cognitive 17) · ×1
  • PersisterStateManagerHandler.handleFindCoordinatorResponse (cognitive 17) server-common/src/main/java/org/apache/kafka/server/share/persister/PersisterStateManager.java:493 — PersisterStateManagerHandler.handleFindCoordinatorResponse has cognitive complexity 17 (threshold 15). Drivers by points: if/else 6 (13 pts), match/switch 2 (3 pts), boolean chains 1 (nesting depth added 8). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
D2 · Cognitive Complexity · ProduceRequestHandler.handleCreateTopicsResponse (cognitive 17) · ×1
  • ProduceRequestHandler.handleCreateTopicsResponse (cognitive 17) server/src/main/java/org/apache/kafka/server/share/dlq/ShareGroupDLQStateManager.java:527 — ProduceRequestHandler.handleCreateTopicsResponse has cognitive complexity 17 (threshold 15). Drivers by points: if/else 4 (11 pts), error handling 1 (3 pts), match/switch 2 (3 pts) (nesting depth added 10). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
D2 · Cognitive Complexity · ConsumerTask.maybeMarkUserPartitionsAsReady (cognitive 17) · ×1
  • ConsumerTask.maybeMarkUserPartitionsAsReady (cognitive 17) storage/src/main/java/org/apache/kafka/server/log/remote/metadata/storage/ConsumerTask.java:189 — ConsumerTask.maybeMarkUserPartitionsAsReady has cognitive complexity 17 (threshold 15). Drivers by points: if/else 7 (13 pts), boolean chains 3, loops 1 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · TopicBasedRemoteLogMetadataManager.initializeResources (cognitive 17) · ×1
  • TopicBasedRemoteLogMetadataManager.initializeResources (cognitive 17) storage/src/main/java/org/apache/kafka/server/log/remote/metadata/storage/TopicBasedRemoteLogMetadataManager.java:316 — TopicBasedRemoteLogMetadataManager.initializeResources has cognitive complexity 17 (threshold 15). Drivers by points: if/else 5 (9 pts), error handling 3 (5 pts), boolean chains 2, loops 1 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · IncrementalCooperativeAssignor.performTaskAssignment (cognitive 17) · ×1
  • IncrementalCooperativeAssignor.performTaskAssignment (cognitive 17) connect/runtime/src/main/java/org/apache/kafka/connect/runtime/distributed/IncrementalCooperativeAssignor.java:197 — IncrementalCooperativeAssignor.performTaskAssignment has cognitive complexity 17 (threshold 15). Drivers by points: if/else 11 (15 pts), boolean chains 2 (nesting depth added 4). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · Builder.build (cognitive 17) · ×1
  • Builder.build (cognitive 17) coordinator-common/src/main/java/org/apache/kafka/coordinator/common/runtime/CoordinatorRuntime.java:207 — Builder.build has cognitive complexity 17 (threshold 15). Drivers by points: if/else 16, boolean chains 1. To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D2 · Cognitive Complexity · UniformHeterogeneousAssignmentBuilder.balanceTopic (cognitive 17) · ×1
  • UniformHeterogeneousAssignmentBuilder.balanceTopic (cognitive 17) group-coordinator/src/main/java/org/apache/kafka/coordinator/group/assignor/UniformHeterogeneousAssignmentBuilder.java:702 — UniformHeterogeneousAssignmentBuilder.balanceTopic has cognitive complexity 17 (threshold 15). Drivers by points: if/else 5 (11 pts), loops 4 (5 pts), boolean chains 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · GroupCoordinatorConfig.shareGroupAssignors (cognitive 17) · ×1
  • GroupCoordinatorConfig.shareGroupAssignors (cognitive 17) group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupCoordinatorConfig.java:1001 — GroupCoordinatorConfig.shareGroupAssignors has cognitive complexity 17 (threshold 15). Drivers by points: error handling 4 (10 pts), if/else 2 (4 pts), loops 2 (3 pts) (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · GroupMetadataManager.classicGroupJoinToConsumerGroup (cognitive 17) · ×1
  • GroupMetadataManager.classicGroupJoinToConsumerGroup (cognitive 17) group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java:2763 — GroupMetadataManager.classicGroupJoinToConsumerGroup has cognitive complexity 17 (threshold 15). Drivers by points: if/else 10 (12 pts), boolean chains 3, ternaries 1 (2 pts) (nesting depth added 3). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
D2 · Cognitive Complexity · FieldDomain.validate (cognitive 17) · ×1
  • FieldDomain.validate (cognitive 17) generator/src/main/java/org/apache/kafka/message/checker/FieldDomain.java:56 — FieldDomain.validate has cognitive complexity 17 (threshold 15). Drivers by points: if/else 8 (16 pts), match/switch 1 (nesting depth added 8). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
D2 · Cognitive Complexity · BrokersToElrs.update (cognitive 17) · ×1
  • BrokersToElrs.update (cognitive 17) metadata/src/main/java/org/apache/kafka/controller/BrokersToElrs.java:50 — BrokersToElrs.update has cognitive complexity 17 (threshold 15). Drivers by points: if/else 11 (16 pts), loops 1 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · QuorumController.appendRecords (cognitive 17) · ×1
  • QuorumController.appendRecords (cognitive 17) metadata/src/main/java/org/apache/kafka/controller/QuorumController.java:889 — QuorumController.appendRecords has cognitive complexity 17 (threshold 15). Drivers by points: if/else 7 (14 pts), loops 1 (2 pts), error handling 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · KRaftMetadataCache.describeTopicResponse (cognitive 17) · ×1
  • KRaftMetadataCache.describeTopicResponse (cognitive 17) metadata/src/main/java/org/apache/kafka/metadata/KRaftMetadataCache.java:278 — KRaftMetadataCache.describeTopicResponse has cognitive complexity 17 (threshold 15). Drivers by points: if/else 6 (12 pts), error handling 1 (4 pts), loops 1 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · DynamicVoter.parse (cognitive 17) · ×1
  • DynamicVoter.parse (cognitive 17) raft/src/main/java/org/apache/kafka/raft/DynamicVoter.java:46 — DynamicVoter.parse has cognitive complexity 17 (threshold 15). Drivers by points: if/else 11 (13 pts), error handling 3, boolean chains 1 (nesting depth added 2). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
D2 · Cognitive Complexity · LsCommandHandler.printEntries (cognitive 17) · ×1
  • LsCommandHandler.printEntries (cognitive 17) shell/src/main/java/org/apache/kafka/shell/command/LsCommandHandler.java:160 — LsCommandHandler.printEntries has cognitive complexity 17 (threshold 15). Drivers by points: if/else 4 (9 pts), loops 3 (8 pts) (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · SubscriptionInfo.taskOffsetSums (cognitive 17) · ×1
  • SubscriptionInfo.taskOffsetSums (cognitive 17) streams/src/main/java/org/apache/kafka/streams/processor/internals/assignment/SubscriptionInfo.java:267 — SubscriptionInfo.taskOffsetSums has cognitive complexity 17 (threshold 15). Drivers by points: if/else 5 (9 pts), loops 2 (8 pts) (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · KafkaStreamsNamedTopologyWrapper.resetOffsets (cognitive 17) · ×1
  • KafkaStreamsNamedTopologyWrapper.resetOffsets (cognitive 17) streams/src/main/java/org/apache/kafka/streams/processor/internals/namedtopology/KafkaStreamsNamedTopologyWrapper.java:298 — KafkaStreamsNamedTopologyWrapper.resetOffsets has cognitive complexity 17 (threshold 15). Drivers by points: error handling 3 (6 pts), if/else 4 (6 pts), ternaries 1 (3 pts), boolean chains 1, loops 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · DefaultTaskManager.lockTasks (cognitive 17) · ×1
  • DefaultTaskManager.lockTasks (cognitive 17) streams/src/main/java/org/apache/kafka/streams/processor/internals/tasks/DefaultTaskManager.java:188 — DefaultTaskManager.lockTasks has cognitive complexity 17 (threshold 15). Drivers by points: if/else 9 (15 pts), boolean chains 1, loops 1 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · GlobalStateManagerImpl.restoreState (cognitive 17) · ×1
  • GlobalStateManagerImpl.restoreState (cognitive 17) streams/src/main/java/org/apache/kafka/streams/processor/internals/GlobalStateManagerImpl.java:466 — GlobalStateManagerImpl.restoreState has cognitive complexity 17 (threshold 15). Drivers by points: if/else 5 (11 pts), loops 3 (6 pts) (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · InternalTopicManager.createTopics (cognitive 17) · ×1
  • InternalTopicManager.createTopics (cognitive 17) streams/src/main/java/org/apache/kafka/streams/processor/internals/InternalTopicManager.java:545 — InternalTopicManager.createTopics has cognitive complexity 17 (threshold 15). Drivers by points: if/else 6 (12 pts), error handling 2 (4 pts), loops 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · RecordCollectorImpl.recordSendError (cognitive 17) · ×1
  • RecordCollectorImpl.recordSendError (cognitive 17) streams/src/main/java/org/apache/kafka/streams/processor/internals/RecordCollectorImpl.java:462 — RecordCollectorImpl.recordSendError has cognitive complexity 17 (threshold 15). Drivers by points: if/else 8 (10 pts), loops 1 (3 pts), boolean chains 2, error handling 1 (2 pts) (nesting depth added 5). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
D2 · Cognitive Complexity · TaskManager.closeDirtyAndRevive (cognitive 17) · ×1
  • TaskManager.closeDirtyAndRevive (cognitive 17) streams/src/main/java/org/apache/kafka/streams/processor/internals/TaskManager.java:274 — TaskManager.closeDirtyAndRevive has cognitive complexity 17 (threshold 15). Drivers by points: if/else 4 (10 pts), error handling 2 (6 pts), loops 1 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · GlobalStateStoreProvider.stores (cognitive 17) · ×1
  • GlobalStateStoreProvider.stores (cognitive 17) streams/src/main/java/org/apache/kafka/streams/state/internals/GlobalStateStoreProvider.java:41 — GlobalStateStoreProvider.stores has cognitive complexity 17 (threshold 15). Drivers by points: if/else 11 (13 pts), boolean chains 4 (nesting depth added 2). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition.
D2 · Cognitive Complexity · PartiallyDeserializedSegmentValue.find (cognitive 17) · ×1
  • PartiallyDeserializedSegmentValue.find (cognitive 17) streams/src/main/java/org/apache/kafka/streams/state/internals/RocksDBVersionedStoreSegmentValueFormatter.java:287 — PartiallyDeserializedSegmentValue.find has cognitive complexity 17 (threshold 15). Drivers by points: if/else 9 (16 pts), loops 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · VerifiableShareConsumer.onRecordsReceived (cognitive 17) · ×1
  • VerifiableShareConsumer.onRecordsReceived (cognitive 17) tools/src/main/java/org/apache/kafka/tools/VerifiableShareConsumer.java:403 — VerifiableShareConsumer.onRecordsReceived has cognitive complexity 17 (threshold 15). Drivers by points: if/else 4 (11 pts), loops 3 (6 pts) (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · TransactionCoordinator.handleAddPartitionsToTransaction (cognitive 17) · ×1
  • TransactionCoordinator.handleAddPartitionsToTransaction (cognitive 17) core/src/main/scala/kafka/coordinator/transaction/TransactionCoordinator.scala:417 — TransactionCoordinator.handleAddPartitionsToTransaction has cognitive complexity 17 (threshold 15). Drivers by points: if/else 8 (10 pts), match/switch 2 (4 pts), boolean chains 3 (nesting depth added 4). To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D2 · Cognitive Complexity · TransactionMarkerChannelManager.addTxnMarkersToBrokerQueue (cognitive 17) · ×1
  • TransactionMarkerChannelManager.addTxnMarkersToBrokerQueue (cognitive 17) core/src/main/scala/kafka/coordinator/transaction/TransactionMarkerChannelManager.scala:339 — TransactionMarkerChannelManager.addTxnMarkersToBrokerQueue has cognitive complexity 17 (threshold 15). Drivers by points: if/else 6 (11 pts), match/switch 2 (5 pts), loops 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · KafkaApis.fetchAllOffsetsForGroup (cognitive 17) · ×1
  • KafkaApis.fetchAllOffsetsForGroup (cognitive 17) core/src/main/scala/kafka/server/KafkaApis.scala:1065 — KafkaApis.fetchAllOffsetsForGroup has cognitive complexity 17 (threshold 15). Drivers by points: if/else 8 (17 pts) (nesting depth added 9). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
D2 · Cognitive Complexity · verify_license.main (cognitive 17) · ×1
  • verify_license.main (cognitive 17) committer-tools/verify_license.py:77 — verify_license.main has cognitive complexity 17 (threshold 15). Drivers by points: if/else 9, loops 4 (6 pts), boolean chains 2 (nesting depth added 2). To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D2 · Cognitive Complexity · ListOffsetsHandler.handleResponse (cognitive 16) · ×1
  • ListOffsetsHandler.handleResponse (cognitive 16) clients/src/main/java/org/apache/kafka/clients/admin/internals/ListOffsetsHandler.java:119 — ListOffsetsHandler.handleResponse has cognitive complexity 16 (threshold 15). Drivers by points: if/else 4 (7 pts), loops 3 (4 pts), ternaries 1 (4 pts), boolean chains 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · BufferPool.allocate (cognitive 16) · ×1
  • BufferPool.allocate (cognitive 16) clients/src/main/java/org/apache/kafka/clients/producer/internals/BufferPool.java:136 — BufferPool.allocate has cognitive complexity 16 (threshold 15). Drivers by points: if/else 10 (12 pts), boolean chains 2, loops 1 (2 pts) (nesting depth added 3). To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D2 · Cognitive Complexity · BuiltInPartitioner.nextPartition (cognitive 16) · ×1
  • BuiltInPartitioner.nextPartition (cognitive 16) clients/src/main/java/org/apache/kafka/clients/producer/internals/BuiltInPartitioner.java:74 — BuiltInPartitioner.nextPartition has cognitive complexity 16 (threshold 15). Drivers by points: if/else 7 (14 pts), boolean chains 2 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · BuiltInPartitioner.updatePartitionLoadStats (cognitive 16) · ×1
  • BuiltInPartitioner.updatePartitionLoadStats (cognitive 16) clients/src/main/java/org/apache/kafka/clients/producer/internals/BuiltInPartitioner.java:273 — BuiltInPartitioner.updatePartitionLoadStats has cognitive complexity 16 (threshold 15). Drivers by points: if/else 9 (13 pts), boolean chains 2, loops 1 (nesting depth added 4). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · InitProducerIdHandler.handleResponse (cognitive 16) · ×1
  • InitProducerIdHandler.handleResponse (cognitive 16) clients/src/main/java/org/apache/kafka/clients/producer/internals/TransactionManager.java:1549 — InitProducerIdHandler.handleResponse has cognitive complexity 16 (threshold 15). Drivers by points: if/else 10 (12 pts), boolean chains 4 (nesting depth added 2). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
D2 · Cognitive Complexity · NetworkClient.handleApiVersionsResponse (cognitive 16) · ×1
  • NetworkClient.handleApiVersionsResponse (cognitive 16) clients/src/main/java/org/apache/kafka/clients/NetworkClient.java:1126 — NetworkClient.handleApiVersionsResponse has cognitive complexity 16 (threshold 15). Drivers by points: if/else 7 (13 pts), boolean chains 3 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · LogManager.asyncDelete (cognitive 16) · ×1
  • LogManager.asyncDelete (cognitive 16) storage/src/main/java/org/apache/kafka/storage/internals/log/LogManager.java:1587 — LogManager.asyncDelete has cognitive complexity 16 (threshold 15). Drivers by points: if/else 7 (12 pts), ternaries 2 (3 pts), boolean chains 1 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · LogManager.createAndValidateLogDirs (cognitive 16) · ×1
  • LogManager.createAndValidateLogDirs (cognitive 16) storage/src/main/java/org/apache/kafka/storage/internals/log/LogManager.java:343 — LogManager.createAndValidateLogDirs has cognitive complexity 16 (threshold 15). Drivers by points: if/else 6 (12 pts), error handling 1 (2 pts), boolean chains 1, loops 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · Sensor.checkQuotas (cognitive 16) · ×1
  • Sensor.checkQuotas (cognitive 16) clients/src/main/java/org/apache/kafka/common/metrics/Sensor.java:255 — Sensor.checkQuotas has cognitive complexity 16 (threshold 15). Drivers by points: if/else 5 (15 pts), loops 1 (nesting depth added 10). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
D2 · Cognitive Complexity · SslTransportLayer.transferFrom (cognitive 16) · ×1
  • SslTransportLayer.transferFrom (cognitive 16) clients/src/main/java/org/apache/kafka/common/network/SslTransportLayer.java:1010 — SslTransportLayer.transferFrom has cognitive complexity 16 (threshold 15). Drivers by points: if/else 9 (15 pts), loops 1 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · Protocol.toHtml (cognitive 16) · ×1
  • Protocol.toHtml (cognitive 16) clients/src/main/java/org/apache/kafka/common/protocol/Protocol.java:163 — Protocol.toHtml has cognitive complexity 16 (threshold 15). Drivers by points: if/else 3 (9 pts), loops 5 (7 pts) (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · Builder.build (cognitive 16) · ×1
  • Builder.build (cognitive 16) clients/src/main/java/org/apache/kafka/common/requests/TxnOffsetCommitRequest.java:100 — Builder.build has cognitive complexity 16 (threshold 15). Drivers by points: if/else 5 (9 pts), loops 2 (4 pts), boolean chains 3 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · CommonNameLoggingTrustManager.sortChainAnWrapEndCertificate (cognitive 16) · ×1
  • CommonNameLoggingTrustManager.sortChainAnWrapEndCertificate (cognitive 16) clients/src/main/java/org/apache/kafka/common/security/ssl/CommonNameLoggingTrustManagerFactoryWrapper.java:217 — CommonNameLoggingTrustManager.sortChainAnWrapEndCertificate has cognitive complexity 16 (threshold 15). Drivers by points: if/else 7 (12 pts), loops 3, boolean chains 1 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · SslFactory.createNewSslEngineFactory (cognitive 16) · ×1
  • SslFactory.createNewSslEngineFactory (cognitive 16) clients/src/main/java/org/apache/kafka/common/security/ssl/SslFactory.java:150 — SslFactory.createNewSslEngineFactory has cognitive complexity 16 (threshold 15). Drivers by points: if/else 10 (13 pts), boolean chains 2, error handling 1 (nesting depth added 3). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
D2 · Cognitive Complexity · WriteStateHandler.handleRequestResponse (cognitive 16) · ×1
  • WriteStateHandler.handleRequestResponse (cognitive 16) server-common/src/main/java/org/apache/kafka/server/share/persister/PersisterStateManager.java:874 — WriteStateHandler.handleRequestResponse has cognitive complexity 16 (threshold 15). Drivers by points: if/else 4 (11 pts), match/switch 2 (4 pts), boolean chains 1 (nesting depth added 9). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
D2 · Cognitive Complexity · ShareGroupDLQRecordHelper.buildDLQRecords (cognitive 16) · ×1
  • ShareGroupDLQRecordHelper.buildDLQRecords (cognitive 16) server/src/main/java/org/apache/kafka/server/share/dlq/ShareGroupDLQRecordHelper.java:173 — ShareGroupDLQRecordHelper.buildDLQRecords has cognitive complexity 16 (threshold 15). Drivers by points: if/else 4 (8 pts), ternaries 2 (6 pts), boolean chains 1, loops 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · 1.onComplete (cognitive 16) · ×1
  • 1.onComplete (cognitive 16) server/src/main/java/org/apache/kafka/server/KRaftTopicCreator.java:83 — 1.onComplete has cognitive complexity 16 (threshold 15). Drivers by points: if/else 9 (12 pts), error handling 1 (4 pts) (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ConsumeCallback.onCompletion (cognitive 16) · ×1
  • ConsumeCallback.onCompletion (cognitive 16) connect/runtime/src/main/java/org/apache/kafka/connect/storage/KafkaConfigBackingStore.java:881 — ConsumeCallback.onCompletion has cognitive complexity 16 (threshold 15). Drivers by points: if/else 12 (14 pts), boolean chains 1, error handling 1 (nesting depth added 2). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
D2 · Cognitive Complexity · InsertField.makeUpdatedSchema (cognitive 16) · ×1
  • InsertField.makeUpdatedSchema (cognitive 16) connect/transforms/src/main/java/org/apache/kafka/connect/transforms/InsertField.java:208 — InsertField.makeUpdatedSchema has cognitive complexity 16 (threshold 15). Drivers by points: ternaries 5 (10 pts), if/else 5, loops 1 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · MirrorMakerConfig.clusterPairs (cognitive 16) · ×1
  • MirrorMakerConfig.clusterPairs (cognitive 16) connect/mirror/src/main/java/org/apache/kafka/connect/mirror/MirrorMakerConfig.java:105 — MirrorMakerConfig.clusterPairs has cognitive complexity 16 (threshold 15). Drivers by points: if/else 4 (12 pts), loops 2 (3 pts), boolean chains 1 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · DistributedHerder.handleRebalanceCompleted (cognitive 16) · ×1
  • DistributedHerder.handleRebalanceCompleted (cognitive 16) connect/runtime/src/main/java/org/apache/kafka/connect/runtime/distributed/DistributedHerder.java:1853 — DistributedHerder.handleRebalanceCompleted has cognitive complexity 16 (threshold 15). Drivers by points: if/else 13 (15 pts), boolean chains 1 (nesting depth added 2). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
D2 · Cognitive Complexity · DistributedHerder.validateSourceConnectorTransactionBoundary (cognitive 16) · ×1
  • DistributedHerder.validateSourceConnectorTransactionBoundary (cognitive 16) connect/runtime/src/main/java/org/apache/kafka/connect/runtime/distributed/DistributedHerder.java:1030 — DistributedHerder.validateSourceConnectorTransactionBoundary has cognitive complexity 16 (threshold 15). Drivers by points: if/else 6 (12 pts), error handling 1 (3 pts), boolean chains 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · IncrementalCooperativeAssignor.loadBalancingRevocations (cognitive 16) · ×1
  • IncrementalCooperativeAssignor.loadBalancingRevocations (cognitive 16) connect/runtime/src/main/java/org/apache/kafka/connect/runtime/distributed/IncrementalCooperativeAssignor.java:676 — IncrementalCooperativeAssignor.loadBalancingRevocations has cognitive complexity 16 (threshold 15). Drivers by points: if/else 6 (12 pts), loops 2 (3 pts), boolean chains 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · TopicAssignmentPartialBuilder.revokeOversharedPartitions (cognitive 16) · ×1
  • TopicAssignmentPartialBuilder.revokeOversharedPartitions (cognitive 16) group-coordinator/src/main/java/org/apache/kafka/coordinator/group/assignor/SimpleHeterogeneousAssignmentBuilder.java:371 — TopicAssignmentPartialBuilder.revokeOversharedPartitions has cognitive complexity 16 (threshold 15). Drivers by points: if/else 5 (14 pts), loops 1 (2 pts) (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · TopicAssignmentPartialBuilder.revokeUnassignablePartitions (cognitive 16) · ×1
  • TopicAssignmentPartialBuilder.revokeUnassignablePartitions (cognitive 16) group-coordinator/src/main/java/org/apache/kafka/coordinator/group/assignor/SimpleHeterogeneousAssignmentBuilder.java:313 — TopicAssignmentPartialBuilder.revokeUnassignablePartitions has cognitive complexity 16 (threshold 15). Drivers by points: if/else 5 (11 pts), loops 2 (5 pts) (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · SimpleHomogeneousAssignmentBuilder.revokeOversharedPartitions (cognitive 16) · ×1
  • SimpleHomogeneousAssignmentBuilder.revokeOversharedPartitions (cognitive 16) group-coordinator/src/main/java/org/apache/kafka/coordinator/group/assignor/SimpleHomogeneousAssignmentBuilder.java:302 — SimpleHomogeneousAssignmentBuilder.revokeOversharedPartitions has cognitive complexity 16 (threshold 15). Drivers by points: if/else 5 (14 pts), loops 1 (2 pts) (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · CurrentAssignmentBuilder.updateCurrentAssignment (cognitive 16) · ×1
  • CurrentAssignmentBuilder.updateCurrentAssignment (cognitive 16) group-coordinator/src/main/java/org/apache/kafka/coordinator/group/modern/consumer/CurrentAssignmentBuilder.java:297 — CurrentAssignmentBuilder.updateCurrentAssignment has cognitive complexity 16 (threshold 15). Drivers by points: if/else 7 (12 pts), boolean chains 2, loops 1 (2 pts) (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · GroupMetadataManager.classicGroupSyncToClassicGroup (cognitive 16) · ×1
  • GroupMetadataManager.classicGroupSyncToClassicGroup (cognitive 16) group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java:8425 — GroupMetadataManager.classicGroupSyncToClassicGroup has cognitive complexity 16 (threshold 15). Drivers by points: if/else 11 (15 pts), boolean chains 1 (nesting depth added 4). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · TestLinearWriteSpeed.main (cognitive 16) · ×1
  • TestLinearWriteSpeed.main (cognitive 16) jmh-benchmarks/src/main/java/org/apache/kafka/jmh/log/TestLinearWriteSpeed.java:67 — TestLinearWriteSpeed.main has cognitive complexity 16 (threshold 15). Drivers by points: if/else 8 (12 pts), loops 4 (nesting depth added 4). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · Formatter.doFormat (cognitive 16) · ×1
  • Formatter.doFormat (cognitive 16) metadata/src/main/java/org/apache/kafka/metadata/storage/Formatter.java:401 — Formatter.doFormat has cognitive complexity 16 (threshold 15). Drivers by points: if/else 8 (11 pts), boolean chains 3, loops 1 (2 pts) (nesting depth added 4). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · KafkaRaftMetrics.initialize (cognitive 16) · ×1
  • KafkaRaftMetrics.initialize (cognitive 16) raft/src/main/java/org/apache/kafka/raft/internals/KafkaRaftMetrics.java:145 — KafkaRaftMetrics.initialize has cognitive complexity 16 (threshold 15). Drivers by points: if/else 13 (14 pts), boolean chains 2 (nesting depth added 1). To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D2 · Cognitive Complexity · KafkaRaftClient.handleFetchSnapshotResponse (cognitive 16) · ×1
  • KafkaRaftClient.handleFetchSnapshotResponse (cognitive 16) raft/src/main/java/org/apache/kafka/raft/KafkaRaftClient.java:2082 — KafkaRaftClient.handleFetchSnapshotResponse has cognitive complexity 16 (threshold 15). Drivers by points: if/else 14 (15 pts), boolean chains 1 (nesting depth added 1). To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D2 · Cognitive Complexity · GlobVisitor.accept (cognitive 16) · ×1
  • GlobVisitor.accept (cognitive 16) shell/src/main/java/org/apache/kafka/shell/glob/GlobVisitor.java:108 — GlobVisitor.accept has cognitive complexity 16 (threshold 15). Drivers by points: if/else 8 (15 pts), loops 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · Graph.populateInOutFlow (cognitive 16) · ×1
  • Graph.populateInOutFlow (cognitive 16) streams/src/main/java/org/apache/kafka/streams/processor/internals/assignment/Graph.java:349 — Graph.populateInOutFlow has cognitive complexity 16 (threshold 15). Drivers by points: if/else 6 (13 pts), loops 2 (3 pts) (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · RackAwareTaskAssignor.optimizeStandbyTasks (cognitive 16) · ×1
  • RackAwareTaskAssignor.optimizeStandbyTasks (cognitive 16) streams/src/main/java/org/apache/kafka/streams/processor/internals/assignment/RackAwareTaskAssignor.java:422 — RackAwareTaskAssignor.optimizeStandbyTasks has cognitive complexity 16 (threshold 15). Drivers by points: if/else 2 (8 pts), loops 3 (6 pts), boolean chains 2 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · InternalTopologyBuilder.copartitionGroups (cognitive 16) · ×1
  • InternalTopologyBuilder.copartitionGroups (cognitive 16) streams/src/main/java/org/apache/kafka/streams/processor/internals/InternalTopologyBuilder.java:1400 — InternalTopologyBuilder.copartitionGroups has cognitive complexity 16 (threshold 15). Drivers by points: if/else 3 (9 pts), loops 3 (7 pts) (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · StreamTask.process (cognitive 16) · ×1
  • StreamTask.process (cognitive 16) streams/src/main/java/org/apache/kafka/streams/processor/internals/StreamTask.java:783 — StreamTask.process has cognitive complexity 16 (threshold 15). Drivers by points: if/else 9 (12 pts), error handling 4 (nesting depth added 3). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · TaskExecutionMetadata.canProcessTask (cognitive 16) · ×1
  • TaskExecutionMetadata.canProcessTask (cognitive 16) streams/src/main/java/org/apache/kafka/streams/processor/internals/TaskExecutionMetadata.java:69 — TaskExecutionMetadata.canProcessTask has cognitive complexity 16 (threshold 15). Drivers by points: if/else 11 (14 pts), boolean chains 2 (nesting depth added 3). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
D2 · Cognitive Complexity · TaskManager.handleTasksInStateUpdater (cognitive 16) · ×1
  • TaskManager.handleTasksInStateUpdater (cognitive 16) streams/src/main/java/org/apache/kafka/streams/processor/internals/TaskManager.java:609 — TaskManager.handleTasksInStateUpdater has cognitive complexity 16 (threshold 15). Drivers by points: if/else 7 (15 pts), loops 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · KStreamKStreamJoinProcessor.emitNonJoinedOuterRecords (cognitive 16) · ×1
  • KStreamKStreamJoinProcessor.emitNonJoinedOuterRecords (cognitive 16) streams/src/main/java/org/apache/kafka/streams/kstream/internals/KStreamKStreamJoin.java:199 — KStreamKStreamJoinProcessor.emitNonJoinedOuterRecords has cognitive complexity 16 (threshold 15). Drivers by points: if/else 8 (13 pts), boolean chains 2, loops 1 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · KTableKTableOuterJoinProcessor.process (cognitive 16) · ×1
  • KTableKTableOuterJoinProcessor.process (cognitive 16) streams/src/main/java/org/apache/kafka/streams/kstream/internals/KTableKTableOuterJoin.java:89 — KTableKTableOuterJoinProcessor.process has cognitive complexity 16 (threshold 15). Drivers by points: if/else 9 (11 pts), boolean chains 5 (nesting depth added 2). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
D2 · Cognitive Complexity · CachingWindowStore.fetchKeyRangeInternal (cognitive 16) · ×1
  • CachingWindowStore.fetchKeyRangeInternal (cognitive 16) streams/src/main/java/org/apache/kafka/streams/state/internals/CachingWindowStore.java:285 — CachingWindowStore.fetchKeyRangeInternal has cognitive complexity 16 (threshold 15). Drivers by points: ternaries 6 (15 pts), if/else 1 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · RocksDBTimeOrderedKeyValueBuffer.evictWhile (cognitive 16) · ×1
  • RocksDBTimeOrderedKeyValueBuffer.evictWhile (cognitive 16) streams/src/main/java/org/apache/kafka/streams/state/internals/RocksDBTimeOrderedKeyValueBuffer.java:219 — RocksDBTimeOrderedKeyValueBuffer.evictWhile has cognitive complexity 16 (threshold 15). Drivers by points: if/else 6 (12 pts), boolean chains 2, loops 1 (2 pts) (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ConsumerGroupService.printMembersHelper (cognitive 16) · ×1
  • ConsumerGroupService.printMembersHelper (cognitive 16) tools/src/main/java/org/apache/kafka/tools/consumer/group/ConsumerGroupCommand.java:456 — ConsumerGroupService.printMembersHelper has cognitive complexity 16 (threshold 15). Drivers by points: if/else 5 (9 pts), ternaries 2 (6 pts), loops 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · StreamsGroupService.printMembers (cognitive 16) · ×1
  • StreamsGroupService.printMembers (cognitive 16) tools/src/main/java/org/apache/kafka/tools/streams/StreamsGroupCommand.java:327 — StreamsGroupService.printMembers has cognitive complexity 16 (threshold 15). Drivers by points: loops 3 (8 pts), if/else 3 (4 pts), ternaries 1 (4 pts) (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · AclCommandOptions.checkArgs (cognitive 16) · ×1
  • AclCommandOptions.checkArgs (cognitive 16) tools/src/main/java/org/apache/kafka/tools/AclCommand.java:544 — AclCommandOptions.checkArgs has cognitive complexity 16 (threshold 15). Drivers by points: boolean chains 9, if/else 7. To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
D2 · Cognitive Complexity · GetOffsetShell.fetchOffsets (cognitive 16) · ×1
  • GetOffsetShell.fetchOffsets (cognitive 16) tools/src/main/java/org/apache/kafka/tools/GetOffsetShell.java:206 — GetOffsetShell.fetchOffsets has cognitive complexity 16 (threshold 15). Drivers by points: if/else 7 (10 pts), boolean chains 2, error handling 1 (2 pts), loops 1, ternaries 1 (nesting depth added 4). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ConsumeMessages.call (cognitive 16) · ×1
  • ConsumeMessages.call (cognitive 16) trogdor/src/main/java/org/apache/kafka/trogdor/workload/ShareConsumeBenchWorker.java:267 — ConsumeMessages.call has cognitive complexity 16 (threshold 15). Drivers by points: if/else 5 (12 pts), loops 2 (3 pts), error handling 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · DelayedShareFetch.maybeCompletePendingRemoteFetch (cognitive 16) · ×1
  • DelayedShareFetch.maybeCompletePendingRemoteFetch (cognitive 16) core/src/main/java/kafka/server/share/DelayedShareFetch.java:1008 — DelayedShareFetch.maybeCompletePendingRemoteFetch has cognitive complexity 16 (threshold 15). Drivers by points: error handling 4 (8 pts), if/else 4 (6 pts), boolean chains 1, loops 1 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · DelayedShareFetch.tryComplete (cognitive 16) · ×1
  • DelayedShareFetch.tryComplete (cognitive 16) core/src/main/java/kafka/server/share/DelayedShareFetch.java:427 — DelayedShareFetch.tryComplete has cognitive complexity 16 (threshold 15). Drivers by points: if/else 10 (14 pts), boolean chains 1, error handling 1 (nesting depth added 4). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · SharePartition.archiveRecords (cognitive 16) · ×1
  • SharePartition.archiveRecords (cognitive 16) core/src/main/java/kafka/server/share/SharePartition.java:1429 — SharePartition.archiveRecords has cognitive complexity 16 (threshold 15). Drivers by points: if/else 4 (11 pts), boolean chains 4, loops 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · SharePartition.rollbackOrProcessStateUpdates (cognitive 16) · ×1
  • SharePartition.rollbackOrProcessStateUpdates (cognitive 16) core/src/main/java/kafka/server/share/SharePartition.java:2539 — SharePartition.rollbackOrProcessStateUpdates has cognitive complexity 16 (threshold 15). Drivers by points: if/else 11 (13 pts), boolean chains 2, loops 1 (nesting depth added 2). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
D2 · Cognitive Complexity · ViolationReporter.writeTextReport (cognitive 16) · ×1
  • ViolationReporter.writeTextReport (cognitive 16) api-checker/core/src/main/java/org/apache/kafka/apicheck/ViolationReporter.java:42 — ViolationReporter.writeTextReport has cognitive complexity 16 (threshold 15). Drivers by points: loops 5 (12 pts), if/else 3, ternaries 1 (nesting depth added 7). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
D2 · Cognitive Complexity · KafkaApis.handleOffsetDeleteRequest (cognitive 16) · ×1
  • KafkaApis.handleOffsetDeleteRequest (cognitive 16) core/src/main/scala/kafka/server/KafkaApis.scala:2440 — KafkaApis.handleOffsetDeleteRequest has cognitive complexity 16 (threshold 15). Drivers by points: if/else 10 (16 pts) (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · KafkaApis.handleListConfigResources (cognitive 16) · ×1
  • KafkaApis.handleListConfigResources (cognitive 16) core/src/main/scala/kafka/server/KafkaApis.scala:3100 — KafkaApis.handleListConfigResources has cognitive complexity 16 (threshold 15). Drivers by points: if/else 9 (16 pts) (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ReplicaManager.handleProduceAppend (cognitive 16) · ×1
  • ReplicaManager.handleProduceAppend (cognitive 16) core/src/main/scala/kafka/server/ReplicaManager.scala:697 — ReplicaManager.handleProduceAppend has cognitive complexity 16 (threshold 15). Drivers by points: if/else 13 (14 pts), boolean chains 1, match/switch 1 (nesting depth added 1). To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D2 · Cognitive Complexity · ReplicaManager.handleOffsetOutOfRangeError (cognitive 16) · ×1
  • ReplicaManager.handleOffsetOutOfRangeError (cognitive 16) core/src/main/scala/kafka/server/ReplicaManager.scala:1913 — ReplicaManager.handleOffsetOutOfRangeError has cognitive complexity 16 (threshold 15). Drivers by points: if/else 8 (14 pts), boolean chains 2 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · TestAnalyzer.get_problematic_quarantined_tests (cognitive 16) · ×1
  • TestAnalyzer.get_problematic_quarantined_tests (cognitive 16) .github/scripts/develocity_reports.py:560 — TestAnalyzer.get_problematic_quarantined_tests has cognitive complexity 16 (threshold 15). Drivers by points: if/else 3 (9 pts), error handling 1 (5 pts), boolean chains 1, loops 1 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D29 · Static Analysis (SAST) · REDACTED · ×1
  • REDACTED
D35 · Change Coupling · Change-coupling hub · ×1
  • Change-coupling hub: ReplicaFetcherThreadBenchmark.java → PartitionMakeFollowerBenchmark.java, UpdateFollowerFetchStateBenchmark.java, PartitionCreationBench.java jmh-benchmarks/src/main/java/org/apache/kafka/jmh/fetcher/ReplicaFetcherThreadBenchmark.java — `jmh-benchmarks/src/main/java/org/apache/kafka/jmh/fetcher/ReplicaFetcherThreadBenchmark.java` changes together with 3 other files — `jmh-benchmarks/src/main/java/org/apache/kafka/jmh/partition/PartitionMakeFollowerBenchmark.java`, `jmh-benchmarks/src/main/java/org/apache/kafka/jmh/partition/UpdateFollowerFetchStateBenchmark.java`, `jmh-benchmarks/src/main/java/org/apache/kafka/jmh/server/PartitionCreationBench.java` — none of which declares a dependency on it: one file is the hub of 3 separate couplings, not 3 unrelated pairs. Read the hub first: if the others each duplicate a part of what it does, the shared concern belongs in ONE unit and extracting it clears every edge at once; if the hub is a registry, dispatcher or barrel that must name each of them, the coupling is structural and the question is whether that list can be discovered instead of enumerated. Fixing the hub is one change; breaking the couplings one pair at a time is 3.
D36 · Supply-chain Provenance & Signing · REDACTED · ×1
  • REDACTED
D36 · Supply-chain Provenance & Signing · REDACTED · ×1
  • REDACTED
D4 · Code Duplication · Near-duplicate member family (4 members, 32 shared lines) · ×1
  • Near-duplicate member family (4 members, 32 shared lines) server-common/src/main/java/org/apache/kafka/server/share/persister/PersisterStateManager.java:660 — server-common/src/main/java/org/apache/kafka/server/share/persister/PersisterStateManager.java:660-743 | server-common/src/main/java/org/apache/kafka/server/share/persister/PersisterStateManager.java:1046-1126 | server-common/src/main/java/org/apache/kafka/server/share/persister/PersisterStateManager.java:1227-1307 | server-common/src/main/java/org/apache/kafka/server/share/persister/PersisterStateManager.java:1401-1485 — These 4 members are variants of one another: a block of 32 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
D4 · Code Duplication · Near-duplicate member family (4 members, 15 shared lines) · ×1
  • Near-duplicate member family (4 members, 15 shared lines) .github/scripts/develocity_reports.py:967 — .github/scripts/develocity_reports.py:967-1029 | .github/scripts/develocity_reports.py:1032-1077 | .github/scripts/develocity_reports.py:1080-1138 | .github/scripts/develocity_reports.py:1141-1208 — These 4 members are variants of one another: a block of 15 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
D4 · Code Duplication · Near-duplicate member family (3 members, 31 shared lines) · ×1
  • Near-duplicate member family (3 members, 31 shared lines) tools/src/main/java/org/apache/kafka/tools/consumer/group/ConsumerGroupCommandOptions.java:122 — tools/src/main/java/org/apache/kafka/tools/consumer/group/ConsumerGroupCommandOptions.java:122-205 | tools/src/main/java/org/apache/kafka/tools/consumer/group/ShareGroupCommandOptions.java:103-172 | tools/src/main/java/org/apache/kafka/tools/streams/StreamsGroupCommandOptions.java:125-208 — These 3 members are variants of one another: a block of 31 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 3 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 3 times.
D4 · Code Duplication · Near-duplicate member family (3 members, 19 shared lines) · ×1
  • Near-duplicate member family (3 members, 19 shared lines) streams/src/main/java/org/apache/kafka/streams/state/Stores.java:376 — streams/src/main/java/org/apache/kafka/streams/state/Stores.java:376-415 | streams/src/main/java/org/apache/kafka/streams/state/internals/RocksDbIndexedTimeOrderedWindowBytesStoreSupplier.java:49-79 | streams/src/main/java/org/apache/kafka/streams/state/internals/RocksDbIndexedTimeOrderedWindowBytesStoreWithHeadersSupplier.java:37-67 — These 3 members are variants of one another: a block of 19 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 3 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 3 times.
D4 · Code Duplication · Near-duplicate member pair (102 shared lines) · ×1
  • Near-duplicate member pair (102 shared lines) tools/src/main/java/org/apache/kafka/tools/consumer/ConsoleConsumerOptions.java:72 — tools/src/main/java/org/apache/kafka/tools/consumer/ConsoleConsumerOptions.java:72-233 | tools/src/main/java/org/apache/kafka/tools/consumer/ConsoleShareConsumerOptions.java:58-205 — These two members are variants of one another: 102 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
D4 · Code Duplication · Near-duplicate member pair (84 shared lines) · ×1
  • Near-duplicate member pair (84 shared lines) tools/src/main/java/org/apache/kafka/tools/ConsumerPerformance.java:287 — tools/src/main/java/org/apache/kafka/tools/ConsumerPerformance.java:287-384 | tools/src/main/java/org/apache/kafka/tools/ShareConsumerPerformance.java:331-428 — These two members are variants of one another: 84 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
D4 · Code Duplication · Near-duplicate member pair (77 shared lines) · ×1
  • Near-duplicate member pair (77 shared lines) core/src/main/scala/kafka/coordinator/transaction/TransactionCoordinator.scala:550 — core/src/main/scala/kafka/coordinator/transaction/TransactionCoordinator.scala:550-711 | core/src/main/scala/kafka/coordinator/transaction/TransactionCoordinator.scala:780-1037 — These two members are variants of one another: 77 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
D4 · Code Duplication · Near-duplicate member pair (67 shared lines) · ×1
  • Near-duplicate member pair (67 shared lines) tools/src/main/java/org/apache/kafka/tools/VerifiableConsumer.java:525 — tools/src/main/java/org/apache/kafka/tools/VerifiableConsumer.java:525-658 | tools/src/main/java/org/apache/kafka/tools/VerifiableShareConsumer.java:584-672 — These two members are variants of one another: 67 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
D4 · Code Duplication · Near-duplicate member pair (33 shared lines) · ×1
  • Near-duplicate member pair (33 shared lines) clients/src/main/java/org/apache/kafka/clients/consumer/internals/AsyncKafkaConsumer.java:1644 — clients/src/main/java/org/apache/kafka/clients/consumer/internals/AsyncKafkaConsumer.java:1644-1694 | clients/src/main/java/org/apache/kafka/clients/consumer/internals/ShareConsumerImpl.java:1015-1060 — These two members are variants of one another: 33 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
D4 · Code Duplication · Near-duplicate member pair (28 shared lines) · ×1
  • Near-duplicate member pair (28 shared lines) streams/src/main/java/org/apache/kafka/streams/kstream/internals/AbstractKStreamTimeWindowAggregateProcessor.java:75 — streams/src/main/java/org/apache/kafka/streams/kstream/internals/AbstractKStreamTimeWindowAggregateProcessor.java:75-126 | streams/src/main/java/org/apache/kafka/streams/kstream/internals/KStreamSessionWindowAggregate.java:124-173 — These two members are variants of one another: 28 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
D4 · Code Duplication · Near-duplicate member pair (17 shared lines) · ×1
  • Near-duplicate member pair (17 shared lines) clients/src/main/java/org/apache/kafka/common/utils/internals/ByteUtils.java:408 — clients/src/main/java/org/apache/kafka/common/utils/internals/ByteUtils.java:408-430 | jmh-benchmarks/src/main/java/org/apache/kafka/jmh/util/ByteUtilsBenchmark.java:560-582 — These two members are variants of one another: 17 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
D4 · Code Duplication · Edited copy of a member (26 corresponding lines) · ×1
  • Edited copy of a member (26 corresponding lines) jmh-benchmarks/src/main/java/org/apache/kafka/jmh/assignor/AssignorBenchmarkUtils.java:237 — jmh-benchmarks/src/main/java/org/apache/kafka/jmh/assignor/AssignorBenchmarkUtils.java:237-275 | jmh-benchmarks/src/main/java/org/apache/kafka/jmh/assignor/AssignorBenchmarkUtils.java:321-357 — These two members are one piece of code written twice and then edited apart: 26 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Edited copy of a member (27 corresponding lines) · ×1
  • Edited copy of a member (27 corresponding lines) clients/src/main/java/org/apache/kafka/clients/consumer/internals/metrics/KafkaConsumerMetrics.java:45 — clients/src/main/java/org/apache/kafka/clients/consumer/internals/metrics/KafkaConsumerMetrics.java:45-94 | clients/src/main/java/org/apache/kafka/clients/consumer/internals/metrics/KafkaShareConsumerMetrics.java:42-71 — These two members are one piece of code written twice and then edited apart: 27 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Edited copy of a member (10 corresponding lines) · ×1
  • Edited copy of a member (10 corresponding lines) metadata/src/main/java/org/apache/kafka/controller/ClusterControlManager.java:666 — metadata/src/main/java/org/apache/kafka/controller/ClusterControlManager.java:666-686 | metadata/src/main/java/org/apache/kafka/image/ClusterDelta.java:138-160 — These two members are one piece of code written twice and then edited apart: 10 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Edited copy of a member (32 corresponding lines) · ×1
  • Edited copy of a member (32 corresponding lines) streams/src/main/java/org/apache/kafka/streams/state/internals/CachingWindowStore.java:583 — streams/src/main/java/org/apache/kafka/streams/state/internals/CachingWindowStore.java:583-614 | streams/src/main/java/org/apache/kafka/streams/state/internals/TimeOrderedCachingWindowStore.java:752-783 — These two members are one piece of code written twice and then edited apart: 32 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Members sharing a duplicated core (13 members, 50+ identical tokens) · ×1
  • Members sharing a duplicated core (13 members, 50+ identical tokens) generator/src/main/java/org/apache/kafka/message/ApiMessageTypeGenerator.java:274 — generator/src/main/java/org/apache/kafka/message/ApiMessageTypeGenerator.java:274-297 | generator/src/main/java/org/apache/kafka/message/ApiMessageTypeGenerator.java:346-382 | generator/src/main/java/org/apache/kafka/message/CoordinatorRecordJsonConvertersGenerator.java:102-127 | generator/src/main/java/org/apache/kafka/message/CoordinatorRecordJsonConvertersGenerator.java:129-154 | generator/src/main/java/org/apache/kafka/message/CoordinatorRecordJsonConvertersGenerator.java:156-181 | generator/src/main/java/org/apache/kafka/message/CoordinatorRecordJsonConvertersGenerator.java:183-208 | generator/src/main/java/org/apache/kafka/message/CoordinatorRecordTypeGenerator.java:163-185 | generator/src/main/java/org/apache/kafka/message/CoordinatorRecordTypeGenerator.java:187-210 | generator/src/main/java/org/apache/kafka/message/CoordinatorRecordTypeGenerator.java:212-235 | generator/src/main/java/org/apache/kafka/message/MetadataJsonConvertersGenerator.java:70-95 | generator/src/main/java/org/apache/kafka/message/MetadataJsonConvertersGenerator.java:97-122 | generator/src/main/java/org/apache/kafka/message/MetadataRecordTypeGenerator.java:120-142 | generator/src/main/java/org/apache/kafka/message/MetadataRecordTypeGenerator.java:144-167 — These 13 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 13 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 13 times.
D4 · Code Duplication · Members sharing a duplicated core (10 members, 50+ identical tokens) · ×1
  • Members sharing a duplicated core (10 members, 50+ identical tokens) streams/src/main/java/org/apache/kafka/streams/kstream/internals/KStreamAggregate.java:102 — streams/src/main/java/org/apache/kafka/streams/kstream/internals/KStreamAggregate.java:102-144 | streams/src/main/java/org/apache/kafka/streams/kstream/internals/KStreamKTableJoinProcessor.java:143-174 | streams/src/main/java/org/apache/kafka/streams/kstream/internals/KStreamReduce.java:99-139 | streams/src/main/java/org/apache/kafka/streams/kstream/internals/KStreamSessionWindowAggregate.java:325-339 | streams/src/main/java/org/apache/kafka/streams/kstream/internals/KTableKTableInnerJoin.java:88-135 | streams/src/main/java/org/apache/kafka/streams/kstream/internals/KTableKTableLeftJoin.java:90-144 | streams/src/main/java/org/apache/kafka/streams/kstream/internals/KTableKTableOuterJoin.java:89-139 | streams/src/main/java/org/apache/kafka/streams/kstream/internals/KTableKTableRightJoin.java:88-135 | streams/src/main/java/org/apache/kafka/streams/kstream/internals/foreignkeyjoin/ForeignTableJoinProcessorSupplier.java:95-143 | streams/src/main/java/org/apache/kafka/streams/kstream/internals/foreignkeyjoin/SubscriptionReceiveProcessorSupplier.java:126-140 — These 10 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 10 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 10 times.
D4 · Code Duplication · Duplicated block (70–72 lines × 2) · ×1
  • Duplicated block (70–72 lines × 2) tools/src/main/java/org/apache/kafka/tools/consumer/ConsoleConsumerOptions.java:93 — tools/src/main/java/org/apache/kafka/tools/consumer/ConsoleConsumerOptions.java:93-162 | tools/src/main/java/org/apache/kafka/tools/consumer/ConsoleShareConsumerOptions.java:64-135 — before extracting anything, compare `tools/src/main/java/org/apache/kafka/tools/consumer/ConsoleConsumerOptions.java` and `tools/src/main/java/org/apache/kafka/tools/consumer/ConsoleShareConsumerOptions.java` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 157 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `tools/src/main/java/org/apache/kafka/tools/consumer/ConsoleConsumerOptions.java:163` calls `accepts` and `tools/src/main/java/org/apache/kafka/tools/consumer/ConsoleShareConsumerOptions.java:136` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (44 lines × 2) · ×1
  • Duplicated block (44 lines × 2) tools/src/main/java/org/apache/kafka/tools/ConsumerPerformance.java:318 — tools/src/main/java/org/apache/kafka/tools/ConsumerPerformance.java:318-361 | tools/src/main/java/org/apache/kafka/tools/ShareConsumerPerformance.java:356-399 — before extracting anything, compare `tools/src/main/java/org/apache/kafka/tools/ConsumerPerformance.java` and `tools/src/main/java/org/apache/kafka/tools/ShareConsumerPerformance.java` as WHOLE FILES: this scan already matched 10 separate duplicated blocks between them, totalling at least 119 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `tools/src/main/java/org/apache/kafka/tools/ConsumerPerformance.java:316` calls `accepts` and `tools/src/main/java/org/apache/kafka/tools/ShareConsumerPerformance.java:355` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (41 lines × 2) · ×1
  • Duplicated block (41 lines × 2) tools/src/main/java/org/apache/kafka/tools/consumer/group/ConsumerGroupCommandOptions.java:123 — tools/src/main/java/org/apache/kafka/tools/consumer/group/ConsumerGroupCommandOptions.java:123-163 | tools/src/main/java/org/apache/kafka/tools/consumer/group/ShareGroupCommandOptions.java:104-144 — before extracting anything, compare `tools/src/main/java/org/apache/kafka/tools/consumer/group/ConsumerGroupCommandOptions.java` and `tools/src/main/java/org/apache/kafka/tools/consumer/group/ShareGroupCommandOptions.java` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 85 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
D4 · Code Duplication · Duplicated block (38–39 lines × 2) · ×1
  • Duplicated block (38–39 lines × 2) connect/runtime/src/main/java/org/apache/kafka/connect/runtime/Worker.java:2183 — connect/runtime/src/main/java/org/apache/kafka/connect/runtime/Worker.java:2183-2220 | connect/runtime/src/main/java/org/apache/kafka/connect/runtime/Worker.java:2255-2293 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `connect/runtime/src/main/java/org/apache/kafka/connect/runtime/Worker.java:2183` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (36–38 lines × 2) · ×1
  • Duplicated block (36–38 lines × 2) streams/src/main/java/org/apache/kafka/streams/state/internals/AbstractDualSchemaRocksDBSegmentedBytesStore.java:250 — streams/src/main/java/org/apache/kafka/streams/state/internals/AbstractDualSchemaRocksDBSegmentedBytesStore.java:250-287 | streams/src/main/java/org/apache/kafka/streams/state/internals/AbstractRocksDBSegmentedBytesStore.java:302-337 — before extracting anything, compare `streams/src/main/java/org/apache/kafka/streams/state/internals/AbstractDualSchemaRocksDBSegmentedBytesStore.java` and `streams/src/main/java/org/apache/kafka/streams/state/internals/AbstractRocksDBSegmentedBytesStore.java` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 80 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
D4 · Code Duplication · Duplicated block (33–38 lines × 2) · ×1
  • Duplicated block (33–38 lines × 2) streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredSessionStore.java:476 — streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredSessionStore.java:476-508 | streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredWindowStore.java:481-518 — before extracting anything, compare `streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredSessionStore.java` and `streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredWindowStore.java` as WHOLE FILES: this scan already matched 11 separate duplicated blocks between them, totalling at least 156 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredSessionStore.java:476` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
D4 · Code Duplication · Duplicated block (35 lines × 2) · ×1
  • Duplicated block (35 lines × 2) streams/src/main/java/org/apache/kafka/streams/kstream/SessionWindowedDeserializer.java:56 — streams/src/main/java/org/apache/kafka/streams/kstream/SessionWindowedDeserializer.java:56-90 | streams/src/main/java/org/apache/kafka/streams/kstream/TimeWindowedDeserializer.java:133-167 — before extracting anything, compare `streams/src/main/java/org/apache/kafka/streams/kstream/SessionWindowedDeserializer.java` and `streams/src/main/java/org/apache/kafka/streams/kstream/TimeWindowedDeserializer.java` as WHOLE FILES: 84% of the shorter file's lines also appear in the other, so this reads as one file having been copied from the other rather than as a helper waiting to be extracted. The 2 duplicated block(s) this scan matched between them are fragments of that copy, not the extent of it — treat the file pair as the unit. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
D4 · Code Duplication · Duplicated block (33–34 lines × 2) · ×1
  • Duplicated block (33–34 lines × 2) clients/src/main/java/org/apache/kafka/clients/admin/internals/DescribeShareGroupsHandler.java:162 — clients/src/main/java/org/apache/kafka/clients/admin/internals/DescribeShareGroupsHandler.java:162-195 | clients/src/main/java/org/apache/kafka/clients/admin/internals/DescribeStreamsGroupsHandler.java:354-386 — before extracting anything, compare `clients/src/main/java/org/apache/kafka/clients/admin/internals/DescribeShareGroupsHandler.java` and `clients/src/main/java/org/apache/kafka/clients/admin/internals/DescribeStreamsGroupsHandler.java` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 58 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
D4 · Code Duplication · Duplicated block (34 lines × 2) · ×1
  • Duplicated block (34 lines × 2) streams/src/main/java/org/apache/kafka/streams/kstream/SessionWindowedSerializer.java:59 — streams/src/main/java/org/apache/kafka/streams/kstream/SessionWindowedSerializer.java:59-92 | streams/src/main/java/org/apache/kafka/streams/kstream/TimeWindowedSerializer.java:60-93 — before extracting anything, compare `streams/src/main/java/org/apache/kafka/streams/kstream/SessionWindowedSerializer.java` and `streams/src/main/java/org/apache/kafka/streams/kstream/TimeWindowedSerializer.java` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 54 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
D4 · Code Duplication · Duplicated block (32 lines × 2) · ×1
  • Duplicated block (32 lines × 2) tools/src/main/java/org/apache/kafka/tools/consumer/group/ConsumerGroupCommand.java:698 — tools/src/main/java/org/apache/kafka/tools/consumer/group/ConsumerGroupCommand.java:698-729 | tools/src/main/java/org/apache/kafka/tools/streams/StreamsGroupCommand.java:633-664 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
D4 · Code Duplication · Duplicated block (31 lines × 2) · ×1
  • Duplicated block (31 lines × 2) tools/src/main/java/org/apache/kafka/tools/consumer/group/ConsumerGroupCommand.java:763 — tools/src/main/java/org/apache/kafka/tools/consumer/group/ConsumerGroupCommand.java:763-793 | tools/src/main/java/org/apache/kafka/tools/streams/StreamsGroupCommand.java:713-743 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
D4 · Code Duplication · Duplicated block (29 lines × 2) · ×1
  • Duplicated block (29 lines × 2) generator/src/main/java/org/apache/kafka/message/CoordinatorRecordJsonConvertersGenerator.java:52 — generator/src/main/java/org/apache/kafka/message/CoordinatorRecordJsonConvertersGenerator.java:52-80 | generator/src/main/java/org/apache/kafka/message/CoordinatorRecordTypeGenerator.java:53-81 — before extracting anything, compare `generator/src/main/java/org/apache/kafka/message/CoordinatorRecordJsonConvertersGenerator.java` and `generator/src/main/java/org/apache/kafka/message/CoordinatorRecordTypeGenerator.java` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 47 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
D4 · Code Duplication · Duplicated block (28–29 lines × 2) · ×1
  • Duplicated block (28–29 lines × 2) streams/src/main/java/org/apache/kafka/streams/processor/internals/StreamThread.java:1689 — streams/src/main/java/org/apache/kafka/streams/processor/internals/StreamThread.java:1689-1716 | streams/src/main/java/org/apache/kafka/streams/processor/internals/StreamThread.java:1720-1748 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `streams/src/main/java/org/apache/kafka/streams/processor/internals/StreamThread.java:1720` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (26 lines × 3) · ×1
  • Duplicated block (26 lines × 3) streams/src/main/java/org/apache/kafka/streams/state/internals/CachingSessionStore.java:571 — streams/src/main/java/org/apache/kafka/streams/state/internals/CachingSessionStore.java:571-596 | streams/src/main/java/org/apache/kafka/streams/state/internals/CachingWindowStore.java:589-614 | streams/src/main/java/org/apache/kafka/streams/state/internals/TimeOrderedCachingWindowStore.java:758-783 — before extracting anything, compare `streams/src/main/java/org/apache/kafka/streams/state/internals/CachingSessionStore.java` and `streams/src/main/java/org/apache/kafka/streams/state/internals/CachingWindowStore.java` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 83 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `streams/src/main/java/org/apache/kafka/streams/state/internals/CachingSessionStore.java:571` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (20–24 lines × 3) · ×1
  • Duplicated block (20–24 lines × 3) server-common/src/main/java/org/apache/kafka/server/share/persister/DefaultStatePersister.java:206 — server-common/src/main/java/org/apache/kafka/server/share/persister/DefaultStatePersister.java:206-225 | server-common/src/main/java/org/apache/kafka/server/share/persister/DefaultStatePersister.java:251-270 | server-common/src/main/java/org/apache/kafka/server/share/persister/DefaultStatePersister.java:554-577 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `server-common/src/main/java/org/apache/kafka/server/share/persister/DefaultStatePersister.java:206` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
D4 · Code Duplication · Duplicated block (15–24 lines × 3) · ×1
  • Duplicated block (15–24 lines × 3) streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredKeyValueStore.java:167 — streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredKeyValueStore.java:167-190 | streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredSessionStore.java:136-150 | streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredWindowStore.java:154-168 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 3 call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredKeyValueStore.java:167` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredSessionStore.java:133` calls `removeSensor`, `toString`, `name` and `streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredWindowStore.java:151` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (23 lines × 5) · ×1
  • Duplicated block (23 lines × 5) streams/src/main/java/org/apache/kafka/streams/kstream/internals/KTableKTableInnerJoin.java:90 — streams/src/main/java/org/apache/kafka/streams/kstream/internals/KTableKTableInnerJoin.java:90-112 | streams/src/main/java/org/apache/kafka/streams/kstream/internals/KTableKTableLeftJoin.java:92-114 | streams/src/main/java/org/apache/kafka/streams/kstream/internals/KTableKTableOuterJoin.java:91-113 | streams/src/main/java/org/apache/kafka/streams/kstream/internals/KTableKTableRightJoin.java:90-112 | streams/src/main/java/org/apache/kafka/streams/kstream/internals/foreignkeyjoin/ForeignTableJoinProcessorSupplier.java:98-120 — before extracting anything, compare `streams/src/main/java/org/apache/kafka/streams/kstream/internals/KTableKTableInnerJoin.java` and `streams/src/main/java/org/apache/kafka/streams/kstream/internals/KTableKTableLeftJoin.java` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 55 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. Note first that the copies are not typed on the same thing: the declarations holding them bind `record` to `Record<K, Change<V1>>` in one and `Record<KRight, Change<VRight>>` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
D4 · Code Duplication · Duplicated block (12–23 lines × 3) · ×1
  • Duplicated block (12–23 lines × 3) server-common/src/main/java/org/apache/kafka/server/share/persister/PersisterStateManager.java:139 — server-common/src/main/java/org/apache/kafka/server/share/persister/PersisterStateManager.java:139-150 | server/src/main/java/org/apache/kafka/server/share/dlq/ShareGroupDLQStateManager.java:108-130 | server/src/main/java/org/apache/kafka/server/util/NetworkPartitionMetadataClient.java:80-94 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times.
D4 · Code Duplication · Duplicated block (20–23 lines × 2) · ×1
  • Duplicated block (20–23 lines × 2) streams/src/main/java/org/apache/kafka/streams/processor/internals/DefaultStateUpdater.java:304 — streams/src/main/java/org/apache/kafka/streams/processor/internals/DefaultStateUpdater.java:304-326 | streams/src/main/java/org/apache/kafka/streams/processor/internals/GlobalStreamThread.java:331-350 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `streams/src/main/java/org/apache/kafka/streams/processor/internals/DefaultStateUpdater.java:304` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (22 lines × 6) · ×1
  • Duplicated block (22 lines × 6) streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredKeyValueStore.java:255 — streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredKeyValueStore.java:255-276 | streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredSessionStore.java:442-463 | streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredTimestampedKeyValueStore.java:142-163 | streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredTimestampedKeyValueStoreWithHeaders.java:320-341 | streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredVersionedKeyValueStore.java:194-215 | streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredWindowStore.java:444-465 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 6 call sites, so a change lands once. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
D4 · Code Duplication · Duplicated block (20–22 lines × 3) · ×1
  • Duplicated block (20–22 lines × 3) clients/src/main/java/org/apache/kafka/clients/admin/internals/DeleteConsumerGroupOffsetsHandler.java:148 — clients/src/main/java/org/apache/kafka/clients/admin/internals/DeleteConsumerGroupOffsetsHandler.java:148-169 | clients/src/main/java/org/apache/kafka/clients/admin/internals/ListConsumerGroupOffsetsHandler.java:201-221 | clients/src/main/java/org/apache/kafka/clients/admin/internals/RemoveMembersFromConsumerGroupHandler.java:126-145 — before extracting anything, compare `clients/src/main/java/org/apache/kafka/clients/admin/internals/DeleteConsumerGroupOffsetsHandler.java` and `clients/src/main/java/org/apache/kafka/clients/admin/internals/RemoveMembersFromConsumerGroupHandler.java` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 61 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (21–22 lines × 3) · ×1
  • Duplicated block (21–22 lines × 3) streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredSessionStoreWithHeaders.java:87 — streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredSessionStoreWithHeaders.java:87-108 | streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredTimestampedKeyValueStoreWithHeaders.java:156-176 | streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredTimestampedWindowStoreWithHeaders.java:98-119 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 3 call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredSessionStoreWithHeaders.java:87` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (19–22 lines × 2) · ×1
  • Duplicated block (19–22 lines × 2) server/src/main/java/org/apache/kafka/server/share/dlq/ShareGroupDLQRecordFetcher.java:333 — server/src/main/java/org/apache/kafka/server/share/dlq/ShareGroupDLQRecordFetcher.java:333-351 | server/src/main/java/org/apache/kafka/server/share/dlq/ShareGroupDLQRecordFetcher.java:472-493 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (21 lines × 4) · ×1
  • Duplicated block (21 lines × 4) server-common/src/main/java/org/apache/kafka/server/share/persister/PersisterStateManager.java:709 — server-common/src/main/java/org/apache/kafka/server/share/persister/PersisterStateManager.java:709-729 | server-common/src/main/java/org/apache/kafka/server/share/persister/PersisterStateManager.java:1092-1112 | server-common/src/main/java/org/apache/kafka/server/share/persister/PersisterStateManager.java:1273-1293 | server-common/src/main/java/org/apache/kafka/server/share/persister/PersisterStateManager.java:1451-1471 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `server-common/src/main/java/org/apache/kafka/server/share/persister/PersisterStateManager.java:709` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (19–20 lines × 4) · ×1
  • Duplicated block (19–20 lines × 4) raft/src/main/java/org/apache/kafka/raft/KafkaRaftClient.java:989 — raft/src/main/java/org/apache/kafka/raft/KafkaRaftClient.java:989-1007 | raft/src/main/java/org/apache/kafka/raft/KafkaRaftClient.java:1198-1216 | raft/src/main/java/org/apache/kafka/raft/KafkaRaftClient.java:1374-1392 | raft/src/main/java/org/apache/kafka/raft/KafkaRaftClient.java:1723-1742 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `raft/src/main/java/org/apache/kafka/raft/KafkaRaftClient.java:989` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (19–20 lines × 2) · ×1
  • Duplicated block (19–20 lines × 2) tools/src/main/java/org/apache/kafka/tools/consumer/ConsoleConsumerOptions.java:209 — tools/src/main/java/org/apache/kafka/tools/consumer/ConsoleConsumerOptions.java:209-227 | tools/src/main/java/org/apache/kafka/tools/consumer/ConsoleShareConsumerOptions.java:181-200 — before extracting anything, compare `tools/src/main/java/org/apache/kafka/tools/consumer/ConsoleConsumerOptions.java` and `tools/src/main/java/org/apache/kafka/tools/consumer/ConsoleShareConsumerOptions.java` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 157 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `tools/src/main/java/org/apache/kafka/tools/consumer/ConsoleShareConsumerOptions.java:177` calls `has`, `printUsageAndExit` and `tools/src/main/java/org/apache/kafka/tools/consumer/ConsoleConsumerOptions.java:208` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (17–19 lines × 5) · ×1
  • Duplicated block (17–19 lines × 5) clients/src/main/java/org/apache/kafka/clients/admin/internals/DeleteConsumerGroupOffsetsHandler.java:150 — clients/src/main/java/org/apache/kafka/clients/admin/internals/DeleteConsumerGroupOffsetsHandler.java:150-168 | clients/src/main/java/org/apache/kafka/clients/admin/internals/DescribeClassicGroupsHandler.java:171-189 | clients/src/main/java/org/apache/kafka/clients/admin/internals/ListConsumerGroupOffsetsHandler.java:203-220 | clients/src/main/java/org/apache/kafka/clients/admin/internals/ListShareGroupOffsetsHandler.java:181-199 | clients/src/main/java/org/apache/kafka/clients/admin/internals/RemoveMembersFromConsumerGroupHandler.java:128-144 — before extracting anything, compare `clients/src/main/java/org/apache/kafka/clients/admin/internals/DeleteConsumerGroupOffsetsHandler.java` and `clients/src/main/java/org/apache/kafka/clients/admin/internals/RemoveMembersFromConsumerGroupHandler.java` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 61 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (18–19 lines × 3) · ×1
  • Duplicated block (18–19 lines × 3) clients/src/main/java/org/apache/kafka/clients/admin/internals/DescribeClassicGroupsHandler.java:169 — clients/src/main/java/org/apache/kafka/clients/admin/internals/DescribeClassicGroupsHandler.java:169-186 | clients/src/main/java/org/apache/kafka/clients/admin/internals/DescribeShareGroupsHandler.java:165-183 | clients/src/main/java/org/apache/kafka/clients/admin/internals/DescribeStreamsGroupsHandler.java:357-374 — before extracting anything, compare `clients/src/main/java/org/apache/kafka/clients/admin/internals/DescribeClassicGroupsHandler.java` and `clients/src/main/java/org/apache/kafka/clients/admin/internals/DescribeShareGroupsHandler.java` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 36 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (19 lines × 3) · ×1
  • Duplicated block (19 lines × 3) streams/src/main/java/org/apache/kafka/streams/state/Stores.java:377 — streams/src/main/java/org/apache/kafka/streams/state/Stores.java:377-395 | streams/src/main/java/org/apache/kafka/streams/state/internals/RocksDbIndexedTimeOrderedWindowBytesStoreSupplier.java:50-68 | streams/src/main/java/org/apache/kafka/streams/state/internals/RocksDbIndexedTimeOrderedWindowBytesStoreWithHeadersSupplier.java:38-56 — before extracting anything, compare `streams/src/main/java/org/apache/kafka/streams/state/internals/RocksDbIndexedTimeOrderedWindowBytesStoreSupplier.java` and `streams/src/main/java/org/apache/kafka/streams/state/internals/RocksDbIndexedTimeOrderedWindowBytesStoreWithHeadersSupplier.java` as WHOLE FILES: 82% of the shorter file's lines also appear in the other, so this reads as one file having been copied from the other rather than as a helper waiting to be extracted. The 2 duplicated block(s) this scan matched between them are fragments of that copy, not the extent of it — treat the file pair as the unit. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
D4 · Code Duplication · Duplicated block (16–19 lines × 3) · ×1
  • Duplicated block (16–19 lines × 3) streams/src/main/java/org/apache/kafka/streams/state/internals/StoreQueryUtils.java:284 — streams/src/main/java/org/apache/kafka/streams/state/internals/StoreQueryUtils.java:284-299 | streams/src/main/java/org/apache/kafka/streams/state/internals/StoreQueryUtils.java:322-340 | streams/src/main/java/org/apache/kafka/streams/state/internals/StoreQueryUtils.java:350-367 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `streams/src/main/java/org/apache/kafka/streams/state/internals/StoreQueryUtils.java:284` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (18–19 lines × 2) · ×1
  • Duplicated block (18–19 lines × 2) clients/src/main/java/org/apache/kafka/clients/consumer/internals/ShareConsumeRequestManager.java:686 — clients/src/main/java/org/apache/kafka/clients/consumer/internals/ShareConsumeRequestManager.java:686-704 | clients/src/main/java/org/apache/kafka/clients/consumer/internals/ShareConsumeRequestManager.java:758-775 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `clients/src/main/java/org/apache/kafka/clients/consumer/internals/ShareConsumeRequestManager.java:686` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `clients/src/main/java/org/apache/kafka/clients/consumer/internals/ShareConsumeRequestManager.java:705` calls `incrementAndGet` and `clients/src/main/java/org/apache/kafka/clients/consumer/internals/ShareConsumeRequestManager.java:777` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (17–19 lines × 2) · ×1
  • Duplicated block (17–19 lines × 2) server/src/main/java/org/apache/kafka/server/KRaftTopicCreator.java:72 — server/src/main/java/org/apache/kafka/server/KRaftTopicCreator.java:72-90 | server/src/main/java/org/apache/kafka/server/KRaftTopicCreator.java:130-146 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `server/src/main/java/org/apache/kafka/server/KRaftTopicCreator.java:72` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (16–19 lines × 2) · ×1
  • Duplicated block (16–19 lines × 2) tools/src/main/java/org/apache/kafka/tools/VerifiableConsumer.java:619 — tools/src/main/java/org/apache/kafka/tools/VerifiableConsumer.java:619-634 | tools/src/main/java/org/apache/kafka/tools/VerifiableShareConsumer.java:628-646 — before extracting anything, compare `tools/src/main/java/org/apache/kafka/tools/VerifiableConsumer.java` and `tools/src/main/java/org/apache/kafka/tools/VerifiableShareConsumer.java` as WHOLE FILES: this scan already matched 9 separate duplicated blocks between them, totalling at least 130 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `tools/src/main/java/org/apache/kafka/tools/VerifiableConsumer.java:619` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (13–17 lines × 5) · ×1
  • Duplicated block (13–17 lines × 5) streams/src/main/java/org/apache/kafka/streams/state/internals/PlainToHeadersStoreAdapter.java:171 — streams/src/main/java/org/apache/kafka/streams/state/internals/PlainToHeadersStoreAdapter.java:171-187 | streams/src/main/java/org/apache/kafka/streams/state/internals/PlainToHeadersWindowStoreAdapter.java:196-212 | streams/src/main/java/org/apache/kafka/streams/state/internals/SessionToHeadersStoreAdapter.java:208-220 | streams/src/main/java/org/apache/kafka/streams/state/internals/TimestampedToHeadersStoreAdapter.java:173-189 | streams/src/main/java/org/apache/kafka/streams/state/internals/TimestampedToHeadersWindowStoreAdapter.java:242-258 — before extracting anything, compare `streams/src/main/java/org/apache/kafka/streams/state/internals/PlainToHeadersStoreAdapter.java` and `streams/src/main/java/org/apache/kafka/streams/state/internals/TimestampedToHeadersStoreAdapter.java` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 44 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `streams/src/main/java/org/apache/kafka/streams/state/internals/PlainToHeadersStoreAdapter.java:171` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
D4 · Code Duplication · Duplicated block (15–17 lines × 4) · ×1
  • Duplicated block (15–17 lines × 4) streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredSessionStoreWithHeaders.java:89 — streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredSessionStoreWithHeaders.java:89-104 | streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredTimestampedKeyValueStoreWithHeaders.java:158-173 | streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredTimestampedKeyValueStoreWithHeaders.java:204-218 | streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredTimestampedWindowStoreWithHeaders.java:100-116 — there are 4 copies across 3 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 4 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredSessionStoreWithHeaders.java:89` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (16–17 lines × 3) · ×1
  • Duplicated block (16–17 lines × 3) clients/src/main/java/org/apache/kafka/clients/admin/KafkaAdminClient.java:2135 — clients/src/main/java/org/apache/kafka/clients/admin/KafkaAdminClient.java:2135-2150 | clients/src/main/java/org/apache/kafka/clients/admin/KafkaAdminClient.java:2208-2223 | clients/src/main/java/org/apache/kafka/clients/admin/KafkaAdminClient.java:3367-3383 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `clients/src/main/java/org/apache/kafka/clients/admin/KafkaAdminClient.java:2135` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (17 lines × 3) · ×1
  • Duplicated block (17 lines × 3) streams/src/main/java/org/apache/kafka/streams/state/internals/InMemoryKeyValueStore.java:153 — streams/src/main/java/org/apache/kafka/streams/state/internals/InMemoryKeyValueStore.java:153-169 | streams/src/main/java/org/apache/kafka/streams/state/internals/InMemorySessionStore.java:483-499 | streams/src/main/java/org/apache/kafka/streams/state/internals/InMemoryWindowStore.java:495-511 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 3 call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `streams/src/main/java/org/apache/kafka/streams/state/internals/InMemoryKeyValueStore.java:153` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `streams/src/main/java/org/apache/kafka/streams/state/internals/InMemoryKeyValueStore.java:152` calls `synchronized` and `streams/src/main/java/org/apache/kafka/streams/state/internals/InMemorySessionStore.java:477` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (16 lines × 6) · ×1
  • Duplicated block (16 lines × 6) streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredSessionStoreWithHeaders.java:92 — streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredSessionStoreWithHeaders.java:92-107 | streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredSessionStoreWithHeaders.java:151-166 | streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredTimestampedKeyValueStoreWithHeaders.java:161-176 | streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredTimestampedKeyValueStoreWithHeaders.java:206-221 | streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredTimestampedKeyValueStoreWithHeaders.java:273-288 | streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredTimestampedWindowStoreWithHeaders.java:104-119 — there are 6 copies across 3 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 6 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredSessionStoreWithHeaders.java:92` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (16 lines × 5) · ×1
  • Duplicated block (16 lines × 5) streams/src/main/java/org/apache/kafka/streams/state/internals/CompositeReadOnlySessionStore.java:81 — streams/src/main/java/org/apache/kafka/streams/state/internals/CompositeReadOnlySessionStore.java:81-96 | streams/src/main/java/org/apache/kafka/streams/state/internals/CompositeReadOnlySessionStore.java:107-122 | streams/src/main/java/org/apache/kafka/streams/state/internals/CompositeReadOnlySessionStore.java:134-149 | streams/src/main/java/org/apache/kafka/streams/state/internals/CompositeReadOnlySessionStore.java:161-176 | streams/src/main/java/org/apache/kafka/streams/state/internals/CompositeReadOnlySessionStore.java:226-241 — all 5 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `streams/src/main/java/org/apache/kafka/streams/state/internals/CompositeReadOnlySessionStore.java:81` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (14–16 lines × 2) · ×1
  • Duplicated block (14–16 lines × 2) clients/src/main/java/org/apache/kafka/clients/admin/internals/AlterShareGroupOffsetsHandler.java:159 — clients/src/main/java/org/apache/kafka/clients/admin/internals/AlterShareGroupOffsetsHandler.java:159-174 | clients/src/main/java/org/apache/kafka/clients/admin/internals/DeleteShareGroupOffsetsHandler.java:161-174 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `clients/src/main/java/org/apache/kafka/clients/admin/internals/AlterShareGroupOffsetsHandler.java:159` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (13–16 lines × 2) · ×1
  • Duplicated block (13–16 lines × 2) clients/src/main/java/org/apache/kafka/clients/consumer/internals/AbstractMembershipManager.java:635 — clients/src/main/java/org/apache/kafka/clients/consumer/internals/AbstractMembershipManager.java:635-650 | clients/src/main/java/org/apache/kafka/clients/consumer/internals/StreamsMembershipManager.java:1031-1043 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `clients/src/main/java/org/apache/kafka/clients/consumer/internals/AbstractMembershipManager.java:635` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (12–16 lines × 2) · ×1
  • Duplicated block (12–16 lines × 2) clients/src/main/java/org/apache/kafka/clients/producer/internals/ChunkedRecordAccumulator.java:145 — clients/src/main/java/org/apache/kafka/clients/producer/internals/ChunkedRecordAccumulator.java:145-156 | clients/src/main/java/org/apache/kafka/clients/producer/internals/RecordAccumulator.java:309-324 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
D4 · Code Duplication · Duplicated block (13–15 lines × 5) · ×1
  • Duplicated block (13–15 lines × 5) streams/src/main/java/org/apache/kafka/streams/state/internals/RocksDBMigratingSessionStoreWithHeaders.java:65 — streams/src/main/java/org/apache/kafka/streams/state/internals/RocksDBMigratingSessionStoreWithHeaders.java:65-77 | streams/src/main/java/org/apache/kafka/streams/state/internals/RocksDBMigratingWindowStoreWithHeaders.java:72-85 | streams/src/main/java/org/apache/kafka/streams/state/internals/RocksDBTimestampedStore.java:61-73 | streams/src/main/java/org/apache/kafka/streams/state/internals/RocksDBTimestampedStoreWithHeaders.java:98-112 | streams/src/main/java/org/apache/kafka/streams/state/internals/RocksDBTimestampedStoreWithHeaders.java:156-168 — before extracting anything, compare `streams/src/main/java/org/apache/kafka/streams/state/internals/RocksDBMigratingSessionStoreWithHeaders.java` and `streams/src/main/java/org/apache/kafka/streams/state/internals/RocksDBMigratingWindowStoreWithHeaders.java` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 48 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `streams/src/main/java/org/apache/kafka/streams/state/internals/RocksDBMigratingSessionStoreWithHeaders.java:65` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (15 lines × 4) · ×1
  • Duplicated block (15 lines × 4) streams/src/main/java/org/apache/kafka/streams/state/internals/RocksDBMigratingSessionStoreWithHeaders.java:79 — streams/src/main/java/org/apache/kafka/streams/state/internals/RocksDBMigratingSessionStoreWithHeaders.java:79-93 | streams/src/main/java/org/apache/kafka/streams/state/internals/RocksDBMigratingWindowStoreWithHeaders.java:87-101 | streams/src/main/java/org/apache/kafka/streams/state/internals/RocksDBTimestampedStore.java:75-89 | streams/src/main/java/org/apache/kafka/streams/state/internals/RocksDBTimestampedStoreWithHeaders.java:114-128 — before extracting anything, compare `streams/src/main/java/org/apache/kafka/streams/state/internals/RocksDBMigratingSessionStoreWithHeaders.java` and `streams/src/main/java/org/apache/kafka/streams/state/internals/RocksDBMigratingWindowStoreWithHeaders.java` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 48 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `streams/src/main/java/org/apache/kafka/streams/state/internals/RocksDBMigratingSessionStoreWithHeaders.java:79` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (14–15 lines × 3) · ×1
  • Duplicated block (14–15 lines × 3) tools/src/main/java/org/apache/kafka/tools/consumer/group/ConsumerGroupCommand.java:681 — tools/src/main/java/org/apache/kafka/tools/consumer/group/ConsumerGroupCommand.java:681-695 | tools/src/main/java/org/apache/kafka/tools/consumer/group/ShareGroupCommand.java:474-487 | tools/src/main/java/org/apache/kafka/tools/streams/StreamsGroupCommand.java:969-983 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. Read the line range as the matched WINDOW rather than a finished unit: at `tools/src/main/java/org/apache/kafka/tools/consumer/group/ConsumerGroupCommand.java:681` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (14 lines × 3) · ×1
  • Duplicated block (14 lines × 3) clients/src/main/java/org/apache/kafka/clients/admin/KafkaAdminClient.java:2119 — clients/src/main/java/org/apache/kafka/clients/admin/KafkaAdminClient.java:2119-2132 | clients/src/main/java/org/apache/kafka/clients/admin/KafkaAdminClient.java:2192-2205 | clients/src/main/java/org/apache/kafka/clients/admin/KafkaAdminClient.java:3351-3364 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `clients/src/main/java/org/apache/kafka/clients/admin/KafkaAdminClient.java:2119` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (12–14 lines × 3) · ×1
  • Duplicated block (12–14 lines × 3) tools/src/main/java/org/apache/kafka/tools/VerifiableConsumer.java:623 — tools/src/main/java/org/apache/kafka/tools/VerifiableConsumer.java:623-634 | tools/src/main/java/org/apache/kafka/tools/VerifiableShareConsumer.java:631-642 | tools/src/main/java/org/apache/kafka/tools/VerifiableShareConsumer.java:652-665 — before extracting anything, compare `tools/src/main/java/org/apache/kafka/tools/VerifiableConsumer.java` and `tools/src/main/java/org/apache/kafka/tools/VerifiableShareConsumer.java` as WHOLE FILES: this scan already matched 9 separate duplicated blocks between them, totalling at least 130 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `tools/src/main/java/org/apache/kafka/tools/VerifiableShareConsumer.java:652` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `tools/src/main/java/org/apache/kafka/tools/VerifiableConsumer.java:635` calls `setDefault`, `getName` and `tools/src/main/java/org/apache/kafka/tools/VerifiableShareConsumer.java:666` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (13 lines × 13) · ×1
  • Duplicated block (13 lines × 13) generator/src/main/java/org/apache/kafka/message/ApiMessageTypeGenerator.java:285 — generator/src/main/java/org/apache/kafka/message/ApiMessageTypeGenerator.java:285-297 | generator/src/main/java/org/apache/kafka/message/ApiMessageTypeGenerator.java:370-382 | generator/src/main/java/org/apache/kafka/message/CoordinatorRecordJsonConvertersGenerator.java:115-127 | generator/src/main/java/org/apache/kafka/message/CoordinatorRecordJsonConvertersGenerator.java:142-154 | generator/src/main/java/org/apache/kafka/message/CoordinatorRecordJsonConvertersGenerator.java:169-181 | generator/src/main/java/org/apache/kafka/message/CoordinatorRecordJsonConvertersGenerator.java:196-208 | generator/src/main/java/org/apache/kafka/message/CoordinatorRecordTypeGenerator.java:173-185 | generator/src/main/java/org/apache/kafka/message/CoordinatorRecordTypeGenerator.java:198-210 | generator/src/main/java/org/apache/kafka/message/CoordinatorRecordTypeGenerator.java:223-235 | generator/src/main/java/org/apache/kafka/message/MetadataJsonConvertersGenerator.java:83-95 | generator/src/main/java/org/apache/kafka/message/MetadataJsonConvertersGenerator.java:110-122 | generator/src/main/java/org/apache/kafka/message/MetadataRecordTypeGenerator.java:130-142 | generator/src/main/java/org/apache/kafka/message/MetadataRecordTypeGenerator.java:155-167 — before extracting anything, compare `generator/src/main/java/org/apache/kafka/message/ApiMessageTypeGenerator.java` and `generator/src/main/java/org/apache/kafka/message/MetadataRecordTypeGenerator.java` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 33 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `generator/src/main/java/org/apache/kafka/message/ApiMessageTypeGenerator.java:285` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (13 lines × 10) · ×1
  • Duplicated block (13 lines × 10) streams/src/main/java/org/apache/kafka/streams/kstream/internals/KStreamAggregate.java:105 — streams/src/main/java/org/apache/kafka/streams/kstream/internals/KStreamAggregate.java:105-117 | streams/src/main/java/org/apache/kafka/streams/kstream/internals/KStreamKTableJoinProcessor.java:158-170 | streams/src/main/java/org/apache/kafka/streams/kstream/internals/KStreamReduce.java:102-114 | streams/src/main/java/org/apache/kafka/streams/kstream/internals/KStreamSessionWindowAggregate.java:326-338 | streams/src/main/java/org/apache/kafka/streams/kstream/internals/KTableKTableInnerJoin.java:91-103 | streams/src/main/java/org/apache/kafka/streams/kstream/internals/KTableKTableLeftJoin.java:93-105 | streams/src/main/java/org/apache/kafka/streams/kstream/internals/KTableKTableOuterJoin.java:92-104 | streams/src/main/java/org/apache/kafka/streams/kstream/internals/KTableKTableRightJoin.java:91-103 | streams/src/main/java/org/apache/kafka/streams/kstream/internals/foreignkeyjoin/ForeignTableJoinProcessorSupplier.java:99-111 | streams/src/main/java/org/apache/kafka/streams/kstream/internals/foreignkeyjoin/SubscriptionReceiveProcessorSupplier.java:127-139 — before extracting anything, compare `streams/src/main/java/org/apache/kafka/streams/kstream/internals/KStreamAggregate.java` and `streams/src/main/java/org/apache/kafka/streams/kstream/internals/KStreamReduce.java` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 50 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Note first that the copies are not typed on the same thing: the declarations holding them bind `record` to `Record<KIn, VIn>` in one and `Record<StreamKey, StreamValue>` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
D4 · Code Duplication · Duplicated block (13 lines × 4) · ×1
  • Duplicated block (13 lines × 4) trogdor/src/main/java/org/apache/kafka/trogdor/agent/Agent.java:208 — trogdor/src/main/java/org/apache/kafka/trogdor/agent/Agent.java:208-220 | trogdor/src/main/java/org/apache/kafka/trogdor/agent/AgentClient.java:221-233 | trogdor/src/main/java/org/apache/kafka/trogdor/coordinator/Coordinator.java:137-149 | trogdor/src/main/java/org/apache/kafka/trogdor/coordinator/CoordinatorClient.java:288-300 — before extracting anything, compare `trogdor/src/main/java/org/apache/kafka/trogdor/agent/AgentClient.java` and `trogdor/src/main/java/org/apache/kafka/trogdor/coordinator/CoordinatorClient.java` as WHOLE FILES: this scan already matched 9 separate duplicated blocks between them, totalling at least 91 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `trogdor/src/main/java/org/apache/kafka/trogdor/agent/Agent.java:208` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `trogdor/src/main/java/org/apache/kafka/trogdor/coordinator/CoordinatorClient.java:301` calls `addParser`, `help`, `addTargetArgument` and `trogdor/src/main/java/org/apache/kafka/trogdor/agent/Agent.java:221` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (12–13 lines × 3) · ×1
  • Duplicated block (12–13 lines × 3) clients/src/main/java/org/apache/kafka/clients/consumer/internals/AsyncKafkaConsumer.java:1682 — clients/src/main/java/org/apache/kafka/clients/consumer/internals/AsyncKafkaConsumer.java:1682-1694 | clients/src/main/java/org/apache/kafka/clients/consumer/internals/ClassicKafkaConsumer.java:1200-1211 | clients/src/main/java/org/apache/kafka/clients/consumer/internals/ShareConsumerImpl.java:1048-1060 — before extracting anything, compare `clients/src/main/java/org/apache/kafka/clients/consumer/internals/AsyncKafkaConsumer.java` and `clients/src/main/java/org/apache/kafka/clients/consumer/internals/ClassicKafkaConsumer.java` as WHOLE FILES: this scan already matched 11 separate duplicated blocks between them, totalling at least 102 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `clients/src/main/java/org/apache/kafka/clients/consumer/internals/AsyncKafkaConsumer.java:1682` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `clients/src/main/java/org/apache/kafka/clients/consumer/internals/AsyncKafkaConsumer.java:1680` calls `closeQuietly` and `clients/src/main/java/org/apache/kafka/clients/consumer/internals/ClassicKafkaConsumer.java:1198` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (11–13 lines × 3) · ×1
  • Duplicated block (11–13 lines × 3) server/src/main/java/org/apache/kafka/server/share/dlq/ShareGroupDLQRecordFetcher.java:343 — server/src/main/java/org/apache/kafka/server/share/dlq/ShareGroupDLQRecordFetcher.java:343-353 | server/src/main/java/org/apache/kafka/server/share/dlq/ShareGroupDLQRecordFetcher.java:407-419 | server/src/main/java/org/apache/kafka/server/share/dlq/ShareGroupDLQRecordFetcher.java:484-495 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `server/src/main/java/org/apache/kafka/server/share/dlq/ShareGroupDLQRecordFetcher.java:343` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (10–13 lines × 2) · ×1
  • Duplicated block (10–13 lines × 2) clients/src/main/java/org/apache/kafka/common/requests/EndQuorumEpochRequest.java:84 — clients/src/main/java/org/apache/kafka/common/requests/EndQuorumEpochRequest.java:84-93 | raft/src/main/java/org/apache/kafka/raft/RaftUtil.java:403-415 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `clients/src/main/java/org/apache/kafka/common/requests/EndQuorumEpochRequest.java:84` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (9–13 lines × 2) · ×1
  • Duplicated block (9–13 lines × 2) streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredTimestampedWindowStoreWithHeaders.java:312 — streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredTimestampedWindowStoreWithHeaders.java:312-320 | streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredWindowStore.java:476-488 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredTimestampedWindowStoreWithHeaders.java:312` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note first that the copies are not typed on the same thing: the declarations holding them bind `query` to `WindowRangeQuery<K, ValueTimestampHeaders<V>>` in one and `Query<R>` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
D4 · Code Duplication · Duplicated block (12 lines × 5) · ×1
  • Duplicated block (12 lines × 5) clients/src/main/java/org/apache/kafka/clients/admin/DescribeClassicGroupsResult.java:54 — clients/src/main/java/org/apache/kafka/clients/admin/DescribeClassicGroupsResult.java:54-65 | clients/src/main/java/org/apache/kafka/clients/admin/DescribeConsumerGroupsResult.java:54-65 | clients/src/main/java/org/apache/kafka/clients/admin/DescribeShareGroupsResult.java:54-65 | clients/src/main/java/org/apache/kafka/clients/admin/DescribeStreamsGroupsResult.java:58-69 | clients/src/main/java/org/apache/kafka/clients/admin/ListConsumerGroupOffsetsResult.java:78-89 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 5 call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `clients/src/main/java/org/apache/kafka/clients/admin/DescribeClassicGroupsResult.java:54` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (11–12 lines × 4) · ×1
  • Duplicated block (11–12 lines × 4) streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredSessionStoreWithHeaders.java:358 — streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredSessionStoreWithHeaders.java:358-369 | streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredSessionStoreWithHeaders.java:400-410 | streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredTimestampedWindowStoreWithHeaders.java:269-279 | streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredTimestampedWindowStoreWithHeaders.java:385-395 — there are 4 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 4 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredSessionStoreWithHeaders.java:358` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note first that the copies are not typed on the same thing: the declarations holding them bind `query` to `WindowRangeQuery<K, AGG>` in one and `TimestampedWindowRangeWithHeadersQuery<K, AGG>` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
D4 · Code Duplication · Duplicated block (11–12 lines × 3) · ×1
  • Duplicated block (11–12 lines × 3) generator/src/main/java/org/apache/kafka/message/VersionConditional.java:90 — generator/src/main/java/org/apache/kafka/message/VersionConditional.java:90-101 | generator/src/main/java/org/apache/kafka/message/VersionConditional.java:115-125 | generator/src/main/java/org/apache/kafka/message/VersionConditional.java:139-149 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `generator/src/main/java/org/apache/kafka/message/VersionConditional.java:90` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (9–12 lines × 3) · ×1
  • Duplicated block (9–12 lines × 3) streams/src/main/java/org/apache/kafka/streams/state/internals/StoreQueryUtils.java:255 — streams/src/main/java/org/apache/kafka/streams/state/internals/StoreQueryUtils.java:255-266 | streams/src/main/java/org/apache/kafka/streams/state/internals/StoreQueryUtils.java:393-404 | streams/src/main/java/org/apache/kafka/streams/state/internals/StoreQueryUtils.java:425-433 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `streams/src/main/java/org/apache/kafka/streams/state/internals/StoreQueryUtils.java:255` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (9–12 lines × 2) · ×1
  • Duplicated block (9–12 lines × 2) api-checker/gradle-plugins/src/main/java/org/apache/kafka/gradle/KafkaInternalApiCheckerTask.java:125 — api-checker/gradle-plugins/src/main/java/org/apache/kafka/gradle/KafkaInternalApiCheckerTask.java:125-133 | api-checker/gradle-plugins/src/main/java/org/apache/kafka/gradle/KafkaPublicApiCheckerTask.java:97-108 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `api-checker/gradle-plugins/src/main/java/org/apache/kafka/gradle/KafkaPublicApiCheckerTask.java:110` calls `isEmpty`, `getLogger`, `lifecycle` and `api-checker/gradle-plugins/src/main/java/org/apache/kafka/gradle/KafkaInternalApiCheckerTask.java:135` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (8–12 lines × 2) · ×1
  • Duplicated block (8–12 lines × 2) group-coordinator/src/main/java/org/apache/kafka/coordinator/group/modern/GroupSpecBuilder.java:75 — group-coordinator/src/main/java/org/apache/kafka/coordinator/group/modern/GroupSpecBuilder.java:75-86 | group-coordinator/src/main/java/org/apache/kafka/coordinator/group/modern/consumer/CurrentAssignmentBuilder.java:486-493 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `group-coordinator/src/main/java/org/apache/kafka/coordinator/group/modern/GroupSpecBuilder.java:75` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (10–11 lines × 4) · ×1
  • Duplicated block (10–11 lines × 4) streams/src/main/java/org/apache/kafka/streams/state/internals/CachingKeyValueStore.java:271 — streams/src/main/java/org/apache/kafka/streams/state/internals/CachingKeyValueStore.java:271-281 | streams/src/main/java/org/apache/kafka/streams/state/internals/CachingSessionStore.java:217-226 | streams/src/main/java/org/apache/kafka/streams/state/internals/CachingWindowStore.java:160-169 | streams/src/main/java/org/apache/kafka/streams/state/internals/TimeOrderedCachingWindowStore.java:268-277 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 4 call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `streams/src/main/java/org/apache/kafka/streams/state/internals/CachingSessionStore.java:217` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (7–11 lines × 2) · ×1
  • Duplicated block (7–11 lines × 2) clients/src/main/java/org/apache/kafka/clients/admin/DescribeUserScramCredentialsResult.java:58 — clients/src/main/java/org/apache/kafka/clients/admin/DescribeUserScramCredentialsResult.java:58-68 | clients/src/main/java/org/apache/kafka/clients/admin/DescribeUserScramCredentialsResult.java:118-124 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `clients/src/main/java/org/apache/kafka/clients/admin/DescribeUserScramCredentialsResult.java:58` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (9–11 lines × 2) · ×1
  • Duplicated block (9–11 lines × 2) streams/src/main/java/org/apache/kafka/streams/processor/internals/StreamsMetadataState.java:382 — streams/src/main/java/org/apache/kafka/streams/processor/internals/StreamsMetadataState.java:382-392 | streams/src/main/java/org/apache/kafka/streams/processor/internals/StreamsMetadataState.java:394-402 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
D4 · Code Duplication · Duplicated block (3–10 lines × 4) · ×1
  • Duplicated block (3–10 lines × 4) streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredKeyValueStore.java:295 — streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredKeyValueStore.java:295-304 | streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredTimestampedKeyValueStore.java:201-210 | streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredTimestampedKeyValueStore.java:270-279 | streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredTimestampedKeyValueStoreWithHeaders.java:493-495 — before extracting anything, compare `streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredKeyValueStore.java` and `streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredTimestampedKeyValueStore.java` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 46 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredKeyValueStore.java:295` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (9 lines × 5) · ×1
  • Duplicated block (9 lines × 5) streams/src/main/java/org/apache/kafka/streams/kstream/internals/KTableFilter.java:125 — streams/src/main/java/org/apache/kafka/streams/kstream/internals/KTableFilter.java:125-133 | streams/src/main/java/org/apache/kafka/streams/kstream/internals/KTableKTableJoinMerger.java:124-132 | streams/src/main/java/org/apache/kafka/streams/kstream/internals/KTableMapValues.java:138-146 | streams/src/main/java/org/apache/kafka/streams/kstream/internals/KTableSource.java:111-119 | streams/src/main/java/org/apache/kafka/streams/kstream/internals/KTableTransformValues.java:107-115 — before extracting anything, compare `streams/src/main/java/org/apache/kafka/streams/kstream/internals/KTableFilter.java` and `streams/src/main/java/org/apache/kafka/streams/kstream/internals/KTableMapValues.java` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 42 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `streams/src/main/java/org/apache/kafka/streams/kstream/internals/KTableFilter.java:125` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note first that the copies are not typed on the same thing: the declarations holding them bind `context` to `ProcessorContext<KIn, Change<VIn>>` in one and `ProcessorContext<K, Change<V>>` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `streams/src/main/java/org/apache/kafka/streams/kstream/internals/KTableSource.java:108` calls `metrics`, `droppedRecordsSensor`, `currentThread` and `streams/src/main/java/org/apache/kafka/streams/kstream/internals/KTableFilter.java:124` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (3–9 lines × 3) · ×1
  • Duplicated block (3–9 lines × 3) streams/src/main/java/org/apache/kafka/streams/state/internals/PlainToHeadersWindowStoreAdapter.java:183 — streams/src/main/java/org/apache/kafka/streams/state/internals/PlainToHeadersWindowStoreAdapter.java:183-191 | streams/src/main/java/org/apache/kafka/streams/state/internals/SessionToHeadersStoreAdapter.java:203-205 | streams/src/main/java/org/apache/kafka/streams/state/internals/TimestampedToHeadersWindowStoreAdapter.java:229-237 — before extracting anything, compare `streams/src/main/java/org/apache/kafka/streams/state/internals/PlainToHeadersWindowStoreAdapter.java` and `streams/src/main/java/org/apache/kafka/streams/state/internals/TimestampedToHeadersWindowStoreAdapter.java` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 33 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `streams/src/main/java/org/apache/kafka/streams/state/internals/PlainToHeadersWindowStoreAdapter.java:183` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (8 lines × 5) · ×1
  • Duplicated block (8 lines × 5) streams/src/main/java/org/apache/kafka/streams/kstream/internals/KGroupedStreamImpl.java:180 — streams/src/main/java/org/apache/kafka/streams/kstream/internals/KGroupedStreamImpl.java:180-187 | streams/src/main/java/org/apache/kafka/streams/kstream/internals/KGroupedTableImpl.java:171-178 | streams/src/main/java/org/apache/kafka/streams/kstream/internals/SessionWindowedKStreamImpl.java:96-103 | streams/src/main/java/org/apache/kafka/streams/kstream/internals/SlidingWindowedKStreamImpl.java:84-91 | streams/src/main/java/org/apache/kafka/streams/kstream/internals/TimeWindowedKStreamImpl.java:96-103 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 5 call sites, so a change lands once. Note first that the copies are not typed on the same thing: the declarations holding them bind `materialized` to `Materialized<K, Long, KeyValueStore<Bytes, byte[]>>` in one and `Materialized<K, Long, SessionStore<Bytes, byte[]>>` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `streams/src/main/java/org/apache/kafka/streams/kstream/internals/SessionWindowedKStreamImpl.java:107` calls `gracePeriodMs`, `inactivityGap` and `streams/src/main/java/org/apache/kafka/streams/kstream/internals/SlidingWindowedKStreamImpl.java:96` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (7–8 lines × 3) · ×1
  • Duplicated block (7–8 lines × 3) streams/src/main/java/org/apache/kafka/streams/state/internals/CachingKeyValueStore.java:223 — streams/src/main/java/org/apache/kafka/streams/state/internals/CachingKeyValueStore.java:223-229 | streams/src/main/java/org/apache/kafka/streams/state/internals/CachingSessionStore.java:185-191 | streams/src/main/java/org/apache/kafka/streams/state/internals/TimeOrderedCachingWindowStore.java:223-230 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 3 call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `streams/src/main/java/org/apache/kafka/streams/state/internals/CachingKeyValueStore.java:223` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (4–8 lines × 3) · ×1
  • Duplicated block (4–8 lines × 3) clients/src/main/java/org/apache/kafka/common/security/oauthbearer/internals/secured/JaasOptionsUtils.java:61 — clients/src/main/java/org/apache/kafka/common/security/oauthbearer/internals/secured/JaasOptionsUtils.java:61-64 | clients/src/main/java/org/apache/kafka/common/security/oauthbearer/internals/unsecured/OAuthBearerUnsecuredLoginCallbackHandler.java:144-151 | clients/src/main/java/org/apache/kafka/common/security/oauthbearer/internals/unsecured/OAuthBearerUnsecuredValidatorCallbackHandler.java:115-122 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. Read the line range as the matched WINDOW rather than a finished unit: at `clients/src/main/java/org/apache/kafka/common/security/oauthbearer/internals/unsecured/OAuthBearerUnsecuredLoginCallbackHandler.java:144` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (3–8 lines × 4) · ×1
  • Duplicated block (3–8 lines × 4) clients/src/main/java/org/apache/kafka/common/utils/internals/ByteUtils.java:417 — clients/src/main/java/org/apache/kafka/common/utils/internals/ByteUtils.java:417-419 | clients/src/main/java/org/apache/kafka/common/utils/internals/ByteUtils.java:423-430 | jmh-benchmarks/src/main/java/org/apache/kafka/jmh/util/ByteUtilsBenchmark.java:569-571 | jmh-benchmarks/src/main/java/org/apache/kafka/jmh/util/ByteUtilsBenchmark.java:575-582 — there are 4 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 4 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `clients/src/main/java/org/apache/kafka/common/utils/internals/ByteUtils.java:417` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (2–8 lines × 3) · ×1
  • Duplicated block (2–8 lines × 3) streams/src/main/java/org/apache/kafka/streams/state/internals/Murmur3.java:276 — streams/src/main/java/org/apache/kafka/streams/state/internals/Murmur3.java:276-283 | streams/src/main/java/org/apache/kafka/streams/state/internals/Murmur3.java:351-352 | streams/src/main/java/org/apache/kafka/streams/state/internals/Murmur3.java:360-367 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (6–7 lines × 2) · ×1
  • Duplicated block (6–7 lines × 2) streams/src/main/java/org/apache/kafka/streams/processor/internals/StreamsMetadataState.java:160 — streams/src/main/java/org/apache/kafka/streams/processor/internals/StreamsMetadataState.java:160-166 | streams/src/main/java/org/apache/kafka/streams/processor/internals/StreamsMetadataState.java:178-183 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `streams/src/main/java/org/apache/kafka/streams/processor/internals/StreamsMetadataState.java:160` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (3–6 lines × 4) · ×1
  • Duplicated block (3–6 lines × 4) metadata/src/main/java/org/apache/kafka/image/AclsDelta.java:96 — metadata/src/main/java/org/apache/kafka/image/AclsDelta.java:96-101 | metadata/src/main/java/org/apache/kafka/image/ClientQuotaDelta.java:62-64 | metadata/src/main/java/org/apache/kafka/image/ConfigurationDelta.java:73-78 | metadata/src/main/java/org/apache/kafka/image/DelegationTokenDelta.java:82-87 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 4 call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `metadata/src/main/java/org/apache/kafka/image/AclsDelta.java:96` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (5–6 lines × 2) · ×1
  • Duplicated block (5–6 lines × 2) clients/src/main/java/org/apache/kafka/common/security/kerberos/KerberosShortNamer.java:51 — clients/src/main/java/org/apache/kafka/common/security/kerberos/KerberosShortNamer.java:51-56 | clients/src/main/java/org/apache/kafka/common/security/ssl/SslPrincipalMapper.java:60-64 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `clients/src/main/java/org/apache/kafka/common/security/kerberos/KerberosShortNamer.java:51` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (4–6 lines × 3) · ×1
  • Duplicated block (4–6 lines × 3) streams/src/main/java/org/apache/kafka/streams/state/internals/TimestampedKeyValueStoreBuilder.java:172 — streams/src/main/java/org/apache/kafka/streams/state/internals/TimestampedKeyValueStoreBuilder.java:172-177 | streams/src/main/java/org/apache/kafka/streams/state/internals/TimestampedWindowStoreBuilder.java:208-213 | streams/src/main/java/org/apache/kafka/streams/state/internals/WrappedStateStore.java:166-169 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 3 call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `streams/src/main/java/org/apache/kafka/streams/state/internals/TimestampedKeyValueStoreBuilder.java:172` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `streams/src/main/java/org/apache/kafka/streams/state/internals/TimestampedKeyValueStoreBuilder.java:171` calls `wrapped`, `query`, `isCollectExecutionInfo` and `streams/src/main/java/org/apache/kafka/streams/state/internals/WrappedStateStore.java:166` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (3–5 lines × 3) · ×1
  • Duplicated block (3–5 lines × 3) clients/src/main/java/org/apache/kafka/clients/admin/internals/DescribeClassicGroupsHandler.java:115 — clients/src/main/java/org/apache/kafka/clients/admin/internals/DescribeClassicGroupsHandler.java:115-117 | clients/src/main/java/org/apache/kafka/clients/admin/internals/DescribeShareGroupsHandler.java:111-115 | clients/src/main/java/org/apache/kafka/clients/admin/internals/DescribeStreamsGroupsHandler.java:121-125 — before extracting anything, compare `clients/src/main/java/org/apache/kafka/clients/admin/internals/DescribeClassicGroupsHandler.java` and `clients/src/main/java/org/apache/kafka/clients/admin/internals/DescribeShareGroupsHandler.java` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 36 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `clients/src/main/java/org/apache/kafka/clients/admin/internals/DescribeClassicGroupsHandler.java:115` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `clients/src/main/java/org/apache/kafka/clients/admin/internals/DescribeStreamsGroupsHandler.java:121` calls `forCode`, `errorCode` and `clients/src/main/java/org/apache/kafka/clients/admin/internals/DescribeClassicGroupsHandler.java:115` does not — after which the two agree again for 5 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (3–5 lines × 5) · ×1
  • Duplicated block (3–5 lines × 5) clients/src/main/java/org/apache/kafka/common/utils/internals/ByteUtils.java:411 — clients/src/main/java/org/apache/kafka/common/utils/internals/ByteUtils.java:411-415 | clients/src/main/java/org/apache/kafka/common/utils/internals/ByteUtils.java:418-420 | jmh-benchmarks/src/main/java/org/apache/kafka/jmh/util/ByteUtilsBenchmark.java:504-507 | jmh-benchmarks/src/main/java/org/apache/kafka/jmh/util/ByteUtilsBenchmark.java:563-567 | jmh-benchmarks/src/main/java/org/apache/kafka/jmh/util/ByteUtilsBenchmark.java:570-572 — there are 5 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 5 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `clients/src/main/java/org/apache/kafka/common/utils/internals/ByteUtils.java:411` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately. Note first that the copies are not typed on the same thing: the declarations holding them bind `value` to `int` in one and `long` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `jmh-benchmarks/src/main/java/org/apache/kafka/jmh/util/ByteUtilsBenchmark.java:507` calls `put` and `clients/src/main/java/org/apache/kafka/common/utils/internals/ByteUtils.java:415` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (189 lines × 2) · ×1
  • Duplicated block (189 lines × 2) clients/src/main/java/org/apache/kafka/common/requests/AbstractRequest.java:177 — clients/src/main/java/org/apache/kafka/common/requests/AbstractRequest.java:177-365 | clients/src/main/java/org/apache/kafka/common/requests/AbstractResponse.java:113-301 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
D4 · Code Duplication · Duplicated block (14 lines × 8) · ×1
  • Duplicated block (14 lines × 8) clients/src/main/java/org/apache/kafka/clients/admin/AbortTransactionResult.java:33 — clients/src/main/java/org/apache/kafka/clients/admin/AbortTransactionResult.java:33-46 | clients/src/main/java/org/apache/kafka/clients/admin/AlterClientQuotasResult.java:40-56 | clients/src/main/java/org/apache/kafka/clients/admin/AlterConfigsResult.java:34-50 | clients/src/main/java/org/apache/kafka/clients/admin/AlterPartitionReassignmentsResult.java:33-56 | clients/src/main/java/org/apache/kafka/clients/admin/AlterReplicaLogDirsResult.java:43-79 | clients/src/main/java/org/apache/kafka/clients/admin/CreateAclsResult.java:34-51 | clients/src/main/java/org/apache/kafka/clients/admin/DeleteRecordsResult.java:34-51 | clients/src/main/java/org/apache/kafka/clients/admin/UpdateFeaturesResult.java:38-51 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 8 call sites, so a change lands once. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. Note first that the copies are not typed on the same thing: the declarations holding them bind `futures` to `Map<TopicPartition, KafkaFuture<Void>>` in one and `Map<ClientQuotaEntity, KafkaFuture<Void>>` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
D4 · Code Duplication · Duplicated block (14 lines × 7) · ×1
  • Duplicated block (14 lines × 7) clients/src/main/java/org/apache/kafka/clients/admin/AlterClientQuotasResult.java:40 — clients/src/main/java/org/apache/kafka/clients/admin/AlterClientQuotasResult.java:40-56 | clients/src/main/java/org/apache/kafka/clients/admin/AlterConfigsResult.java:34-50 | clients/src/main/java/org/apache/kafka/clients/admin/AlterPartitionReassignmentsResult.java:33-56 | clients/src/main/java/org/apache/kafka/clients/admin/AlterReplicaLogDirsResult.java:43-79 | clients/src/main/java/org/apache/kafka/clients/admin/CreateAclsResult.java:34-51 | clients/src/main/java/org/apache/kafka/clients/admin/DeleteRecordsResult.java:34-51 | clients/src/main/java/org/apache/kafka/clients/admin/UpdateFeaturesResult.java:38-51 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 7 call sites, so a change lands once. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. Note first that the copies are not typed on the same thing: the declarations holding them bind `futures` to `Map<ClientQuotaEntity, KafkaFuture<Void>>` in one and `Map<ConfigResource, KafkaFuture<Void>>` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
D4 · Code Duplication · Duplicated block (68 lines × 2) · ×1
  • Duplicated block (68 lines × 2) clients/src/main/java/org/apache/kafka/clients/consumer/internals/events/ApplicationEvent.java:1 — clients/src/main/java/org/apache/kafka/clients/consumer/internals/events/ApplicationEvent.java:1-80 | clients/src/main/java/org/apache/kafka/clients/consumer/internals/events/BackgroundEvent.java:1-68 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `clients/src/main/java/org/apache/kafka/clients/consumer/internals/events/ApplicationEvent.java:1` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (43 lines × 2) · ×1
  • Duplicated block (43 lines × 2) clients/src/main/java/org/apache/kafka/common/errors/DuplicateResourceException.java:38 — clients/src/main/java/org/apache/kafka/common/errors/DuplicateResourceException.java:38-80 | clients/src/main/java/org/apache/kafka/common/errors/ResourceNotFoundException.java:37-79 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (42 lines × 3) · ×1
  • Duplicated block (42 lines × 3) group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupCoordinatorRecordSerde.java:1 — group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupCoordinatorRecordSerde.java:1-44 | share-coordinator/src/main/java/org/apache/kafka/coordinator/share/ShareCoordinatorRecordSerde.java:1-42 | transaction-coordinator/src/main/java/org/apache/kafka/coordinator/transaction/TransactionCoordinatorRecordSerde.java:1-42 — before extracting anything, compare `group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupCoordinatorRecordSerde.java` and `share-coordinator/src/main/java/org/apache/kafka/coordinator/share/ShareCoordinatorRecordSerde.java` as WHOLE FILES: 91% of the shorter file's lines also appear in the other, so this reads as one file having been copied from the other rather than as a helper waiting to be extracted. The 1 duplicated block(s) this scan matched between them are fragments of that copy, not the extent of it — treat the file pair as the unit. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupCoordinatorRecordSerde.java:1` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note first that the copies are not typed on the same thing: `CoordinatorRecordType` names `org.apache.kafka.coordinator.group.generated.CoordinatorRecordType` in one and `org.apache.kafka.coordinator.share.generated.CoordinatorRecordType` in another — different types that share a simple name, which is why the text matched. A single extracted unit cannot be given a parameter type that fits both, so unifying those types (or introducing a shared abstraction over them) is the step that has to come BEFORE the extraction above; if they are deliberately separate, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
D4 · Code Duplication · Duplicated block (18 lines × 4) · ×1
  • Duplicated block (18 lines × 4) tools/src/main/java/org/apache/kafka/tools/consumer/ConsumerGroupMessageFormatter.java:43 — tools/src/main/java/org/apache/kafka/tools/consumer/ConsumerGroupMessageFormatter.java:43-60 | tools/src/main/java/org/apache/kafka/tools/consumer/GroupMetadataMessageFormatter.java:33-50 | tools/src/main/java/org/apache/kafka/tools/consumer/OffsetsMessageFormatter.java:37-54 | tools/src/main/java/org/apache/kafka/tools/consumer/ShareGroupMessageFormatter.java:42-59 — before extracting anything, compare `tools/src/main/java/org/apache/kafka/tools/consumer/ConsumerGroupMessageFormatter.java` and `tools/src/main/java/org/apache/kafka/tools/consumer/GroupMetadataMessageFormatter.java` as WHOLE FILES: 89% of the shorter file's lines also appear in the other, so this reads as one file having been copied from the other rather than as a helper waiting to be extracted. The 1 duplicated block(s) this scan matched between them are fragments of that copy, not the extent of it — treat the file pair as the unit. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (7 lines × 5) · ×1
  • Duplicated block (7 lines × 5) generator/src/main/java/org/apache/kafka/message/ApiMessageTypeGenerator.java:329 — generator/src/main/java/org/apache/kafka/message/ApiMessageTypeGenerator.java:329-335 | generator/src/main/java/org/apache/kafka/message/CoordinatorRecordTypeGenerator.java:237-243 | generator/src/main/java/org/apache/kafka/message/MessageDataGenerator.java:1656-1662 | generator/src/main/java/org/apache/kafka/message/MessageDataGenerator.java:1693-1699 | generator/src/main/java/org/apache/kafka/message/MetadataRecordTypeGenerator.java:169-175 — before extracting anything, compare `generator/src/main/java/org/apache/kafka/message/ApiMessageTypeGenerator.java` and `generator/src/main/java/org/apache/kafka/message/MetadataRecordTypeGenerator.java` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 33 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
D4 · Code Duplication · Duplicated block (5 lines × 9) · ×1
  • Duplicated block (5 lines × 9) clients/src/main/java/org/apache/kafka/common/requests/AllocateProducerIdsRequest.java:35 — clients/src/main/java/org/apache/kafka/common/requests/AllocateProducerIdsRequest.java:35-39 | clients/src/main/java/org/apache/kafka/common/requests/AlterPartitionRequest.java:49-53 | clients/src/main/java/org/apache/kafka/common/requests/AssignReplicasToDirsRequest.java:63-69 | clients/src/main/java/org/apache/kafka/common/requests/ConsumerGroupHeartbeatRequest.java:85-91 | clients/src/main/java/org/apache/kafka/common/requests/DescribeLogDirsRequest.java:60-64 | clients/src/main/java/org/apache/kafka/common/requests/FetchSnapshotRequest.java:37-43 | clients/src/main/java/org/apache/kafka/common/requests/RenewDelegationTokenRequest.java:45-50 | clients/src/main/java/org/apache/kafka/common/requests/ShareGroupHeartbeatRequest.java:63-69 | clients/src/main/java/org/apache/kafka/common/requests/StreamsGroupHeartbeatRequest.java:82-88 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 9 call sites, so a change lands once. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `clients/src/main/java/org/apache/kafka/common/requests/AlterPartitionRequest.java:55` calls `parse`, `AlterPartitionRequest`, `AlterPartitionRequestData` and `clients/src/main/java/org/apache/kafka/common/requests/RenewDelegationTokenRequest.java:52` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (6 lines × 5) · ×1
  • Duplicated block (6 lines × 5) streams/src/main/java/org/apache/kafka/streams/state/SessionStore.java:60 — streams/src/main/java/org/apache/kafka/streams/state/SessionStore.java:60-67 | streams/src/main/java/org/apache/kafka/streams/state/SessionStore.java:72-79 | streams/src/main/java/org/apache/kafka/streams/state/SessionStore.java:109-115 | streams/src/main/java/org/apache/kafka/streams/state/WindowStore.java:94-99 | streams/src/main/java/org/apache/kafka/streams/state/WindowStore.java:110-115 — there are 5 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 5 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `streams/src/main/java/org/apache/kafka/streams/state/SessionStore.java:60` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (5 lines × 7) · ×1
  • Duplicated block (5 lines × 7) raft/src/main/java/org/apache/kafka/raft/RaftUtil.java:727 — raft/src/main/java/org/apache/kafka/raft/RaftUtil.java:727-731 | raft/src/main/java/org/apache/kafka/raft/RaftUtil.java:734-738 | raft/src/main/java/org/apache/kafka/raft/RaftUtil.java:741-745 | raft/src/main/java/org/apache/kafka/raft/RaftUtil.java:748-752 | raft/src/main/java/org/apache/kafka/raft/RaftUtil.java:755-759 | raft/src/main/java/org/apache/kafka/raft/RaftUtil.java:762-766 | raft/src/main/java/org/apache/kafka/raft/RaftUtil.java:769-773 — all 7 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit. Note first that the copies are not typed on the same thing: the declarations holding them bind `data` to `VoteResponseData` in one and `VoteRequestData` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
D4 · Code Duplication · Duplicated block (5 lines × 5) · ×1
  • Duplicated block (5 lines × 5) share-coordinator/src/main/java/org/apache/kafka/coordinator/share/ShareCoordinatorShard.java:800 — share-coordinator/src/main/java/org/apache/kafka/coordinator/share/ShareCoordinatorShard.java:800-804 | share-coordinator/src/main/java/org/apache/kafka/coordinator/share/ShareCoordinatorShard.java:856-860 | share-coordinator/src/main/java/org/apache/kafka/coordinator/share/ShareCoordinatorShard.java:891-895 | share-coordinator/src/main/java/org/apache/kafka/coordinator/share/ShareCoordinatorShard.java:924-928 | share-coordinator/src/main/java/org/apache/kafka/coordinator/share/ShareCoordinatorShard.java:966-970 — all 5 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `share-coordinator/src/main/java/org/apache/kafka/coordinator/share/ShareCoordinatorShard.java:800` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (36–37 lines × 2) · ×1
  • Duplicated block (36–37 lines × 2) core/src/main/scala/kafka/coordinator/transaction/TransactionCoordinator.scala:641 — core/src/main/scala/kafka/coordinator/transaction/TransactionCoordinator.scala:641-676 | core/src/main/scala/kafka/coordinator/transaction/TransactionCoordinator.scala:966-1002 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `core/src/main/scala/kafka/coordinator/transaction/TransactionCoordinator.scala:641` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
D4 · Code Duplication · Duplicated block (21–24 lines × 2) · ×1
  • Duplicated block (21–24 lines × 2) core/src/main/scala/kafka/server/KafkaApis.scala:310 — core/src/main/scala/kafka/server/KafkaApis.scala:310-330 | core/src/main/scala/kafka/server/KafkaApis.scala:2119-2142 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `core/src/main/scala/kafka/server/KafkaApis.scala:310` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (22 lines × 3) · ×1
  • Duplicated block (22 lines × 3) core/src/main/scala/kafka/server/KafkaApis.scala:2750 — core/src/main/scala/kafka/server/KafkaApis.scala:2750-2771 | core/src/main/scala/kafka/server/KafkaApis.scala:3004-3025 | core/src/main/scala/kafka/server/KafkaApis.scala:3223-3244 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `core/src/main/scala/kafka/server/KafkaApis.scala:2750` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (20–21 lines × 2) · ×1
  • Duplicated block (20–21 lines × 2) core/src/main/scala/kafka/coordinator/transaction/TransactionMarkerRequestCompletionHandler.scala:48 — core/src/main/scala/kafka/coordinator/transaction/TransactionMarkerRequestCompletionHandler.scala:48-68 | core/src/main/scala/kafka/coordinator/transaction/TransactionMarkerRequestCompletionHandler.scala:103-122 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `core/src/main/scala/kafka/coordinator/transaction/TransactionMarkerRequestCompletionHandler.scala:48` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (17 lines × 4) · ×1
  • Duplicated block (17 lines × 4) core/src/main/scala/kafka/server/KafkaApis.scala:1341 — core/src/main/scala/kafka/server/KafkaApis.scala:1341-1357 | core/src/main/scala/kafka/server/KafkaApis.scala:2752-2768 | core/src/main/scala/kafka/server/KafkaApis.scala:3006-3022 | core/src/main/scala/kafka/server/KafkaApis.scala:3225-3241 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `core/src/main/scala/kafka/server/KafkaApis.scala:1341` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Members sharing a duplicated core (9 members, 50+ identical tokens) · ×1
  • Members sharing a duplicated core (9 members, 50+ identical tokens) streams/examples/src/main/java/org/apache/kafka/streams/examples/pageview/PageViewTypedDemo.java:175 — streams/examples/src/main/java/org/apache/kafka/streams/examples/pageview/PageViewTypedDemo.java:175-249 | streams/examples/src/main/java/org/apache/kafka/streams/examples/pipe/PipeDemo.java:41-74 | streams/examples/src/main/java/org/apache/kafka/streams/examples/temperature/TemperatureDemo.java:71-128 | streams/examples/src/main/java/org/apache/kafka/streams/examples/wordcount/WordCountDemo.java:87-111 | streams/examples/src/main/java/org/apache/kafka/streams/examples/wordcount/WordCountProcessorDemo.java:99-152 | streams/examples/src/main/java/org/apache/kafka/streams/examples/wordcount/WordCountTransformerDemo.java:115-159 | streams/quickstart/java/src/main/resources/archetype-resources/src/main/java/LineSplit.java:38-71 | streams/quickstart/java/src/main/resources/archetype-resources/src/main/java/Pipe.java:35-66 | streams/quickstart/java/src/main/resources/archetype-resources/src/main/java/WordCount.java:44-80 — These 9 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 9 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 9 times.
D4 · Code Duplication · Duplicated block (21 lines × 3) · ×1
  • Duplicated block (21 lines × 3) streams/quickstart/java/src/main/resources/archetype-resources/src/main/java/LineSplit.java:51 — streams/quickstart/java/src/main/resources/archetype-resources/src/main/java/LineSplit.java:51-71 | streams/quickstart/java/src/main/resources/archetype-resources/src/main/java/Pipe.java:46-66 | streams/quickstart/java/src/main/resources/archetype-resources/src/main/java/WordCount.java:60-80 — before extracting anything, compare `streams/quickstart/java/src/main/resources/archetype-resources/src/main/java/LineSplit.java` and `streams/quickstart/java/src/main/resources/archetype-resources/src/main/java/Pipe.java` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 40 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `streams/quickstart/java/src/main/resources/archetype-resources/src/main/java/LineSplit.java:51` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (17–19 lines × 3) · ×1
  • Duplicated block (17–19 lines × 3) streams/examples/src/main/java/org/apache/kafka/streams/examples/wordcount/WordCountDemo.java:53 — streams/examples/src/main/java/org/apache/kafka/streams/examples/wordcount/WordCountDemo.java:53-71 | streams/examples/src/main/java/org/apache/kafka/streams/examples/wordcount/WordCountProcessorDemo.java:100-117 | streams/examples/src/main/java/org/apache/kafka/streams/examples/wordcount/WordCountTransformerDemo.java:116-132 — before extracting anything, compare `streams/examples/src/main/java/org/apache/kafka/streams/examples/wordcount/WordCountDemo.java` and `streams/examples/src/main/java/org/apache/kafka/streams/examples/wordcount/WordCountProcessorDemo.java` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 48 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
D4 · Code Duplication · Duplicated block (15 lines × 5) · ×1
  • Duplicated block (15 lines × 5) streams/examples/src/main/java/org/apache/kafka/streams/examples/pipe/PipeDemo.java:60 — streams/examples/src/main/java/org/apache/kafka/streams/examples/pipe/PipeDemo.java:60-74 | streams/examples/src/main/java/org/apache/kafka/streams/examples/temperature/TemperatureDemo.java:114-128 | streams/examples/src/main/java/org/apache/kafka/streams/examples/wordcount/WordCountDemo.java:97-111 | streams/examples/src/main/java/org/apache/kafka/streams/examples/wordcount/WordCountProcessorDemo.java:138-152 | streams/examples/src/main/java/org/apache/kafka/streams/examples/wordcount/WordCountTransformerDemo.java:145-159 — before extracting anything, compare `streams/examples/src/main/java/org/apache/kafka/streams/examples/pipe/PipeDemo.java` and `streams/examples/src/main/java/org/apache/kafka/streams/examples/temperature/TemperatureDemo.java` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 35 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `streams/examples/src/main/java/org/apache/kafka/streams/examples/pipe/PipeDemo.java:60` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (14 lines × 9) · ×1
  • Duplicated block (14 lines × 9) streams/examples/src/main/java/org/apache/kafka/streams/examples/pageview/PageViewTypedDemo.java:230 — streams/examples/src/main/java/org/apache/kafka/streams/examples/pageview/PageViewTypedDemo.java:230-243 | streams/examples/src/main/java/org/apache/kafka/streams/examples/pipe/PipeDemo.java:56-69 | streams/examples/src/main/java/org/apache/kafka/streams/examples/temperature/TemperatureDemo.java:110-123 | streams/examples/src/main/java/org/apache/kafka/streams/examples/wordcount/WordCountDemo.java:93-106 | streams/examples/src/main/java/org/apache/kafka/streams/examples/wordcount/WordCountProcessorDemo.java:134-147 | streams/examples/src/main/java/org/apache/kafka/streams/examples/wordcount/WordCountTransformerDemo.java:141-154 | streams/quickstart/java/src/main/resources/archetype-resources/src/main/java/LineSplit.java:53-66 | streams/quickstart/java/src/main/resources/archetype-resources/src/main/java/Pipe.java:48-61 | streams/quickstart/java/src/main/resources/archetype-resources/src/main/java/WordCount.java:62-75 — before extracting anything, compare `streams/examples/src/main/java/org/apache/kafka/streams/examples/pipe/PipeDemo.java` and `streams/examples/src/main/java/org/apache/kafka/streams/examples/temperature/TemperatureDemo.java` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 35 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `streams/examples/src/main/java/org/apache/kafka/streams/examples/pageview/PageViewTypedDemo.java:230` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `streams/examples/src/main/java/org/apache/kafka/streams/examples/pageview/PageViewTypedDemo.java:245` calls `printStackTrace` and `streams/examples/src/main/java/org/apache/kafka/streams/examples/pipe/PipeDemo.java:71` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D5 · Coupling · Off the main sequence · ×1
  • Off the main sequence: kafka-api-checker:core — kafka-api-checker:core: abstractness 0.00, instability 0.00, distance 1.00 — zone of pain — concrete and depended on by 2 project(s), so it's rigid to change.
Minor — 1275 finding(s)
D34 · Knowledge Freshness · Orphaned file · ×1087
  • Orphaned file metadata/src/main/java/org/apache/kafka/controller/BrokerHeartbeatManager.java:1 — No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
  • Orphaned file jmh-benchmarks/src/main/java/org/apache/kafka/jmh/connect/JsonConverterBenchmark.java:1 — No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
  • Orphaned file clients/src/main/java/org/apache/kafka/common/security/kerberos/KerberosLogin.java:1 — No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
  • Orphaned file trogdor/src/main/java/org/apache/kafka/trogdor/workload/RoundTripWorkerBase.java:1 — No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
  • Orphaned file connect/runtime/src/main/java/org/apache/kafka/connect/runtime/rest/RestServerConfig.java:1 — No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
  • Orphaned file metadata/src/main/java/org/apache/kafka/metadata/PartitionRegistration.java:1 — No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
  • Orphaned file tools/src/main/java/org/apache/kafka/tools/GetOffsetShell.java:1 — No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
  • Orphaned file clients/src/main/java/org/apache/kafka/common/security/ssl/CommonNameLoggingTrustManagerFactoryWrapper.java:1 — No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
  • Orphaned file server/src/main/java/org/apache/kafka/server/FetchContext.java:1 — No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
  • Orphaned file connect/runtime/src/main/java/org/apache/kafka/connect/runtime/Herder.java:1 — No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
  • Orphaned file clients/src/main/java/org/apache/kafka/clients/consumer/ConsumerPartitionAssignor.java:1 — No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
  • Orphaned file server-common/src/main/java/org/apache/kafka/timeline/SnapshottableHashTable.java:1 — No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
  • Orphaned file streams/src/main/java/org/apache/kafka/streams/state/internals/PrefixedSessionKeySchemas.java:1 — No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
  • Orphaned file streams/src/main/java/org/apache/kafka/streams/state/internals/Murmur3.java:1 — No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
  • Orphaned file streams/src/main/java/org/apache/kafka/streams/kstream/Materialized.java:1 — No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
  • Orphaned file metadata/src/main/java/org/apache/kafka/metadata/placement/StripedReplicaPlacer.java:1 — No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
  • Orphaned file metadata/src/main/java/org/apache/kafka/image/MetadataDelta.java:1 — No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
  • Orphaned file trogdor/src/main/java/org/apache/kafka/trogdor/workload/ProduceBenchWorker.java:1 — No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
  • Orphaned file connect/runtime/src/main/java/org/apache/kafka/connect/runtime/errors/RetryWithToleranceOperator.java:1 — No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
  • Orphaned file trogdor/src/main/java/org/apache/kafka/trogdor/common/WorkerUtils.java:1 — No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
  • Orphaned file streams/src/main/java/org/apache/kafka/streams/processor/internals/assignment/TaskMovement.java:1 — No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
  • Orphaned file metadata/src/main/java/org/apache/kafka/metadata/ListenerInfo.java:1 — No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
  • Orphaned file clients/src/main/java/org/apache/kafka/common/Cluster.java:1 — No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
  • Orphaned file connect/runtime/src/main/java/org/apache/kafka/connect/runtime/distributed/ConnectProtocol.java:1 — No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
  • Orphaned file connect/api/src/main/java/org/apache/kafka/connect/header/ConnectHeaders.java:1 — No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
  • + 1062 more in this group — see findings.md.
M4 · Documentation accuracy · README/code drift · ×40
  • README/code drift tests/README.md:318 — tests/README.md changes into `kafka/tests`, but no such folder exists. Checked without a model against the repository: its files and folders, the scripts and dependencies of every package.json, the projects, namespaces, package references and target frameworks of the .NET build, the SDK and Node pins, and the identifiers of every file that is not a document; the documents' own text never counts. A footprint generated at build time, read only by a platform, or living outside this repository is not seen, and this row is then wrong.
  • README/code drift docs/configuration/system-properties.md:95 — docs/configuration/system-properties.md links to `/community/cve-list/#[CVE redacted]`, but `community/cve-list` does not exist. Checked without a model against the repository: its files and folders, the scripts and dependencies of every package.json, the projects, namespaces, package references and target frameworks of the .NET build, the SDK and Node pins, and the identifiers of every file that is not a document; the documents' own text never counts. A footprint generated at build time, read only by a platform, or living outside this repository is not seen, and this row is then wrong.
  • README/code drift docs/design/design.md:445 — docs/design/design.md links to `/documentation.html#topicconfigs`, but `documentation.html` does not exist. Checked without a model against the repository: its files and folders, the scripts and dependencies of every package.json, the projects, namespaces, package references and target frameworks of the .NET build, the SDK and Node pins, and the identifiers of every file that is not a document; the documents' own text never counts. A footprint generated at build time, read only by a platform, or living outside this repository is not seen, and this row is then wrong.
  • README/code drift docs/design/protocol.md:183 — docs/design/protocol.md links to `/documentation/#recordbatch`, but `documentation` does not exist. Checked without a model against the repository: its files and folders, the scripts and dependencies of every package.json, the projects, namespaces, package references and target frameworks of the .NET build, the SDK and Node pins, and the identifiers of every file that is not a document; the documents' own text never counts. A footprint generated at build time, read only by a platform, or living outside this repository is not seen, and this row is then wrong.
  • README/code drift docs/getting-started/compatibility.md:316 — docs/getting-started/compatibility.md links to `/40/documentation.html#upgrade_400_notable_consumer`, but `40/documentation.html` does not exist. Checked without a model against the repository: its files and folders, the scripts and dependencies of every package.json, the projects, namespaces, package references and target frameworks of the .NET build, the SDK and Node pins, and the identifiers of every file that is not a document; the documents' own text never counts. A footprint generated at build time, read only by a platform, or living outside this repository is not seen, and this row is then wrong.
  • README/code drift docs/getting-started/introduction.md:51 — docs/getting-started/introduction.md links to `/powered-by`, but `powered-by` does not exist. Checked without a model against the repository: its files and folders, the scripts and dependencies of every package.json, the projects, namespaces, package references and target frameworks of the .NET build, the SDK and Node pins, and the identifiers of every file that is not a document; the documents' own text never counts. A footprint generated at build time, read only by a platform, or living outside this repository is not seen, and this row is then wrong.
  • README/code drift docs/getting-started/introduction.md:63 — docs/getting-started/introduction.md links to `/protocol.html`, but `protocol.html` does not exist. Checked without a model against the repository: its files and folders, the scripts and dependencies of every package.json, the projects, namespaces, package references and target frameworks of the .NET build, the SDK and Node pins, and the identifiers of every file that is not a document; the documents' own text never counts. A footprint generated at build time, read only by a platform, or living outside this repository is not seen, and this row is then wrong.
  • README/code drift docs/getting-started/introduction.md:67 — docs/getting-started/introduction.md links to `/documentation/streams/`, but `documentation/streams` does not exist. Checked without a model against the repository: its files and folders, the scripts and dependencies of every package.json, the projects, namespaces, package references and target frameworks of the .NET build, the SDK and Node pins, and the identifiers of every file that is not a document; the documents' own text never counts. A footprint generated at build time, read only by a platform, or living outside this repository is not seen, and this row is then wrong.
  • README/code drift docs/getting-started/introduction.md:89 — docs/getting-started/introduction.md links to `/documentation/#design`, but `documentation` does not exist. Checked without a model against the repository: its files and folders, the scripts and dependencies of every package.json, the projects, namespaces, package references and target frameworks of the .NET build, the SDK and Node pins, and the identifiers of every file that is not a document; the documents' own text never counts. A footprint generated at build time, read only by a platform, or living outside this repository is not seen, and this row is then wrong.
  • README/code drift docs/getting-started/introduction.md:95 — docs/getting-started/introduction.md links to `/documentation.html#adminapi`, but `documentation.html` does not exist. Checked without a model against the repository: its files and folders, the scripts and dependencies of every package.json, the projects, namespaces, package references and target frameworks of the .NET build, the SDK and Node pins, and the identifiers of every file that is not a document; the documents' own text never counts. A footprint generated at build time, read only by a platform, or living outside this repository is not seen, and this row is then wrong.
  • README/code drift docs/getting-started/introduction.md:105 — docs/getting-started/introduction.md links to `/quickstart`, but `quickstart` does not exist. Checked without a model against the repository: its files and folders, the scripts and dependencies of every package.json, the projects, namespaces, package references and target frameworks of the .NET build, the SDK and Node pins, and the identifiers of every file that is not a document; the documents' own text never counts. A footprint generated at build time, read only by a platform, or living outside this repository is not seen, and this row is then wrong.
  • README/code drift docs/getting-started/introduction.md:106 — docs/getting-started/introduction.md links to `/books-and-papers`, but `books-and-papers` does not exist. Checked without a model against the repository: its files and folders, the scripts and dependencies of every package.json, the projects, namespaces, package references and target frameworks of the .NET build, the SDK and Node pins, and the identifiers of every file that is not a document; the documents' own text never counts. A footprint generated at build time, read only by a platform, or living outside this repository is not seen, and this row is then wrong.
  • README/code drift docs/getting-started/introduction.md:108 — docs/getting-started/introduction.md links to `/events`, but `events` does not exist. Checked without a model against the repository: its files and folders, the scripts and dependencies of every package.json, the projects, namespaces, package references and target frameworks of the .NET build, the SDK and Node pins, and the identifiers of every file that is not a document; the documents' own text never counts. A footprint generated at build time, read only by a platform, or living outside this repository is not seen, and this row is then wrong.
  • README/code drift docs/getting-started/quickstart.md:96 — docs/getting-started/quickstart.md links to `/documentation/#messages`, but `documentation` does not exist. Checked without a model against the repository: its files and folders, the scripts and dependencies of every package.json, the projects, namespaces, package references and target frameworks of the .NET build, the SDK and Node pins, and the identifiers of every file that is not a document; the documents' own text never counts. A footprint generated at build time, read only by a platform, or living outside this repository is not seen, and this row is then wrong.
  • README/code drift docs/getting-started/quickstart.md:225 — docs/getting-started/quickstart.md links to `/documentation/streams`, but `documentation/streams` does not exist. Checked without a model against the repository: its files and folders, the scripts and dependencies of every package.json, the projects, namespaces, package references and target frameworks of the .NET build, the SDK and Node pins, and the identifiers of every file that is not a document; the documents' own text never counts. A footprint generated at build time, read only by a platform, or living outside this repository is not seen, and this row is then wrong.
  • README/code drift docs/getting-started/quickstart.md:263 — docs/getting-started/quickstart.md links to `/intro`, but `intro` does not exist. Checked without a model against the repository: its files and folders, the scripts and dependencies of every package.json, the projects, namespaces, package references and target frameworks of the .NET build, the SDK and Node pins, and the identifiers of every file that is not a document; the documents' own text never counts. A footprint generated at build time, read only by a platform, or living outside this repository is not seen, and this row is then wrong.
  • README/code drift docs/getting-started/quickstart.md:264 — docs/getting-started/quickstart.md links to `/powered-by`, but `powered-by` does not exist. Checked without a model against the repository: its files and folders, the scripts and dependencies of every package.json, the projects, namespaces, package references and target frameworks of the .NET build, the SDK and Node pins, and the identifiers of every file that is not a document; the documents' own text never counts. A footprint generated at build time, read only by a platform, or living outside this repository is not seen, and this row is then wrong.
  • README/code drift docs/getting-started/quickstart.md:265 — docs/getting-started/quickstart.md links to `/events`, but `events` does not exist. Checked without a model against the repository: its files and folders, the scripts and dependencies of every package.json, the projects, namespaces, package references and target frameworks of the .NET build, the SDK and Node pins, and the identifiers of every file that is not a document; the documents' own text never counts. A footprint generated at build time, read only by a platform, or living outside this repository is not seen, and this row is then wrong.
  • README/code drift docs/getting-started/uses.md:63 — docs/getting-started/uses.md links to `/documentation.html#compaction`, but `documentation.html` does not exist. Checked without a model against the repository: its files and folders, the scripts and dependencies of every package.json, the projects, namespaces, package references and target frameworks of the .NET build, the SDK and Node pins, and the identifiers of every file that is not a document; the documents' own text never counts. A footprint generated at build time, read only by a platform, or living outside this repository is not seen, and this row is then wrong.
  • README/code drift docs/operations/geo-replication-(cross-cluster-data-mirroring).md:250 — docs/operations/geo-replication-(cross-cluster-data-mirroring).md links to `/documentation/#mirrormakerconfigs`, but `documentation` does not exist. Checked without a model against the repository: its files and folders, the scripts and dependencies of every package.json, the projects, namespaces, package references and target frameworks of the .NET build, the SDK and Node pins, and the identifiers of every file that is not a document; the documents' own text never counts. A footprint generated at build time, read only by a platform, or living outside this repository is not seen, and this row is then wrong.
  • README/code drift docs/operations/kraft.md:133 — docs/operations/kraft.md documents the environment variable `CONTROLLER_0_UUID`, but no code, script or configuration file names it. Checked without a model against the repository: its files and folders, the scripts and dependencies of every package.json, the projects, namespaces, package references and target frameworks of the .NET build, the SDK and Node pins, and the identifiers of every file that is not a document; the documents' own text never counts. A footprint generated at build time, read only by a platform, or living outside this repository is not seen, and this row is then wrong.
  • README/code drift docs/operations/kraft.md:134 — docs/operations/kraft.md documents the environment variable `CONTROLLER_1_UUID`, but no code, script or configuration file names it. Checked without a model against the repository: its files and folders, the scripts and dependencies of every package.json, the projects, namespaces, package references and target frameworks of the .NET build, the SDK and Node pins, and the identifiers of every file that is not a document; the documents' own text never counts. A footprint generated at build time, read only by a platform, or living outside this repository is not seen, and this row is then wrong.
  • README/code drift docs/operations/kraft.md:135 — docs/operations/kraft.md documents the environment variable `CONTROLLER_2_UUID`, but no code, script or configuration file names it. Checked without a model against the repository: its files and folders, the scripts and dependencies of every package.json, the projects, namespaces, package references and target frameworks of the .NET build, the SDK and Node pins, and the identifiers of every file that is not a document; the documents' own text never counts. A footprint generated at build time, read only by a platform, or living outside this repository is not seen, and this row is then wrong.
  • README/code drift docs/streams/architecture.md:96 — docs/streams/architecture.md links to `/documentation`, but `documentation` does not exist. Checked without a model against the repository: its files and folders, the scripts and dependencies of every package.json, the projects, namespaces, package references and target frameworks of the .NET build, the SDK and Node pins, and the identifiers of every file that is not a document; the documents' own text never counts. A footprint generated at build time, read only by a platform, or living outside this repository is not seen, and this row is then wrong.
  • README/code drift docs/streams/architecture.md:97 — docs/streams/architecture.md links to `/documentation/streams`, but `documentation/streams` does not exist. Checked without a model against the repository: its files and folders, the scripts and dependencies of every package.json, the projects, namespaces, package references and target frameworks of the .NET build, the SDK and Node pins, and the identifiers of every file that is not a document; the documents' own text never counts. A footprint generated at build time, read only by a platform, or living outside this repository is not seen, and this row is then wrong.
  • + 15 more in this group — see findings.md.
X4 · Structured logging · Interpolated log message defeats structured logging · ×40
  • Interpolated log message defeats structured logging committer-tools/refresh_collaborators.py:74 — `info` at line 74 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.info("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `log.info("order moved", order_id=order_id, status=status)` with structlog.
  • Interpolated log message defeats structured logging committer-tools/refresh_collaborators.py:100 — `info` at line 100 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.info("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `log.info("order moved", order_id=order_id, status=status)` with structlog.
  • Interpolated log message defeats structured logging committer-tools/refresh_collaborators.py:111 — `info` at line 111 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.info("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `log.info("order moved", order_id=order_id, status=status)` with structlog.
  • Interpolated log message defeats structured logging committer-tools/refresh_collaborators.py:131 — `info` at line 131 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.info("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `log.info("order moved", order_id=order_id, status=status)` with structlog.
  • Interpolated log message defeats structured logging committer-tools/refresh_collaborators.py:150 — `error` at line 150 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.error("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `log.error("order moved", order_id=order_id, status=status)` with structlog.
  • Interpolated log message defeats structured logging clients/src/main/java/org/apache/kafka/common/security/oauthbearer/internals/expiring/ExpiringCredentialRefreshingLogin.java:114 — `warn` at line 114 is handed a message assembled at the call — a string concatenated with a value, or `String.format` — through SLF4J or log4j 2, so the logger receives one finished string: the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the level is filtered out. Pass a constant pattern and the values beside it instead: `log.warn("Order {} moved to {}", orderId, status)`, which keeps the pattern and its arguments apart on the event for a structured encoder (logstash-logback-encoder, log4j 2's JsonTemplateLayout, OpenTelemetry), or `log.atInfo().addKeyValue("order_id", orderId).log("order moved")` with SLF4J 2's fluent API. An exception goes last, as the throwable argument, not into the text.
  • Interpolated log message defeats structured logging clients/src/main/java/org/apache/kafka/common/security/ssl/CommonNameLoggingTrustManagerFactoryWrapper.java:164 — `info` at line 164 is handed a message assembled at the call — a string concatenated with a value, or `String.format` — through SLF4J or log4j 2, so the logger receives one finished string: the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the level is filtered out. Pass a constant pattern and the values beside it instead: `log.info("Order {} moved to {}", orderId, status)`, which keeps the pattern and its arguments apart on the event for a structured encoder (logstash-logback-encoder, log4j 2's JsonTemplateLayout, OpenTelemetry), or `log.atInfo().addKeyValue("order_id", orderId).log("order moved")` with SLF4J 2's fluent API. An exception goes last, as the throwable argument, not into the text.
  • Interpolated log message defeats structured logging metadata/src/main/java/org/apache/kafka/image/loader/MetadataLoader.java:261 — `info` at line 261 is handed a message assembled at the call — a string concatenated with a value, or `String.format` — through SLF4J or log4j 2, so the logger receives one finished string: the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the level is filtered out. Pass a constant pattern and the values beside it instead: `log.info("Order {} moved to {}", orderId, status)`, which keeps the pattern and its arguments apart on the event for a structured encoder (logstash-logback-encoder, log4j 2's JsonTemplateLayout, OpenTelemetry), or `log.atInfo().addKeyValue("order_id", orderId).log("order moved")` with SLF4J 2's fluent API. An exception goes last, as the throwable argument, not into the text.
  • Interpolated log message defeats structured logging metadata/src/main/java/org/apache/kafka/image/loader/MetadataLoader.java:266 — `info` at line 266 is handed a message assembled at the call — a string concatenated with a value, or `String.format` — through SLF4J or log4j 2, so the logger receives one finished string: the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the level is filtered out. Pass a constant pattern and the values beside it instead: `log.info("Order {} moved to {}", orderId, status)`, which keeps the pattern and its arguments apart on the event for a structured encoder (logstash-logback-encoder, log4j 2's JsonTemplateLayout, OpenTelemetry), or `log.atInfo().addKeyValue("order_id", orderId).log("order moved")` with SLF4J 2's fluent API. An exception goes last, as the throwable argument, not into the text.
  • Interpolated log message defeats structured logging shell/src/main/java/org/apache/kafka/shell/MetadataShell.java:221 — `debug` at line 221 is handed a message assembled at the call — a string concatenated with a value, or `String.format` — through SLF4J or log4j 2, so the logger receives one finished string: the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the level is filtered out. Pass a constant pattern and the values beside it instead: `log.debug("Order {} moved to {}", orderId, status)`, which keeps the pattern and its arguments apart on the event for a structured encoder (logstash-logback-encoder, log4j 2's JsonTemplateLayout, OpenTelemetry), or `log.atInfo().addKeyValue("order_id", orderId).log("order moved")` with SLF4J 2's fluent API. An exception goes last, as the throwable argument, not into the text.
  • Interpolated log message defeats structured logging shell/src/main/java/org/apache/kafka/shell/MetadataShell.java:225 — `error` at line 225 is handed a message assembled at the call — a string concatenated with a value, or `String.format` — through SLF4J or log4j 2, so the logger receives one finished string: the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the level is filtered out. Pass a constant pattern and the values beside it instead: `log.error("Order {} moved to {}", orderId, status)`, which keeps the pattern and its arguments apart on the event for a structured encoder (logstash-logback-encoder, log4j 2's JsonTemplateLayout, OpenTelemetry), or `log.atInfo().addKeyValue("order_id", orderId).log("order moved")` with SLF4J 2's fluent API. An exception goes last, as the throwable argument, not into the text.
  • Interpolated log message defeats structured logging shell/src/main/java/org/apache/kafka/shell/command/TreeCommandHandler.java:99 — `trace` at line 99 is handed a message assembled at the call — a string concatenated with a value, or `String.format` — through SLF4J or log4j 2, so the logger receives one finished string: the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the level is filtered out. Pass a constant pattern and the values beside it instead: `log.trace("Order {} moved to {}", orderId, status)`, which keeps the pattern and its arguments apart on the event for a structured encoder (logstash-logback-encoder, log4j 2's JsonTemplateLayout, OpenTelemetry), or `log.atInfo().addKeyValue("order_id", orderId).log("order moved")` with SLF4J 2's fluent API. An exception goes last, as the throwable argument, not into the text.
  • Interpolated log message defeats structured logging shell/src/main/java/org/apache/kafka/shell/command/CatCommandHandler.java:99 — `trace` at line 99 is handed a message assembled at the call — a string concatenated with a value, or `String.format` — through SLF4J or log4j 2, so the logger receives one finished string: the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the level is filtered out. Pass a constant pattern and the values beside it instead: `log.trace("Order {} moved to {}", orderId, status)`, which keeps the pattern and its arguments apart on the event for a structured encoder (logstash-logback-encoder, log4j 2's JsonTemplateLayout, OpenTelemetry), or `log.atInfo().addKeyValue("order_id", orderId).log("order moved")` with SLF4J 2's fluent API. An exception goes last, as the throwable argument, not into the text.
  • Interpolated log message defeats structured logging shell/src/main/java/org/apache/kafka/shell/glob/GlobComponent.java:140 — `debug` at line 140 is handed a message assembled at the call — a string concatenated with a value, or `String.format` — through SLF4J or log4j 2, so the logger receives one finished string: the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the level is filtered out. Pass a constant pattern and the values beside it instead: `log.debug("Order {} moved to {}", orderId, status)`, which keeps the pattern and its arguments apart on the event for a structured encoder (logstash-logback-encoder, log4j 2's JsonTemplateLayout, OpenTelemetry), or `log.atInfo().addKeyValue("order_id", orderId).log("order moved")` with SLF4J 2's fluent API. An exception goes last, as the throwable argument, not into the text.
  • Interpolated log message defeats structured logging streams/src/main/java/org/apache/kafka/streams/KafkaStreams.java:2128 — `debug` at line 2128 is handed a message assembled at the call — a string concatenated with a value, or `String.format` — through SLF4J or log4j 2, so the logger receives one finished string: the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the level is filtered out. Pass a constant pattern and the values beside it instead: `log.debug("Order {} moved to {}", orderId, status)`, which keeps the pattern and its arguments apart on the event for a structured encoder (logstash-logback-encoder, log4j 2's JsonTemplateLayout, OpenTelemetry), or `log.atInfo().addKeyValue("order_id", orderId).log("order moved")` with SLF4J 2's fluent API. An exception goes last, as the throwable argument, not into the text.
  • Interpolated log message defeats structured logging streams/src/main/java/org/apache/kafka/streams/processor/internals/TaskManager.java:942 — `debug` at line 942 is handed a message assembled at the call — a string concatenated with a value, or `String.format` — through SLF4J or log4j 2, so the logger receives one finished string: the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the level is filtered out. Pass a constant pattern and the values beside it instead: `log.debug("Order {} moved to {}", orderId, status)`, which keeps the pattern and its arguments apart on the event for a structured encoder (logstash-logback-encoder, log4j 2's JsonTemplateLayout, OpenTelemetry), or `log.atInfo().addKeyValue("order_id", orderId).log("order moved")` with SLF4J 2's fluent API. An exception goes last, as the throwable argument, not into the text.
  • Interpolated log message defeats structured logging streams/src/main/java/org/apache/kafka/streams/processor/internals/TaskExecutor.java:107 — `error` at line 107 is handed a message assembled at the call — a string concatenated with a value, or `String.format` — through SLF4J or log4j 2, so the logger receives one finished string: the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the level is filtered out. Pass a constant pattern and the values beside it instead: `log.error("Order {} moved to {}", orderId, status)`, which keeps the pattern and its arguments apart on the event for a structured encoder (logstash-logback-encoder, log4j 2's JsonTemplateLayout, OpenTelemetry), or `log.atInfo().addKeyValue("order_id", orderId).log("order moved")` with SLF4J 2's fluent API. An exception goes last, as the throwable argument, not into the text.
  • Interpolated log message defeats structured logging streams/src/main/java/org/apache/kafka/streams/processor/internals/TaskExecutor.java:118 — `error` at line 118 is handed a message assembled at the call — a string concatenated with a value, or `String.format` — through SLF4J or log4j 2, so the logger receives one finished string: the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the level is filtered out. Pass a constant pattern and the values beside it instead: `log.error("Order {} moved to {}", orderId, status)`, which keeps the pattern and its arguments apart on the event for a structured encoder (logstash-logback-encoder, log4j 2's JsonTemplateLayout, OpenTelemetry), or `log.atInfo().addKeyValue("order_id", orderId).log("order moved")` with SLF4J 2's fluent API. An exception goes last, as the throwable argument, not into the text.
  • Interpolated log message defeats structured logging streams/src/main/java/org/apache/kafka/streams/processor/internals/TaskExecutor.java:122 — `error` at line 122 is handed a message assembled at the call — a string concatenated with a value, or `String.format` — through SLF4J or log4j 2, so the logger receives one finished string: the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the level is filtered out. Pass a constant pattern and the values beside it instead: `log.error("Order {} moved to {}", orderId, status)`, which keeps the pattern and its arguments apart on the event for a structured encoder (logstash-logback-encoder, log4j 2's JsonTemplateLayout, OpenTelemetry), or `log.atInfo().addKeyValue("order_id", orderId).log("order moved")` with SLF4J 2's fluent API. An exception goes last, as the throwable argument, not into the text.
  • Interpolated log message defeats structured logging streams/src/main/java/org/apache/kafka/streams/processor/internals/TaskExecutor.java:189 — `error` at line 189 is handed a message assembled at the call — a string concatenated with a value, or `String.format` — through SLF4J or log4j 2, so the logger receives one finished string: the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the level is filtered out. Pass a constant pattern and the values beside it instead: `log.error("Order {} moved to {}", orderId, status)`, which keeps the pattern and its arguments apart on the event for a structured encoder (logstash-logback-encoder, log4j 2's JsonTemplateLayout, OpenTelemetry), or `log.atInfo().addKeyValue("order_id", orderId).log("order moved")` with SLF4J 2's fluent API. An exception goes last, as the throwable argument, not into the text.
  • Interpolated log message defeats structured logging streams/src/main/java/org/apache/kafka/streams/processor/internals/TaskExecutor.java:216 — `error` at line 216 is handed a message assembled at the call — a string concatenated with a value, or `String.format` — through SLF4J or log4j 2, so the logger receives one finished string: the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the level is filtered out. Pass a constant pattern and the values beside it instead: `log.error("Order {} moved to {}", orderId, status)`, which keeps the pattern and its arguments apart on the event for a structured encoder (logstash-logback-encoder, log4j 2's JsonTemplateLayout, OpenTelemetry), or `log.atInfo().addKeyValue("order_id", orderId).log("order moved")` with SLF4J 2's fluent API. An exception goes last, as the throwable argument, not into the text.
  • Interpolated log message defeats structured logging streams/src/main/java/org/apache/kafka/streams/processor/internals/StreamThread.java:1016 — `warn` at line 1016 is handed a message assembled at the call — a string concatenated with a value, or `String.format` — through SLF4J or log4j 2, so the logger receives one finished string: the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the level is filtered out. Pass a constant pattern and the values beside it instead: `log.warn("Order {} moved to {}", orderId, status)`, which keeps the pattern and its arguments apart on the event for a structured encoder (logstash-logback-encoder, log4j 2's JsonTemplateLayout, OpenTelemetry), or `log.atInfo().addKeyValue("order_id", orderId).log("order moved")` with SLF4J 2's fluent API. An exception goes last, as the throwable argument, not into the text.
  • Interpolated log message defeats structured logging streams/src/main/java/org/apache/kafka/streams/processor/internals/StreamThread.java:1792 — `debug` at line 1792 is handed a message assembled at the call — a string concatenated with a value, or `String.format` — through SLF4J or log4j 2, so the logger receives one finished string: the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the level is filtered out. Pass a constant pattern and the values beside it instead: `log.debug("Order {} moved to {}", orderId, status)`, which keeps the pattern and its arguments apart on the event for a structured encoder (logstash-logback-encoder, log4j 2's JsonTemplateLayout, OpenTelemetry), or `log.atInfo().addKeyValue("order_id", orderId).log("order moved")` with SLF4J 2's fluent API. An exception goes last, as the throwable argument, not into the text.
  • Interpolated log message defeats structured logging streams/src/main/java/org/apache/kafka/streams/processor/internals/StreamTask.java:1478 — `debug` at line 1478 is handed a message assembled at the call — a string concatenated with a value, or `String.format` — through SLF4J or log4j 2, so the logger receives one finished string: the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the level is filtered out. Pass a constant pattern and the values beside it instead: `log.debug("Order {} moved to {}", orderId, status)`, which keeps the pattern and its arguments apart on the event for a structured encoder (logstash-logback-encoder, log4j 2's JsonTemplateLayout, OpenTelemetry), or `log.atInfo().addKeyValue("order_id", orderId).log("order moved")` with SLF4J 2's fluent API. An exception goes last, as the throwable argument, not into the text.
  • Interpolated log message defeats structured logging streams/src/main/java/org/apache/kafka/streams/processor/internals/StoreChangelogReader.java:555 — `warn` at line 555 is handed a message assembled at the call — a string concatenated with a value, or `String.format` — through SLF4J or log4j 2, so the logger receives one finished string: the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the level is filtered out. Pass a constant pattern and the values beside it instead: `log.warn("Order {} moved to {}", orderId, status)`, which keeps the pattern and its arguments apart on the event for a structured encoder (logstash-logback-encoder, log4j 2's JsonTemplateLayout, OpenTelemetry), or `log.atInfo().addKeyValue("order_id", orderId).log("order moved")` with SLF4J 2's fluent API. An exception goes last, as the throwable argument, not into the text.
  • + 15 more in this group — see findings.md.
AX6 · Interface segregation · Fat interface · ×26
  • Fat interface: Admin (66 abstract methods) clients/src/main/java/org/apache/kafka/clients/admin/Admin.java:127 — `Admin` declares 66 abstract methods: `abortTransaction`, `addRaftVoter`, `alterClientQuotas`, `alterConsumerGroupOffsets`, `alterPartitionReassignments`, `alterReplicaLogDirs`, `alterShareGroupOffsets`, `alterStreamsGroupOffsets`, `alterUserScramCredentials`, `clientInstanceId`, `close`, `createAcls`, `createDelegationToken`, `createPartitions`, `createTopics`, `deleteAcls`, `deleteConsumerGroupOffsets`, `deleteConsumerGroups`, `deleteRecords`, `deleteShareGroupOffsets`, `deleteShareGroups`, `deleteStreamsGroupOffsets`, `deleteStreamsGroups`, `deleteTopics`, `describeAcls`, `describeClassicGroups`, `describeClientQuotas`, `describeCluster`, `describeConfigs`, `describeConsumerGroups`, `describeDelegationToken`, `describeFeatures`, `describeLogDirs`, `describeMetadataQuorum`, `describeProducers`, `describeReplicaLogDirs`, `describeShareGroups`, `describeStreamsGroups`, `describeTopics`, `describeTransactions`, and 26 more. Counted over its ABSTRACT methods, once per signature; `default`, `static` and `private` methods and constants are not counted, because no implementer is forced to write them. A wide interface forces every implementer and caller to depend on methods they don't use (the Interface-Segregation 'I' in SOLID). Split it into focused role-interfaces.
  • Fat interface: Consumer<K, V> (52 abstract methods) clients/src/main/java/org/apache/kafka/clients/consumer/Consumer.java:41 — `Consumer<K, V>` declares 52 abstract methods: `assign`, `assignment`, `beginningOffsets`, `beginningOffsets`, `clientInstanceId`, `close`, `close`, `close`, `commitAsync`, `commitAsync`, `commitAsync`, `commitSync`, `commitSync`, `commitSync`, `commitSync`, `committed`, `committed`, `currentLag`, `endOffsets`, `endOffsets`, `enforceRebalance`, `enforceRebalance`, `groupMetadata`, `listTopics`, `listTopics`, `metrics`, `offsetsForTimes`, `offsetsForTimes`, `partitionsFor`, `partitionsFor`, `pause`, `paused`, `poll`, `position`, `position`, `registerMetricForSubscription`, `resume`, `seek`, `seek`, `seekToBeginning`, and 12 more. Counted over its ABSTRACT methods, once per signature; `default`, `static` and `private` methods and constants are not counted, because no implementer is forced to write them. Those 52 declarations carry 31 distinct name(s), so part of the width is overloading rather than separate responsibilities — but 31 operations clears the >15 bar on its own, so the row is about responsibilities, not signatures. A wide interface forces every implementer and caller to depend on methods they don't use (the Interface-Segregation 'I' in SOLID). Split it into focused role-interfaces.
  • Fat interface: RebalanceConsumer (32 abstract methods) clients/src/main/java/org/apache/kafka/clients/consumer/RebalanceConsumer.java:84 — `RebalanceConsumer` declares 32 abstract methods: `assignment`, `beginningOffsets`, `beginningOffsets`, `clientInstanceId`, `commitAsync`, `commitAsync`, `commitAsync`, `commitSync`, `commitSync`, `commitSync`, `commitSync`, `committed`, `committed`, `currentLag`, `endOffsets`, `endOffsets`, `groupMetadata`, `listTopics`, `listTopics`, `offsetsForTimes`, `offsetsForTimes`, `partitionsFor`, `partitionsFor`, `pause`, `paused`, `position`, `position`, `resume`, `seek`, `seek`, `seekToBeginning`, `seekToEnd`. Counted over its ABSTRACT methods, once per signature; `default`, `static` and `private` methods and constants are not counted, because no implementer is forced to write them. Those 32 declarations carry 19 distinct name(s), so part of the width is overloading rather than separate responsibilities — but 19 operations clears the >15 bar on its own, so the row is about responsibilities, not signatures. A wide interface forces every implementer and caller to depend on methods they don't use (the Interface-Segregation 'I' in SOLID). Split it into focused role-interfaces.
  • Fat interface: ShareConsumer<K, V> (19 abstract methods) clients/src/main/java/org/apache/kafka/clients/consumer/ShareConsumer.java:41 — `ShareConsumer<K, V>` declares 19 abstract methods under just 15 distinct name(s): `acknowledge`, `acknowledge`, `acknowledge`, `acquisitionLockTimeoutMs`, `clientInstanceId`, `close`, `close`, `commitAsync`, `commitSync`, `commitSync`, `metrics`, `poll`, `registerMetricForSubscription`, `setAcknowledgementCommitCallback`, `subscribe`, `subscription`, `unregisterMetricFromSubscription`, `unsubscribe`, `wakeup`. Counted over its ABSTRACT methods, once per signature; `default`, `static` and `private` methods and constants are not counted, because no implementer is forced to write them. That is an OVERLOAD SET, not 19 separate responsibilities: a caller binds to 15 operation(s) and uses the overload it selected, so the Interface-Segregation harm does NOT apply on the caller's side and splitting this into role-interfaces would scatter one operation without relieving anything. The burden that does remain is the IMPLEMENTER's — all 19 signatures must be written and kept in step. Reduce it by collapsing overloads (optional or default parameters, or an options object) rather than by segregating the interface.
  • Fat interface: Producer<K, V> (17 abstract methods) clients/src/main/java/org/apache/kafka/clients/producer/Producer.java:42 — `Producer<K, V>` declares 17 abstract methods under just 15 distinct name(s): `abortTransaction`, `beginTransaction`, `clientInstanceId`, `close`, `close`, `commitTransaction`, `completeTransaction`, `flush`, `initTransactions`, `metrics`, `partitionsFor`, `prepareTransaction`, `registerMetricForSubscription`, `send`, `send`, `sendOffsetsToTransaction`, `unregisterMetricFromSubscription`. Counted over its ABSTRACT methods, once per signature; `default`, `static` and `private` methods and constants are not counted, because no implementer is forced to write them. That is an OVERLOAD SET, not 17 separate responsibilities: a caller binds to 15 operation(s) and uses the overload it selected, so the Interface-Segregation harm does NOT apply on the caller's side and splitting this into role-interfaces would scatter one operation without relieving anything. The burden that does remain is the IMPLEMENTER's — all 17 signatures must be written and kept in step. Reduce it by collapsing overloads (optional or default parameters, or an options object) rather than by segregating the interface.
  • Fat interface: KafkaClient (21 abstract methods) clients/src/main/java/org/apache/kafka/clients/KafkaClient.java:29 — `KafkaClient` declares 21 abstract methods: `active`, `authenticationException`, `close`, `connectionDelay`, `connectionFailed`, `disconnect`, `hasInFlightRequests`, `hasInFlightRequests`, `hasReadyNodes`, `inFlightRequestCount`, `inFlightRequestCount`, `initiateClose`, `isReady`, `leastLoadedNode`, `newClientRequest`, `newClientRequest`, `poll`, `pollDelayMs`, `ready`, `send`, `wakeup`. Counted over its ABSTRACT methods, once per signature; `default`, `static` and `private` methods and constants are not counted, because no implementer is forced to write them. Those 21 declarations carry 18 distinct name(s), so part of the width is overloading rather than separate responsibilities — but 18 operations clears the >15 bar on its own, so the row is about responsibilities, not signatures. A wide interface forces every implementer and caller to depend on methods they don't use (the Interface-Segregation 'I' in SOLID). Split it into focused role-interfaces.
  • Fat interface: ClusterInstance (22 abstract methods) test-common/test-common-runtime/src/main/java/org/apache/kafka/common/test/ClusterInstance.java:72 — `ClusterInstance` declares 22 abstract methods: `bootstrapControllers`, `bootstrapServers`, `brokers`, `clientListener`, `clusterId`, `config`, `controllerIds`, `controllerListenerName`, `controllers`, `firstFatalException`, `firstNonFatalException`, `restartBroker`, `restartBrokersWithSwappedClientListenerPorts`, `setClientSslConfig`, `shutdownBroker`, `start`, `startBroker`, `started`, `stop`, `stopped`, `type`, `waitForReadyBrokers`. Counted over its ABSTRACT methods, once per signature; `default`, `static` and `private` methods and constants are not counted, because no implementer is forced to write them. A wide interface forces every implementer and caller to depend on methods they don't use (the Interface-Segregation 'I' in SOLID). Split it into focused role-interfaces.
  • Fat interface: Headers (30 abstract methods) connect/api/src/main/java/org/apache/kafka/connect/header/Headers.java:34 — `Headers` declares 30 abstract methods: `add`, `add`, `add`, `addBoolean`, `addByte`, `addBytes`, `addDate`, `addDecimal`, `addDouble`, `addFloat`, `addInt`, `addList`, `addLong`, `addMap`, `addShort`, `addString`, `addStruct`, `addTime`, `addTimestamp`, `allWithName`, `apply`, `apply`, `clear`, `duplicate`, `isEmpty`, `lastWithName`, `remove`, `retainLatest`, `retainLatest`, `size`. Counted over its ABSTRACT methods, once per signature; `default`, `static` and `private` methods and constants are not counted, because no implementer is forced to write them. Those 30 declarations carry 26 distinct name(s), so part of the width is overloading rather than separate responsibilities — but 26 operations clears the >15 bar on its own, so the row is about responsibilities, not signatures. A wide interface forces every implementer and caller to depend on methods they don't use (the Interface-Segregation 'I' in SOLID). Split it into focused role-interfaces.
  • Fat interface: StatusBackingStore (16 abstract methods) connect/runtime/src/main/java/org/apache/kafka/connect/storage/StatusBackingStore.java:31 — `StatusBackingStore` declares 16 abstract methods under just 12 distinct name(s): `configure`, `connectors`, `deleteTopic`, `flush`, `get`, `get`, `getAll`, `getAllTopics`, `getTopic`, `put`, `put`, `put`, `putSafe`, `putSafe`, `start`, `stop`. Counted over its ABSTRACT methods, once per signature; `default`, `static` and `private` methods and constants are not counted, because no implementer is forced to write them. That is an OVERLOAD SET, not 16 separate responsibilities: a caller binds to 12 operation(s) and uses the overload it selected, so the Interface-Segregation harm does NOT apply on the caller's side and splitting this into role-interfaces would scatter one operation without relieving anything. The burden that does remain is the IMPLEMENTER's — all 16 signatures must be written and kept in step. Reduce it by collapsing overloads (optional or default parameters, or an options object) rather than by segregating the interface.
  • Fat interface: Herder (42 abstract methods) connect/runtime/src/main/java/org/apache/kafka/connect/runtime/Herder.java:62 — `Herder` declares 42 abstract methods: `allLoggerLevels`, `alterConnectorOffsets`, `connectMetrics`, `connectorActiveTopics`, `connectorConfig`, `connectorInfo`, `connectorInfo`, `connectorOffsets`, `connectorPluginConfig`, `connectorPluginConfig`, `connectorStatus`, `connectors`, `connectors`, `deleteConnectorConfig`, `fenceZombieSourceTasks`, `healthCheck`, `isReady`, `kafkaClusterId`, `loggerLevel`, `patchConnectorConfig`, `pauseConnector`, `plugins`, `putConnectorConfig`, `putConnectorConfig`, `putTaskConfigs`, `requestTaskReconfiguration`, `resetConnectorActiveTopics`, `resetConnectorOffsets`, `restartConnector`, `restartConnector`, `restartConnectorAndTasks`, `restartTask`, `resumeConnector`, `setClusterLoggerLevel`, `setWorkerLoggerLevel`, `start`, `statusBackingStore`, `stop`, `stopConnector`, `taskConfigs`, and 2 more. Counted over its ABSTRACT methods, once per signature; `default`, `static` and `private` methods and constants are not counted, because no implementer is forced to write them. Those 42 declarations carry 37 distinct name(s), so part of the width is overloading rather than separate responsibilities — but 37 operations clears the >15 bar on its own, so the row is about responsibilities, not signatures. A wide interface forces every implementer and caller to depend on methods they don't use (the Interface-Segregation 'I' in SOLID). Split it into focused role-interfaces.
  • Fat interface: Group (17 abstract methods) group-coordinator/src/main/java/org/apache/kafka/coordinator/group/Group.java:36 — `Group` declares 17 abstract methods: `asListedGroup`, `createGroupTombstoneRecords`, `groupId`, `hasMember`, `isEmpty`, `isInStates`, `isSubscribedToTopic`, `numMembers`, `offsetExpirationCondition`, `requestMetadataRefresh`, `stateAsString`, `stateAsString`, `type`, `validateDeleteGroup`, `validateOffsetCommit`, `validateOffsetDelete`, `validateOffsetFetch`. Counted over its ABSTRACT methods, once per signature; `default`, `static` and `private` methods and constants are not counted, because no implementer is forced to write them. Those 17 declarations carry 16 distinct name(s), so part of the width is overloading rather than separate responsibilities — but 16 operations clears the >15 bar on its own, so the row is about responsibilities, not signatures. A wide interface forces every implementer and caller to depend on methods they don't use (the Interface-Segregation 'I' in SOLID). Split it into focused role-interfaces.
  • Fat interface: GroupCoordinator (32 abstract methods) group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupCoordinator.java:74 — `GroupCoordinator` declares 32 abstract methods: `alterShareGroupOffsets`, `commitOffsets`, `commitTransactionalOffsets`, `completeTransaction`, `consumerGroupDescribe`, `consumerGroupHeartbeat`, `deleteGroups`, `deleteOffsets`, `deleteShareGroupOffsets`, `describeGroups`, `describeShareGroupAllOffsets`, `describeShareGroupOffsets`, `fetchOffsets`, `groupConfig`, `groupMetadataTopicConfigs`, `heartbeat`, `joinGroup`, `leaveGroup`, `listGroups`, `onElection`, `onMetadataUpdate`, `onResignation`, `partitionFor`, `shareGroupDescribe`, `shareGroupHeartbeat`, `shutdown`, `startup`, `streamsGroupDescribe`, `streamsGroupHeartbeat`, `streamsGroupTopologyDescriptionUpdate`, `syncGroup`, `updateGroupConfig`. Counted over its ABSTRACT methods, once per signature; `default`, `static` and `private` methods and constants are not counted, because no implementer is forced to write them. A wide interface forces every implementer and caller to depend on methods they don't use (the Interface-Segregation 'I' in SOLID). Split it into focused role-interfaces.
  • Fat interface: Controller (31 abstract methods) metadata/src/main/java/org/apache/kafka/controller/Controller.java:67 — `Controller` declares 31 abstract methods: `allocateProducerIds`, `alterClientQuotas`, `alterPartition`, `alterPartitionReassignments`, `alterUserScramCredentials`, `assignReplicasToDirs`, `beginShutdown`, `close`, `createDelegationToken`, `createPartitions`, `createTopics`, `curClaimEpoch`, `deleteTopics`, `describeConfigs`, `electLeaders`, `expireDelegationToken`, `finalizedFeatures`, `findAllTopicIds`, `findTopicIds`, `findTopicNames`, `incrementalAlterConfigs`, `legacyAlterConfigs`, `listPartitionReassignments`, `processBrokerHeartbeat`, `registerBroker`, `registerController`, `renewDelegationToken`, `unregisterBroker`, `unregisterController`, `updateFeatures`, `waitForReadyBrokers`. Counted over its ABSTRACT methods, once per signature; `default`, `static` and `private` methods and constants are not counted, because no implementer is forced to write them. A wide interface forces every implementer and caller to depend on methods they don't use (the Interface-Segregation 'I' in SOLID). Split it into focused role-interfaces.
  • Fat interface: MetadataCache (25 abstract methods) metadata/src/main/java/org/apache/kafka/metadata/MetadataCache.java:50 — `MetadataCache` declares 25 abstract methods: `contains`, `contains`, `describeClientQuotas`, `describeScramCredentials`, `describeTopicResponse`, `features`, `getAliveBrokerEpoch`, `getAliveBrokerNode`, `getAliveBrokerNodes`, `getAllTopics`, `getBrokerNodes`, `getLeaderAndIsr`, `getPartitionLeaderEndpoint`, `getPartitionReplicaEndpoints`, `getRandomAliveBrokerId`, `getTopicId`, `getTopicMetadata`, `getTopicName`, `hasAliveBroker`, `isBrokerFenced`, `isBrokerShuttingDown`, `metadataVersion`, `numPartitions`, `topicIdsToNames`, `topicNamesToIds`. Counted over its ABSTRACT methods, once per signature; `default`, `static` and `private` methods and constants are not counted, because no implementer is forced to write them. Those 25 declarations carry 24 distinct name(s), so part of the width is overloading rather than separate responsibilities — but 24 operations clears the >15 bar on its own, so the row is about responsibilities, not signatures. A wide interface forces every implementer and caller to depend on methods they don't use (the Interface-Segregation 'I' in SOLID). Split it into focused role-interfaces.
  • Fat interface: RaftClient<T> (16 abstract methods) raft/src/main/java/org/apache/kafka/raft/RaftClient.java:35 — `RaftClient<T>` declares 16 abstract methods: `createSnapshot`, `highWatermark`, `kraftVersion`, `latestSnapshotId`, `latestVoterSet`, `leaderAndEpoch`, `logEndOffset`, `nodeId`, `prepareAppend`, `register`, `resign`, `schedulePreparedAppend`, `shutdown`, `unregister`, `upgradeKRaftVersion`, `voterNode`. Counted over its ABSTRACT methods, once per signature; `default`, `static` and `private` methods and constants are not counted, because no implementer is forced to write them. A wide interface forces every implementer and caller to depend on methods they don't use (the Interface-Segregation 'I' in SOLID). Split it into focused role-interfaces.
  • Fat interface: RaftLog (24 abstract methods) raft/src/main/java/org/apache/kafka/raft/RaftLog.java:28 — `RaftLog` declares 24 abstract methods: `appendAsFollower`, `appendAsLeader`, `createNewSnapshot`, `createNewSnapshotUnchecked`, `deleteBeforeSnapshot`, `earliestSnapshotId`, `endOffset`, `endOffsetForEpoch`, `flush`, `highWatermark`, `initializeLeaderEpoch`, `lastFetchedEpoch`, `latestSnapshot`, `latestSnapshotId`, `maybeClean`, `onSnapshotFrozen`, `read`, `readSnapshot`, `startOffset`, `topicId`, `topicPartition`, `truncateTo`, `truncateToLatestSnapshot`, `updateHighWatermark`. Counted over its ABSTRACT methods, once per signature; `default`, `static` and `private` methods and constants are not counted, because no implementer is forced to write them. A wide interface forces every implementer and caller to depend on methods they don't use (the Interface-Segregation 'I' in SOLID). Split it into focused role-interfaces.
  • Fat interface: TaskManager (16 abstract methods) streams/src/main/java/org/apache/kafka/streams/processor/internals/tasks/TaskManager.java:30 — `TaskManager` declares 16 abstract methods: `add`, `assignNextTask`, `awaitProcessableTasks`, `drainUncaughtExceptions`, `getTasks`, `hasUncaughtException`, `lockAllTasks`, `lockTasks`, `remove`, `setUncaughtException`, `shutdown`, `signalTaskExecutors`, `startTaskExecutors`, `unassignTask`, `unlockAllTasks`, `unlockTasks`. Counted over its ABSTRACT methods, once per signature; `default`, `static` and `private` methods and constants are not counted, because no implementer is forced to write them. A wide interface forces every implementer and caller to depend on methods they don't use (the Interface-Segregation 'I' in SOLID). Split it into focused role-interfaces.
  • Fat interface: InternalProcessorContext<KOut, VOut> (19 abstract methods) streams/src/main/java/org/apache/kafka/streams/processor/internals/InternalProcessorContext.java:39 — `InternalProcessorContext<KOut, VOut>` declares 19 abstract methods: `addProcessorMetadataKeyValue`, `cache`, `changelogFor`, `currentNode`, `initialize`, `logChange`, `metrics`, `processorMetadata`, `processorMetadataForKey`, `recordContext`, `registerCacheFlushListener`, `setCurrentNode`, `setProcessorMetadata`, `setRecordContext`, `setSystemTimeMs`, `taskType`, `transitionToActive`, `transitionToStandby`, `uninitialize`. Counted over its ABSTRACT methods, once per signature; `default`, `static` and `private` methods and constants are not counted, because no implementer is forced to write them. A wide interface forces every implementer and caller to depend on methods they don't use (the Interface-Segregation 'I' in SOLID). Split it into focused role-interfaces.
  • Fat interface: StateUpdater (16 abstract methods) streams/src/main/java/org/apache/kafka/streams/processor/internals/StateUpdater.java:33 — `StateUpdater` declares 16 abstract methods: `add`, `drainExceptionsAndFailedTasks`, `drainQueuedTasks`, `drainRestoredActiveTasks`, `fatalException`, `hasExceptionsAndFailedTasks`, `remove`, `restoreConsumerInstanceId`, `restoresActiveTasks`, `shutdown`, `signalResume`, `standbyTasks`, `start`, `taskEndOffsetSumSnapshot`, `tasks`, `updatingTasks`. Counted over its ABSTRACT methods, once per signature; `default`, `static` and `private` methods and constants are not counted, because no implementer is forced to write them. A wide interface forces every implementer and caller to depend on methods they don't use (the Interface-Segregation 'I' in SOLID). Split it into focused role-interfaces.
  • Fat interface: Task (31 abstract methods) streams/src/main/java/org/apache/kafka/streams/processor/internals/Task.java:37 — `Task` declares 31 abstract methods: `addRecords`, `changelogOffsets`, `changelogPartitions`, `clearTaskTimeout`, `closeClean`, `closeDirty`, `commitNeeded`, `committedOffsets`, `completeRestoration`, `highWaterMark`, `id`, `initializeIfNeeded`, `inputPartitions`, `isActive`, `markChangelogAsCorrupted`, `maybeCheckpoint`, `maybeInitTaskTimeoutOrThrow`, `postCommit`, `prepareCommit`, `prepareRecycle`, `recordRestoration`, `resume`, `resumePollingForPartitionsWithAvailableSpace`, `revive`, `state`, `stateManager`, `store`, `suspend`, `timeCurrentIdlingStarted`, `updateInputPartitions`, `updateLags`. Counted over its ABSTRACT methods, once per signature; `default`, `static` and `private` methods and constants are not counted, because no implementer is forced to write them. A wide interface forces every implementer and caller to depend on methods they don't use (the Interface-Segregation 'I' in SOLID). Split it into focused role-interfaces.
  • Fat interface: TasksRegistry (35 abstract methods) streams/src/main/java/org/apache/kafka/streams/processor/internals/TasksRegistry.java:26 — `TasksRegistry` declares 35 abstract methods: `activeInitializedTaskIds`, `activeInitializedTasks`, `activeInitializedTasksForInputPartition`, `addActiveTask`, `addActiveTasks`, `addFailedTask`, `addPendingActiveTasksToCreate`, `addPendingStandbyTasksToCreate`, `addPendingTasksToClose`, `addPendingTasksToInit`, `addStandbyTask`, `addStandbyTasks`, `addTask`, `allInitializedTaskIds`, `allInitializedTasks`, `allInitializedTasksPerId`, `allNonFailedInitializedTasks`, `clear`, `clearPendingTasksToCreate`, `containsInitialized`, `drainPendingActiveTasksForTopologies`, `drainPendingActiveTasksToInit`, `drainPendingStandbyTasksForTopologies`, `drainPendingStandbyTasksToInit`, `drainPendingTasksToInit`, `hasPendingTasksToClose`, `hasPendingTasksToInit`, `initializedTask`, `initializedTasks`, `pendingTasksToClose`, `pendingTasksToInit`, `removeTask`, `replaceStandbyWithActive`, `standbyInitializedTasks`, `updateActiveTaskInputPartitions`. Counted over its ABSTRACT methods, once per signature; `default`, `static` and `private` methods and constants are not counted, because no implementer is forced to write them. A wide interface forces every implementer and caller to depend on methods they don't use (the Interface-Segregation 'I' in SOLID). Split it into focused role-interfaces.
  • Fat interface: ProcessorContext (22 abstract methods) streams/src/main/java/org/apache/kafka/streams/processor/ProcessorContext.java:52 — `ProcessorContext` declares 22 abstract methods: `appConfigs`, `appConfigsWithPrefix`, `applicationId`, `commit`, `currentStreamTimeMs`, `currentSystemTimeMs`, `forward`, `forward`, `getStateStore`, `headers`, `keySerde`, `metrics`, `offset`, `partition`, `register`, `schedule`, `schedule`, `stateDir`, `taskId`, `timestamp`, `topic`, `valueSerde`. Counted over its ABSTRACT methods, once per signature; `default`, `static` and `private` methods and constants are not counted, because no implementer is forced to write them. Those 22 declarations carry 20 distinct name(s), so part of the width is overloading rather than separate responsibilities — but 20 operations clears the >15 bar on its own, so the row is about responsibilities, not signatures. A wide interface forces every implementer and caller to depend on methods they don't use (the Interface-Segregation 'I' in SOLID). Split it into focused role-interfaces.
  • Fat interface: KStream<K, V> (77 abstract methods) streams/src/main/java/org/apache/kafka/streams/kstream/KStream.java:63 — `KStream<K, V>` declares 77 abstract methods: `filter`, `filter`, `filterNot`, `filterNot`, `flatMap`, `flatMap`, `flatMapValues`, `flatMapValues`, `flatMapValues`, `flatMapValues`, `foreach`, `foreach`, `groupBy`, `groupBy`, `groupByKey`, `groupByKey`, `join`, `join`, `join`, `join`, `join`, `join`, `join`, `join`, `join`, `join`, `join`, `join`, `join`, `join`, `leftJoin`, `leftJoin`, `leftJoin`, `leftJoin`, `leftJoin`, `leftJoin`, `leftJoin`, `leftJoin`, `leftJoin`, `leftJoin`, and 37 more. Counted over its ABSTRACT methods, once per signature; `default`, `static` and `private` methods and constants are not counted, because no implementer is forced to write them. Those 77 declarations carry 22 distinct name(s), so part of the width is overloading rather than separate responsibilities — but 22 operations clears the >15 bar on its own, so the row is about responsibilities, not signatures. A wide interface forces every implementer and caller to depend on methods they don't use (the Interface-Segregation 'I' in SOLID). Split it into focused role-interfaces.
  • Fat interface: KTable<K, V> (56 abstract methods) streams/src/main/java/org/apache/kafka/streams/kstream/KTable.java:91 — `KTable<K, V>` declares 56 abstract methods under just 11 distinct name(s): `filter`, `filter`, `filter`, `filter`, `filterNot`, `filterNot`, `filterNot`, `filterNot`, `groupBy`, `groupBy`, `join`, `join`, `join`, `join`, `join`, `join`, `join`, `join`, `join`, `join`, `join`, `join`, `leftJoin`, `leftJoin`, `leftJoin`, `leftJoin`, `leftJoin`, `leftJoin`, `leftJoin`, `leftJoin`, `leftJoin`, `leftJoin`, `leftJoin`, `leftJoin`, `mapValues`, `mapValues`, `mapValues`, `mapValues`, `mapValues`, `mapValues`, and 16 more. Counted over its ABSTRACT methods, once per signature; `default`, `static` and `private` methods and constants are not counted, because no implementer is forced to write them. That is an OVERLOAD SET, not 56 separate responsibilities: a caller binds to 11 operation(s) and uses the overload it selected, so the Interface-Segregation harm does NOT apply on the caller's side and splitting this into role-interfaces would scatter one operation without relieving anything. The burden that does remain is the IMPLEMENTER's — all 56 signatures must be written and kept in step. Reduce it by collapsing overloads (optional or default parameters, or an options object) rather than by segregating the interface.
  • Fat interface: RecordBatch (25 abstract methods) clients/src/main/java/org/apache/kafka/common/record/internal/RecordBatch.java:34 — `RecordBatch` declares 25 abstract methods: `baseOffset`, `baseSequence`, `checksum`, `compressionType`, `countOrNull`, `deleteHorizonMs`, `ensureValid`, `hasProducerId`, `isCompressed`, `isControlBatch`, `isTransactional`, `isValid`, `lastOffset`, `lastSequence`, `magic`, `maxTimestamp`, `nextOffset`, `partitionLeaderEpoch`, `producerEpoch`, `producerId`, `sizeInBytes`, `streamingIterator`, `streamingIterator`, `timestampType`, `writeTo`. Counted over its ABSTRACT methods, once per signature; `default`, `static` and `private` methods and constants are not counted, because no implementer is forced to write them. Those 25 declarations carry 24 distinct name(s), so part of the width is overloading rather than separate responsibilities — but 24 operations clears the >15 bar on its own, so the row is about responsibilities, not signatures. A wide interface forces every implementer and caller to depend on methods they don't use (the Interface-Segregation 'I' in SOLID). Split it into focused role-interfaces.
  • + 1 more in this group — see findings.md.
X10 · Duplicated predicate · Duplicated predicate · ×25
  • Duplicated predicate clients/src/main/java/org/apache/kafka/clients/consumer/internals/CompletedFetch.java:360 — `!abortedTransactions.isEmpty() && abortedTransactions.peek().firstOffset() <= offset` appears character-identically in 2 files — clients/src/main/java/org/apache/kafka/clients/consumer/internals/CompletedFetch.java, storage/src/main/java/org/apache/kafka/storage/internals/log/CleanedTransactionMetadata.java. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate clients/src/main/java/org/apache/kafka/common/security/plain/internals/PlainSaslServer.java:107 — `!authorizationIdFromClient.isEmpty() && !authorizationIdFromClient.equals(username)` appears character-identically in 2 files — clients/src/main/java/org/apache/kafka/common/security/plain/internals/PlainSaslServer.java, clients/src/main/java/org/apache/kafka/common/security/scram/internals/ScramSaslServer.java. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate streams/src/main/java/org/apache/kafka/streams/processor/internals/assignment/BalanceSubtopologyGraphConstructor.java:202 — `!hasReplica && taskClientMap.containsKey(taskId)` appears character-identically in 2 files — streams/src/main/java/org/apache/kafka/streams/processor/internals/assignment/BalanceSubtopologyGraphConstructor.java, streams/src/main/java/org/apache/kafka/streams/processor/internals/assignment/MinTrafficGraphConstructor.java. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate tools/src/main/java/org/apache/kafka/tools/consumer/group/ConsumerGroupCommandOptions.java:248 — `!options.has(dryRunOpt) && !options.has(executeOpt)` appears character-identically in 3 files — tools/src/main/java/org/apache/kafka/tools/consumer/group/ConsumerGroupCommandOptions.java, tools/src/main/java/org/apache/kafka/tools/consumer/group/ShareGroupCommandOptions.java, tools/src/main/java/org/apache/kafka/tools/streams/StreamsGroupCommandOptions.java. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate tools/src/main/java/org/apache/kafka/tools/consumer/group/ConsumerGroupCommandOptions.java:216 — `!options.has(groupOpt) && !options.has(allGroupsOpt)` appears character-identically in 3 files — tools/src/main/java/org/apache/kafka/tools/consumer/group/ConsumerGroupCommandOptions.java, tools/src/main/java/org/apache/kafka/tools/consumer/group/ShareGroupCommandOptions.java, tools/src/main/java/org/apache/kafka/tools/streams/StreamsGroupCommandOptions.java. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate tools/src/main/java/org/apache/kafka/tools/consumer/group/ConsumerGroupCommandOptions.java:239 — `!options.has(groupOpt) || !options.has(topicOpt)` appears character-identically in 2 files — tools/src/main/java/org/apache/kafka/tools/consumer/group/ConsumerGroupCommandOptions.java, tools/src/main/java/org/apache/kafka/tools/consumer/group/ShareGroupCommandOptions.java. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate group-coordinator/src/main/java/org/apache/kafka/coordinator/group/streams/topics/RepartitionTopics.java:145 — `!progressMadeThisIteration && partitionCountNeeded` appears character-identically in 2 files — group-coordinator/src/main/java/org/apache/kafka/coordinator/group/streams/topics/RepartitionTopics.java, streams/src/main/java/org/apache/kafka/streams/processor/internals/RepartitionTopics.java. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate tools/src/main/java/org/apache/kafka/tools/consumer/ConsoleConsumer.java:215 — `!recordIter.hasNext() && (time.milliseconds() - startTimeMs > timeoutMs)` appears character-identically in 2 files — tools/src/main/java/org/apache/kafka/tools/consumer/ConsoleConsumer.java, tools/src/main/java/org/apache/kafka/tools/consumer/ConsoleShareConsumer.java. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate tools/src/main/java/org/apache/kafka/tools/consumer/group/ShareGroupCommand.java:250 — `!state.equals(GroupState.DEAD) && numRows > 0` appears character-identically in 2 files — tools/src/main/java/org/apache/kafka/tools/consumer/group/ShareGroupCommand.java, tools/src/main/java/org/apache/kafka/tools/streams/StreamsGroupCommand.java. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate clients/src/main/java/org/apache/kafka/clients/consumer/internals/AbstractMembershipManager.java:236 — `!state.equals(nextState) && !nextState.getPreviousValidStates().contains(state)` appears character-identically in 2 files — clients/src/main/java/org/apache/kafka/clients/consumer/internals/AbstractMembershipManager.java, clients/src/main/java/org/apache/kafka/clients/consumer/internals/StreamsMembershipManager.java. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate streams/src/main/java/org/apache/kafka/streams/state/internals/PrefixedWindowKeySchemas.java:134 — `(binaryKeyFrom == null || keyBytes.compareTo(binaryKeyFrom) >= 0) && (binaryKeyTo == null || keyBytes.compareTo(binaryKeyTo) <= 0) && time >…` appears character-identically in 2 files — streams/src/main/java/org/apache/kafka/streams/state/internals/PrefixedWindowKeySchemas.java, streams/src/main/java/org/apache/kafka/streams/state/internals/WindowKeySchema.java. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate trogdor/src/main/java/org/apache/kafka/trogdor/workload/GaussianTimestampConstantPayloadGenerator.java:110 — `(messageSize == 0) || (messageTracker >= messagesUntilSizeChange)` appears character-identically in 2 files — trogdor/src/main/java/org/apache/kafka/trogdor/workload/GaussianTimestampConstantPayloadGenerator.java, trogdor/src/main/java/org/apache/kafka/trogdor/workload/GaussianTimestampRandomPayloadGenerator.java. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate clients/src/main/java/org/apache/kafka/common/Uuid.java:107 — `(null == obj) || (obj.getClass() != this.getClass())` appears character-identically in 2 files — clients/src/main/java/org/apache/kafka/common/Uuid.java, storage/src/main/java/org/apache/kafka/storage/internals/log/VerificationGuard.java. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate clients/src/main/java/org/apache/kafka/common/protocol/types/RawTaggedField.java:45 — `(o == null) || (!o.getClass().equals(getClass()))` appears character-identically in 2 files — clients/src/main/java/org/apache/kafka/common/protocol/types/RawTaggedField.java, clients/src/main/java/org/apache/kafka/server/policy/AlterConfigPolicy.java. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate metadata/src/main/java/org/apache/kafka/controller/ScramControlManager.java:157 — `Arrays.equals(salt, other.salt) && Arrays.equals(storedKey, other.storedKey) && Arrays.equals(serverKey, other.serverKey) && iterations == o…` appears character-identically in 2 files — metadata/src/main/java/org/apache/kafka/controller/ScramControlManager.java, metadata/src/main/java/org/apache/kafka/metadata/ScramCredentialData.java. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate clients/src/main/java/org/apache/kafka/common/quota/ClientQuotaAlteration.java:65 — `Objects.equals(key, that.key) && Objects.equals(value, that.value)` appears character-identically in 2 files — clients/src/main/java/org/apache/kafka/common/quota/ClientQuotaAlteration.java, coordinator-common/src/main/java/org/apache/kafka/coordinator/common/runtime/CoordinatorRecord.java. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate streams/src/main/java/org/apache/kafka/streams/processor/internals/RepartitionTopicConfig.java:80 — `Objects.equals(name, that.name) && Objects.equals(topicConfigs, that.topicConfigs) && Objects.equals(enforceNumberOfPartitions, that.enforce…` appears character-identically in 2 files — streams/src/main/java/org/apache/kafka/streams/processor/internals/RepartitionTopicConfig.java, streams/src/main/java/org/apache/kafka/streams/processor/internals/UnwindowedUnversionedChangelogTopicConfig.java. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate streams/src/main/java/org/apache/kafka/streams/processor/assignment/assignors/StickyTaskAssignor.java:463 — `Objects.equals(task1, pair.task1) && Objects.equals(task2, pair.task2)` appears character-identically in 2 files — streams/src/main/java/org/apache/kafka/streams/processor/assignment/assignors/StickyTaskAssignor.java, streams/src/main/java/org/apache/kafka/streams/processor/internals/assignment/LegacyStickyTaskAssignor.java. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate streams/src/main/java/org/apache/kafka/streams/state/internals/MemoryNavigableLRUCache.java:47 — `Objects.nonNull(from) && Objects.nonNull(to) && from.compareTo(to) > 0` appears character-identically in 2 files — streams/src/main/java/org/apache/kafka/streams/state/internals/MemoryNavigableLRUCache.java, streams/src/main/java/org/apache/kafka/streams/state/internals/RocksDBStore.java. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate clients/src/main/java/org/apache/kafka/common/security/oauthbearer/internals/secured/JaasOptionsUtils.java:64 — `Objects.requireNonNull(jaasConfigEntries).size() != 1 || jaasConfigEntries.get(0) == null` appears character-identically in 3 files — clients/src/main/java/org/apache/kafka/common/security/oauthbearer/internals/secured/JaasOptionsUtils.java, clients/src/main/java/org/apache/kafka/common/security/oauthbearer/internals/unsecured/OAuthBearerUnsecuredLoginCallbackHandler.java, clients/src/main/java/org/apache/kafka/common/security/oauthbearer/internals/unsecured/OAuthBearerUnsecuredValidatorCallbackHandler.java. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate clients/src/main/java/org/apache/kafka/clients/consumer/internals/AsyncKafkaConsumer.java:1673 — `backgroundEventReaper != null && backgroundEventQueue != null` appears character-identically in 2 files — clients/src/main/java/org/apache/kafka/clients/consumer/internals/AsyncKafkaConsumer.java, clients/src/main/java/org/apache/kafka/clients/consumer/internals/ShareConsumerImpl.java. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate clients/src/main/java/org/apache/kafka/clients/consumer/internals/CompletedFetch.java:367 — `batch.isTransactional() && abortedProducerIds.contains(batch.producerId())` appears character-identically in 2 files — clients/src/main/java/org/apache/kafka/clients/consumer/internals/CompletedFetch.java, core/src/main/java/kafka/server/share/SharePartition.java. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate clients/src/main/java/org/apache/kafka/common/utils/internals/ByteUtils.java:91 — `buffer1 == buffer2 && offset1 == offset2 && length1 == length2` appears character-identically in 2 files — clients/src/main/java/org/apache/kafka/common/utils/internals/ByteUtils.java, jmh-benchmarks/src/main/java/org/apache/kafka/jmh/util/BytesCompareBenchmark.java. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate clients/src/main/java/org/apache/kafka/common/security/oauthbearer/internals/OAuthBearerSaslClient.java:90 — `challenge != null && challenge.length != 0` appears character-identically in 2 files — clients/src/main/java/org/apache/kafka/common/security/oauthbearer/internals/OAuthBearerSaslClient.java, clients/src/main/java/org/apache/kafka/common/security/scram/internals/ScramSaslClient.java. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate clients/src/main/java/org/apache/kafka/clients/NetworkClientUtils.java:135 — `client.connectionFailed(node) && client.connectionDelay(node, time.milliseconds()) > 0` appears character-identically in 2 files — clients/src/main/java/org/apache/kafka/clients/NetworkClientUtils.java, clients/src/main/java/org/apache/kafka/clients/consumer/internals/NetworkClientDelegate.java. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
X23 · Unguarded diagnostic materialisation · Diagnostic log message is built whether or not it is wanted · ×12
  • Diagnostic log message is built whether or not it is wanted clients/src/main/java/org/apache/kafka/common/security/authenticator/SaslClientAuthenticator.java:219 — `debug` at line 219 is called with an argument built by `Arrays.toString(mechs)` (line 220), whose cost grows with the collection it walks. Java evaluates a call's arguments BEFORE entering the method, so that join/projection runs in full every time this line is reached — and then the level check inside the logger discards the string it produced, because debug is a level a shipped configuration normally leaves off. Nothing here decides beforehand whether the message is wanted: no `isDebugEnabled`/`isTraceEnabled` test, no debug flag, no lambda or `Supplier` the logger calls only when the level is on.
  • Diagnostic log message is built whether or not it is wanted connect/runtime/src/main/java/org/apache/kafka/connect/runtime/WorkerSinkTask.java:331 — `debug` at line 331 is called with an argument built by `String.join("…", topics)` (line 331), whose cost grows with the collection it walks. Java evaluates a call's arguments BEFORE entering the method, so that join/projection runs in full every time this line is reached — and then the level check inside the logger discards the string it produced, because debug is a level a shipped configuration normally leaves off. Nothing here decides beforehand whether the message is wanted: no `isDebugEnabled`/`isTraceEnabled` test, no debug flag, no lambda or `Supplier` the logger calls only when the level is on.
  • Diagnostic log message is built whether or not it is wanted connect/runtime/src/main/java/org/apache/kafka/connect/runtime/distributed/IncrementalCooperativeAssignor.java:479 — `debug` at line 479 is called with an argument built by `candidateWorkerLoad.stream()` (line 481), whose cost grows with the collection it walks. Java evaluates a call's arguments BEFORE entering the method, so that join/projection runs in full every time this line is reached — and then the level check inside the logger discards the string it produced, because debug is a level a shipped configuration normally leaves off. Nothing here decides beforehand whether the message is wanted: no `isDebugEnabled`/`isTraceEnabled` test, no debug flag, no lambda or `Supplier` the logger calls only when the level is on.
  • Diagnostic log message is built whether or not it is wanted group-coordinator/src/main/java/org/apache/kafka/coordinator/group/streams/topics/ChangelogTopics.java:88 — `debug` at line 88 is called with an argument built by `stream()` (line 89), whose cost grows with the collection it walks. Java evaluates a call's arguments BEFORE entering the method, so that join/projection runs in full every time this line is reached — and then the level check inside the logger discards the string it produced, because debug is a level a shipped configuration normally leaves off. Nothing here decides beforehand whether the message is wanted: no `isDebugEnabled`/`isTraceEnabled` test, no debug flag, no lambda or `Supplier` the logger calls only when the level is on.
  • Diagnostic log message is built whether or not it is wanted metadata/src/main/java/org/apache/kafka/controller/PartitionChangeBuilder.java:306 — `trace` at line 306 is called with an argument built by `Arrays.toString(partition.lastKnownElr)` (line 307), whose cost grows with the collection it walks. Java evaluates a call's arguments BEFORE entering the method, so that join/projection runs in full every time this line is reached — and then the level check inside the logger discards the string it produced, because trace is a level a shipped configuration normally leaves off. Nothing here decides beforehand whether the message is wanted: no `isDebugEnabled`/`isTraceEnabled` test, no debug flag, no lambda or `Supplier` the logger calls only when the level is on.
  • Diagnostic log message is built whether or not it is wanted metadata/src/main/java/org/apache/kafka/metadata/KRaftMetadataCache.java:160 — `debug` at line 160 is called with an argument built by `Arrays.stream(partition.replicas)` (line 160), whose cost grows with the collection it walks. Java evaluates a call's arguments BEFORE entering the method, so that join/projection runs in full every time this line is reached — and then the level check inside the logger discards the string it produced, because debug is a level a shipped configuration normally leaves off. Nothing here decides beforehand whether the message is wanted: no `isDebugEnabled`/`isTraceEnabled` test, no debug flag, no lambda or `Supplier` the logger calls only when the level is on.
  • Diagnostic log message is built whether or not it is wanted metadata/src/main/java/org/apache/kafka/metadata/KRaftMetadataCache.java:163 — `debug` at line 163 is called with an argument built by `Arrays.stream(partition.isr)` (line 163), whose cost grows with the collection it walks. Java evaluates a call's arguments BEFORE entering the method, so that join/projection runs in full every time this line is reached — and then the level check inside the logger discards the string it produced, because debug is a level a shipped configuration normally leaves off. Nothing here decides beforehand whether the message is wanted: no `isDebugEnabled`/`isTraceEnabled` test, no debug flag, no lambda or `Supplier` the logger calls only when the level is on.
  • Diagnostic log message is built whether or not it is wanted streams/src/main/java/org/apache/kafka/streams/KafkaStreams.java:326 — `debug` at line 326 is called with an argument built by `Arrays.stream(targetStates)` (line 328), whose cost grows with the collection it walks. Java evaluates a call's arguments BEFORE entering the method, so that join/projection runs in full every time this line is reached — and then the level check inside the logger discards the string it produced, because debug is a level a shipped configuration normally leaves off. Nothing here decides beforehand whether the message is wanted: no `isDebugEnabled`/`isTraceEnabled` test, no debug flag, no lambda or `Supplier` the logger calls only when the level is on.
  • Diagnostic log message is built whether or not it is wanted streams/src/main/java/org/apache/kafka/streams/processor/internals/TaskExecutor.java:176 — `debug` at line 176 is called with an argument built by `stream()` (line 176), whose cost grows with the collection it walks. Java evaluates a call's arguments BEFORE entering the method, so that join/projection runs in full every time this line is reached — and then the level check inside the logger discards the string it produced, because debug is a level a shipped configuration normally leaves off. Nothing here decides beforehand whether the message is wanted: no `isDebugEnabled`/`isTraceEnabled` test, no debug flag, no lambda or `Supplier` the logger calls only when the level is on.
  • Diagnostic log message is built whether or not it is wanted tools/src/main/java/org/apache/kafka/tools/ConfigCommand.java:141 — `debug` at line 141 is called with an argument built by `String.join("…", args)` (line 141), whose cost grows with the collection it walks. Java evaluates a call's arguments BEFORE entering the method, so that join/projection runs in full every time this line is reached — and then the level check inside the logger discards the string it produced, because debug is a level a shipped configuration normally leaves off. Nothing here decides beforehand whether the message is wanted: no `isDebugEnabled`/`isTraceEnabled` test, no debug flag, no lambda or `Supplier` the logger calls only when the level is on.
  • Diagnostic log message is built whether or not it is wanted tools/src/main/java/org/apache/kafka/tools/ConfigCommand.java:145 — `debug` at line 145 is called with an argument built by `String.join("…", args)` (line 145), whose cost grows with the collection it walks. Java evaluates a call's arguments BEFORE entering the method, so that join/projection runs in full every time this line is reached — and then the level check inside the logger discards the string it produced, because debug is a level a shipped configuration normally leaves off. Nothing here decides beforehand whether the message is wanted: no `isDebugEnabled`/`isTraceEnabled` test, no debug flag, no lambda or `Supplier` the logger calls only when the level is on.
  • Diagnostic log message is built whether or not it is wanted tools/src/main/java/org/apache/kafka/tools/ConfigCommand.java:149 — `debug` at line 149 is called with an argument built by `String.join("…", args)` (line 149), whose cost grows with the collection it walks. Java evaluates a call's arguments BEFORE entering the method, so that join/projection runs in full every time this line is reached — and then the level check inside the logger discards the string it produced, because debug is a level a shipped configuration normally leaves off. Nothing here decides beforehand whether the message is wanted: no `isDebugEnabled`/`isTraceEnabled` test, no debug flag, no lambda or `Supplier` the logger calls only when the level is on.
D16 · Bus Factor · Off-boarding risk · ×9
  • Off-boarding risk: anonymized user #1 — If anonymized user #1 becomes unavailable, 7 significant file(s) lose their only recent owner: streams/src/main/java/org/apache/kafka/streams/state/internals/LegacyCheckpointingStateStore.java, streams/src/main/java/org/apache/kafka/streams/state/internals/InMemorySessionTransactionBuffer.java, streams/src/main/java/org/apache/kafka/streams/state/internals/AbstractTransactionBuffer.java, streams/src/main/java/org/apache/kafka/streams/state/internals/InMemoryWindowTransactionBuffer.java, streams/src/main/java/org/apache/kafka/streams/state/internals/InMemoryTransactionBuffer.java, streams/src/main/java/org/apache/kafka/streams/state/internals/VersionedKeyValueToBytesStoreAdapter.java, streams/src/main/java/org/apache/kafka/streams/state/internals/TransactionBuffer.java. Pair on, review, or document these before any departure.
  • Off-boarding risk: anonymized user #2 — If anonymized user #2 becomes unavailable, 6 significant file(s) lose their only recent owner: jmh-benchmarks/src/main/java/org/apache/kafka/jmh/assignor/ConsumerAssignorBenchmark.java, clients/src/main/java/org/apache/kafka/common/requests/TxnOffsetCommitRequest.java, group-coordinator/src/main/java/org/apache/kafka/coordinator/group/modern/TopicIds.java, generator/src/main/java/org/apache/kafka/message/CoordinatorRecordTypeGenerator.java, group-coordinator/src/main/java/org/apache/kafka/coordinator/group/OffsetAndMetadata.java, coordinator-common/src/main/java/org/apache/kafka/coordinator/common/runtime/CoordinatorMetadataImage.java. Pair on, review, or document these before any departure.
  • Off-boarding risk: anonymized user #3 — If anonymized user #3 becomes unavailable, 6 significant file(s) lose their only recent owner: streams/src/main/java/org/apache/kafka/streams/state/WindowStore.java, streams/src/main/java/org/apache/kafka/streams/kstream/Produced.java, streams/src/main/java/org/apache/kafka/streams/query/TimestampedRangeWithHeadersQuery.java, streams/src/main/java/org/apache/kafka/streams/processor/api/Record.java, streams/src/main/java/org/apache/kafka/streams/state/internals/AbstractMeteredIterator.java, streams/src/main/java/org/apache/kafka/streams/processor/api/ReadOnlyRecord.java. Pair on, review, or document these before any departure.
  • Off-boarding risk: anonymized user #4 — If anonymized user #4 becomes unavailable, 5 significant file(s) lose their only recent owner: server/src/main/java/org/apache/kafka/server/BrokerLifecycleManager.java, server/src/main/java/org/apache/kafka/server/ForwardingManagerImpl.java, connect/basic-auth-extension/src/main/java/org/apache/kafka/connect/rest/basic/auth/extension/PropertyFileLoginModule.java, core/src/main/scala/kafka/server/RequestHandlerHelper.scala, connect/runtime/src/main/java/org/apache/kafka/connect/runtime/rest/ConnectRestServer.java. Pair on, review, or document these before any departure.
  • Off-boarding risk: anonymized user #5 — If anonymized user #5 becomes unavailable, 5 significant file(s) lose their only recent owner: streams/src/main/java/org/apache/kafka/streams/processor/StandbyUpdateListener.java, streams/src/main/java/org/apache/kafka/streams/processor/StateRestoreListener.java, clients/src/main/java/org/apache/kafka/common/requests/StreamsGroupHeartbeatRequest.java, streams/src/main/java/org/apache/kafka/streams/processor/internals/ProcessorContextUtils.java, streams/src/main/java/org/apache/kafka/streams/processor/internals/PunctuationQueue.java. Pair on, review, or document these before any departure.
  • Off-boarding risk: anonymized user #6 — If anonymized user #6 becomes unavailable, 4 significant file(s) lose their only recent owner: server/src/main/java/org/apache/kafka/server/share/dlq/ShareGroupDLQStateManager.java, core/src/main/java/kafka/server/share/ShareCoordinatorMetadataCacheHelperImpl.java, server/src/main/java/org/apache/kafka/server/share/dlq/ShareGroupDLQMetadataCacheHelper.java, server/src/main/java/org/apache/kafka/server/share/dlq/DefaultShareGroupDLQManager.java. Pair on, review, or document these before any departure.
  • Off-boarding risk: anonymized user #7 — If anonymized user #7 becomes unavailable, 4 significant file(s) lose their only recent owner: api-checker/core/src/main/java/org/apache/kafka/apicheck/CascadeValidator.java, api-checker/maven-plugin/src/main/java/org/apache/kafka/maven/KafkaInternalApiCheckerMojo.java, api-checker/build.gradle, api-checker/core/src/main/java/org/apache/kafka/apicheck/PublicApiViolation.java. Pair on, review, or document these before any departure.
  • Off-boarding risk: anonymized user #8 — If anonymized user #8 becomes unavailable, 3 significant file(s) lose their only recent owner: server/src/main/java/org/apache/kafka/server/EnvelopeUtils.java, server/src/main/java/org/apache/kafka/server/logger/LoggingController.java, storage/src/main/java/org/apache/kafka/storage/internals/checkpoint/PartitionMetadataReadBuffer.java. Pair on, review, or document these before any departure.
  • Off-boarding risk: anonymized user #9 — If anonymized user #9 becomes unavailable, 5 significant file(s) lose their only recent owner: clients/src/main/java/org/apache/kafka/clients/consumer/internals/Acknowledgements.java, clients/src/main/java/org/apache/kafka/clients/consumer/internals/ShareFetch.java, clients/src/main/java/org/apache/kafka/clients/consumer/internals/ShareFetchBuffer.java, clients/src/main/java/org/apache/kafka/clients/consumer/internals/ShareInFlightBatch.java, clients/src/main/java/org/apache/kafka/clients/consumer/internals/ShareConsumerDelegateCreator.java. Pair on, review, or document these before any departure.
IC1 · Incompleteness & stubs · Disabled test · ×9
  • Disabled test clients/src/test/java/org/apache/kafka/common/utils/internals/ByteUtilsTest.java:346 — A test is skipped/ignored — coverage that looks present but never runs. Re-enable it or delete it so the green run means something.
  • Disabled test clients/src/test/java/org/apache/kafka/common/utils/internals/ByteUtilsTest.java:430 — A test is skipped/ignored — coverage that looks present but never runs. Re-enable it or delete it so the green run means something.
  • Disabled test group-coordinator/src/test/java/org/apache/kafka/coordinator/group/GroupCoordinatorShardCompactionReplayTest.java:333 — A test is skipped/ignored — coverage that looks present but never runs. Re-enable it or delete it so the green run means something.
  • Disabled test group-coordinator/src/test/java/org/apache/kafka/coordinator/group/GroupCoordinatorShardCompactionReplayTest.java:406 — A test is skipped/ignored — coverage that looks present but never runs. Re-enable it or delete it so the green run means something.
  • Disabled test metadata/src/test/java/org/apache/kafka/controller/FeatureControlManagerTest.java:382 — A test is skipped/ignored — coverage that looks present but never runs. Re-enable it or delete it so the green run means something.
  • Disabled test streams/integration-tests/src/test/java/org/apache/kafka/streams/integration/NamedTopologyIntegrationTest.java:338 — A test is skipped/ignored — coverage that looks present but never runs. Re-enable it or delete it so the green run means something.
  • Disabled test streams/integration-tests/src/test/java/org/apache/kafka/streams/integration/NamedTopologyIntegrationTest.java:436 — A test is skipped/ignored — coverage that looks present but never runs. Re-enable it or delete it so the green run means something.
  • Disabled test streams/integration-tests/src/test/java/org/apache/kafka/streams/integration/NamedTopologyIntegrationTest.java:451 — A test is skipped/ignored — coverage that looks present but never runs. Re-enable it or delete it so the green run means something.
  • Disabled test streams/src/test/java/org/apache/kafka/streams/kstream/internals/KTableSourceTest.java:94 — A test is skipped/ignored — coverage that looks present but never runs. Re-enable it or delete it so the green run means something.
IC1 · Incompleteness & stubs · Member throws NotSupportedException · ×4
  • Member throws NotSupportedException clients/src/main/java/org/apache/kafka/common/record/internal/CompressionType.java:176 — `defaultLevel`'s body only throws NotSupportedException — sometimes a deliberate contract, often an unfinished stub. Confirm it's intentional.
  • Member throws NotSupportedException clients/src/main/java/org/apache/kafka/common/record/internal/CompressionType.java:180 — `maxLevel`'s body only throws NotSupportedException — sometimes a deliberate contract, often an unfinished stub. Confirm it's intentional.
  • Member throws NotSupportedException clients/src/main/java/org/apache/kafka/common/record/internal/CompressionType.java:184 — `minLevel`'s body only throws NotSupportedException — sometimes a deliberate contract, often an unfinished stub. Confirm it's intentional.
  • Member throws NotSupportedException clients/src/main/java/org/apache/kafka/common/record/internal/CompressionType.java:188 — `levelValidator`'s body only throws NotSupportedException — sometimes a deliberate contract, often an unfinished stub. Confirm it's intentional.
X7 · Silent fallback defaults · Silent fallback default in catch · ×4
  • Silent fallback default in catch clients/clients-integration-tests/src/test/java/org/apache/kafka/clients/producer/ProducerSendWhileDeletionTest.java:283 — `partitionNotInCheckpoint` swallows every exception into `return new HashMap<TopicPartition, Long>()` — a data error becomes a silent behavior change with no trail. Log the failure or let it propagate. If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment in the catch or in the Javadoc, and the row stops firing.
  • Silent fallback default in catch clients/clients-integration-tests/src/test/java/org/apache/kafka/clients/MetadataVersionIntegrationTest.java:58 — `testBasicMetadataVersionUpgrade` swallows every exception into `return false` — a data error becomes a silent behavior change with no trail. Log the failure or let it propagate. If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment in the catch or in the Javadoc, and the row stops firing.
  • Silent fallback default in catch streams/integration-tests/src/test/java/org/apache/kafka/streams/integration/AtLeastOnceDeliveryMessageLossIntegrationTest.java:189 — `waitForProcessingAndCommit` swallows every exception into `return false` — a data error becomes a silent behavior change with no trail. Log the failure or let it propagate. If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment in the catch or in the Javadoc, and the row stops firing.
  • Silent fallback default in catch tests/kafkatest/services/connect.py:89 — `pids` swallows every exception into `return []` — a data error becomes a silent behavior change with no trail. Log the failure or let it raise. If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment on the handler or in the docstring, and the row stops firing.
D31 · IaC & Container Security · Low IaC · ×3
  • REDACTED
  • REDACTED
  • REDACTED
X7 · Silent fallback defaults · Silent fallback default on parse failure · ×3
  • Silent fallback default on parse failure tests/kafkatest/services/kafka/kafka.py:968 — `pids` returns `[]` when `(RemoteCommandError, ValueError)` is raised, with no log or raise — a malformed value silently becomes that default. Log the input or fail validation. If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment on the handler or in the docstring, and the row stops firing.
  • Silent fallback default on parse failure tests/kafkatest/services/performance/producer_performance.py:111 — `pids` returns `[]` when `(RemoteCommandError, ValueError)` is raised, with no log or raise — a malformed value silently becomes that default. Log the input or fail validation. If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment on the handler or in the docstring, and the row stops firing.
  • Silent fallback default on parse failure tests/kafkatest/services/verifiable_client.py:262 — `pids` returns `[]` when `(RemoteCommandError, ValueError)` is raised, with no log or raise — a malformed value silently becomes that default. Log the input or fail validation. If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment on the handler or in the docstring, and the row stops firing.
D16 · Bus Factor · Further sole-owners (lower concentration) · ×1
  • Further sole-owners (lower concentration) — 37 other contributor(s) are each the sole owner of a small amount of code below the off-boarding threshold — folded into the bus-factor score and metrics (99 single-owned of 2463 analysed files in total, counted over production source files of roughly 2,400 bytes or more, excluding vendored, generated and example/demo trees and test files identified by path convention, largest first; 2463 of the 3884 production source files in this repository met that bar). They are anonymized user #10 (4 file(s)), anonymized user #11 (3 file(s)), anonymized user #12 (3 file(s)), anonymized user #13 (2 file(s)), anonymized user #14 (2 file(s)), anonymized user #15 (2 file(s)) (+31 more) — spread or document their files in the same way, at lower priority than the named off-boarding risks above. The files folded here: clients/src/main/java/org/apache/kafka/clients/FetchSessionHandler.java, clients/src/main/java/org/apache/kafka/clients/producer/internals/ChunkedByteBufferOutputStream.java, clients/src/main/java/org/apache/kafka/clients/consumer/internals/events/PartitionsAssignedEvent.java, clients/src/main/java/org/apache/kafka/clients/consumer/internals/events/ApplyAssignmentEvent.java, storage/src/main/java/org/apache/kafka/server/log/remote/metadata/storage/RemoteLogSegmentMetadataSnapshot.java, storage/api/src/main/java/org/apache/kafka/server/log/remote/storage/RemoteLogSegmentMetadataUpdate.java, storage/api/src/main/java/org/apache/kafka/server/log/remote/storage/RemotePartitionDeleteMetadata.java, group-coordinator/src/main/java/org/apache/kafka/coordinator/group/streams/StreamsGroupTopologyDescriptionConverter.java (+46 more).
D20 · ADR Quality · No ADRs found · ×1
  • No ADRs found — No ADRs found. No recognised ADR directory (`docs/adr/`, `docs/decisions/`, `adr/`, `docs/rfcs/`, an `ADR0001/` folder, or their siblings) exists anywhere in this tree. What was searched, so you can tell an empty log from a search that missed one: every directory under the tree (build output, dependencies and VCS metadata excepted), for a document that is either any non-index page inside a recognised ADR directory, whatever its name and however deeply nested (`docs/adr/use-postgres.md`, `docs/adr/2024/0001-x.md`); or a file anywhere whose name is ADR-shaped (`0001-use-postgres.md`, `adr-012-caching.md`); or, when neither turned anything up, a document carrying the decision-record signature (an "Architecture Decision Record" heading, or Status / Context / Decision / Consequences as section headings). A decision log that clears none of these — unnumbered files outside any recognised directory, without those headings — is not seen by this check and this row is then wrong. If that is your case, say so rather than renaming anything; otherwise, consider recording architectural decisions in `docs/adr/`.
D26 · Project Cohesion · Projects may be oversized for their cohesion · ×1
  • Projects may be oversized for their cohesion — 1 of 8 project(s) overshoot their size bounds, lowering Project Cohesion to 7.5/10. The most over is `(repository root)` (623855 LoC, 4555 module-visible types across 314 directories). Review these for cohesion — draw the boundary inside the module first (group each responsibility into its own package or directory and keep the cross-boundary members non-public), since splitting a published package moves types between packages and breaks consumers.
D28 · Secrets (history) · Rotate the exposed credentials · ×1
  • REDACTED
D29 · Static Analysis (SAST) · REDACTED · ×1
  • REDACTED
D34 · Knowledge Freshness · Further orphaned files (smaller) · ×1
  • Further orphaned files (smaller) — 1087 smaller file(s) also have no living knowledge — folded into the freshness score and metrics rather than raised one row each — most significant first: metadata/src/main/java/org/apache/kafka/controller/BrokerHeartbeatManager.java, jmh-benchmarks/src/main/java/org/apache/kafka/jmh/connect/JsonConverterBenchmark.java, trogdor/src/main/java/org/apache/kafka/trogdor/workload/RoundTripWorkerBase.java, connect/runtime/src/main/java/org/apache/kafka/connect/runtime/rest/RestServerConfig.java, metadata/src/main/java/org/apache/kafka/metadata/PartitionRegistration.java, tools/src/main/java/org/apache/kafka/tools/GetOffsetShell.java, server/src/main/java/org/apache/kafka/server/FetchContext.java, connect/runtime/src/main/java/org/apache/kafka/connect/runtime/Herder.java (and 1079 more) (1137 orphaned of 2501 analysed files in total, counted over production source files of roughly 2,400 bytes or more, excluding vendored, generated and example/demo trees and test files identified by path convention, largest first; 2501 of the 3884 production source files in this repository met that bar). Attach the read to the next change that touches one of them: have a second person review that change, and leave behind a short comment or test recording what the file is for, so the knowledge comes back at the cost of a change you were making anyway.
D36 · Supply-chain Provenance & Signing · REDACTED · ×1
  • REDACTED
D36 · Supply-chain Provenance & Signing · REDACTED · ×1
  • REDACTED
M2 · Architecture documentation · No ADRs · ×1
  • No ADRs — No Architecture Decision Records found — no conventional ADR directory, no numbered `NNNN-title` documents in any markup this check reads, and nothing ADR-shaped by content. Design rationale recorded elsewhere (a design-notes tree, a mailing list, pull-request discussion) is not visible to this check and is not re-findable per decision, so a future maintainer cannot ask why one choice was made and get an answer.
P10 · Library API & versioning · Large public API surface · ×1
  • Large public API surface — 4132/5576 types (74%) declared in the published library are public. For a library, every public type is a stability contract — keep implementation types off the surface and expose only the intended API.
P2 · Observability · Logging is not universal · ×1
  • Logging is not universal — Only 3/6 runnable modules use logging (modules with no entry point or server are excluded — they are libraries a runnable module hosts). Silent: `docker`, `release`, `streams/quickstart/java/src/main/resources/archetype-resources`.
P6 · Release Hygiene · No changelog · ×1
  • No changelog — No CHANGELOG/HISTORY/RELEASES file — what shipped when isn't easy to reconstruct for support or audit. (Versioning/tagging makes releases traceable, but a changelog records the what.)
X5 · Nullable reference types · Java packages are not null-marked everywhere · ×1
  • Java packages are not null-marked everywhere — 0/291 of this repository's Java package directories are under a non-null default: a `package-info.java` declaring `@NullMarked` (JSpecify) or `@NonNullApi`, `@ParametersAreNonnullByDefault`, `@NonNullByDefault`, `@DefaultQualifier(NonNull.class)`; a `module-info.java` declaring `@NullMarked`; every type in it `@NullMarked`; or a build that runs NullAway with the package in `AnnotatedPackages`, or the Checker Framework's `NullnessChecker`. Elsewhere every reference admits null and no checker warns on the dereference that throws a `NullPointerException`.
Minor — 9 finding(s)
D10 · Test Quality · Skipped (documented) · ×9
  • Skipped (documented): testDsaKeyPair clients/src/test/java/org/apache/kafka/common/network/SslTransportLayerTest.java:486 — Skipped with a documented reason — a deferral, not lazy debt: skipped at run time by a JUnit assumption
  • Skipped (documented): testCorrectnessReadUnsignedVarlong clients/src/test/java/org/apache/kafka/common/utils/internals/ByteUtilsTest.java:431 — Skipped with a documented reason — a deferral, not lazy debt: switched off by @Disabled
  • Skipped (documented): testCorrectnessWriteUnsignedVarlong clients/src/test/java/org/apache/kafka/common/utils/internals/ByteUtilsTest.java:347 — Skipped with a documented reason — a deferral, not lazy debt: switched off by @Disabled
  • Skipped (documented): testFlushPathThrowsForMissingPath clients/src/test/java/org/apache/kafka/common/utils/UtilsTest.java:633 — Skipped with a documented reason — a deferral, not lazy debt: skipped at run time by a JUnit assumption
  • Skipped (documented): testConsumerGroupDowngradeByLeave group-coordinator/src/test/java/org/apache/kafka/coordinator/group/GroupCoordinatorShardCompactionReplayTest.java:334 — Skipped with a documented reason — a deferral, not lazy debt: switched off by @Disabled
  • Skipped (documented): testConsumerGroupDowngradeByStaticMemberReplacement group-coordinator/src/test/java/org/apache/kafka/coordinator/group/GroupCoordinatorShardCompactionReplayTest.java:407 — Skipped with a documented reason — a deferral, not lazy debt: switched off by @Disabled
  • Skipped (documented): testVerifyEvolutionGit generator/src/test/java/org/apache/kafka/message/checker/MetadataSchemaCheckerToolTest.java:38 — Skipped with a documented reason — a deferral, not lazy debt: skipped at run time by a JUnit assumption
  • Skipped (documented): testCanUseUnsafeDowngradeIfMetadataChanged metadata/src/test/java/org/apache/kafka/controller/FeatureControlManagerTest.java:384 — Skipped with a documented reason — a deferral, not lazy debt: switched off by @Disabled
  • Skipped (documented): testKTableSourceEmitOnChange streams/src/test/java/org/apache/kafka/streams/kstream/internals/KTableSourceTest.java:96 — Skipped with a documented reason — a deferral, not lazy debt: switched off by @Disabled

Appendix B — Reproduction & audit trail

Every external tool invocation behind a deep-scan dimension — the tool, its captured version, the exact command, how many findings it yielded, and a link to the retained raw output. To reproduce any finding: check out the same commit and run the command shown (repo-relative — never an absolute scratch path). The complete raw scanner output is retained verbatim under artifacts/raw/ (indexed in artifacts/raw/index.json); per-invocation exit codes and wall-clock durations are in sidecar.json — kept out of this table so the rendered report stays byte-identical across runs of the same commit.

DimensionToolVersionCommandFindingsRaw output
D28 · Secrets (history)gitleaks—gitleaks detect --no-banner --config /opt/gitleaks-rules/watchdog-gitleaks.toml --report-format json --report-path /tmp/watchdog-gitleaks-11ad2c51dbb64ed28f2a60717d41060c/history.json --exit-code 0 --source .1artifacts/raw/gitleaks-history.json
D28 · Secrets (history)gitleaks—gitleaks detect --no-git --no-banner --config /opt/gitleaks-rules/watchdog-gitleaks.toml --report-format json --report-path /tmp/watchdog-gitleaks-11ad2c51dbb64ed28f2a60717d41060c/tree.json --exit-code 0 --source .0artifacts/raw/gitleaks-tree.json
D29 · Static Analysis (SAST)semgrep—semgrep --config /opt/semgrep-rules/security-audit.yml --config /opt/semgrep-rules/owasp-top-ten.yml --config /opt/semgrep-rules/watchdog-sast.yml --json --quiet --timeout 10 --timeout-threshold 3 --metrics off .73artifacts/raw/semgrep.json
D30 · Dependency Vulnerabilitiesosv-scanner—osv-scanner --format json --recursive --experimental-disable-plugins transitivedependency/requirements --experimental-disable-plugins dotnet/csproj --experimental-disable-plugins dotnet/nugetcpm .0artifacts/raw/osv-scanner.json
D31 · IaC & Container Securitytrivy—trivy config --format json --quiet .16artifacts/raw/trivy-config.json
D32 · Data Compliance (PII/GDPR)semgrep—semgrep: not applicable — No personal data was found crossing a boundary the PII/GDPR ruleset checks — nothing written to a log or console sink, placed in a URL or query string, or persisted to browser storage. That is a clean result for the LEAK surface only: this ruleset detects personal data escaping, it does not inventory the personal data a repository holds, so it is not evidence that this repository has no personal-data surface. The personal-data map (Appendix C) and the C1-C5 compliance cards are what speak to that. semgrep could not parse 3 file(s) — `streams/quickstart/java/src/main/resources/archetype-resources/src/main/java/LineSplit.java`, `streams/quickstart/java/src/main/resources/archetype-resources/src/main/java/Pipe.java`, `streams/quickstart/java/src/main/resources/archetype-resources/src/main/java/WordCount.java` — so the PII/GDPR sweep did not cover the unparsed regions of them; rows reported elsewhere in those files are real.0—
D40 · Network Egress Confinementruntime-hardening—runtime-hardening: not applicable — No Kubernetes/orchestration workloads found in the repository manifests; network egress policy is a cluster-native control that may live at the platform/firewall layer, so there is nothing to assess here.0—
D41 · Kernel & Syscall Confinementruntime-hardening—runtime-hardening: not applicable — No Kubernetes/orchestration workloads found in the repository manifests; seccomp/AppArmor/SELinux confinement is a workload-level control, so there is nothing to assess here.0—
D42 · Runtime Threat Enforcementruntime-hardening—runtime-hardening: not applicable — No Kubernetes/orchestration workloads found in the repository manifests; runtime threat-detection and admission-control policy are cluster-level controls, so there is nothing to assess here.0—
D43 · Malicious Dependenciesosv-scanner—osv-scanner --format json --recursive --experimental-disable-plugins transitivedependency/requirements --experimental-disable-plugins dotnet/csproj --experimental-disable-plugins dotnet/nugetcpm .0artifacts/raw/osv-scanner.json

Run 01a16701-55a9-7469-9071-ef4b6e87ba1f · every finding is also locatable in findings.md, and the complete scoring record (with exit codes + durations) in sidecar.json.

Downloadable artifacts

Machine-readable and reproducible from this commit + frozen rubric — drop them straight into a contract appendix, a CRA dossier, or a downstream SCA / VEX tool.

⬇ Findings, MITRE CWE-tagged .sarif⬇ Health changelog .md