FileName/FileFormat domain primitive; fix new-code Sonar findings - #364
Merged
Conversation
…ar findings
FileFormat (CSV/PARQUET/VORTEX) + FileName wrap the extension parsing
and swapping import/export both need, replacing a scattered set of
endsWith(".xxx") checks and hand-counted substring(0, name.length() - N)
suffix strips duplicated across ImportCommand and ExportCommand.
Also fixes the 17 SonarCloud findings in the new-code period
(sinceLeakPeriod=true), triaged individually:
- ImportCommand: the .parquet literal duplication (S1192) is resolved
as a side effect of the FileName refactor above. Two ternaries moved
inside their single Path.of(...) call (S9358). The CSV-to-Parquet
temp file now gets owner-only POSIX permissions (rw-------) via
FileAttribute, since the system temp directory is commonly
world-writable (S5443, CRITICAL) -- falls back to the plain overload
on Windows, where FileAttribute-based permissions aren't supported.
- CsvImporter: split the 17-cognitive-complexity private importCsv
helper into readFirstChunk/writeFirstChunk/streamRemainingChunks,
each well under the 15 threshold (S3776).
- ParquetExporter: switched `case DType.Xxx ignored ->` to the JDK
unnamed-variable `_`, matching the convention CsvImporter's own
switches already use elsewhere in this codebase -- `_` is exempt from
the unused-variable rule by design, `ignored` isn't (S1481 x7).
- ParquetExporterTest: extracted an inline `new DType.Primitive(...)`
out of an assertThatThrownBy lambda into a `// Given` variable, so
the lambda contains exactly one invocation that can throw (S5778);
three isEqualTo(0) assertions switched to isZero() (S5838 x3).
- ZstdEncodingEncoderTest: same S5778 shape (EncodeTestHelper.testCtx()
invocation extracted out of the lambda), from a slightly earlier
commit still inside the leak period.
Review caught two real regressions in the FileName refactor itself,
both fixed:
- FileName#withFormat stripped ANY known extension before appending
the target's, including one already equal to the target -- so
deriving a default output name from an input already in that format
(e.g. `import data.vortex` with no output arg) returned the input's
own name back. import/export would then open that path for writing
while still reading it as the source, truncating it. Fixed by only
stripping a *different* known extension; added a regression test
(withFormat_alreadyTargetFormat_appendsRatherThanReturningSameName).
- CsvImporter's FirstChunk record had its rows list mutated (.clear())
after construction, fighting the immutable-value-object expectation
records set up. Restructured so importCsv stops referencing the
FirstChunk (and thus its buffered rows) after handing it to
writeFirstChunk, instead of mutating it -- the streaming loop that
follows still doesn't retain the buffered rows, without needing a
mutation to make that true. Also dropped the redundant chunkSize
parameter threaded through two helpers when it was always just
options.chunkSize().
Also converted two FileNameTest cases to // Given / // When / // Then
(they'd collapsed to a single comment with stacked assertions).
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LjU7zWghUiJauRxK58nyUs
dfa1
force-pushed
the
refactor/file-name-primitive-and-sonar
branch
from
September 3, 2026 16:56
6340f35 to
fa7fa9d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
FileFormat/FileName(package-private,climodule): a small domain primitive centralizing extension parsing/swapping (.csv/.parquet/.vortex), replacing scatteredendsWith(".xxx")checks and hand-countedsubstring(0, name.length() - N)suffix strips acrossImportCommand/ExportCommand. Behavior-preserving — no functional change.sinceLeakPeriod=true), triaged individually — see commit message for the per-finding reasoning. Highlights:ImportCommand:.parquetliteral duplication resolved as a side effect of the refactor; a temp-file-permissions fix (S5443, CRITICAL) restricts the CSV→Parquet chain's scratch file to owner-only on POSIX, with a Windows-safe fallback.CsvImporter: split an over-15-cognitive-complexity method into three smaller ones (S3776).ParquetExporter: switchedignoredpattern-variable bindings to the JDK unnamed_, matching this codebase's own established convention elsewhere.Test plan
./mvnw verify -pl cli -am/-pl csv -am/-pl parquet -am/-pl writer -am— all green, including a newFileNameTest./mvnw verify— full reactor build, all modules green./mvnw verify -pl integration -am -Dit.test=DocsConsistencyTest— living-docs claims still resolve🤖 Generated with Claude Code
https://claude.ai/code/session_01LjU7zWghUiJauRxK58nyUs