Improve Code Quality: Recommendations for Quality Issues in Code | Microsoft AZ-400 Exam

Recommendations for Improving Code Quality

Question

During a code review, you discover many quality issues. Many modules contain unused variables and empty catch blocks.

You need to recommend a solution to improve the quality of the code.

What should you recommend?

Answers

Explanations

Click on the arrows to vote for the correct answer

A. B. C. D.

B

PMD is a source code analyzer. It finds common programming flaws like unused variables, empty catch blocks, unnecessary object creation, and so forth.

There is an Apache Maven PMD Plugin which allows you to automatically run the PMD code analysis tool on your project's source code and generate a site report with its results.

Incorrect Answers:

C: xcpretty is a fast and flexible formatter for xcodebuild.

https://pmd.github.io

/

Among the given options, option D is the most appropriate recommendation to improve the quality of the code during a code review.

Gradle is a build automation tool that can be used to manage and build projects written in Java, C++, Python, and other languages. Gradle provides many plugins that can be used to analyze and improve the quality of the code. One such plugin is Checkstyle, which checks the code against a set of coding standards and guidelines.

Unused variables and empty catch blocks are quality issues that can be detected by Checkstyle. Unused variables can be identified by the UnusedVariable check, and empty catch blocks can be detected by the EmptyCatchBlock check. By running Checkstyle as part of the Gradle build task, developers can be notified of these quality issues and take appropriate actions to fix them.

Therefore, option D, "In a Gradle build task, select Run Checkstyle," is the most appropriate recommendation to improve the quality of the code.