Source Code Based Suspicious Code and Bad Programming Practice Detecting
- Author
- LiuWei
- Advisor
- ChenJunLiang
- School
- Beijing University of Posts and Telecommunications
- Major
- Computer Science and Technology
- Classification
- TP311.52 Software Development
- Degree
- Master's thesis
- Year
- 2009
- Downloads
- 61
- Citations
- 0
Abstract
This paper introduces how to detect kinds of suspicious code models and bad programming practices which are collected by the author. This paper also proposes a method to detect duplicated code.Suspicious code makes code reviewer feel suspicious, and when running, suspicious code always outputs unexpected data. Suspicious code also breaks the rules which keep programmers far away from bugs. Our static analyzing tool Defect Detecting System (DTS) reads in the source code and constructs abstract syntax trees (AST), control flow graphs (CFG) and context information to detect defects. The author does some research on suspicious code and designs some detecting methods and implements those methods under the testing framework of DTS. Duplicated code makes people delusive and could be eliminated by refracting. The author proposes a method based on abstract syntax tree to parameterize match similar code, and make use of context information to reasonably decide the searching distance. The method is proved to be efficient on detecting inconsecutive duplicated code.
Table of contents
Abstract 4-5
ABSTRACT 5-9
first chapter 9-12
1.1 Introduction 9
1.2 development of software testing 9-10
1.3 software testing significance 10-11
1.4 main job 11
1.5 paper structure 11-12
Chapter II software testing and software testing tool 12-18
2.1 software testing concepts 12
2.2 software testing methods 12-15
2.2.1 static tests 12-13
2.2.2 dynamic test 13
2.2.3 Black Box 13-14
2.2.4 White-box testing 14
2.2.5 model-based software testing 14-15
2.3 static testing tool instance 15-18
2.3.1 Lint 15-16
2.3.2 Klocwork 16
2.3.3 Findbugs 16-17
2.3.4 DTS 17-18
Chapter doubt and DTS static code testing tools 18-32
3.1 compiler technology brief 18-21
3.2 doubt code generation 21-24
3.2.1 type compatibility issues 21
3.2.2 compiled and linked defects 21
3.2.3 object-Oriented mechanisms 21-22
3.2.4 control flow and logic 22
3.2.5 language design issues 22-23
3.2.6 compiler implementation differences 23-24
3.3 DTS static testing tools 24-32
3.3.1 Introduction 24-25
3.3.2 in the context of data structure 25-29
3.3.3 state machine operation mechanism 29-32
Chapter doubt code patterns and detection 32-59 <br / > 4.1 language-independent model 32-38
4.1.1 Definition ( assignment ) using relational 32-34
4.1.2 self-assignment 34-35
4.1.3 null statement the suspect 35-36
4.1.4 empty conditional block 36
4.1.5 suspect assignment operator 36 -37
4.1.6 conditional branching same 37
4.1.7 comparison Operators 37
4.1.8 shift computational problems 37-38 < br /> 4.2 C \\ C doubt mode 38-53
4.2.1 memory Allocation 38-39
4.2.2 object lifecycle management 39 < br /> 4.2.3 sizeof related issues 39-40
4.2.4 operator Precedence 40-41
4.2.5 operators new and delete definitions 41-42
4.2.6 undefined calculation 42-43
4.2.7 enumeration type comparison 43
4.2.8 operator Overloading 43
4.2.9 no return value path 43
4.2.10 invalid and hidden typedef 43-44
4.2.11 file 10 operating 44-46
4.2.12 language customary type 46-47
4.2.13 logical structure of the doubt 47-48
4.2.14 grammatical structure consistency 48
4.2.15 is not compatible with the type of conversion 48-50
4.2.16 non- uniform structure 50-51
4.2.17 construction function 51-52
4.2.18 object leaks 52-53
4.3 Java questions pattern 53-57
4.3.1 type conversion is not accurate 53-54
4.3.2 unnecessary lock operations 54
4.3.3 string comparison 54-55
4.3.4 weird assignment expression 55-56
4.3.5 no aftereffect statement 56
4.3.6 class design problems 56-57
4.4 questions patterns and detection methods summarized 57-59
Chapter duplicate code detection method 59-72
5.1 background 59
5.2 duplication of code and its detection technology 59-61
5.2.1 duplicate code generation 59-60
5.2.2 duplicate code classification 60
5.2.3 detection technology classification 60-61
5.3 design and Analysis 61-67
5.3.1 algorithm Design 61-67
5.3.2 complexity analysis 67
5.4 experimental results 67-71
5.4.1 single file test results comparing 67-69
5.4.2 multi-file test results contrast 69-71
5.5 analysis and Evaluation 71-72
Chapter Summary and Outlook 72-73
6.1 work Summary 72
6.2 Prospects 72-73
References 73-75
Appendix 75-76
Thanks 76 -77
papers published during the master's degree directory 77
Related dissertations
- Research on Anti-analysis Technology of Malicious Code and Corresponding Countermeasure
- Static Analysis Research of Privacy Information Leakin Android Application
- Study Band-gap Theory of One-dimensional Function Photonic Crystal
- Research and Application of Duplicated Code Detecting
- Research and Implementation of Inter-Procedural Analysis for Java
- The Research of Automation Technique of Software Globalization to Large-Scale Legacy System