複審代碼爲C語言代碼,過程式的實現了需求。編程
代碼文件爲共計620行的單文件,代碼中使用多個函數封裝了執行過程當中的多種操做。數組
代碼中也存在問題:安全
1.做爲一個工程化項目,單文件的方式有欠考慮。ide
2.代碼中的部分變量名,如son和mo,不便於理解。函數
3.沒有模測試,僅能經過結果測試程序是否正確。oop
4.沒有註釋。測試
複審結果以下:(其中N/A表明無效項)ui
General | ||
Does the code work? Does it perform its intended function, the logic is correct etc. | Y | |
Is all the code easily understood? | Y | |
Does it conform to your agreed coding conventions? | N/A | |
Is there any redundant or duplicate code? | N | |
Is the code as modular as possible? | Y | |
Can any global variables be replaced? | Y | |
Is there any commented out code? | N | |
Do loops have a set length and correct termination conditions? | N | |
Can any of the code be replaced with library functions? | N | |
Can any logging or debugging code be removed? | N | |
Security | ||
Are all data inputs checked (for the correct type, length, format, and range) and encoded? | N | |
Where third-party utilities are used, are returning errors being caught? | N/A | |
Are output values checked and encoded? | Y | |
Are invalid parameter values handled? | N | |
Documentation | ||
Do comments exist and describe the intent of the code? | N | |
Are all functions commented? | N | |
Is any unusual behavior or edge-case handling described? | N | |
Is the use and function of third-party libraries documented? | N/A | |
Are data structures and units of measurement explained? | N/A | |
Is there any incomplete code? If so, should it be removed or flagged with a suitable marker like ‘TODO’? | N | |
Testing | ||
Is the code testable? i.e. don’t add too many or hide dependencies, unable to initialize objects, test frameworks can use methods etc. | Y | |
Do tests exist and are they comprehensive? i.e. has at least your agreed on code coverage. | N | |
Do unit tests actually test that the code is performing the intended functionality? | N | |
Are arrays checked for ‘out-of-bound’ errors? | N | |
Could any test code be replaced with the use of an existing API? | N |
細化分析:spa
概要:debug
代碼能夠正常工做,在正確的輸入下能夠獲得預期的結果。可是因爲沒有進行錯誤處理,致使輸入錯誤值(如n<0)程序崩潰。
代碼可讀性較好,函數名、變量名基本能體現所表明含義。可是變量名使用依然不是很是清晰,如全局變量能夠考慮使用使用g_做爲開頭。又如,代碼中的分子和分母取名爲son和mo,能夠考慮使用numerator和denominator。縮進、括號位置、Tab/空格均保持一致。
代碼精煉,沒有多餘的內容。主要功能均使用函數進行封裝,莫花花結構較好。
代碼中使用大量的全局變量,大數組做爲全局變量會佔用不少不須要的空間,這種實現方式效果很差。建議使用局部數組+指針進行傳參。
安全:
全部輸入未進行檢查,輸入非法參數或非法文件會致使程序崩潰。
程序僅在正確輸入狀況下獲得正確的結果。
文檔:
單文件c代碼緊湊,未出現任何文檔類註釋。
測試:
程序中不存在測試用代碼。測試時手動構造測試。
經測試,合法狀況的傳參能夠獲得正確的結果,非法傳參結果不正確或崩潰。
因爲做者使用過程式編程,很容易就能夠遍歷全部分支。