Repository navigation
Issue #21501: Fix file extensions for paths with dotted directories - #21518
Conversation
|
Hi @romani, I opened this PR following your request in #21501 (comment). The Check PR Description workflow is failing because #21501 does not yet have the approved label: https://github.com/checkstyle/checkstyle/actions/runs/34238961004. Could you please review the implementation and, if you approve the issue, add the label and rerun the check? Thanks. |
arturict
left a comment
There was a problem hiding this comment.
checked this on linux: both new tests fail on master, config.d/filename gives d/filename and ../filename gives /filename, and they pass with the change. it also lines up with what getFileNameWithoutExtension has been doing all along.
| */ | ||
| public static String getFileExtension(String fileNameWithExtension) { | ||
| final String fileName = Path.of(fileNameWithExtension).toString(); | ||
| final String fileName = Path.of(fileNameWithExtension).toFile().getName(); |
There was a problem hiding this comment.
this code might be 20 years old.
and I think modern jdk already should have method for get file extension.
Issue: #21501
Submitted following romani's request to review the implementation in a PR.
CommonUtil.getFileExtension("config.d/filename")currently returnsd/filename, even though the final filename has no extension. Extract the final filename before searching for its last dot, using the same approach asgetFileNameWithoutExtension.Add regression tests for dotted parent directories and current/parent-relative paths, including preservation of a real
.propertiesextension. This addresses the public utility; the existingTranslationCheckcaller already supplies a bare filename.Validation:
CommonUtilTestandTranslationCheckTestpassed.d89b173, Java 21mvn -B -ntp clean verifypassed: 6,790 unit/example tests (2 skipped), 1,349 integration tests, and all configured quality checks; no failures or errors.Codex assisted with investigation, implementation, and validation.