clang-format version detection is slightly broken (and definitely so for trunk builds)
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 35/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Stale
- Tech stack
- vim
- Domain
- tooling
Research direction
Start in autoload/codefmt/clangformat.vim at the version parsing around lines 32-38, and compare its behavior with the numeric and trunk-style clang-format --version outputs shown in the issue. Verify that literal dotted versions are parsed correctly and that non-standard versions receive the intended feature handling.
Written by the indexing model from the issue text.
Description
At https://github.com/google/vim-codefmt/blob/293c208/autoload/codefmt/clangformat.vim#L32-34, we have this code:
let l:version_string = matchstr(l:version_output, '\v\d+(.\d+)+')
" If no version string was matched, cached version will be an empty list.
let s:clang_format_version = map(split(l:version_string, '\.'), 'v:val + 0')
which is trying to find a version number (possibly "1.2.3" or "1.2" or just "1") in the output of clang-format --version:
$ clang-format --version
clang-format version 7.0.1-8+deb10u2 (tags/RELEASE_701/final)
However, for trunk builds, the output looks something like:
clang-format --version
clang-format version mainline (4321b9f2e9842982d13234920a643e3a4657c60b)
(where "mainline" can be any string the configurer chooses).
However:
matchstr(l:version_output, '\v\d+(.\d+)+')has.matching any character. That probably was intended to be a literal (\.) instead, otherwise the pattern could just have been\v\d.+.- As a result, we consider any trunk build to be a version "number" containing the numeric start of the hex string (i.e. version 4321 in the above example).
- This means that we usually consider trunk builds to have all features (good), but only if their version string starts with enough non-zero/non-hex digits (bad).
We probably should do something like:
- Change the regexp to use
\.instead to match a literal. - Consider a non-standard version to always have the feature rather than not have it (at https://github.com/google/vim-codefmt/blob/293c208/autoload/codefmt/clangformat.vim#L38.
- Dominant language
- Vim Script
- Stars
- 1.1k
- Forks
- 102
- PR merge metrics
- No merged PRs in 30d
Contributor guide
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.
More from google/vim-codefmt
-
Write a codefmt FAQ Openenhancement
Difficulty 1/5 1-3 hours Newbie friendliness 68/100
google/vim-codefmt#53 ·
-
Add meson format Opennew formatter
Difficulty 3/5 1-2 days Newbie friendliness 45/100
google/vim-codefmt#243 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 52/100
google/vim-codefmt#240 · 1 comment ·
-
Add `:CodefmtInfo` command to report diagnostics to help users check config / diagnose problems Openenhancement
Difficulty 5/5 Over a week Newbie friendliness 35/100
google/vim-codefmt#234 · 2 comments ·
-
Difficulty 1/5 1-3 hours Newbie friendliness 45/100
google/vim-codefmt#222 · 3 comments ·
All issues in google/vim-codefmt
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
-
Difficulty 1/5 Under an hour Newbie friendliness 92/100
-
Difficulty 1/5 1-3 hours Newbie friendliness 86/100
DavidAnson/markdownlint-cli2#940 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 72/100
EclipseFdn/open-vsx.org#13385 · 1 comment ·
-
bug ci good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 88/100