CheckStyle 用到的代码

文件1:check.xml

<project name="checkstyle" default="checkstyle.checkstyle" basedir="../">
    <property file="build/build.properties" />
    <!-- set global properties for this build -->
    <property name="target.dir" value="${basedir}/checkstyle" />
    <property name="version" value="6.13" />
    <property name="checkstyle.dir" value="src/checkstyle/com/puppycrawl/tools/checkstyle" />
    <property name="project" value="sccms" />

    <path id="run.classpath">
        <pathelement location="${target.dir}/checkstyle-${version}-all.jar" />
    </path>
    <path id="project.libs.path">
        <fileset dir="${libs.dir}">
            <include name="**/*.jar" />
        </fileset>
    </path>
    <path id="project.tomcat.path">
        <fileset dir="${tomcat.home}/lib">
            <include name="*.jar" />
        </fileset>
    </path>
    <target name="checkstyle.checkstyle" description="Runs checkstyle against it's own sources">
        <taskdef name="checkstyle" classname="com.puppycrawl.tools.checkstyle.ant.CheckstyleAntTask">
            <classpath refid="run.classpath" />
        </taskdef>
        <delete file="${target.dir}/cachefile" />
        <property name="checkstyle.pattern.todo" value="NOTHingWillMatCH_-" />
        <property name="check.config" location="${target.dir}/chances_checkstyle.xml" />
        <checkstyle config="${check.config}" failOnViolation="false" failureProperty="checkstyle.failure.property">
            <fileset dir="${publishtask.dir}" includes="**/*.java" />
            <fileset dir="${chances.commons.dir}" includes="**/*.java" />
            <fileset dir="${chances.webui.dir}" includes="**/*.java" />
            <fileset dir="${content.dir}" includes="**/*.java" />
            <fileset dir="${template.dir}" includes="**/*.java" />
            <fileset dir="${commons.dir}" includes="**/*.java" />
            <fileset dir="${biz.dir}" includes="**/*.java" />
            <fileset dir="${system.dir}" includes="**/*.java" />
            <fileset dir="${entity.dir}" includes="**/*.java" />
            <fileset dir="${search.dir}" includes="**/*.java" />
            <fileset dir="${collect.dir}" includes="**/*.java" />
            <formatter type="plain" />
            <formatter type="xml" toFile="${target.dir}/checkstyle_${project}.xml" />
            <classpath refid="run.classpath" />
            <classpath refid="project.libs.path" />
            <classpath refid="project.tomcat.path" />
            <property key="checkstyle.cache.file" file="${target.dir}/cachefile" />
            <property key="checkstyle.header.file" file="${target.dir}/java.header" />
            <property key="checkstyle.regexp.header.file" file="${target.dir}/java_regexp.header" />
            <property key="checkstyle.importcontrol.file" file="${target.dir}/import-control.xml" />
            <property key="checkstyle.suppressions.file" file="${target.dir}/suppressions.xml" />
        </checkstyle>
        <xslt in="${target.dir}/checkstyle_${project}.xml" out="${target.dir}/checkstyle_${project}.html" style="${target.dir}/contrib/checkstyle-simple.xsl" />
        <fail if="checkstyle.failure.property" message="Checkstyle failed: ${checkstyle.failure.property}" />
    </target>
</project>

文件2:checkstyle_sccms.xml
其中一个文件检查结果

<?xml version="1.0" encoding="UTF-8"?>
<checkstyle version="6.13">
<file name="D:\workspace\sctv_cms4.0\src\core\publishtask\chances\cms\publish\dao\AbstractEpgDaoImpl.java">
<error line="0" severity="warning" message="File does not end with a newline." source="com.puppycrawl.tools.checkstyle.checks.NewlineAtEndOfFileCheck"/>
<error line="13" severity="warning" message="Wrong order for 'chances.cms.entity.biz.Album' import." source="com.puppycrawl.tools.checkstyle.checks.imports.ImportOrderCheck"/>
<error line="24" severity="warning" message="First sentence should end with a period." source="com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocStyleCheck"/>
<error line="36" column="29" severity="warning" message="Variable 'epgDaoFactory' must be private and have accessor methods." source="com.puppycrawl.tools.checkstyle.checks.design.VisibilityModifierCheck"/>
<error line="39" column="22" severity="warning" message="Variable 'cmsDao' must be private and have accessor methods." source="com.puppycrawl.tools.checkstyle.checks.design.VisibilityModifierCheck"/>
<error line="42" column="26" severity="warning" message="Variable 'previewSqlSession' must be private and have accessor methods." source="com.puppycrawl.tools.checkstyle.checks.design.VisibilityModifierCheck"/>
<error line="44" column="26" severity="warning" message="Variable 'releaseSqlSession' must be private and have accessor methods." source="com.puppycrawl.tools.checkstyle.checks.design.VisibilityModifierCheck"/>
<error line="46" column="36" severity="warning" message="Variable 'publishableValidator' must be private and have accessor methods." source="com.puppycrawl.tools.checkstyle.checks.design.VisibilityModifierCheck"/>
<error line="48" severity="warning" message="First sentence should end with a period." source="com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocStyleCheck"/>
<error line="56" severity="warning" message="Expected an @return tag." source="com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocMethodCheck"/>
<error line="56" column="74" severity="warning" message="Expected @param tag for 'task'." source="com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocMethodCheck"/>
<error line="57" column="30" severity="warning" message="Expected @param tag for 'taskItem'." source="com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocMethodCheck"/>
<error line="58" column="32" severity="warning" message="Expected @param tag for 'client'." source="com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocMethodCheck"/>
<error line="60" severity="warning" message="First sentence should end with a period." source="com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocStyleCheck"/>
<error line="67" severity="warning" message="Expected an @return tag." source="com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocMethodCheck"/>
<error line="67" column="57" severity="warning" message="Parameter contentCode should be final." source="com.puppycrawl.tools.checkstyle.checks.FinalParametersCheck"/>
<error line="67" column="64" severity="warning" message="Expected @param tag for 'contentCode'." source="com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocMethodCheck"/>
<error line="68" column="29" severity="warning" message="Variable 'ibatisContexts' should be declared final." source="com.puppycrawl.tools.checkstyle.checks.coding.FinalLocalVariableCheck"/>
<error line="73" severity="warning" message="First sentence should end with a period." source="com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocStyleCheck"/>
<error line="81" severity="warning" message="Expected an @return tag." source="com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocMethodCheck"/>
<error line="81" column="54" severity="warning" message="Parameter task should be final." source="com.puppycrawl.tools.checkstyle.checks.FinalParametersCheck"/>
<error line="81" column="66" severity="warning" message="Expected @param tag for 'task'." source="com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocMethodCheck"/>
<error line="82" column="21" severity="warning" message="Parameter taskItem should be final." source="com.puppycrawl.tools.checkstyle.checks.FinalParametersCheck"/>
<error line="82" column="30" severity="warning" message="Expected @param tag for 'taskItem'." source="com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocMethodCheck"/>
<error line="83" column="21" severity="warning" message="Parameter client should be final." source="com.puppycrawl.tools.checkstyle.checks.FinalParametersCheck"/>
<error line="83" column="32" severity="warning" message="Expected @param tag for 'client'." source="com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocMethodCheck"/>
<error line="87" severity="warning" message="First sentence should end with a period." source="com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocStyleCheck"/>
<error line="95" severity="warning" message="Expected an @return tag." source="com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocMethodCheck"/>
<error line="95" column="75" severity="warning" message="Expected @param tag for 'task'." source="com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocMethodCheck"/>
<error line="96" column="30" severity="warning" message="Expected @param tag for 'taskItem'." source="com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocMethodCheck"/>
<error line="97" column="32" severity="warning" message="Expected @param tag for 'client'." source="com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocMethodCheck"/>
<error line="99" severity="warning" message="First sentence should end with a period." source="com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocStyleCheck"/>
<error line="107" severity="warning" message="Expected an @return tag." source="com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocMethodCheck"/>
<error line="108" column="21" severity="warning" message="Parameter contentCode should be final." source="com.puppycrawl.tools.checkstyle.checks.FinalParametersCheck"/>
<error line="108" column="28" severity="warning" message="Expected @param tag for 'contentCode'." source="com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocMethodCheck"/>
<error line="109" column="21" severity="warning" message="Parameter contentType should be final." source="com.puppycrawl.tools.checkstyle.checks.FinalParametersCheck"/>
<error line="109" column="28" severity="warning" message="Expected @param tag for 'contentType'." source="com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocMethodCheck"/>
<error line="109" column="41" severity="warning" message="Parameter client should be final." source="com.puppycrawl.tools.checkstyle.checks.FinalParametersCheck"/>
<error line="109" column="52" severity="warning" message="Expected @param tag for 'client'." source="com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocMethodCheck"/>
<error line="110" column="21" severity="warning" message="Parameter publish2Release should be final." source="com.puppycrawl.tools.checkstyle.checks.FinalParametersCheck"/>
<error line="110" column="29" severity="warning" message="Expected @param tag for 'publish2Release'." source="com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocMethodCheck"/>
<error line="111" column="29" severity="warning" message="Variable 'ibatisContexts' should be declared final." source="com.puppycrawl.tools.checkstyle.checks.coding.FinalLocalVariableCheck"/>
<error line="116" column="16" severity="warning" message="Variable 'dao' should be declared final." source="com.puppycrawl.tools.checkstyle.checks.coding.FinalLocalVariableCheck"/>
<error line="117" column="28" severity="warning" message="Variable 'daoImpl' should be declared final." source="com.puppycrawl.tools.checkstyle.checks.coding.FinalLocalVariableCheck"/>
<error line="118" column="21" severity="warning" message="Variable 'task' should be declared final." source="com.puppycrawl.tools.checkstyle.checks.coding.FinalLocalVariableCheck"/>
<error line="124" column="5" severity="warning" message="Missing a Javadoc comment." source="com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocMethodCheck"/>
<error line="124" column="26" severity="warning" message="Parameter client should be final." source="com.puppycrawl.tools.checkstyle.checks.FinalParametersCheck"/>
<error line="124" column="45" severity="warning" message="Parameter contexts should be final." source="com.puppycrawl.tools.checkstyle.checks.FinalParametersCheck"/>
<error line="132" column="39" severity="warning" message="The String " object:" appears 2 times in the file." source="com.puppycrawl.tools.checkstyle.checks.coding.MultipleStringLiteralsCheck"/>
<error line="137" severity="warning" message="Line is longer than 80 characters (found 81)." source="com.puppycrawl.tools.checkstyle.checks.sizes.LineLengthCheck"/>
<error line="150" severity="warning" message="First sentence should end with a period." source="com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocStyleCheck"/>
<error line="155" column="25" severity="warning" message="Parameter contexts should be final." source="com.puppycrawl.tools.checkstyle.checks.FinalParametersCheck"/>
<error line="155" column="45" severity="warning" message="Expected @param tag for 'contexts'." source="com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocMethodCheck"/>
<error line="156" column="28" severity="warning" message="Variable 'result' should be declared final." source="com.puppycrawl.tools.checkstyle.checks.coding.FinalLocalVariableCheck"/>
<error line="169" column="5" severity="warning" message="Missing a Javadoc comment." source="com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocMethodCheck"/>
<error line="169" column="31" severity="warning" message="Parameter objType should be final." source="com.puppycrawl.tools.checkstyle.checks.FinalParametersCheck"/>
<error line="170" column="18" severity="warning" message="Variable 'needPublishs' should be declared final." source="com.puppycrawl.tools.checkstyle.checks.coding.FinalLocalVariableCheck"/>
<error line="171" severity="warning" message="'array initialization' child have incorrect indentation level 24, expected level should be one of the following: 12, 46, 49." source="com.puppycrawl.tools.checkstyle.checks.indentation.IndentationCheck"/>
<error line="172" severity="warning" message="'array initialization' child have incorrect indentation level 24, expected level should be one of the following: 12, 46, 49." source="com.puppycrawl.tools.checkstyle.checks.indentation.IndentationCheck"/>
<error line="173" severity="warning" message="'array initialization' child have incorrect indentation level 24, expected level should be one of the following: 12, 46, 49." source="com.puppycrawl.tools.checkstyle.checks.indentation.IndentationCheck"/>
<error line="174" severity="warning" message="'array initialization' child have incorrect indentation level 24, expected level should be one of the following: 12, 46, 49." source="com.puppycrawl.tools.checkstyle.checks.indentation.IndentationCheck"/>
<error line="175" severity="warning" message="'array initialization' child have incorrect indentation level 24, expected level should be one of the following: 12, 46, 49." source="com.puppycrawl.tools.checkstyle.checks.indentation.IndentationCheck"/>
<error line="175" severity="warning" message="Array should contain trailing comma." source="com.puppycrawl.tools.checkstyle.checks.coding.ArrayTrailingCommaCheck"/>
<error line="179" column="34" severity="warning" message="The String "objType:" appears 2 times in the file." source="com.puppycrawl.tools.checkstyle.checks.coding.MultipleStringLiteralsCheck"/>
<error line="190" column="5" severity="warning" message="Missing a Javadoc comment." source="com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocMethodCheck"/>
<error line="190" column="5" severity="warning" message="Return count is 8 (max allowed is 3)." source="com.puppycrawl.tools.checkstyle.checks.coding.ReturnCountCheck"/>
<error line="190" column="32" severity="warning" message="Parameter code should be final." source="com.puppycrawl.tools.checkstyle.checks.FinalParametersCheck"/>
<error line="190" column="45" severity="warning" message="Parameter type should be final." source="com.puppycrawl.tools.checkstyle.checks.FinalParametersCheck"/>
<error line="198" column="19" severity="warning" message="Variable 'album' should be declared final." source="com.puppycrawl.tools.checkstyle.checks.coding.FinalLocalVariableCheck"/>
<error line="201" column="21" severity="warning" message="Variable 'channel' should be declared final." source="com.puppycrawl.tools.checkstyle.checks.coding.FinalLocalVariableCheck"/>
<error line="204" column="22" severity="warning" message="Variable 'schedule' should be declared final." source="com.puppycrawl.tools.checkstyle.checks.coding.FinalLocalVariableCheck"/>
<error line="207" column="20" severity="warning" message="Variable 'series' should be declared final." source="com.puppycrawl.tools.checkstyle.checks.coding.FinalLocalVariableCheck"/>
<error line="210" column="21" severity="warning" message="Variable 'subject' should be declared final." source="com.puppycrawl.tools.checkstyle.checks.coding.FinalLocalVariableCheck"/>
<error line="213" column="21" severity="warning" message="Variable 'pro' should be declared final." source="com.puppycrawl.tools.checkstyle.checks.coding.FinalLocalVariableCheck"/>
<error line="220" column="5" severity="warning" message="Missing a Javadoc comment." source="com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocMethodCheck"/>
<error line="220" column="26" severity="warning" message="Parameter task should be final." source="com.puppycrawl.tools.checkstyle.checks.FinalParametersCheck"/>
<error line="220" column="44" severity="warning" message="Parameter taskItems should be final." source="com.puppycrawl.tools.checkstyle.checks.FinalParametersCheck"/>
<error line="221" column="21" severity="warning" message="Parameter client should be final." source="com.puppycrawl.tools.checkstyle.checks.FinalParametersCheck"/>
<error line="228" column="29" severity="warning" message="Variable 'contexts' should be declared final." source="com.puppycrawl.tools.checkstyle.checks.coding.FinalLocalVariableCheck"/>
<error line="238" severity="warning" message="Line is longer than 80 characters (found 82)." source="com.puppycrawl.tools.checkstyle.checks.sizes.LineLengthCheck"/>
<error line="247" severity="warning" message="Line is longer than 80 characters (found 83)." source="com.puppycrawl.tools.checkstyle.checks.sizes.LineLengthCheck"/>
<error line="260" column="27" severity="warning" message="Parameter task should be final." source="com.puppycrawl.tools.checkstyle.checks.FinalParametersCheck"/>
<error line="260" column="45" severity="warning" message="Parameter taskItems should be final." source="com.puppycrawl.tools.checkstyle.checks.FinalParametersCheck"/>
<error line="269" column="31" severity="warning" message="Parameter task should be final." source="com.puppycrawl.tools.checkstyle.checks.FinalParametersCheck"/>
<error line="269" column="49" severity="warning" message="Parameter taskItems should be final." source="com.puppycrawl.tools.checkstyle.checks.FinalParametersCheck"/>
</file>
</checkstyle>

文件3:解析代码

CheckStyleErrorParse.java

package chances.com.cn.dom4j;

import java.io.IOException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;

import org.apache.commons.digester3.Digester;
import org.xml.sax.SAXException;

import chances.com.cn.dom4j.entity.CheckFile;
import chances.com.cn.dom4j.entity.CheckStyle;
import chances.com.cn.dom4j.entity.FileError;

import com.mysql.jdbc.PreparedStatement;

public class CheckStyleErrorParse {

    public static final String TABLE_NAME = "checkstyle_error";
    public static final String ID = "id";
    public static final String FILENAME = "file_name";
    public static final String COLUMN = "ccolumn";
    public static final String LINE = "line";
    public static final String SEVERITY = "severity";
    public static final String MESSAGE = "message";
    public static final String SOURCE = "source";
    public static final String PROJECT = "project";
    public static final String PROJECT_NAME = "sccms";

    public static Connection conn = null;
    public static Statement stmt = null;

    private static final String INSERT_SQL = "insert into " + TABLE_NAME + "("
                    + FILENAME + "," + COLUMN + "," + LINE + "," + SEVERITY
                    + ","+ MESSAGE + "," + SOURCE + "," + PROJECT
                    + ")values(?,?,?,?,?,?,?)";

    public static void main(String[] args) throws IOException, SAXException {
        Digester digester = new Digester();

        String checkstyle = "checkstyle";
        String checkFile = checkstyle + "/file";
        String Error = checkFile + "/error";

        // 设置解析规则
        digester.setValidating(false);
        digester.addObjectCreate(checkstyle, CheckStyle.class);
        digester.addSetProperties(checkstyle);
        digester.addObjectCreate(checkFile, CheckFile.class);
        digester.addSetProperties(checkFile);
        digester.addObjectCreate(Error, FileError.class);
        digester.addSetProperties(Error);
        digester.addSetNext(Error, "addFileError");
        digester.addSetNext(checkFile, "addCheckFile");
        try {
            // 解析XML文件,并得到ROOT元素
            CheckStyle checkStyle = (CheckStyle) digester
                            .parse(CheckStyleErrorParse.class
                                            .getResourceAsStream("checkstyle_"
                                                            + PROJECT_NAME
                                                            + ".xml"));

            System.out.println(" CheckStyle 的版本: " + checkStyle.getVersion());
            System.out.println(" 共有多少个文件: "
                            + checkStyle.getCheckFileList().size());
            System.out.println(" ***************************** ");

            Connection conn = getConnection(); // 获取连接
            PreparedStatement stm = (PreparedStatement) conn
                            .prepareStatement(INSERT_SQL);
            for (CheckFile checkFile1 : checkStyle.getCheckFileList()) {
                System.out.println(" 共有多少个错误: "
                                + checkFile1.getFileErrorList().size());

                for (FileError CheckStyleError : checkFile1.getFileErrorList()) {
                    stm.setString(1, checkFile1.getName());
                    stm.setString(2, CheckStyleError.getColumn());
                    stm.setString(3, CheckStyleError.getLine());
                    stm.setString(4, CheckStyleError.getSeverity());
                    stm.setString(5, CheckStyleError.getMessage());
                    stm.setString(6, CheckStyleError.getSource());
                    stm.setString(7, PROJECT_NAME);
                    stm.addBatch();
                }
                stm.executeBatch();
            }
            stm.close(); // 关闭连接
            System.out.println("插入数据库已结束");

        }
        catch (Exception e) {
            e.printStackTrace();
        }
        try {

            conn.close();
        }
        catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

    }

    public static Connection getConnection() {

        try {
            Class.forName("com.mysql.jdbc.Driver").newInstance();
            // 建立到MySQL的连接
            conn = DriverManager.getConnection(
                            "jdbc:mysql://192.168.220.126:3306/qingqian2015",
                            "user",
                            "pwd");
        }
        catch (InstantiationException e2) {
            // TODO Auto-generated catch block
            e2.printStackTrace();
        }
        catch (IllegalAccessException e2) {
            // TODO Auto-generated catch block
            e2.printStackTrace();
        }
        catch (ClassNotFoundException e2) {
            // TODO Auto-generated catch block
            e2.printStackTrace();
        }
        catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        return conn;
    }

}

实体类CheckStyle.java
package chances.com.cn.dom4j.entity;

import java.util.ArrayList;
import java.util.List;

public class CheckStyle {
    private String version;
    private List<CheckFile> checkFileList = new ArrayList<CheckFile>();
    public String getVersion() {
        return version;
    }
    public void setVersion(String version) {
        this.version = version;
    }
    public List<CheckFile> getCheckFileList() {
        return checkFileList;
    }
    
    public void addCheckFile(CheckFile checkFile){
        checkFileList.add(checkFile);
    }
    
}


实体类CheckFile.java
package chances.com.cn.dom4j.entity;

import java.util.ArrayList;
import java.util.List;

public class CheckFile {
    private String name;
    private List<FileError> fileErrorList = new ArrayList<FileError>();

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public List<FileError> getFileErrorList() {
        return fileErrorList;
    }

    public void addFileError(FileError fileError) {
        fileErrorList.add(fileError);
    }
}

实体类FileError.java
package chances.com.cn.dom4j.entity;

public class FileError {
    private String line;
    private String severity;
    private String column;
    private String message;
    private String source;


    public String getLine() {
        return line;
    }

    public void setLine(String line) {
        this.line = line;
    }

    public String getSeverity() {
        return severity;
    }

    public void setSeverity(String severity) {
        this.severity = severity;
    }

    public String getColumn() {
        return column;
    }

    public void setColumn(String column) {
        this.column = column;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public String getSource() {
        return source;
    }

    public void setSource(String source) {
        this.source = source;
    }
}

文件:cleanup.xml

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<profiles version="2">
<profile kind="CleanUpProfile" name="chances" version="2">
<setting id="cleanup.format_source_code" value="true"/>
<setting id="cleanup.add_missing_annotations" value="true"/>
<setting id="cleanup.use_this_for_non_static_method_access_only_if_necessary" value="false"/>
<setting id="cleanup.remove_unused_private_types" value="true"/>
<setting id="cleanup.qualify_static_member_accesses_through_instances_with_declaring_class" value="true"/>
<setting id="cleanup.qualify_static_method_accesses_with_declaring_class" value="false"/>
<setting id="cleanup.add_generated_serial_version_id" value="true"/>
<setting id="cleanup.make_variable_declarations_final" value="true"/>
<setting id="cleanup.add_missing_methods" value="true"/>
<setting id="cleanup.always_use_this_for_non_static_field_access" value="true"/>
<setting id="cleanup.remove_trailing_whitespaces_ignore_empty" value="false"/>
<setting id="cleanup.correct_indentation" value="false"/>
<setting id="cleanup.never_use_parentheses_in_expressions" value="false"/>
<setting id="cleanup.add_serial_version_id" value="true"/>
<setting id="cleanup.remove_unused_private_methods" value="true"/>
<setting id="cleanup.use_this_for_non_static_field_access" value="true"/>
<setting id="cleanup.use_blocks_only_for_return_and_throw" value="false"/>
<setting id="cleanup.remove_unused_private_members" value="false"/>
<setting id="cleanup.add_missing_override_annotations_interface_methods" value="true"/>
<setting id="cleanup.remove_trailing_whitespaces_all" value="true"/>
<setting id="cleanup.make_type_abstract_if_missing_method" value="false"/>
<setting id="cleanup.always_use_this_for_non_static_method_access" value="true"/>
<setting id="cleanup.remove_unnecessary_nls_tags" value="true"/>
<setting id="cleanup.format_source_code_changes_only" value="false"/>
<setting id="cleanup.qualify_static_field_accesses_with_declaring_class" value="false"/>
<setting id="cleanup.add_missing_nls_tags" value="false"/>
<setting id="cleanup.use_this_for_non_static_field_access_only_if_necessary" value="false"/>
<setting id="cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class" value="true"/>
<setting id="cleanup.remove_unnecessary_casts" value="true"/>
<setting id="cleanup.qualify_static_member_accesses_with_declaring_class" value="false"/>
<setting id="cleanup.use_parentheses_in_expressions" value="true"/>
<setting id="cleanup.remove_unused_private_fields" value="true"/>
<setting id="cleanup.make_parameters_final" value="false"/>
<setting id="cleanup.remove_trailing_whitespaces" value="false"/>
<setting id="cleanup.remove_unused_imports" value="true"/>
<setting id="cleanup.organize_imports" value="true"/>
<setting id="cleanup.sort_members" value="true"/>
<setting id="cleanup.remove_private_constructors" value="true"/>
<setting id="cleanup.convert_to_enhanced_for_loop" value="false"/>
<setting id="cleanup.always_use_blocks" value="true"/>
<setting id="cleanup.never_use_blocks" value="false"/>
<setting id="cleanup.always_use_parentheses_in_expressions" value="true"/>
<setting id="cleanup.use_this_for_non_static_method_access" value="true"/>
<setting id="cleanup.remove_unused_local_variables" value="false"/>
<setting id="cleanup.make_private_fields_final" value="true"/>
<setting id="cleanup.add_missing_deprecated_annotations" value="true"/>
<setting id="cleanup.add_default_serial_version_id" value="false"/>
<setting id="cleanup.sort_members_all" value="false"/>
<setting id="cleanup.use_blocks" value="true"/>
<setting id="cleanup.add_missing_override_annotations" value="true"/>
<setting id="cleanup.make_local_variable_final" value="false"/>
</profile>
<profile kind="CleanUpProfile" name="eclipse-cs sctv_cms4.0" version="2">
<setting id="cleanup.format_source_code" value="false"/>
<setting id="cleanup.add_missing_annotations" value="true"/>
<setting id="cleanup.use_this_for_non_static_method_access_only_if_necessary" value="true"/>
<setting id="cleanup.remove_unused_private_types" value="true"/>
<setting id="cleanup.qualify_static_member_accesses_through_instances_with_declaring_class" value="true"/>
<setting id="cleanup.qualify_static_method_accesses_with_declaring_class" value="false"/>
<setting id="cleanup.add_generated_serial_version_id" value="false"/>
<setting id="cleanup.make_variable_declarations_final" value="false"/>
<setting id="cleanup.add_missing_methods" value="false"/>
<setting id="cleanup.always_use_this_for_non_static_field_access" value="false"/>
<setting id="cleanup.remove_trailing_whitespaces_ignore_empty" value="false"/>
<setting id="cleanup.correct_indentation" value="false"/>
<setting id="cleanup.never_use_parentheses_in_expressions" value="true"/>
<setting id="cleanup.add_serial_version_id" value="false"/>
<setting id="cleanup.remove_unused_private_methods" value="true"/>
<setting id="cleanup.use_this_for_non_static_field_access" value="false"/>
<setting id="cleanup.use_blocks_only_for_return_and_throw" value="false"/>
<setting id="cleanup.remove_unused_private_members" value="false"/>
<setting id="cleanup.add_missing_override_annotations_interface_methods" value="true"/>
<setting id="cleanup.remove_trailing_whitespaces_all" value="true"/>
<setting id="cleanup.make_type_abstract_if_missing_method" value="false"/>
<setting id="cleanup.always_use_this_for_non_static_method_access" value="false"/>
<setting id="cleanup.remove_unnecessary_nls_tags" value="true"/>
<setting id="cleanup.format_source_code_changes_only" value="false"/>
<setting id="cleanup.qualify_static_field_accesses_with_declaring_class" value="false"/>
<setting id="cleanup.add_missing_nls_tags" value="false"/>
<setting id="cleanup.use_this_for_non_static_field_access_only_if_necessary" value="true"/>
<setting id="cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class" value="true"/>
<setting id="cleanup.remove_unnecessary_casts" value="true"/>
<setting id="cleanup.qualify_static_member_accesses_with_declaring_class" value="true"/>
<setting id="cleanup.use_parentheses_in_expressions" value="false"/>
<setting id="cleanup.remove_unused_private_fields" value="true"/>
<setting id="cleanup.make_parameters_final" value="false"/>
<setting id="cleanup.remove_trailing_whitespaces" value="false"/>
<setting id="cleanup.remove_unused_imports" value="true"/>
<setting id="cleanup.organize_imports" value="true"/>
<setting id="cleanup.sort_members" value="false"/>
<setting id="cleanup.remove_private_constructors" value="true"/>
<setting id="cleanup.convert_to_enhanced_for_loop" value="false"/>
<setting id="cleanup.always_use_blocks" value="true"/>
<setting id="cleanup.never_use_blocks" value="false"/>
<setting id="cleanup.always_use_parentheses_in_expressions" value="false"/>
<setting id="cleanup.use_this_for_non_static_method_access" value="false"/>
<setting id="cleanup.remove_unused_local_variables" value="false"/>
<setting id="cleanup.make_private_fields_final" value="true"/>
<setting id="cleanup.add_missing_deprecated_annotations" value="true"/>
<setting id="cleanup.add_default_serial_version_id" value="true"/>
<setting id="cleanup.sort_members_all" value="false"/>
<setting id="cleanup.use_blocks" value="true"/>
<setting id="cleanup.add_missing_override_annotations" value="true"/>
<setting id="cleanup.make_local_variable_final" value="true"/>
</profile>
<profile kind="CleanUpProfile" name="eclipse-cs sctv_epg4.0" version="2">
<setting id="cleanup.format_source_code" value="false"/>
<setting id="cleanup.add_missing_annotations" value="true"/>
<setting id="cleanup.use_this_for_non_static_method_access_only_if_necessary" value="true"/>
<setting id="cleanup.remove_unused_private_types" value="true"/>
<setting id="cleanup.qualify_static_member_accesses_through_instances_with_declaring_class" value="true"/>
<setting id="cleanup.qualify_static_method_accesses_with_declaring_class" value="false"/>
<setting id="cleanup.add_generated_serial_version_id" value="false"/>
<setting id="cleanup.make_variable_declarations_final" value="true"/>
<setting id="cleanup.add_missing_methods" value="false"/>
<setting id="cleanup.always_use_this_for_non_static_field_access" value="false"/>
<setting id="cleanup.remove_trailing_whitespaces_ignore_empty" value="false"/>
<setting id="cleanup.correct_indentation" value="false"/>
<setting id="cleanup.never_use_parentheses_in_expressions" value="true"/>
<setting id="cleanup.add_serial_version_id" value="false"/>
<setting id="cleanup.remove_unused_private_methods" value="true"/>
<setting id="cleanup.use_this_for_non_static_field_access" value="false"/>
<setting id="cleanup.use_blocks_only_for_return_and_throw" value="false"/>
<setting id="cleanup.remove_unused_private_members" value="false"/>
<setting id="cleanup.add_missing_override_annotations_interface_methods" value="true"/>
<setting id="cleanup.remove_trailing_whitespaces_all" value="true"/>
<setting id="cleanup.make_type_abstract_if_missing_method" value="false"/>
<setting id="cleanup.always_use_this_for_non_static_method_access" value="false"/>
<setting id="cleanup.remove_unnecessary_nls_tags" value="true"/>
<setting id="cleanup.format_source_code_changes_only" value="false"/>
<setting id="cleanup.qualify_static_field_accesses_with_declaring_class" value="false"/>
<setting id="cleanup.add_missing_nls_tags" value="false"/>
<setting id="cleanup.use_this_for_non_static_field_access_only_if_necessary" value="true"/>
<setting id="cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class" value="true"/>
<setting id="cleanup.remove_unnecessary_casts" value="true"/>
<setting id="cleanup.qualify_static_member_accesses_with_declaring_class" value="true"/>
<setting id="cleanup.use_parentheses_in_expressions" value="false"/>
<setting id="cleanup.remove_unused_private_fields" value="true"/>
<setting id="cleanup.make_parameters_final" value="true"/>
<setting id="cleanup.remove_trailing_whitespaces" value="false"/>
<setting id="cleanup.remove_unused_imports" value="true"/>
<setting id="cleanup.organize_imports" value="true"/>
<setting id="cleanup.sort_members" value="false"/>
<setting id="cleanup.remove_private_constructors" value="true"/>
<setting id="cleanup.convert_to_enhanced_for_loop" value="false"/>
<setting id="cleanup.always_use_blocks" value="true"/>
<setting id="cleanup.never_use_blocks" value="false"/>
<setting id="cleanup.always_use_parentheses_in_expressions" value="false"/>
<setting id="cleanup.use_this_for_non_static_method_access" value="false"/>
<setting id="cleanup.remove_unused_local_variables" value="false"/>
<setting id="cleanup.make_private_fields_final" value="true"/>
<setting id="cleanup.add_missing_deprecated_annotations" value="true"/>
<setting id="cleanup.add_default_serial_version_id" value="true"/>
<setting id="cleanup.sort_members_all" value="false"/>
<setting id="cleanup.use_blocks" value="true"/>
<setting id="cleanup.add_missing_override_annotations" value="true"/>
<setting id="cleanup.make_local_variable_final" value="true"/>
</profile>
</profiles>

文件:codeTemplates.xml

<?xml version="1.0" encoding="UTF-8" standalone="no"?><templates><template autoinsert="true" context="gettercomment_context" deleted="false" description="Comment for getter method" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.gettercomment" name="gettercomment">/**
 * @return the ${bare_field_name}
 */</template><template autoinsert="true" context="settercomment_context" deleted="false" description="Comment for setter method" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.settercomment" name="settercomment">/**
 * @param ${param} the ${bare_field_name} to set
 */</template><template autoinsert="false" context="constructorcomment_context" deleted="false" description="Comment for created constructors" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.constructorcomment" name="constructorcomment">/** 
 * Creates a new instance of ${enclosing_type}. 
 * 
 * ${tags} 
 */ 

</template><template autoinsert="false" context="filecomment_context" deleted="false" description="Comment for created Java files" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.filecomment" name="filecomment">/** 
 * Project Name:${project_name} 
 * File Name:${file_name} 
 * Package Name:${package_name} 
 * Date:${date}${time} 
 * Copyright (c) ${year}, chances.com.cn All Rights Reserved. 
 * 
 */</template><template autoinsert="false" context="typecomment_context" deleted="false" description="Comment for created types" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.typecomment" name="typecomment">/** 
 * ClassName: ${type_name} <br/> 
 * Function: ${todo} ADD FUNCTION. <br/> 
 * Reason: ${todo} ADD REASON(可选). <br/> 
 * date: ${date} ${time} <br/> 
 * 
 * @author ${user} 
 * @version ${enclosing_type}${tags} 
 */  
</template><template autoinsert="false" context="fieldcomment_context" deleted="false" description="Comment for fields" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.fieldcomment" name="fieldcomment">/**
 * ${field}:${todo}(用一句话描述这个变量表示什么). 
 */</template><template autoinsert="false" context="methodcomment_context" deleted="false" description="Comment for non-overriding methods" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.methodcomment" name="methodcomment">/** 
 * ${enclosing_method}:(这里用一句话描述这个方法的作用). <br/> 
 * ${todo}(这里描述这个方法适用条件 – 可选).<br/> 
 * ${todo}(这里描述这个方法的执行流程 – 可选).<br/> 
 * 
 * @author ${user} 
 * ${tags} 
 */
</template><template autoinsert="true" context="overridecomment_context" deleted="false" description="Comment for overriding methods" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.overridecomment" name="overridecomment">/* (non-Javadoc)
 * ${see_to_overridden}
 */</template><template autoinsert="true" context="delegatecomment_context" deleted="false" description="Comment for delegate methods" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.delegatecomment" name="delegatecomment">/**
 * ${tags}
 * ${see_to_target}
 */</template><template autoinsert="false" context="newtype_context" deleted="false" description="Newly created files" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.newtype" name="newtype">/** 
 * Project Name:${project_name} 
 * File Name:${file_name} 
 * Package Name:${package_name} 
 * Date:${date}${time} 
 * Copyright (c) ${year}, chanes.com.cn All Rights Reserved. 
 * 
 */  
${filecomment}  
${package_declaration}  
/** 
 * ClassName:${type_name} <br/> 
 * Function: ${todo} ADD FUNCTION. <br/> 
 * Reason:   ${todo} ADD REASON. <br/> 
 * Date:     ${date} ${time} <br/> 
 * @author   ${user} 
 * @version   
 * @see       
 */  
${typecomment}  
${type_declaration} 
</template><template autoinsert="true" context="classbody_context" deleted="false" description="Code in new class type bodies" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.classbody" name="classbody">
</template><template autoinsert="true" context="interfacebody_context" deleted="false" description="Code in new interface type bodies" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.interfacebody" name="interfacebody">
</template><template autoinsert="true" context="enumbody_context" deleted="false" description="Code in new enum type bodies" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.enumbody" name="enumbody">
</template><template autoinsert="true" context="annotationbody_context" deleted="false" description="Code in new annotation type bodies" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.annotationbody" name="annotationbody">
</template><template autoinsert="true" context="catchblock_context" deleted="false" description="Code in new catch blocks" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.catchblock" name="catchblock">// ${todo} Auto-generated catch block
${exception_var}.printStackTrace();</template><template autoinsert="true" context="methodbody_context" deleted="false" description="Code in created method stubs" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.methodbody" name="methodbody">// ${todo} Auto-generated method stub
${body_statement}</template><template autoinsert="true" context="constructorbody_context" deleted="false" description="Code in created constructor stubs" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.constructorbody" name="constructorbody">${body_statement}
// ${todo} Auto-generated constructor stub</template><template autoinsert="true" context="getterbody_context" deleted="false" description="Code in created getters" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.getterbody" name="getterbody">return ${field};</template><template autoinsert="true" context="setterbody_context" deleted="false" description="Code in created setters" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.setterbody" name="setterbody">${field} = ${param};</template></templates>
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 211,817评论 6 492
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 90,329评论 3 385
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 157,354评论 0 348
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 56,498评论 1 284
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 65,600评论 6 386
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 49,829评论 1 290
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 38,979评论 3 408
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 37,722评论 0 266
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 44,189评论 1 303
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 36,519评论 2 327
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 38,654评论 1 340
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 34,329评论 4 330
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 39,940评论 3 313
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 30,762评论 0 21
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 31,993评论 1 266
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 46,382评论 2 360
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 43,543评论 2 349

推荐阅读更多精彩内容

  • 本文主要介绍以下内容:(1)CheckStyle详细使用(2)如何定制专属CheckStyle检查规则(3)如何定...
    freddyyao阅读 14,781评论 11 16
  • 1 背景 一个项目开发必然会涉及团队协作,而工程质量就需要团队去保证。一般我们期望的代码:无潜在风险、无重复逻辑、...
    zyl06阅读 3,213评论 5 16
  • Spring Cloud为开发人员提供了快速构建分布式系统中一些常见模式的工具(例如配置管理,服务发现,断路器,智...
    卡卡罗2017阅读 134,633评论 18 139
  • 晚上八点篝火晚会开始了,那个本地的老妈妈随着音乐跳起热情的舞蹈,边跳边邀请远道而来的客人们,我们陆陆续续站起来,加...
    诗渝阅读 336评论 0 0
  • 云霞草三寸,寻花待雨辰。 日日青石坐,姗姗寺门行。 公子瑾瑜 《遗爱行》 ...
    通往天上地下阅读 182评论 1 0