cheshirekow / cmake_format

Source code formatter for cmake listfiles.
GNU General Public License v3.0
954 stars 105 forks source link

lint not working when executed with config file #209

Closed souchtal closed 4 years ago

souchtal commented 4 years ago

Hello,

I am using cmake-lint to check for formatting issues in my cmake files. I am interested in format-related warnings/messages only, so i m using --diabled-codes but that does not accept more than one code. I m running as: cmake-lint --disabled-codes E1120 file.cmake but it won't execute by the way unless i put a = sign between the flag and the value (the help guide shows: --disabled-codes [DISABLED_CODES [DISABLED_CODES ...]]). Furthermore, what is the correct way to inject more than one code, i m trying everything from coma to space to quotation marks around each code. Also, I tried to use a Python configuration file where i write down those code in: disabled_codes = ['E1120'], but output shows that no file has been parsed, it s like passing the configuration file using -c does not yield an actual parsing of the file in question. I generated the file using cmake-format --dump-config python and i m changing the value of the disabled-codes. In general, regardless of this specific flag, running cmake-lint with the clean generated conf file does not allow any scanning. I followed the guidelines here: https://readthedocs.org/projects/cmake-format/downloads/pdf/latest/ and i also ran into some issues on your repo where users have been advised to name their conf file: '.cmake_format.py' or '.cmake-format.py', which i did.

the output is:

Summary

files scanned: 0 found lint:

By the way, this does not work for type C, W, R and E codes. I am using cmake-format version 0.6.9 on Linux 4.12.14-lp151.28.40-default x86_64. Anything wrong i m doing?

Thanks !

cheshirekow commented 4 years ago

i m using --diabled-codes but that does not accept more than one code

It does but...

but it won't execute by the way unless i put a = sign between the flag and the value

That is because --disabled-codes accepts multiple arguments and if this is the last option on the command line before the list of files, then the command line parser doesn't know where the list of disabled-codes ends and where the list of files begins. You can provide this hint by separating the two with a bare double-dash (--). So try: cmake-lint --disabled-codes E1120 E1121 -- <filename>.

it s like passing the configuration file using -c does not yield an actual parsing of the file in question

This is the same issue as above. --config-files takes multiple arguments so if this is the last option before the file list you need to separate the two with a bare double-dash --

i also ran into some issues on your repo where users have been advised to name their conf file:

The naming of the config file only matters if you want cmake-lint to pick up the config file automatically. If you provide it on the command line the name doesn't matter.

Let me know if this info solves your problem!

souchtal commented 4 years ago

Perfect ! Both scenarios work now. Thank you very much.