Article Index
Quick Guide
Setting the License
Running the Standard Analysis
Viewing Results
Writing Your Own Analysis
Organizing Your Analyses
Further Help

Running the Standard Analysis

SemmleCode Professional ships with a standard analysis, which contains dozens of code analyses that analyze the architectural properties of your code, find hard-to-maintain classes, uncover refactoring opportunities and locate latent bugs in Java code. Running the analysis takes only a few clicks, and the results are displayed within Eclipse.

To run the standard analysis:

  1. Select a set of projects in the Package Explorer, right click to bring up the popup menu and select SemmleCode > Run Default Analysis. This will begin indexing your selected projects and start the standard analysis.

  2. After the projects have been indexed, the standard analysis will be run and the Results View will be shown. You can view the progress of the analysis as well as its results in that view.

Standard Analysis Highlights

After running the standard analysis, you may want to look at the results for the following analyses, as they highlight important properties of the analyzed code.

  • Classes with complex control flow
    (Architecture > General Class-Level Information > Classes with complex control flow)

    This analysis shows classes with complex control flow (deep nested loops and branches) as a heat map, with complex classes showing in red and simpler classes showing in green. This allows you to easily find the classes in your code that can potentially be a maintenance nightmare and see if they could be simplified.

  • Ant target dependencies
    (Architecture > General Top-Level Information > Ant target dependencies)

    This analysis displays the dependencies of the targets in your ant files in a graph diagram, with targets appearing as nodes connected by arrows to their dependencies. This enables you to easily see the structure of your ant tasks, which can be difficult to see in code due to lack of structure and tools for editing ant files.

  • Large Types
    (Architecture > Refactoring Opportunities > Large types)

    This analysis displays classes with a large number of lines of code. Classes that get too large usually indicate that they can be refactored into smaller classes.

  • Array in String Append
    (Violations of Best Practices > Undesirable Calls > Array in String append)

    This analysis finds code that appends an array to a String. This will most likely produce a result that is not what the author expected, with the resulting String containing the object id of the array instead of its contents.

        class A {
            public static void main(String[] args) {
    	    System.out.println("arguments: "+args);
            }
        }

  • Ignores exceptional return value
    (Violations of Best Practices > Exception Handling > Ignores exceptional return value)

    This analysis finds calls to common Java library functions like InputStream.read that do not check the return value of the method. These are potential bugs as these methods return the status of their result in the return value and ignoring them can lead to an unexpected condition.

        java.io.InputStream is = (...);
        byte[] b = new byte[16];
        is.read(b);

The next section of the tutorial shows how to make full use of the Result View for navigating the analysis results.