#1450: read a version only when the whole string is one - #1469
opusstudiohq-max wants to merge 4 commits into
Conversation
`Version.CORE` was anchored at the start only, and `parsed` used `find`, so it read the first three numbers it met and ignored whatever followed. `1.2.3garbage`, `1.2.3.4` and `999.0.0oops` all came back as valid versions. That reaches a user through `LtSyntaxVersion`, which documents that a non-SemVer `+syntax` value is ignored. A malformed value was instead compared as if it were a version, so `+syntax 999.0.0oops` could raise a hard error demanding a newer parser. The pattern now describes the whole spelling and `matches` requires all of it: the numeric core, then an optional SemVer pre-release or build suffix. A real pre-release such as `1.2.3-alpha.1` is still read by its numeric core, which is what the comparison wants. The digits are still `\d+` rather than SemVer's stricter no-leading-zero form, so nothing that parses today stops parsing except the malformed spellings above. A component above `Integer.MAX_VALUE` still matches the pattern and is still turned into an empty result by the existing `NumberFormatException` guard; the last test pins that, so this change cannot quietly undo objectionary#1442.
Qulice forbids concatenating string literals (StringLiteralsConcatenationCheck), and the pattern was split across three of them. It is one literal now, and short enough to stay within the line limit. The shape it accepts is unchanged for everything the tests cover, and slightly tighter otherwise: a suffix must have at least one character after its `-` or `+`, so `1.2.3-` is no longer read as a version, and a pre-release followed by build metadata such as `1.2.3-rc.1+exp.sha.1` is now accepted where the previous spelling stopped at the `+`.
The previous spelling of the pattern stopped at the plus, so this shape was not accepted and nothing said so. It is accepted now, and this pins it.
|
CI is green here and the change reads correctly for #1450, but I am not confident enough to merge it unreviewed. Switching Assigning to @yegor256 for a look. Generated by Claude Code |
…not compared Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
f7202bf to
149ee16
Compare
|
Checked every call site. 1. The What the PR changes is which strings count as malformed. A numeric core with junk glued on — 2. The parser's own So the audit result is: one site reports-or-ignores exactly as it did, with the ignored set widened and now tested at its edge; the other skips as it did before. If you would rather the lint report a |
|
I went through the call sites. An empty On the specific worry that a malformed |
Closes #1450.
Version.COREwas anchored at the start only, andparsedusedfind, so it took the first three numbers it met and ignored the rest of the string:That reaches a user through
LtSyntaxVersion, the only caller, which documents that a non-SemVer+syntaxvalue is ignored. A malformed value was instead compared as if it were a version, so+syntax 999.0.0oopscould raise a hard error demanding a newer parser — a false positive produced by the parser being lenient, not by anything in the object.The pattern now describes the whole spelling and
matchesrequires all of it: the numeric core, then an optional SemVer pre-release or build suffix.1.2.3-alpha.1is still read by its numeric core, which is whatnewerThancompares.Deliberately not tightened further. The components stay
\d+rather than SemVer's stricter no-leading-zero form, so nothing that parses today stops parsing except the three malformed shapes above. Making them strict would be a second, unrelated behaviour change.It does not undo #1442. A component above
Integer.MAX_VALUEstill matches the pattern and is still turned into an empty result by the existingNumberFormatExceptionguard.returnsEmptyWhenComponentOverflowspins that, so this change cannot quietly regress it.Verified on my own fork before opening this, rather than here:
mvngreen on ubuntu, macos and windows, and the log showsorg.eolang.lints.VersionTest — Tests run: 7, Failures: 0, Errors: 0, Skipped: 0on each, so the tests genuinely execute. Full suite 714 tests, 0 failures.By the way, #1442 itself looks already fixed on master by 7c5a762; the issue is just still open.
🤖 Generated with Claude Code