Formatting for IntellJ - soot-oss/soot GitHub Wiki

The coding conventions defined in soot_checkstyle_checks.xml are automatically checked with Maven Checkstyle plugin and the build fails if the conventions are not followed.

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-checkstyle-plugin</artifactId>
  <version>${maven-checkstyle-plugin.version}</version>
  <dependencies>
    <dependency>
      <groupId>com.puppycrawl.tools</groupId>
      <artifactId>checkstyle</artifactId>
      <version>${checkstyle.version}</version>
    </dependency>
  </dependencies>
  <executions>
    <execution>
      <id>validate</id>
      <phase>validate</phase>
      <configuration>
        <propertyExpansion>config_loc=${checkstyle.dir.path}</propertyExpansion>
        <configLocation>${checkstyle.file.path}</configLocation>
        <encoding>UTF-8</encoding>
        <consoleOutput>true</consoleOutput>
        <failsOnError>true</failsOnError>
        <violationSeverity>warning</violationSeverity>
      </configuration>
      <goals>
        <goal>check</goal>
      </goals>
    </execution>
  </executions>
</plugin>

You will require three files from the directory directory codingstyle namely,

Step 1.

Once you open the project in Eclipse, go to Windows -> Preferences -> Java -> Code Style -> Clean Up, click on "Import" and select the eclipse_code_cleanup file from the directory codingstyle.

Step 2.

Go to Windows -> Preferences -> Java -> Code Style -> Formatter, click on "Import" and select the soot_eclipse_formatter.xml file from the directory codingstyle.

Step 3.

Go to Windows -> Preferences -> Java -> Code Style -> Organize Imports, click on "Import" and select the soot_eclipse_import.importorder file from the directory codingstyle. Change the values in the fields for "Number of imports needed for .* " and "Number of static imports needed for .* " to 999. And click "Apply and close".

Step 4.

In Package Explorer, right click on the directory src/main/java, navigate to Source -> Clean Up and select "Use configured profile" (eclipse-cs soot). Click next to preview the changes and finish to apply them.

Step 5.

Similary, in Package Explorer right click on the directory src/main/java, navigate to Source -> Format.

Step 6.

Just as above, right click on the directory src/main/java, navigate to Source -> Organize Import.


After following the above 6 steps, you can now validate the formatting against the checkstyle configurations by executing Maven Validate.

Formatting is now automatically checked with the checkstyle plugin and violations(if any) are reported.

⚠️ **GitHub.com Fallback** ⚠️