Static Code Analysis Exercise
Static Code Analysis Exercise
Static Code Analysis Exercise
For this exercise, you will run SonarQube to analyze your Java project code and SonarScanner
to analyze your TypeScript code. There is a deliverable due by end of class and another for
Sprint 4.
With the generated reports, you will put together a plan to address issues that were flagged in
your Java or TypeScript code.
Note: Make SonarQube is running, which you should have verified in the setup document.
1. In SonarQube, click the “Create Project” button in the upper right corner and select
“Manually”
2. Enter a name for your project and click “Set Up”
5. Select “Locally”
6. For #1 Provide a Token, Enter any name for your token and click “Generate”
7. Click “Continue”
8. For #2 Run analysis on your project, select Other (for JS, TS, Go, Python, PHP, ...)
9. Select your OS
10. You should see something similar to below:
11. Copy the command under “Execute the Scanner” and go to the directory where your
TypeScript code resides and paste this to run. You should see something similar to
below:
12. Go back to the SonarQube web page and you should see both your projects listed.
Take a screen shot of the projects (similar to above) and deposit it in the Static Code Analysis -
individual in the myCourses Assignments by the date shown on your section's schedule.
Depending on the complexity of your code, certain metrics like Cognitive Complexity might get
triggered, requiring attention for potentially refactoring:
Other “code smells” may get flagged due to issues with readability or other factors. This may
indicate a problem or possibly a false flag.
If a particular issue is not clear, click the “Why is this an issue?”, which will provide a description
of the issue including code examples of a non-compliant issue and a compliant solution.
Identify 3-4 areas within your code that have been flagged by SonarQube and provide your
analysis and recommendations. Include any relevant screenshot(s) with each area. This will be
part of your final design documentation in your Sprint 4 submission. Be sure to include at least
one from both reports (Java and TypeScript).
Stopping SonarQube
Refer to the setup document to stop SonarQube.