STATIC TESTING REPORT
Software Testing – Lab 1: Static Analysis of Source Code
Date: [09/02/2025]
Creator: [Nguyen Ba Anh Duc]
1. Test Strategy
Objective:
The goal of the static analysis is to identify and fix issues related to code quality,
security vulnerabilities, and maintainability, ensuring better system performance and
stability.
Tool Used:
✅ SonarLint
Project Details:
Project Name: Library Management System
Code Base Information:
o Total Files: 1
o Total Lines of Code (LOC): 110
o Programming Languages: Java
Scope:
The analysis focuses on:
Detecting logical errors (e.g., missing exception handling for
user input)
Identifying code smells (e.g., using System.exit(0) instead of a
constant)
Finding duplicate code (e.g., similar logic in addBook() and
addMember())
Spotting potential security vulnerabilities
2. Test Results
2.1 Lines of Code (LOC) Tested
Total LOC: 110
Analyzed LOC: 110
2.2 Number of Issues Found
Total Issues: 18
2.3 Types of Issues
Cou
Category Examples
nt
Blocker
2 - Missing break in switch-case
Issues
- Infinite loop (no exit condition)
Major - No exception handling for
15
Issues Integer.parseInt()
- No empty list check before displaying
data
- Code duplication (addBook() &
addMember())
Minor
1 - Using the default unnamed package
Issues
3. Issue Fixes
Issue Type Specific Issue Fix Implemented
Magic Replaced with constant
Using System.exit(0) directly
Number EXIT_CODE_SUCCESS
Exception No exception handling for Wrapped Integer.parseInt()
Handling integer input in try-catch
Issue Type Specific Issue Fix Implemented
Code addBook() and addMember() Created a common method
Duplication have similar logic getInputData()
Null/Empty No empty list check before Used .isEmpty() check
Check displaying books/members before printing
Deleting a book without Added a verification step
Logic Error
checking if it exists before deletion
4. Results Summary
LOC Analyzed: 110
Issues Resolved:
o Code Smells: 10/15
o Bugs: 2/2
o Security Issues: 0/0
Remaining Issues: 6 (non-critical)
5. Lessons Learned
Importance of Coding Standards:
Using constants instead of hardcoded values improves
maintainability.
Benefits of Static Analysis Tools:
SonarLint quickly detects issues without requiring program
execution.
Improving Maintainability:
Creating reusable methods (getInputData()) reduces code
duplication.
Preventing User Input Errors:
Exception handling for user input prevents crashes and enhances
usability.