When you analyze software by using the Code Review component,
you apply rules that govern coding practices to a set of source code
files. The Code Review component searches for violations of these
rules in the source files that are analyzed. In a single operation,
you can check the results for coding violations, open a source code
file that contains a violation, and fix the problem.
The software analysis is guided by a software
analysis configuration, which is created in the software analysis
configuration editor. The configuration contains two types of
information:
- Scope
- The scope identifies the source code files to which the software
analysis is to be applied.
- Rules
- The rules are a set of preferred coding practices.
The Code Review component includes two interfaces for analyzing
source code:
- A graphical user interface
- A command-line code review application
Code Review graphical user interface
When
you run a software analysis configuration, the Code Review runtime
component applies the rules to each source code file in the scope.
For each rule, the runtime component scans the source code file and
looks for a violation: a segment of source code that is inconsistent
with the rule.
For each violation, or result, the
runtime component records the rule ID, the source code file, the failing
segment, and the line number where the failing segment begins.
When
you edit a source code file after a code review, each violation is flagged in the left and right margins of the first
line of the failing segment. Hovering the mouse over either icon displays
the text of the rule.
You can view the complete results
of the code review in the Software Analyzer Results view. Clicking a result and then clicking View
Result opens the relevant source code file in the
editor and positions the cursor at the location of the violation.
The Code Review component also includes the following features:
- You can save the results of a code review by generating a report
in PDF or HTML format.
- You can distribute a software analysis configuration to developers
by using push-to-client.
- You can export the results of a code review to a
file in XML or CSV format.
Command-line code review application
The code review application, which is started from a Linux or Windows command line, has the same code analysis
capabilities as the user-interactive code review. It also supports
the following functions:
- Batch capabilities
- Analysis of files inside or outside of the product workspace
- An include list and an exclude list of individual files
- Generation of output data files in XML and CSV format