checkstyle / checkstyle

Checkstyle is a development tool to help programmers write Java code that adheres to a coding standard. By default it supports the Google Java Style Guide and Sun Code Conventions, but is highly configurable. It can be invoked with an ANT task and a command line program.
https://checkstyle.org
GNU Lesser General Public License v2.1
8.32k stars 3.67k forks source link

CustomImportOrder: documentation should have description that only one separtor line is allowed #7080

Closed romani closed 5 years ago

romani commented 5 years ago

identified at https://github.com/checkstyle/checkstyle/pull/6830#discussion_r297799608

The documentation says

groups are separated by, at least, one blank line

but it is 'exactly one blank line'.

# config from https://checkstyle.org/config_imports.html#CustomImportOrder_Examples 
# for first 'groups are separated by, at least, one blank line'
$ cat config.xml 
<?xml version="1.0"?>
<!DOCTYPE module PUBLIC
  "-//Checkstyle//DTD Checkstyle Configuration 1.3//EN"
  "https://checkstyle.org/dtds/configuration_1_3.dtd">
<module name="Checker">
  <module name="TreeWalker">
    <module name="CustomImportOrder">
      <property name="customImportOrderRules"
        value="STATIC###STANDARD_JAVA_PACKAGE###SPECIAL_IMPORTS###THIRD_PARTY_PACKAGE"/>
      <property name="specialImportsRegExp" value="^org\."/>
      <property name="thirdPartyPackageRegExp" value="^com\."/>
      <property name="sortImportsInGroupAlphabetically" value="true"/>
      <property name="separateLineBetweenGroups" value="true"/>
    </module>
  </module>
</module>

$ cat Test.java 

package com.example;

import static java.awt.Button.ABORT;

import java.util.Map;

class InputCustomImportOrderSingleLine {}

$ java -jar checkstyle-8.24-all.jar -c config.xml Test.java
Starting audit...
[ERROR] /var/tmp/Test.java:7: 'java.util.Map' should be separated from 
previous import group by one line. [CustomImportOrder]
Audit done.
Checkstyle ends with 1 errors.
romani commented 5 years ago

fix is merged