objectionary / objectionary/lints
`sprintf-without-formatters` rule ineffective due to removed `Φ.txt.sprintf` object, failing to match `base='.printf'`
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 14
- Forks
- 39
- Avg merge
- 22h 54m
- Merged PRs (30d)
- 90
Description
sprintf-without-formatters selects the same object wrong-sprintf-arguments does, and that object no longer exists in EO, so this rule cannot fire either.
src/main/resources/org/eolang/lints/misc/sprintf-without-formatters.xsl:20:
<xsl:for-each select="//o[@base='Φ.txt.sprintf']">
There is no txt package in objectionary/eo any more and no sprintf object anywhere in the runtime. Formatting is eo-runtime/src/main/eo/string/printf.eo, called as a method on the format string, so what a current XMIR carries is base=".printf":
$ grep -rl "txt.sprintf" eo-runtime/target/eo/1-parse/
(nothing)
$ grep -rlo "\.printf" eo-runtime/target/eo/1-parse/*.xmir | wc -l
13
The check it performs is still worth having. It reports a format template with none of the supported conversions, on the grounds that formatting without a formatter is pointless — a real mistake that is easy to make and invisible at runtime, since the template simply comes back unchanged.
Adapting it means matching the dispatch rather than the base:
<xsl:for-each select="//o[@base='.printf']">
and reading the template from the receiver, which for a dispatch is emitted as a preceding sibling rather than as a child, so the $text extraction on lines 21-38 has to follow it there.
Two things are worth revisiting in the same change. The message on line 60 names "%s", "%d", "%f", "%x", "%b" as the supported set, and current printf handles more than that — flags, widths and precisions such as %5d, %08.2f, %.0f all work — so a template using only those would now be reported as having no formatters at all. And the message text names "Φ.txt.sprintf" three times, which will read oddly once the rule matches something else.
The sibling rule wrong-sprintf-arguments has the same dead selector and is reported separately, since the two need different adaptations: that one is about arity and tuple shape, this one about the template's content.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with src/main/resources/org/eolang/lints/misc/sprintf-without-formatters.xsl, then inspect eo-runtime/src/main/eo/string/printf.eo and current XMIR examples. Update the selector and receiver-based template extraction, revisit supported format syntax and stale message text, and keep the change separate from wrong-sprintf-arguments. Done means the rule reports format strings without supported conversions on current .printf dispatches.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- xml
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 72/100