cmake_format
cmake_format copied to clipboard
[cmake-lint] Crash when encountering an unquoted comment with spaces
Simple cmake file that can be used to reproduce this:
cmake_minimum_required(VERSION 3.20)
project(sample)
add_custom_target(
something
# Can be anything
COMMAND pip --version
COMMENT foo bar
)
Result:
cmake-lint CMakeLists.txt
ERROR An internal error occured. Please consider filing a bug report at github.com/cheshirekow/cmakelang/issues
Traceback (most recent call last):
File "/usr/local/lib/python3.8/dist-packages/cmakelang/lint/__main__.py", line 185, in main
return inner_main()
File "/usr/local/lib/python3.8/dist-packages/cmakelang/lint/__main__.py", line 168, in inner_main
process_file(cfg, local_ctx, intext)
File "/usr/local/lib/python3.8/dist-packages/cmakelang/lint/__main__.py", line 45, in process_file
parse_tree = parse.parse(tokens, ctx)
File "/usr/local/lib/python3.8/dist-packages/cmakelang/parse/__init__.py", line 68, in parse
return BodyNode.consume(ctx, tokens)
File "/usr/local/lib/python3.8/dist-packages/cmakelang/parse/body_nodes.py", line 67, in consume
subtree = StatementNode.consume(ctx, tokens)
File "/usr/local/lib/python3.8/dist-packages/cmakelang/parse/statement_node.py", line 89, in consume
node.argtree = subtree = parse_fun(ctx, tokens, breakstack)
File "/usr/local/lib/python3.8/dist-packages/cmakelang/parse/funs/add_xxx.py", line 252, in parse_add_custom_target
ctx.lint_ctx.record_lint("E1122", location=tokens[0].get_location())
File "/usr/local/lib/python3.8/dist-packages/cmakelang/lint/lint_util.py", line 90, in record_lint
msg = spec.msgfmt.format(*args, **kwargs)
IndexError: Replacement index 0 out of range for positional args tuple
Ideally, cmake-lint
should probably issue a warning in this case.
It is worth noting that cmake-format
with the default configuration will reformat the file to:
cmake_minimum_required(VERSION 3.20)
project(sample)
add_custom_target(
something
# Can be anything
COMMAND pip --version
COMMENT foo
bar)
I'm not sure if this is the right behavior, maybe some quotes should be added?
I'm using cmake-lint
0.6.13, Python 3.8.10 on Ubuntu 20.04.3.