0% found this document useful (0 votes)
6 views23 pages

Group Project ThayMan 2

The document outlines a project aimed at analyzing software defect data to enhance testing quality, focusing on a student management system. It details the project's objectives, implementation methods, and various error detection and code quality measurement techniques. The project involves developing an automated tool for code analysis and providing recommendations for improving software quality.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views23 pages

Group Project ThayMan 2

The document outlines a project aimed at analyzing software defect data to enhance testing quality, focusing on a student management system. It details the project's objectives, implementation methods, and various error detection and code quality measurement techniques. The project involves developing an automated tool for code analysis and providing recommendations for improving software quality.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 23

ANALYZE SOFTWARE DEFECT

DATA TO IMPROVE TESTING


QUALITY
Submitted by
Mai Hoang Lan
Ngo Hong Ky
Truong Cong Thanh
Le Hoa Hiep

Mentor:
Name Signature Date
Mr Nguyen Duc Man

1
PROJECT INFORMATION

Project acronym ASDDTITQP

ANALYZE SOFTWARE DEFECT DATA TO IMPROVE


Project Title
TESTING QUALITY PROJECT

Start Date End Date

Lead Institution International School, DuyTan University

Nguyen Duc Man

Project Mentor Email: [email protected]

Tel: 0904235945

Mai Hoang Lan


Project Leader
Email: [email protected]
& contact details
Tel: 0869090860

Name Email Tel

Mai Hoang Lan [email protected] 0869090860


Team members
Ngo Hong Ky [email protected] 0334595134
Truong Cong Thanh [email protected] 0367163476
Le Hoa Hiep [email protected] 0867797246

2
TOPIC 5 DOCUMENT

Document Title Topic 5 document

Author(s)

Role Topic 5 document

Date 24 March 2025 File name 1. Group project topic 5

URL

Access Project and CMU Program

DOCUMENT HISTORY
Version Person Date Description
Mai Hoang Lan
Ngo Hong Ky
1.0 24 March, 2025 Draft
Truong Cong Thanh
Le Hoa Hiep

3
Contents
1. Introduction................................................................................................................5
1.1. Context..................................................................................................................5
1.2. Objectives..............................................................................................................5
1.3. Scope......................................................................................................................5
2. Theoretical Basis........................................................................................................5
2.1. Error Detection Techniques in the Student Management System..................5
2.2. Code Quality Measurement Techniques............................................................6
3. Method of implementation........................................................................................7
3.1. Implementation process.......................................................................................7
3.2. Data Collection...................................................................................................10
3.2.1. Data source:..............................................................................................10
3.2.2. Data size:...................................................................................................10
4. Experimental results................................................................................................15
4.1. Input data............................................................................................................15
4.2. Measured / Predicted Results............................................................................19
4.3. Compare with traditional model (if any).........................................................19
5. Review and analysis.................................................................................................19
5.1. Advantages of the implemented method..........................................................19
5.2. Limitations of the study.....................................................................................19
6. Conclusion and recommendations.........................................................................20
6.1. Conclude..............................................................................................................20
6.2. Suggested improvements...................................................................................20
7. References.................................................................................................................21

4
1. Introduction
1.1. Context
In software development, evaluating source code quality is a crucial factor in
ensuring maintainability, readability, and performance optimization. A student
management system is a software application designed to store, manage, and
process student-related data such as enrollment, grades, and attendance. Ensuring
high-quality source code for such a system is essential for long-term scalability
and stability.
1.2. Objectives
- Develop an automated tool for collecting and analyzing code quality metrics.
- Provide a visual representation of the evaluation results.
- Offer optimization suggestions to improve code quality.
1.3. Scope
- Supports analyzing Python and Java source code.
- Utilizes key software quality metrics: Lines of Code (LOC), Cyclomatic
Complexity, Code Duplication, Cohesion & Coupling.
- Displays results through a web-based interface.
2. Theoretical Basis
2.1. Error Detection Techniques in the Student Management System
During the development of a student management system, detecting and fixing
errors is crucial to ensuring software quality. Common techniques for error
detection include:
 Static Analysis:
 Uses tools like pylint, ESLint, SonarQube to detect syntax errors, logical
errors, and coding style violations.
 Checks for issues such as memory leaks and uninitialized variables.

5
 Unit Testing:
 Writing test cases to verify the functionality of individual components.
 Popular tools: JUnit (Java), Jest (JavaScript), PyTest (Python).
 Integration Testing:
 Ensures that different modules of the system work correctly when
integrated.
 Supporting tools: Postman, Selenium, Cypress.
 Black Box Testing:
 Tests the system without requiring knowledge of the source code, focusing
on inputs and expected outputs.
 Typically performed by QA teams or test users.
 White Box Testing:
 Analyzes the source code to verify logical paths and data flow.
 Tools: JUnit, Mocha, PyUnit.
 Error Monitoring in Production:
 Uses logging systems such as ELK Stack (Elasticsearch, Logstash, Kibana)
or Sentry to track errors occurring in real-time environments.
2.2. Code Quality Measurement Techniques
- To ensure high-quality code in the student management system, the following
measurement techniques are applied:
 Lines of Code (LOC):
 Measures the total number of lines in the system.
 A high LOC count may indicate complex and hard-to-maintain code.
 Measurement tools: cloc, radon.
 Cyclomatic Complexity:
 Evaluates the complexity of control flow based on the number of decision
branches in the source code.

6
 High values may indicate code that is difficult to understand and error-
prone.

 Measurement tools: radon (Python), SonarQube.


 Code Duplication:
 Detects duplicated code fragments within the system.
 Code duplication increases maintenance costs and the risk of errors.
 Measurement tools: SonarQube, PMD, jscpd.
 Cohesion & Coupling:
 Cohesion: Measures the level of internal connectivity within a module. A
higher cohesion value is better as it indicates a more independent module.
 Coupling: Measures the interdependencies between different modules.
Lower coupling is preferable for better maintainability.
 Measurement tools: Understand, SonarQube.
3. Method of implementation
3.1. Implementation process
1. Start
The project begins with a clear objective of improving the testing process and
minimizing defects in the system.
2. Collect Defect Data
Gather defect data from various sources, including defect reports, system logs,
user feedback, and previous test results.
3. Analyze Defect Trends
Analyze the collected data to identify common defect patterns, frequency of
occurrence, root causes, and their impact on the system.
4. Identify High-Risk Components
Based on the analysis, identify the system modules or components that have the
highest risk of defects or the greatest impact on overall performance.

7
5. Propose Testing Strategies
Develop and propose suitable testing strategies to improve accuracy, including
automated testing, manual testing, security testing, and performance testing.
6. Apply & Evaluate Effectiveness
Implement the proposed testing strategies, collect results, and assess their
effectiveness. Adjust methods if necessary to optimize the testing process.
7. End
The project concludes once the testing strategies have been applied and their
effectiveness has been validated. A final report may be created, along with
recommendations for future improvements.

8
Flow chart

9
3.2. Data Collection

10
3.2.1. Data source:
https://github.com/LanHoang30062004/measurement.git
3.2.2. Data size:
 Number of samples
 Number of Functions analyzed: 26
- StaffService.java:
- Number of functions: 9
 findAll()
 findById(Long id)
 findByName(String name)
 findByClassEntityId(Long id)
 findAllByClassEntityIdIsNull()
 save(StaffDTO staffDTO)
 findByStaffId(Long id)
 findBySubjectEntitiesIsEmpty()
 deleteById(Long id)
- StudentService.java:
- Number of functions: 5
 findById(Long id)
 findAll()
 save(StudentDTO student)
 findByStudentId(Long id)
 deleteById(Long id)
- SubjectService.java:
- Number of functions: 4
 findById(Long id)
 findAll()
 save(SubjectDTO, subjectDTO)

11
 deleteById(Long id)
- TranscriptService.java:
- Number of functions: 5
 save(TranscriptDTO transcriptDTO)
 findAll()
 findByStudentID(Long id)
 findById(Long id)
 deleteById(Long id)
- UserService.java:
- Number of functions: 3
 loadUserByUsername(String username)
 authorities(List<RoleEntity> roles)
 addNewUser(UserEntity user)
 Number of measured variables
- StaffService.java
 LOC: 41
 Cyclomatic Complexity ( CC=E−N+2P ):
 Nodes (N): 2
 Edges (E): 2
 Components (P): 1
 CC=E−N+2P=2−2+2(1)=2
 Code Duplication: 10%

- StudentService.java
 LOC: 37

12
 Cyclomatic Complexity ( CC=E−N+2P ):
 Nodes (N): 3
 Edges (E): 3
 Components (P): 1
 CC=E−N+2P= 3−3+2(1)=2
 Code Duplication: 8%
- SubjectService.java
 LOC: 37
 Cyclomatic Complexity ( CC=E−N+2P ):
 Nodes (N): 3
 Edges (E): 3
 Components (P): 1
 CC=E−N+2P= 3−3+2(1)=2
 Code Duplication: 7%
- TranscriptService.java
 LOC: 42
 Cyclomatic Complexity ( CC=E−N+2P ):
 Nodes (N): 4
 Edges (E): 5
 Components (P):
 CC=E−N+2P= 5−4+2(1)=3
 Code Duplication: 12%

- UserService.java
 LOC: 29

13
 Cyclomatic Complexity ( CC=E−N+2P ):
 Nodes (N): 3
 Edges (E): 3
 Components (P): 1
 CC=E−N+2P= 3−3+2(1)=2
 Code Duplication: 9%
 Function Point
- StaffService.java
 EI: 2 (weight 4)
 EO: 3(weight 5)
 EQ: 3 (weight 4)
 ILF : 2 (weight 7)
 EIF: 1 (weight 5)
 FP=(2×4)+(3×5)+(3×4)+(2×7)+(1×5)=54
- StudentService.java
 EI: 2 (weight 4)
 EO: 2(weight 5)
 EQ: 2 (weight 4)
 ILF : 2 (weight 7)
 EIF: 1 (weight 5)
 FP=(2×4)+(2×5)+(2×4)+(2×7)+(1×5)=45
- SubjectService.java
 EI: 1 (weight 4)
 EO: 2(weight 5)
 EQ: 1 (weight 4)
 ILF : 1 (weight 7)
 EIF: 1 (weight 5)
 FP=(1×4)+(2×5)+(1×4)+(1×7)+(1×5)=30
- TranscriptService.java
 EI: 3 (weight 4)

14
EO: 3(weight 5)

EQ: 2 (weight 4)

ILF : 2 (weight 7)

EIF: 1 (weight 5)

 FP=(3×4)+(3×5)+(2×4)+(2×7)+(1×5)=62
- UserService.java
 EI: 2 (weight 4)
 EO: 2(weight 5)
 EQ: 2 (weight 4)
 ILF : 1 (weight 7)
 EIF: 1 (weight 5)
 FP=(2×4)+(2×5)+(2×4)+(1×7)+(1×5)=42
3.3. Tools used

4. Experimental results
4.1. Input data

15
ID Service Function Type Time Period

Khi cập nhật


Save NullPointerException
1 StaffService Runtime thông tin sinh
(StaffDTO staffDTO) (nếu staffEntity == null)
viên

Khi xóa Khi xử lý xóa


NullPointerException (nếu Staff dữ liệu trong
deleteById
2 staffEntity.getClassEntity() || không có Service
(Long id)
staffEntity.getSubjectEntity() == null) Class hoặc
Subject

Khi tìm Khi truy vấn


kiếm tên cơ sở dữ liệu
findByName
3 Lỗi nếu không có dữ liệu trả về Staff
(String name)
không tồn
tại

Khi tìm Khi truy vấn


findByClassEntityId Lỗi nếu ID không hợp lệ hoặc kiếm Staff cơ sở dữ liệu
4
(Long id) không có dữ liệu theo
ClassId

Khi tìm Khi truy vấn


findByStaffId Lỗi nếu ID không hợp lệ hoặc kiếm Staff cơ sở dữ liệu
5
(Long id) không có dữ liệu theo
StaffId

NullPointerException nếu Khi cập nhật


Save
findById(student.getId()) trả về null, thông tin sinh
6 StudentService (StudentDTO Runtime
sau đó gọi viên
student)
studentEntity.getStudentDetailEntity()

16
NullPointerException nếu Khi xóa sinh
deleteById
7 findById(id) trả về null, sau đó gọi Runtime viên không tồn
(Long id)
các phương thức trên studentEntity tại

reportCardEntity.setStudentEntity Khi xóa sinh


deleteById (null); viên có bảng
8 Runtime
(Long id) có thể gây lỗi nếu danh sách điểm
reportCardEntities là null

Save studentRepository.save Khi lưu dữ liệu


Compile-
9 (StudentDTO (studentEntity) sinh viên
time
student) không kiểm tra ràng buộc dữ liệu

Khi tìm kiếm


findByStudentId Không xử lý trường hợp
10 Runtime theo ID không
(Long id) findByStudentId(id) trả về null
tồn tại

NullPointerException Khi lưu môn


Save nếu staffEntity == null do học với giáo
11 SubjectService (SubjectDTO staffRepository.findByName Runtime viên không tồn
subjectDTO) (subjectDTO.getNameStaff()) trả về tại
null

NullPointerException nếu Khi cập nhật


findById(subjectDTO.getId()) trả về môn học
save(SubjectDTO
12 Null rồi gọi setName() trên Runtime không tồn tài
subjectDTO)
subjectEntity

NullPointerException nếu Khi xóa môn


subjectEntity.getStaffEntity() học không có
13 deleteById(Long id) Runtime
trả về nul, rồi gọi giáo viên
staffEntity.setSubjectEntity(null)

17
NullPointerException nếu Khi xóa môn
reportCardEntities hoặc học không có
14 deleteById(Long id) transcriptSubjectEntities là null, Runtime bảng điểm
rồi gọi vòng lặp for trên danh sách hoặc transcript
này

Khi tìm môn


Không xử lý trường hợp findById
15 FindById(Long id) Runtime học theo ID
trả về null
không tồn tại

NullPointerException nếu Khi lưu


save(TranscriptDTO studentRepository.findById trancript với
16 TranscriptService Runtime
transcriptDTO) (transcriptDTO.getIdStudent()) trả về idStudent
null không hợp lệ

NullPointerException nếu Khi lưu


save(TranscriptDTO subjectRepository.findByName trancript với
17 Runtime
transcriptDTO) (transcriptDTO.getIdStudent()) trả về môn học
null không tồn tại

Khi lưu
NullPointerException nếu
trancript với
save(TranscriptDTO transcriptEntity
18 Runtime danh sách môn
transcriptDTO) .getTrancriptSubjectEntities()
học chưa khởi
là nul trước khi gọi add()
tạo

Không kiểm tra nếu trancriptEntity là Khi cập nhật


save(TranscriptDTO
19 null khi findById Runtime trancript không
transcriptDTO)
(trancriptDTO.getId()) tồn tại

Không kiểm tra nếu transcript == null Khi xóa


20 deleteById(Long id) Trước khi gọi phương thức trên đối Runtime transcript
tượng này không tồn tại

18
NullPointerException nếu Khi xóa
transcriptEntity transcript
21 deleteById(Long id) Runtime
.getTranscriptSubjectEntities() là null không có môn
trước khi duyệt danh sách học liên kết

Khi tìm
findByStudentID Không kiểm tra nếu findByID(id)
22 Runtime transcript với
(Long id) trả về null
id

NullPointerException nếu Khi đăng nhập


loadUserByUsernam userRespository.findByUserName với tên người
23 UserService e (username) trả về null, nhưng dòng Runtime dùng không
(String username) userEntity.setRoles(roles); vẫn được tồn tại
thực thi

Khi đăng nhập


Không kiểm tra nếu
loadUserByUsernam mà hệ thống
roleRepository.findAll() trả về danh
24 e Runtime hông có vai trò
sách rỗng hoặc null, có thể gây lỗi khi
(String username) nào trong
tạo ra danh sách quyền hạn
database

Khi gọi
loadUser
Không kiểm tra roles có phải null
Authorities(List ByUserName
25 trước khi gọi stream(), có thể gây Runtime
<RoleEntity>roles) nhưng user
NullPointerException
không có vai
trò nào

26 addNewUser Không kiểm tra user.getPassword() Runtime Khi thêm user


(UserEntity user) trước khi gọi encode(), có thể gây mới nhưng
NullPointerException nếu password là không có
null password hợp

19
lệ

roleRepository.findAll() có thể trả về Khi thêm user


addNewUser danh sách rỗng hoặc null, dẫn đến mới nhưng
27 Runtime
(UserEntity user) NullPointerException khi set vào không có vai
user.setRoles() trò nào

4.2. Measured / Predicted Results


4.3. Compare with traditional model (if any)
5. Review and analysis
5.1. Advantages of the implemented method
- The code quality measurement system incorporates key metrics such as LOC,
Cyclomatic Complexity, Code Duplication, Cohesion & Coupling, providing a
comprehensive evaluation.
- Automation tools like pylint, radon, SonarQube, PMD enable quick detection of
errors and improvement of source code quality.
- Visual representation of results allows users to easily analyze and understand the
measurements.
- Function Points (FP) analysis helps assess the complexity of each module, aiding
in software development planning.
5.2. Limitations of the study
- Limited dataset: The number of analyzed data samples is still small, which may
not be sufficient for general conclusions.
- Measurement accuracy: Some metrics such as Cyclomatic Complexity, Code
Duplication can be influenced by individual coding styles.
- Tool coverage: Currently, the system only supports Python and Java, without
extending to other popular programming languages.

20
- Impact of project structure: Certain factors like coding style and framework usage
may affect the measurement results but have not yet been considered.

6. Conclusion and recommendations


6.1. Conclude
- Function Point (FP) analysis highlights module complexity, with
TranscriptService.java having the highest FP = 62.
- The source code quality evaluation system has been successfully implemented
and effectively analyzes LOC, Cyclomatic Complexity, Code Duplication,
Cohesion & Coupling.
- Measurement results indicate differences between modules in the student
management system. For example, TranscriptService.java has a higher
complexity with CC = 3, while other modules have CC = 2.
- The visualization tool assists developers in quickly detecting and optimizing
source code.
6.2. Suggested improvements
- Expand language support: Integrate additional programming languages such
as JavaScript, C++, and C# to enhance applicability.
- Enhance analysis algorithms: Improve the accuracy of measurements,
particularly Cyclomatic Complexity and Code Duplication.
- Increase dataset size: Collect and analyze more projects for a more
comprehensive evaluation.
- Incorporate Machine Learning: Apply ML models to predict potential errors
and provide recommendations for code improvement.

21
7. References

 https://ieeexplore.ieee.org/
 https://dl.acm.org/
 https://pylint.pycqa.org/
 https://radon.readthedocs.io/
 https://www.sonarqube.org/
 https://www.ifpug.org/publications/counting-practices-manual/
 https://iso25000.com/index.php/en/iso-25000-standards/iso-25010
 https://cleancoder.com/

22
23

You might also like