Skip to content

python script clang tidy for reporting#9

Open
SajaKhdour wants to merge 6 commits intoelbosch:masterfrom
SajaKhdour:feature/#62-python-script-clang-tidy
Open

python script clang tidy for reporting#9
SajaKhdour wants to merge 6 commits intoelbosch:masterfrom
SajaKhdour:feature/#62-python-script-clang-tidy

Conversation

@SajaKhdour
Copy link
Copy Markdown

@SajaKhdour SajaKhdour commented Mar 18, 2020

  • New python script to report functions which exceeds recommended size/complexity thresholds [readability-function-size].
  • Thresholds: (LineThresholods, BranchThresholds, NestingThresholds)
  • to apply this script as a command you need to call the paths of (clang-tidy-report.py) script with (clang-report.txt) that generated before to report it with (.clang-tidy) config. like this:
    python <path-of-clang-tidy-script> <path-of-clang-report.txt> <path-of-.clang-tidy>
  • then will show you the final report of these functions

SajaKhdour and others added 2 commits March 2, 2020 11:21
Signed-off-by: SajaKhdour <fixed-term.Saja.Khdour@de.bosch.com>

############### read specific string from file
def readClangConfig():
stringLineToMatch = "LineThreshold"
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@HansUweRempler
Copy link
Copy Markdown

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants