From 6e02694dba1b13a4d21161779961dd0fc6c4c21a Mon Sep 17 00:00:00 2001 From: SajaKhdour Date: Wed, 18 Mar 2020 16:45:28 +0100 Subject: [PATCH 1/5] added clang tide python script file for reporting Signed-off-by: SajaKhdour --- clang-tidy-report-script.py | 145 ++++++++++++++++++++++++++++++++++++ 1 file changed, 145 insertions(+) create mode 100644 clang-tidy-report-script.py diff --git a/clang-tidy-report-script.py b/clang-tidy-report-script.py new file mode 100644 index 00000000..0e72ecaa --- /dev/null +++ b/clang-tidy-report-script.py @@ -0,0 +1,145 @@ +import re +from io import StringIO +import sys + + + +################# write the result in the final file for the final report +def writeText(function): + textfile = open("Final-Clang-Tidy-Report.txt","w") + textfile.write(function) + textfile.write('\n') + textfile.close() + +############### read specific string from file +def readClangConfig(): + stringLineToMatch = "LineThreshold" + + stringBranchToMatch = "BranchThreshold" + + stringNestingToMatch = "NestingThreshold" + + stringValueToMatch = " value:" + + global resultL + global resultB + global resultN + #### here we gave the function the third position of sys arguments when you should put the file path of .clang-tidy cofig. + with open(sys.argv[2],"r") as f: + + while True: + line1 = f.readline() + line2 = f.readline() + + if stringLineToMatch in line1 and stringValueToMatch in line2: + elementsLineThres= line2.split(" value: '", 1) + matchedEndLine = "'" + if matchedEndLine in line2: + new2 = elementsLineThres[1].split(matchedEndLine,1) + resultL=new2[0].strip() + # print(resultL) + + if stringBranchToMatch in line1 and stringValueToMatch in line2: + elementsBranchThres= line2.split(" value: '", 1) + matchedEndBranch = "'" + if matchedEndBranch in line2: + new2 = elementsBranchThres[1].split(matchedEndBranch,1) + resultB=new2[0].strip() + #print(resultB) + + if stringNestingToMatch in line1 and stringValueToMatch in line2: + elementsNestingThres= line2.split(" value: '", 1) + matchedEndNesting = "'" + if matchedEndNesting in line2: + new2 = elementsNestingThres[1].split(matchedEndNesting,1) + resultN=new2[0].strip() + #print(resultN) + if not line2: break + + +################## read from file the line then find the specific string of warning functions to write all the result line to another file +def readFileAndFindWarningFunctions(): + + ##get the name of the warning functions by this string + WarningFunctions = "warning: function" + matchedLineF = '' + ##get the notes of the warning functions by this string + NoteOfTheFunctionsThresholds ="note:" + + result = [] + result2 = [] + result3 = [] + result4 = [] + + listResult = [] + + matchedline='' + matchednesting='' + matchedbranch='' + + ffinal ='' + flag2 =False + i = 1 + re = '' + + ##### this to call the method which get the specific string from .clang-tidy config + readClangConfig() + ##### then apply it here global variables in the below string for the final report + listResult.append('\nClang Tidy Reporting for Kiso functions.. \n' + +'The functions exceed recommended size/complexity thresholds [readability-function-size]:\n' + + 'Thresholds: LineThresholods > '+resultL+' | BranchThresholds > '+resultB+' | NestingThresholds > '+resultN+'\n' + + '--------------------------------------------------------------------------------') + + #### here when you run your python script file path and with the .txt file path + #### this sys.argv[1] give you the .txt file path from the command you will run with the python script file path + with open(sys.argv[1],"r") as f: + for line in f: + if WarningFunctions in line: + matchedLineF = line + elementsNameOfFunctions= matchedLineF.split('warning: ', 1) + + if len(WarningFunctions)<2: + print("there are no warning functions") + else: + new = elementsNameOfFunctions[1].split('exceeds',1) + result=new[0].strip() + re = 'Function ' + str(i) + listResult.append('\n') + listResult.append(re) + listResult.append('------------') + listResult.append(result+':') + flag2 =True + i = i+1 + elif NoteOfTheFunctionsThresholds in line: + matchedLineF = line + elementsNameOfFunctions = matchedLineF.split('note:',1) + if len(NoteOfTheFunctionsThresholds)<2: + print("there are no notes for warning functions") + else: + matchedline ='including whitespace and comments (threshold '+resultL+')' + matchednesting ='starts here (threshold '+resultN+')' + matchedbranch=' (threshold '+resultB+')' + if matchedline in matchedLineF: + new2 = elementsNameOfFunctions[1].split(matchedline,1) + result2=new2[0].strip() + listResult.append(result2) + + if matchedbranch in matchedLineF: + new4 = elementsNameOfFunctions[1].split(matchedbranch,1) + result4=new4[0].strip() + listResult.append(result4) + + if matchednesting in matchedLineF and flag2== True: + new3 = elementsNameOfFunctions[1].split(matchednesting,1) + result3=new3[0].strip() + listResult.append(result3) + flag2= False + + + ffinal = '\n'.join(listResult) + writeText(ffinal) + print(ffinal+'\n') + +#### here it will call the function will do the final report +readFileAndFindWarningFunctions() + \ No newline at end of file From cf9d7bcd2c993c1ea21d1a31f6395f4497c47e50 Mon Sep 17 00:00:00 2001 From: SajaKhdour Date: Wed, 3 Jun 2020 18:45:38 +0200 Subject: [PATCH 2/5] added update on jenkins file and the clang-tidy script Signed-off-by: SajaKhdour --- Final-Clang-Tidy-Report.txt | 542 +++++++++++++++++++++++++++++++++ Jenkinsfile | 4 +- ci/clang-tidy-report-script.py | 149 +++++++++ core/.clang-tidy | 6 +- 4 files changed, 697 insertions(+), 4 deletions(-) create mode 100644 Final-Clang-Tidy-Report.txt create mode 100644 ci/clang-tidy-report-script.py diff --git a/Final-Clang-Tidy-Report.txt b/Final-Clang-Tidy-Report.txt new file mode 100644 index 00000000..1e22b5f1 --- /dev/null +++ b/Final-Clang-Tidy-Report.txt @@ -0,0 +1,542 @@ +-------------------------------------------------------------------------------- +Clang Tidy Reporting for Kiso functions.. +The functions exceed recommended size/complexity thresholds [readability-function-size]: +Thresholds: LineThresholods > 20 | BranchThresholds > 5 | NestingThresholds > 3 +-------------------------------------------------------------------------------- + + +Function 1 +------------ +function 'NoOs_Signal_Wait': +30 lines + + +Function 2 +------------ +function 'MCU_CRC8': +44 lines + + +Function 3 +------------ +function 'MCU_CRC16': +44 lines + + +Function 4 +------------ +function 'MCU_CRC32': +75 lines +8 branches + + +Function 5 +------------ +function 'MCU_I2C_Initialize': +90 lines +8 branches +nesting level 4 + + +Function 6 +------------ +function 'MCU_I2C_Send': +38 lines +nesting level 4 + + +Function 7 +------------ +function 'MCU_I2C_Receive': +39 lines +nesting level 4 + + +Function 8 +------------ +function 'MCU_I2C_WriteRegister': +38 lines +nesting level 4 + + +Function 9 +------------ +function 'MCU_I2C_ReadRegister': +39 lines +nesting level 4 + + +Function 10 +------------ +function 'I2C_SendPollMode': +114 lines +14 branches +nesting level 4 + + +Function 11 +------------ +function 'I2C_ReceivePollMode': +34 lines +6 branches + + +Function 12 +------------ +function 'I2C_WriteRegisterIntMode': +38 lines +7 branches + + +Function 13 +------------ +function 'I2C_ReadRegisterIntMode': +33 lines + + +Function 14 +------------ +function 'I2C_ReadRegisterDmaMode': +32 lines + + +Function 15 +------------ +function 'HAL_I2C_MasterTxCpltCallback': +22 lines +nesting level 4 + + +Function 16 +------------ +function 'MCU_RNG_Generate': +40 lines +nesting level 4 + + +Function 17 +------------ +function 'MCU_SPI_Initialize': +85 lines +9 branches +nesting level 4 + + +Function 18 +------------ +function 'MCU_SPI_Send': +45 lines +7 branches +nesting level 4 + + +Function 19 +------------ +function 'MCU_SPI_Receive': +51 lines +8 branches +nesting level 4 + + +Function 20 +------------ +function 'MCU_SPI_Transfer': +46 lines +7 branches +nesting level 4 + + +Function 21 +------------ +function 'MCU_SPI_GetDataCount': +22 lines + + +Function 22 +------------ +function 'HAL_SPI_ErrorCallback': +46 lines + + +Function 23 +------------ +function 'MCU_UART_Initialize': +107 lines +11 branches +nesting level 4 + + +Function 24 +------------ +function 'MCU_UART_Send': +43 lines +7 branches +nesting level 4 + + +Function 25 +------------ +function 'MCU_UART_Receive': +36 lines +nesting level 4 + + +Function 26 +------------ +function 'UART_SendPolling': +25 lines + + +Function 27 +------------ +function 'UART_SendInt': +21 lines + + +Function 28 +------------ +function 'UART_SendDMA': +22 lines + + +Function 29 +------------ +function 'CRC_8': +49 lines +nesting level 4 + + +Function 30 +------------ +function 'CRC_16': +47 lines +nesting level 4 + + +Function 31 +------------ +function 'CRC_32': +49 lines +nesting level 4 + + +Function 32 +------------ +function 'CRC_32_Reverse': +51 lines +nesting level 4 + + +Function 33 +------------ +function 'CmdLineDbg_RegisterCmd': +25 lines + + +Function 34 +------------ +function 'CmdLineDbg_RegisterCmdArray': +27 lines + + +Function 35 +------------ +function 'CmdLineDbg_Parse': +36 lines + + +Function 36 +------------ +function 'ErrorLogger_Init': +33 lines +nesting level 4 + + +Function 37 +------------ +function 'ErrorLogger_LogError': +28 lines + + +Function 38 +------------ +function 'ErrorLogger_GetLastErrorLog': +22 lines +nesting level 4 + + +Function 39 +------------ +function 'ErrorLogger_HasError': +nesting level 4 + + +Function 40 +------------ +function 'Escape_SpecialCharacters': +33 lines +6 branches + + +Function 41 +------------ +function 'UnEscape_SpecialCharacters': +21 lines + + +Function 42 +------------ +function 'XProtocol_EncodeFrame': +91 lines +10 branches + + +Function 43 +------------ +function 'XProtocol_GetPayloadLength': +28 lines + + +Function 44 +------------ +function 'XProtocol_DecodeFrame': +92 lines +12 branches +nesting level 4 + + +Function 45 +------------ +function 'XProtocol_IsCompleteFrame': +24 lines + + +Function 46 +------------ +function 'CmdProcessor_Initialize': +38 lines +nesting level 4 + + +Function 47 +------------ +function 'CmdProcessor_Enqueue': +32 lines + + +Function 48 +------------ +function 'CmdProcessor_EnqueueFromIsr': +33 lines +nesting level 4 + + +Function 49 +------------ +function 'Dequeue': +29 lines +nesting level 4 + + +Function 50 +------------ +function 'EventHub_Observe': +37 lines +6 branches + + +Function 51 +------------ +function 'EventHub_ObserveAll': +36 lines +6 branches + + +Function 52 +------------ +function 'EventHub_Notify': +34 lines +7 branches +nesting level 4 + + +Function 53 +------------ +function 'GuardedTask_Deinitialize': +27 lines + + +Function 54 +------------ +function 'GuardedTask_Initialize': +36 lines +6 branches +nesting level 4 + + +Function 55 +------------ +function 'GuardedTask_Signal': +23 lines + + +Function 56 +------------ +function 'GuardedTask_SignalFromIsr': +26 lines +nesting level 4 + + +Function 57 +------------ +function 'I2CTransceiver_LoopCallback': +46 lines +10 branches +nesting level 4 + + +Function 58 +------------ +function 'I2CTransceiver_Init': +40 lines +nesting level 4 + + +Function 59 +------------ +function 'I2CTransceiver_Read': +47 lines +9 branches +nesting level 4 + + +Function 60 +------------ +function 'I2CTransceiver_Write': +46 lines +9 branches +nesting level 4 + + +Function 61 +------------ +function 'RunFilter': +65 lines +9 branches +nesting level 4 + + +Function 62 +------------ +function 'PipeAndFilter_CreateFilter': +32 lines + + +Function 63 +------------ +function 'TaskMonitor_Register': +25 lines +nesting level 4 + + +Function 64 +------------ +function 'TaskMonitor_Check': +47 lines +7 branches +nesting level 4 + + +Function 65 +------------ +function 'UARTTransceiver_Initialize': +32 lines +nesting level 4 + + +Function 66 +------------ +function 'UARTTransceiver_Start': +42 lines +nesting level 4 + + +Function 67 +------------ +function 'UARTTransceiver_StartInAsyncMode': +44 lines +nesting level 4 + + +Function 68 +------------ +function 'UARTTransceiver_Stop': +33 lines +nesting level 4 + + +Function 69 +------------ +function 'UARTTransceiver_Suspend': +32 lines +nesting level 4 + + +Function 70 +------------ +function 'UARTTransceiver_Resume': +32 lines +nesting level 4 + + +Function 71 +------------ +function 'UARTTransceiver_ReadData': +35 lines +nesting level 4 + + +Function 72 +------------ +function 'UARTTransceiver_WriteData': +46 lines +6 branches +nesting level 4 + + +Function 73 +------------ +function 'UARTTransceiver_LoopCallback': +60 lines +15 branches +nesting level 4 + + +Function 74 +------------ +function 'LogFilter_Add': +21 lines + + +Function 75 +------------ +function 'LogFilter_Apply': +nesting level 4 + + +Function 76 +------------ +function 'Logging_Init': +25 lines + + +Function 77 +------------ +function 'SyncRecorder_Write': +33 lines + + +Function 78 +------------ +function 'UartAppenderInit': +22 lines diff --git a/Jenkinsfile b/Jenkinsfile index 3d806100..02d5032a 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -59,8 +59,10 @@ pipeline echo "run static analysis" sh 'cmake . -Bbuilddir-static -G"Unix Makefiles" -DPROJECT_CONFIG_PATH=ci/testing_config -DENABLE_STATIC_CHECKS=1 -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON' sh 'cmake --build builddir-static 2> builddir-static/clang-report.txt' - sh 'if [ ! -s builddir-static/clang-report.txt ]; then echo "Good, all tests have been passed w/o findings" > builddir-static/clang-report.txt; fi;' + sh 'if [ ! -s builddir-static/clang-report.txt ]; then echo "Good, all tests have been passed w/o findings" > builddir-static/clang-final-report.txt; fi;' sh 'cat builddir-static/clang-report.txt | python ci/thirdparty/clangTidyToJunit/clang-tidy-to-junit.py `pwd` > builddir-static/clang-report.xml' + sh 'cat ./core/.clang-tidy >> builddir-static/clang-final-report.txt' + sh 'python ./ci/clang-tidy-report-script.py ./builddir-static/clang-report.txt ./core/.clang-tidy >> ./builddir-static/clang-final-report.txt' } } } diff --git a/ci/clang-tidy-report-script.py b/ci/clang-tidy-report-script.py new file mode 100644 index 00000000..ecc454ba --- /dev/null +++ b/ci/clang-tidy-report-script.py @@ -0,0 +1,149 @@ +import re +from io import StringIO +import sys + + + +################# write the result in the final file for the final report +def writeText(function): + textfile = open("Final-Clang-Tidy-Report.txt","w") + textfile.write(function) + textfile.write('\n') + textfile.close() + +############### read specific string from file +def readClangConfig(): + stringLineToMatch = "LineThreshold" + + stringBranchToMatch = "BranchThreshold" + + stringNestingToMatch = "NestingThreshold" + + stringValueToMatch = " value:" + + global resultL + global resultB + global resultN + #### here we gave the function the third position of sys arguments when you should put the file path of .clang-tidy cofig. + with open(sys.argv[2],"r") as f: + + while True: + line1 = f.readline() + line2 = f.readline() + + if stringLineToMatch in line1 and stringValueToMatch in line2: + elementsLineThres= line2.split(" value: '", 1) + matchedEndLine = "'" + if matchedEndLine in line2: + new2 = elementsLineThres[1].split(matchedEndLine,1) + resultL=new2[0].strip() + # print(resultL) + + if stringBranchToMatch in line1 and stringValueToMatch in line2: + elementsBranchThres= line2.split(" value: '", 1) + matchedEndBranch = "'" + if matchedEndBranch in line2: + new2 = elementsBranchThres[1].split(matchedEndBranch,1) + resultB=new2[0].strip() + #print(resultB) + + if stringNestingToMatch in line1 and stringValueToMatch in line2: + elementsNestingThres= line2.split(" value: '", 1) + matchedEndNesting = "'" + if matchedEndNesting in line2: + new2 = elementsNestingThres[1].split(matchedEndNesting,1) + resultN=new2[0].strip() + #print(resultN) + if not line2: break + + +################## read from file the line then find the specific string of warning functions to write all the result line to another file +def readFileAndFindWarningFunctions(): + + ##get the name of the warning functions by this string + WarningFunctions = "warning: function" + matchedLineF = '' + ##get the notes of the warning functions by this string + NoteOfTheFunctionsThresholds ="note:" + + result = [] + result2 = [] + result3 = [] + result4 = [] + + listResult = [] + + matchedline='' + matchednesting='' + matchedbranch='' + + ffinal ='' + flag2 =False + i = 1 + re = '' + + ##### this to call the method which get the specific string from .clang-tidy config + readClangConfig() + ##### then apply it here global variables in the below string for the final report + listResult.append('--------------------------------------------------------------------------------' + +'\nClang Tidy Reporting for Kiso functions.. \n' + +'The functions exceed recommended size/complexity thresholds [readability-function-size]:\n' + + 'Thresholds: LineThresholods > '+resultL+' | BranchThresholds > '+resultB+' | NestingThresholds > '+resultN+'\n' + + '--------------------------------------------------------------------------------') + + #### here when you run your python script file path and with the .txt file path + #### this sys.argv[1] give you the .txt file path from the command you will run with the python script file path + with open(sys.argv[1],"r") as f: + for line in f: + if WarningFunctions in line: + matchedLineF = line + elementsNameOfFunctions= matchedLineF.split('warning: ', 1) + + if len(WarningFunctions)<2: + print("there are no warning functions") + else: + new = elementsNameOfFunctions[1].split('exceeds',1) + result=new[0].strip() + re = 'Function ' + str(i) + listResult.append('\n') + listResult.append(re) + listResult.append('------------') + listResult.append(result+':') + flag2 =True + i = i+1 + elif NoteOfTheFunctionsThresholds in line: + matchedLineF = line + elementsNameOfFunctions = matchedLineF.split('note:',1) + if len(NoteOfTheFunctionsThresholds)<2: + listResult.append("there are no notes for this warning function exceed recommended size/complexity thresholds [readability-function-size].") + #print("there are no notes for warning functions") + else: + matchedline ='including whitespace and comments (threshold '+resultL+')' + matchednesting ='starts here (threshold '+resultN+')' + matchedbranch=' (threshold '+resultB+')' + if matchedline in matchedLineF: + new2 = elementsNameOfFunctions[1].split(matchedline,1) + result2=new2[0].strip() + listResult.append(result2) + + if matchedbranch in matchedLineF: + new4 = elementsNameOfFunctions[1].split(matchedbranch,1) + result4=new4[0].strip() + listResult.append(result4) + + if matchednesting in matchedLineF and flag2== True: + new3 = elementsNameOfFunctions[1].split(matchednesting,1) + result3=new3[0].strip() + listResult.append(result3) + flag2= False + + + ffinal = '\n'.join(listResult) + writeText(ffinal) + print(ffinal+'\n') + + +#### here it will call the function will do the final report + +readFileAndFindWarningFunctions() + \ No newline at end of file diff --git a/core/.clang-tidy b/core/.clang-tidy index 4e69c612..8c1da9dd 100644 --- a/core/.clang-tidy +++ b/core/.clang-tidy @@ -3,11 +3,11 @@ Checks: '-*, readability-*, clang-analyzer-*, misc-*' CheckOptions: - key: readability-function-size.LineThreshold - value: '120' + value: '20' - key: readability-function-size.BranchThreshold - value: '15' + value: '5' - key: readability-function-size.NestingThreshold - value: '7' + value: '3' - key: readability-function-size.ParameterThreshold value: '8' - key: readability-function-size.StatementThreshold From 7990424b0a88a38e7187f5899e1c6e274b37a111 Mon Sep 17 00:00:00 2001 From: SajaKhdour <56433736+SajaKhdour@users.noreply.github.com> Date: Thu, 4 Jun 2020 13:44:05 +0200 Subject: [PATCH 3/5] Delete Final-Clang-Tidy-Report.txt --- Final-Clang-Tidy-Report.txt | 542 ------------------------------------ 1 file changed, 542 deletions(-) delete mode 100644 Final-Clang-Tidy-Report.txt diff --git a/Final-Clang-Tidy-Report.txt b/Final-Clang-Tidy-Report.txt deleted file mode 100644 index 1e22b5f1..00000000 --- a/Final-Clang-Tidy-Report.txt +++ /dev/null @@ -1,542 +0,0 @@ --------------------------------------------------------------------------------- -Clang Tidy Reporting for Kiso functions.. -The functions exceed recommended size/complexity thresholds [readability-function-size]: -Thresholds: LineThresholods > 20 | BranchThresholds > 5 | NestingThresholds > 3 --------------------------------------------------------------------------------- - - -Function 1 ------------- -function 'NoOs_Signal_Wait': -30 lines - - -Function 2 ------------- -function 'MCU_CRC8': -44 lines - - -Function 3 ------------- -function 'MCU_CRC16': -44 lines - - -Function 4 ------------- -function 'MCU_CRC32': -75 lines -8 branches - - -Function 5 ------------- -function 'MCU_I2C_Initialize': -90 lines -8 branches -nesting level 4 - - -Function 6 ------------- -function 'MCU_I2C_Send': -38 lines -nesting level 4 - - -Function 7 ------------- -function 'MCU_I2C_Receive': -39 lines -nesting level 4 - - -Function 8 ------------- -function 'MCU_I2C_WriteRegister': -38 lines -nesting level 4 - - -Function 9 ------------- -function 'MCU_I2C_ReadRegister': -39 lines -nesting level 4 - - -Function 10 ------------- -function 'I2C_SendPollMode': -114 lines -14 branches -nesting level 4 - - -Function 11 ------------- -function 'I2C_ReceivePollMode': -34 lines -6 branches - - -Function 12 ------------- -function 'I2C_WriteRegisterIntMode': -38 lines -7 branches - - -Function 13 ------------- -function 'I2C_ReadRegisterIntMode': -33 lines - - -Function 14 ------------- -function 'I2C_ReadRegisterDmaMode': -32 lines - - -Function 15 ------------- -function 'HAL_I2C_MasterTxCpltCallback': -22 lines -nesting level 4 - - -Function 16 ------------- -function 'MCU_RNG_Generate': -40 lines -nesting level 4 - - -Function 17 ------------- -function 'MCU_SPI_Initialize': -85 lines -9 branches -nesting level 4 - - -Function 18 ------------- -function 'MCU_SPI_Send': -45 lines -7 branches -nesting level 4 - - -Function 19 ------------- -function 'MCU_SPI_Receive': -51 lines -8 branches -nesting level 4 - - -Function 20 ------------- -function 'MCU_SPI_Transfer': -46 lines -7 branches -nesting level 4 - - -Function 21 ------------- -function 'MCU_SPI_GetDataCount': -22 lines - - -Function 22 ------------- -function 'HAL_SPI_ErrorCallback': -46 lines - - -Function 23 ------------- -function 'MCU_UART_Initialize': -107 lines -11 branches -nesting level 4 - - -Function 24 ------------- -function 'MCU_UART_Send': -43 lines -7 branches -nesting level 4 - - -Function 25 ------------- -function 'MCU_UART_Receive': -36 lines -nesting level 4 - - -Function 26 ------------- -function 'UART_SendPolling': -25 lines - - -Function 27 ------------- -function 'UART_SendInt': -21 lines - - -Function 28 ------------- -function 'UART_SendDMA': -22 lines - - -Function 29 ------------- -function 'CRC_8': -49 lines -nesting level 4 - - -Function 30 ------------- -function 'CRC_16': -47 lines -nesting level 4 - - -Function 31 ------------- -function 'CRC_32': -49 lines -nesting level 4 - - -Function 32 ------------- -function 'CRC_32_Reverse': -51 lines -nesting level 4 - - -Function 33 ------------- -function 'CmdLineDbg_RegisterCmd': -25 lines - - -Function 34 ------------- -function 'CmdLineDbg_RegisterCmdArray': -27 lines - - -Function 35 ------------- -function 'CmdLineDbg_Parse': -36 lines - - -Function 36 ------------- -function 'ErrorLogger_Init': -33 lines -nesting level 4 - - -Function 37 ------------- -function 'ErrorLogger_LogError': -28 lines - - -Function 38 ------------- -function 'ErrorLogger_GetLastErrorLog': -22 lines -nesting level 4 - - -Function 39 ------------- -function 'ErrorLogger_HasError': -nesting level 4 - - -Function 40 ------------- -function 'Escape_SpecialCharacters': -33 lines -6 branches - - -Function 41 ------------- -function 'UnEscape_SpecialCharacters': -21 lines - - -Function 42 ------------- -function 'XProtocol_EncodeFrame': -91 lines -10 branches - - -Function 43 ------------- -function 'XProtocol_GetPayloadLength': -28 lines - - -Function 44 ------------- -function 'XProtocol_DecodeFrame': -92 lines -12 branches -nesting level 4 - - -Function 45 ------------- -function 'XProtocol_IsCompleteFrame': -24 lines - - -Function 46 ------------- -function 'CmdProcessor_Initialize': -38 lines -nesting level 4 - - -Function 47 ------------- -function 'CmdProcessor_Enqueue': -32 lines - - -Function 48 ------------- -function 'CmdProcessor_EnqueueFromIsr': -33 lines -nesting level 4 - - -Function 49 ------------- -function 'Dequeue': -29 lines -nesting level 4 - - -Function 50 ------------- -function 'EventHub_Observe': -37 lines -6 branches - - -Function 51 ------------- -function 'EventHub_ObserveAll': -36 lines -6 branches - - -Function 52 ------------- -function 'EventHub_Notify': -34 lines -7 branches -nesting level 4 - - -Function 53 ------------- -function 'GuardedTask_Deinitialize': -27 lines - - -Function 54 ------------- -function 'GuardedTask_Initialize': -36 lines -6 branches -nesting level 4 - - -Function 55 ------------- -function 'GuardedTask_Signal': -23 lines - - -Function 56 ------------- -function 'GuardedTask_SignalFromIsr': -26 lines -nesting level 4 - - -Function 57 ------------- -function 'I2CTransceiver_LoopCallback': -46 lines -10 branches -nesting level 4 - - -Function 58 ------------- -function 'I2CTransceiver_Init': -40 lines -nesting level 4 - - -Function 59 ------------- -function 'I2CTransceiver_Read': -47 lines -9 branches -nesting level 4 - - -Function 60 ------------- -function 'I2CTransceiver_Write': -46 lines -9 branches -nesting level 4 - - -Function 61 ------------- -function 'RunFilter': -65 lines -9 branches -nesting level 4 - - -Function 62 ------------- -function 'PipeAndFilter_CreateFilter': -32 lines - - -Function 63 ------------- -function 'TaskMonitor_Register': -25 lines -nesting level 4 - - -Function 64 ------------- -function 'TaskMonitor_Check': -47 lines -7 branches -nesting level 4 - - -Function 65 ------------- -function 'UARTTransceiver_Initialize': -32 lines -nesting level 4 - - -Function 66 ------------- -function 'UARTTransceiver_Start': -42 lines -nesting level 4 - - -Function 67 ------------- -function 'UARTTransceiver_StartInAsyncMode': -44 lines -nesting level 4 - - -Function 68 ------------- -function 'UARTTransceiver_Stop': -33 lines -nesting level 4 - - -Function 69 ------------- -function 'UARTTransceiver_Suspend': -32 lines -nesting level 4 - - -Function 70 ------------- -function 'UARTTransceiver_Resume': -32 lines -nesting level 4 - - -Function 71 ------------- -function 'UARTTransceiver_ReadData': -35 lines -nesting level 4 - - -Function 72 ------------- -function 'UARTTransceiver_WriteData': -46 lines -6 branches -nesting level 4 - - -Function 73 ------------- -function 'UARTTransceiver_LoopCallback': -60 lines -15 branches -nesting level 4 - - -Function 74 ------------- -function 'LogFilter_Add': -21 lines - - -Function 75 ------------- -function 'LogFilter_Apply': -nesting level 4 - - -Function 76 ------------- -function 'Logging_Init': -25 lines - - -Function 77 ------------- -function 'SyncRecorder_Write': -33 lines - - -Function 78 ------------- -function 'UartAppenderInit': -22 lines From d6317ee409d17d6181021665385abbe2feb4962f Mon Sep 17 00:00:00 2001 From: SajaKhdour <56433736+SajaKhdour@users.noreply.github.com> Date: Thu, 4 Jun 2020 13:44:54 +0200 Subject: [PATCH 4/5] Update clang-tidy-report-script.py --- ci/clang-tidy-report-script.py | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/ci/clang-tidy-report-script.py b/ci/clang-tidy-report-script.py index ecc454ba..90bf327e 100644 --- a/ci/clang-tidy-report-script.py +++ b/ci/clang-tidy-report-script.py @@ -3,13 +3,6 @@ import sys - -################# write the result in the final file for the final report -def writeText(function): - textfile = open("Final-Clang-Tidy-Report.txt","w") - textfile.write(function) - textfile.write('\n') - textfile.close() ############### read specific string from file def readClangConfig(): @@ -139,11 +132,10 @@ def readFileAndFindWarningFunctions(): ffinal = '\n'.join(listResult) - writeText(ffinal) print(ffinal+'\n') #### here it will call the function will do the final report readFileAndFindWarningFunctions() - \ No newline at end of file + From 52d1f2253589e7b1860731ae944cc26be3efa42c Mon Sep 17 00:00:00 2001 From: SajaKhdour <56433736+SajaKhdour@users.noreply.github.com> Date: Thu, 4 Jun 2020 14:36:21 +0200 Subject: [PATCH 5/5] Delete clang-tidy-report-script.py --- clang-tidy-report-script.py | 145 ------------------------------------ 1 file changed, 145 deletions(-) delete mode 100644 clang-tidy-report-script.py diff --git a/clang-tidy-report-script.py b/clang-tidy-report-script.py deleted file mode 100644 index 0e72ecaa..00000000 --- a/clang-tidy-report-script.py +++ /dev/null @@ -1,145 +0,0 @@ -import re -from io import StringIO -import sys - - - -################# write the result in the final file for the final report -def writeText(function): - textfile = open("Final-Clang-Tidy-Report.txt","w") - textfile.write(function) - textfile.write('\n') - textfile.close() - -############### read specific string from file -def readClangConfig(): - stringLineToMatch = "LineThreshold" - - stringBranchToMatch = "BranchThreshold" - - stringNestingToMatch = "NestingThreshold" - - stringValueToMatch = " value:" - - global resultL - global resultB - global resultN - #### here we gave the function the third position of sys arguments when you should put the file path of .clang-tidy cofig. - with open(sys.argv[2],"r") as f: - - while True: - line1 = f.readline() - line2 = f.readline() - - if stringLineToMatch in line1 and stringValueToMatch in line2: - elementsLineThres= line2.split(" value: '", 1) - matchedEndLine = "'" - if matchedEndLine in line2: - new2 = elementsLineThres[1].split(matchedEndLine,1) - resultL=new2[0].strip() - # print(resultL) - - if stringBranchToMatch in line1 and stringValueToMatch in line2: - elementsBranchThres= line2.split(" value: '", 1) - matchedEndBranch = "'" - if matchedEndBranch in line2: - new2 = elementsBranchThres[1].split(matchedEndBranch,1) - resultB=new2[0].strip() - #print(resultB) - - if stringNestingToMatch in line1 and stringValueToMatch in line2: - elementsNestingThres= line2.split(" value: '", 1) - matchedEndNesting = "'" - if matchedEndNesting in line2: - new2 = elementsNestingThres[1].split(matchedEndNesting,1) - resultN=new2[0].strip() - #print(resultN) - if not line2: break - - -################## read from file the line then find the specific string of warning functions to write all the result line to another file -def readFileAndFindWarningFunctions(): - - ##get the name of the warning functions by this string - WarningFunctions = "warning: function" - matchedLineF = '' - ##get the notes of the warning functions by this string - NoteOfTheFunctionsThresholds ="note:" - - result = [] - result2 = [] - result3 = [] - result4 = [] - - listResult = [] - - matchedline='' - matchednesting='' - matchedbranch='' - - ffinal ='' - flag2 =False - i = 1 - re = '' - - ##### this to call the method which get the specific string from .clang-tidy config - readClangConfig() - ##### then apply it here global variables in the below string for the final report - listResult.append('\nClang Tidy Reporting for Kiso functions.. \n' - +'The functions exceed recommended size/complexity thresholds [readability-function-size]:\n' - + 'Thresholds: LineThresholods > '+resultL+' | BranchThresholds > '+resultB+' | NestingThresholds > '+resultN+'\n' - + '--------------------------------------------------------------------------------') - - #### here when you run your python script file path and with the .txt file path - #### this sys.argv[1] give you the .txt file path from the command you will run with the python script file path - with open(sys.argv[1],"r") as f: - for line in f: - if WarningFunctions in line: - matchedLineF = line - elementsNameOfFunctions= matchedLineF.split('warning: ', 1) - - if len(WarningFunctions)<2: - print("there are no warning functions") - else: - new = elementsNameOfFunctions[1].split('exceeds',1) - result=new[0].strip() - re = 'Function ' + str(i) - listResult.append('\n') - listResult.append(re) - listResult.append('------------') - listResult.append(result+':') - flag2 =True - i = i+1 - elif NoteOfTheFunctionsThresholds in line: - matchedLineF = line - elementsNameOfFunctions = matchedLineF.split('note:',1) - if len(NoteOfTheFunctionsThresholds)<2: - print("there are no notes for warning functions") - else: - matchedline ='including whitespace and comments (threshold '+resultL+')' - matchednesting ='starts here (threshold '+resultN+')' - matchedbranch=' (threshold '+resultB+')' - if matchedline in matchedLineF: - new2 = elementsNameOfFunctions[1].split(matchedline,1) - result2=new2[0].strip() - listResult.append(result2) - - if matchedbranch in matchedLineF: - new4 = elementsNameOfFunctions[1].split(matchedbranch,1) - result4=new4[0].strip() - listResult.append(result4) - - if matchednesting in matchedLineF and flag2== True: - new3 = elementsNameOfFunctions[1].split(matchednesting,1) - result3=new3[0].strip() - listResult.append(result3) - flag2= False - - - ffinal = '\n'.join(listResult) - writeText(ffinal) - print(ffinal+'\n') - -#### here it will call the function will do the final report -readFileAndFindWarningFunctions() - \ No newline at end of file