Uploaded image for project: 'Apache Hudi'
  1. Apache Hudi
  2. HUDI-354

Introduce stricter comment and code style validation rules

    XMLWordPrintableJSON

Details

    • Task
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • None
    • code-quality
    • None

    Description

      This is an umbrella issue used to track apply some stricter comment and code style validation rules for the whole project. The rules list below:

      1. All public classes must add class-level comments;
      2. All comments must end with a clear "."
      3. In the import statement of the class, clearly distinguish (by blank lines) the import of Java SE and the import of non-java SE. Currently, I saw at least two projects(Spark and Flink) that implement this rule. Flink implements stricter rules than Spark. It is divided into several blocks from top to bottom(owner import -> non-owner and non-JavaSE import -> Java SE import -> static import), each block are sorted according to the natural sequence of letters;
      4. Reconfirm the method and whether the comment is consistency;

      Each project sub-module mappings to one subtask.

      How to find all the invalidated points?

      • Add the XML code snippet into PROJECT_ROOT/style/checkstyle.xml
      <module name="TreeWalker">
      
          <!-- add the below modules-->
      
          <!-- JAVADOC CHECKS -->
      <module name="JavadocStyle">
          <property name="severity" value="error"/>
      </module>
      <module name="JavadocType">
          <property name="scope" value="protected"/>
          <property name="severity" value="error"/>
          <property name="allowMissingParamTags" value="true"/>
      </module>
      <module name="ImportOrder">
          <!-- Checks for out of order import statements. -->
          <property name="severity" value="error"/>
          <property name="groups" value="org.apache.hudi,*,javax,java,scala"/>
          <property name="separated" value="true"/>
          <property name="sortStaticImportsAlphabetically" value="true"/>
          <property name="option" value="bottom"/>
          <property name="tokens" value="STATIC_IMPORT, IMPORT"/>
          <message key="import.ordering"
            value="Import {0} appears after other imports that it should precede"/>
      </module>
      <module name="RedundantImport">
          <!-- Checks for redundant import statements. -->
          <property name="severity" value="error"/>
          <message key="import.redundancy"
            value="Redundant import {0}."/>
      </module>
      <module name="AvoidStarImport">
          <property name="severity" value="error"/>
      </module>
      </module>
      •  Make sure you have installed CheckStyle-IDEA plugin and activated for the project.
      • Scan the project module you want to refactor and fix all the issues one by one.

       

      Attachments

        1. Screenshot 2019-11-22 at 5.02.32 PM.png
          24 kB
          Gurudatt Kulkarni
        2. Screenshot 2019-11-22 at 4.58.58 PM.png
          28 kB
          Gurudatt Kulkarni

        Activity

          People

            Unassigned Unassigned
            yanghua vinoyang
            Votes:
            1 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0h
                0h
                Logged:
                Time Spent - 1h 20m
                1h 20m