When you choose the code base to run a code review on, the code
must meet certain prerequisites; most importantly, all files in the code base
must be built and compiled without errors when you run the review.
Note the following prerequisites when running a code review, and
the problems that can occur if they are not met:
- The code must be compiled. Running code review on uncompiled code might
result in partial, inconsistent, and sometimes erroneous results.
- There must be no encoding problems. If a project is not readable because
of encoding problems in it, and therefore cannot run on uncompiled sections,
the code review will not work at all.
- Encoding settings must be correct. Wrong encoding settings might produce
the results similar to running code review on uncompiled code.
The following prerequisites apply to the J2EE Best
Practices code review only:
- J2EE dynamic Web projects must be compiled. This allows all the rules
in the J2EE Best Practices code review to be activated.
- If you migrate code from a WebSphere® Studio Application Developer
(WSAD) workspace, you need to manually set the server. Right-click the project
and then click Properties > Server.
Caveats
After you satisfy the prerequisites
and are ready to run a code review, some caveats apply in certain situations.
Avoiding
multiple files with the same Java™ path: When you run certain code
reviews on the workspace, the review does not cover multiple files with the
same Java path
even if the files are in different projects. This behavior applies to code
reviews or rules that require heavy system processing:
- J2EE Best Practices code review
- Complete code review
Consequently, it is better to avoid multiple files with the same Java path.
Example: Suppose
the workspace contains the RED_Examples project and the BLUE_Examples project.
Both projects contain the Color package which includes the bright.java file.
When you run a code review on the workspace, the review covers one bright.java
file only. You can review the code in both files by not having two files with
the same path, such as renaming them to brightr.java and brightb.java.
If
the workspace does have multiple files with the same Java path,
you can run a code review that covers the multiple files by setting up the
workspace in the following way:
- Partition the workspace so that no two files with the same path are in
one workspace.
- Load one workspace at a time.
- Run a separate code review on each workspace.