python script clang tidy for reporting#9
Conversation
Signed-off-by: SajaKhdour <fixed-term.Saja.Khdour@de.bosch.com>
|
|
||
| ############### read specific string from file | ||
| def readClangConfig(): | ||
| stringLineToMatch = "LineThreshold" |
There was a problem hiding this comment.
We just talked about this detail via Skype. My notes: please do not hard-code the options here. Instead, cycle over all the check options.
Here's some example I wrote (my last meeting was not so fruitful for me ;-)) for your reference - maybe it helps to make my point clear:
rempler@RT-Z0ITK:~/r/eclipse$ cat kiso/core/.clang-tidy
---
Checks: '-*, readability-*, clang-analyzer-*, misc-*'
CheckOptions:
- key: readability-function-size.LineThreshold
value: '120'
- key: readability-function-size.BranchThreshold
value: '15'
- key: readability-function-size.NestingThreshold
value: '7'
- key: readability-function-size.ParameterThreshold
value: '8'
- key: readability-function-size.StatementThreshold
value: '100'
- key: readability-function-size.VariableThreshold
value: '8'
- key: readability-inconsistent-declaration-parameter-name.Strict
value: '0'
rempler@RT-Z0ITK:~/r/eclipse$ python3 clang_options_extract.py
--> key: readability-function-size.LineThreshold
--> val: '120'
--> key: readability-function-size.BranchThreshold
--> val: '15'
--> key: readability-function-size.NestingThreshold
--> val: '7'
--> key: readability-function-size.ParameterThreshold
--> val: '8'
--> key: readability-function-size.StatementThreshold
--> val: '100'
--> key: readability-function-size.VariableThreshold
--> val: '8'
--> key: readability-inconsistent-declaration-parameter-name.Strict
--> val: '0'
rempler@RT-Z0ITK:~/r/eclipse$ cat clang_options_extract.py
filne = "kiso/core/.clang-tidy"
with open(filne, 'r+') as f:
lines = f.readlines()
for i in range(0, len(lines)):
line = lines[i]
# CheckOptions:
if line[:7] == " - key:":
valueline = lines[i + 1] # you may want to check that i < len(lines)
key = line.split(":")[1]
value = valueline.split(":")[-1:][0]
print('--> key: ', key.strip())
print('--> val: ', value.strip())
rempler@RT-Z0ITK:~/r/eclipse$
@elbosch : I don't want to interfere here - I had a quick chat with Saja about her code while we talked about our Kiso daily. I just wanted to give her a hint in code from what I thought about.
|
@elbosch and @SajaKhdour : after I thought about it a little - maybe I think too complicated? What if we just output the clang-tidy file itself and that's it. No special formatting but the pure text file in our Jenkins dashboard... Just an idea. This could increase our effectivity here. |
Signed-off-by: SajaKhdour <fixed-term.Saja.Khdour@de.bosch.com>
python <path-of-clang-tidy-script> <path-of-clang-report.txt> <path-of-.clang-tidy>