Uploaded image for project: 'PUBLIC - Liferay Portal Community Edition'
  1. PUBLIC - Liferay Portal Community Edition
  2. LPS-131887

JavaClassNameCheck duplicates imports if the class is in default the package

Details

    Description

      The Java class in the attached project is in the default package (it has not package declaration). When I run the JavaClassNameCheck Source Formatter check, the class's import list is duplicated.

      Steps

      1. Unzip the attached project
      2. cd project-uses-default-package/
      3. Run
        ./gradlew formatSource

      Output:

      > Task :formatSource
      Scanning for files...
      Initializing checks...
      /home/jhinkey/projects/project-uses-default-java-package/source-formatter-suppressions.xml (SourceCheck:XMLIndentationCheck)
      /home/jhinkey/projects/project-uses-default-java-package/java/DocumentFolder_DELETE_ById.java (JavaParser)
      /home/jhinkey/projects/project-uses-default-java-package/java/DocumentFolder_DELETE_ById.java (SourceCheck:JavaClassNameCheck)
      Processing checks: 7% completed
      

      Actual result:
      The class's import list is duplicated...

      import com.liferay.headless.delivery.client.resource.v1_0.DocumentResource;
      
      import com.liferay.headless.delivery.client.resource.v1_0.DocumentResource;
      
      public class Document_DELETE_ById {
      ...
      

      Expected result:

      The class's source is formatted and its import list is untouched.

      Attachments

        Activity

          People

            michael.saechang Michael Saechang
            james.hinkey James Hinkey (Inactive)
            Kiyoshi Lee Kiyoshi Lee
            Alan Huang Alan Huang
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              1 year, 28 weeks ago

              Packages

                Version Package
                7.4.3.17 CE GA17
                Master