MIS3202-Secure Software Systems
Assignment 02
[Link]
2016MIS022
Extract the chatsocket project to eclipse as a maven project. Analyze the project using Sonar Lint plugin
and provide solutions for 10 issues. You need to provide sample codes of issues and solution codes as
well.
1. [Link] - Merge this if statement with the enclosing one.
Solution:
2. [Link] - Use a logger to log this exception.
Solution:
3. [Link] - Replace this "switch" statement by "if" statements to increase
readability.
Solution:
4. [Link] - Add a default case to this switch.
Solution:
5. [Link] - Either remove or fill this block of code.
Solution:
6. [Link] - Define a constant instead of duplicating this literal "Change..." 3 times.
Solution:
7. [Link] - Rename this constant name to match the regular expression '^[A-Z][A-Z0-
9]*(_[A-Z0-9]+)*$'.
Solution:
8. [Link] - Define and throw a dedicated exception instead of using a generic one.
Solution:
9. [Link] - "notify" may not wake up the appropriate thread
Solution:
10. [Link] - Make "extra" transient or serializable
Solution:
Briefly describe how to setup sonarcube in your local machine to improve code quality
with a suitable system diagram.
1. Unzip - let's say in "C:\sonarqube" or "/etc/sonarqube", the SonarQube distribution once
it's downloaded. (Download Page)
2. Start the SonarQube server:
# On Windows, execute:
C:\sonarqube\bin\windows-x86-xx\[Link]
# On other operating system, execute:
/etc/sonarqube/bin/[OS]/[Link] console
3. Log in to [Link] with System Administrator credentials (admin/admin)
and follow the tutorial to analyze your first project.
To scan a project with sonar-scanner follow the following steps.
1. Download Sonar Qube Scanner from the following link
[Link]
2. Expand the downloaded file into the directory of your choice. We'll refer to it as
<install_directory> in the next steps.
3. Update the global settings to point to your SonarQube server by editing
<install_directory>/conf/[Link]:
4. Add the <install_directory>/bin directory to your path.
5. You can verify your installation by opening a new shell and executing the command
sonar-scanner -h (on Windows platform the command is [Link] -h)
6. Create a configuration file in the root directory of the project: sonar-
[Link]
7. Run the following command from the project base directory to launch the analysis:
8. Once the analysis is successful, check the sonarqube which will provide the results.