Skip to content

Commit

Permalink
Checkstyle import rules should be consistent with the codebase (gwtpr…
Browse files Browse the repository at this point in the history
…oject#9920)

The old checkstyle was similar but not identical to the Google Java
Style Guide, and it seems that checkstyle updates have changed import
behaviors in a way to make them incompatible with those conventions (but
more compatible with the Google style). These new rules are a close
approximation to the old convention, with a few exceptions, mostly that
imports are all listed at the top. There were also some inconsistencies,
such as grouping jsinterop and javaemul with java packages - those have
been resolved as simply as possible, with checkstyle rules to enforce
this.
  • Loading branch information
niloc132 authored Feb 12, 2024
1 parent 3e84582 commit b5dc7f6
Show file tree
Hide file tree
Showing 71 changed files with 84 additions and 76 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

import com.google.gwt.core.ext.TreeLogger;
import com.google.gwt.core.ext.UnableToCompleteException;

import com.google.gwt.dev.jjs.JJSOptions;
import com.google.gwt.thirdparty.guava.common.base.Joiner;
import com.google.gwt.util.tools.shared.Md5Utils;
Expand Down
1 change: 0 additions & 1 deletion dev/core/src/com/google/gwt/dev/js/JsUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@

import java.util.Collections;
import java.util.List;

import java.util.regex.Pattern;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import com.google.gwt.dev.shell.jetty.JettyLauncherUtils;
import com.google.gwt.dev.shell.jetty.JettyTreeLogger;
import com.google.gwt.dev.shell.jetty.SslConfiguration;

import org.eclipse.jetty.security.ConstraintSecurityHandler;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.ServerConnector;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package com.google.gwt.dev.shell.jetty;

import com.google.gwt.core.ext.TreeLogger;

import org.eclipse.jetty.server.HttpConfiguration;
import org.eclipse.jetty.server.HttpConnectionFactory;
import org.eclipse.jetty.server.SecureRequestCustomizer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package com.google.gwt.dev.shell.jetty;

import com.google.gwt.core.ext.TreeLogger;

import org.eclipse.jetty.util.log.Logger;

/**
Expand Down
1 change: 1 addition & 0 deletions dev/core/test/com/google/gwt/dev/CompilerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import com.google.gwt.thirdparty.guava.common.collect.Sets;
import com.google.gwt.thirdparty.guava.common.io.Files;
import com.google.gwt.util.tools.Utility;

import java.io.File;
import java.io.IOException;
import java.util.Arrays;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import com.google.gwt.dev.jjs.ast.JInterfaceType;
import com.google.gwt.dev.jjs.ast.JProgram;
import com.google.gwt.dev.jjs.ast.JStringLiteral;

import java.util.Arrays;
import java.util.List;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,10 @@
package com.google.gwt.dev.resource.impl;

import com.google.gwt.dev.resource.impl.DefaultFilters.FilterFileType;
import com.google.gwt.thirdparty.apache.ant.types.ZipScanner;

import junit.framework.TestCase;

import com.google.gwt.thirdparty.apache.ant.types.ZipScanner;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
Expand Down
10 changes: 6 additions & 4 deletions eclipse/settings/code-style/gwt-checkstyle-tests.xml
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,12 @@ A more lenient set of style checks for test cases, needed because test often nee
<property name="allowMissingReturnTag" value="true"/>
<property name="tokens" value="METHOD_DEF"/>
</module>
<module name="CustomImportOrder">
<property name="sortImportsInGroupAlphabetically" value="true"/>
<property name="separateLineBetweenGroups" value="true"/>
<property name="customImportOrderRules" value="STATIC###THIRD_PARTY_PACKAGE"/>
<module name="ImportOrder">
<property name="groups" value="/^com\.google\./, /^cern\./, /^com\./, /^junit\./, /^net\./, /^org\./, /^(java|javaemul|jsinterop)\./, /^javax\./" />
<property name="option" value="top" />
<property name="separated" value="true" />
<property name="separatedStaticGroups" value="true" />
<property name="sortStaticImportsAlphabetically" value="true" />
</module>
<module name="DefaultComesLast">
<metadata name="com.atlassw.tools.eclipse.checkstyle.lastEnabledSeverity" value="error"/>
Expand Down
10 changes: 6 additions & 4 deletions eclipse/settings/code-style/gwt-checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,12 @@ Description:
<property name="allowMissingReturnTag" value="true"/>
<property name="tokens" value="METHOD_DEF"/>
</module>
<module name="CustomImportOrder">
<property name="sortImportsInGroupAlphabetically" value="true"/>
<property name="separateLineBetweenGroups" value="true"/>
<property name="customImportOrderRules" value="STATIC###THIRD_PARTY_PACKAGE"/>
<module name="ImportOrder">
<property name="groups" value="/^com\.google\./, /^cern\./, /^com\./, /^junit\./, /^net\./, /^org\./, /^(java|javaemul|jsinterop)\./, /^javax\./" />
<property name="option" value="top" />
<property name="separated" value="true" />
<property name="separatedStaticGroups" value="true" />
<property name="sortStaticImportsAlphabetically" value="true" />
</module>
<module name="DefaultComesLast">
<property name="severity" value="error"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
package com.google.gwt.sample.validation.shared;

import com.google.gwt.sample.validation.server.ServerConstraint;

import com.google.gwt.user.client.rpc.IsSerializable;

import java.util.Map;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,11 @@
import com.google.gwt.dev.util.arg.SourceLevel;
import com.google.gwt.dev.util.log.AbstractTreeLogger;
import com.google.gwt.dev.util.log.PrintWriterTreeLogger;
import com.google.gwt.thirdparty.apache.ant.types.ZipScanner;
import com.google.gwt.util.tools.ArgHandlerFlag;
import com.google.gwt.util.tools.ArgHandlerString;
import com.google.gwt.util.tools.ToolBase;

import com.google.gwt.thirdparty.apache.ant.types.ZipScanner;

import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import com.google.gwt.dev.util.Name;
import com.google.gwt.dev.util.Name.SourceOrBinaryName;
import com.google.gwt.dev.util.Util;

import com.google.web.bindery.event.shared.SimpleEventBus;
import com.google.web.bindery.requestfactory.apt.RfValidator;
import com.google.web.bindery.requestfactory.apt.ValidationTool;
Expand Down
2 changes: 0 additions & 2 deletions user/super/com/google/gwt/emul/java/lang/Boolean.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@
import static javaemul.internal.InternalPreconditions.checkNotNull;

import java.io.Serializable;

import javaemul.internal.JsUtils;

import jsinterop.annotations.JsMethod;

/**
Expand Down
2 changes: 0 additions & 2 deletions user/super/com/google/gwt/emul/java/lang/CharSequence.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@
import java.util.Spliterators;
import java.util.stream.IntStream;
import java.util.stream.StreamSupport;

import javaemul.internal.JsUtils;

import jsinterop.annotations.JsMethod;

/**
Expand Down
1 change: 0 additions & 1 deletion user/super/com/google/gwt/emul/java/lang/Class.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import com.google.gwt.core.client.JavaScriptObject;

import java.lang.reflect.Type;

import javaemul.internal.annotations.DoNotInline;

/**
Expand Down
1 change: 0 additions & 1 deletion user/super/com/google/gwt/emul/java/lang/Comparable.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
package java.lang;

import javaemul.internal.JsUtils;

import jsinterop.annotations.JsMethod;

/**
Expand Down
1 change: 1 addition & 0 deletions user/super/com/google/gwt/emul/java/lang/Enum.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import static javaemul.internal.InternalPreconditions.checkNotNull;

import com.google.gwt.core.client.JavaScriptObject;

import java.io.Serializable;
import jsinterop.annotations.JsIgnore;
import jsinterop.annotations.JsNonNull;
Expand Down
2 changes: 0 additions & 2 deletions user/super/com/google/gwt/emul/java/lang/Throwable.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@

import java.io.PrintStream;
import java.io.Serializable;

import javaemul.internal.annotations.DoNotInline;

import jsinterop.annotations.JsMethod;
import jsinterop.annotations.JsNonNull;
import jsinterop.annotations.JsPackage;
Expand Down
1 change: 0 additions & 1 deletion user/super/com/google/gwt/emul/java/math/MathContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
import static javaemul.internal.InternalPreconditions.checkNotNull;

import java.io.Serializable;

import javaemul.internal.NativeRegExp;

/**
Expand Down
1 change: 0 additions & 1 deletion user/super/com/google/gwt/emul/java/util/Collection.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import java.util.function.Predicate;
import java.util.stream.Stream;
import java.util.stream.StreamSupport;

import jsinterop.annotations.JsIgnore;
import jsinterop.annotations.JsType;

Expand Down
1 change: 0 additions & 1 deletion user/super/com/google/gwt/emul/java/util/Collections.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import java.io.Serializable;
import java.util.function.Predicate;
import java.util.function.UnaryOperator;

import jsinterop.annotations.JsNonNull;

/**
Expand Down
1 change: 0 additions & 1 deletion user/super/com/google/gwt/emul/java/util/Date.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
package java.util;

import java.io.Serializable;

import jsinterop.annotations.JsPackage;
import jsinterop.annotations.JsType;

Expand Down
3 changes: 1 addition & 2 deletions user/super/com/google/gwt/emul/java/util/List.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,8 @@
import static javaemul.internal.InternalPreconditions.checkNotNull;

import java.util.function.UnaryOperator;
import javaemul.internal.ArrayHelper;
import java.util.stream.Collectors;

import javaemul.internal.ArrayHelper;
import jsinterop.annotations.JsIgnore;
import jsinterop.annotations.JsMethod;
import jsinterop.annotations.JsNonNull;
Expand Down
1 change: 0 additions & 1 deletion user/super/com/google/gwt/emul/java/util/Map.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import java.util.function.BiFunction;
import java.util.function.Function;
import java.util.stream.Collectors;

import jsinterop.annotations.JsIgnore;
import jsinterop.annotations.JsNonNull;
import jsinterop.annotations.JsType;
Expand Down
1 change: 0 additions & 1 deletion user/super/com/google/gwt/emul/java/util/Set.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import static javaemul.internal.InternalPreconditions.checkNotNull;

import java.util.stream.Collectors;

import jsinterop.annotations.JsIgnore;
import jsinterop.annotations.JsType;

Expand Down
1 change: 0 additions & 1 deletion user/super/com/google/gwt/emul/java/util/Vector.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import java.util.function.Consumer;
import java.util.function.Predicate;
import java.util.function.UnaryOperator;

import jsinterop.annotations.JsNonNull;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
*/
package java.util.function;

import java.util.Comparator;

import static javaemul.internal.InternalPreconditions.checkCriticalNotNull;

import java.util.Comparator;

/**
* See <a href="https://docs.oracle.com/javase/8/docs/api/java/util/function/BinaryOperator.html">
* the official Java API doc</a> for details.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
*/
package java.util.function;

import java.util.Objects;

import static javaemul.internal.InternalPreconditions.checkCriticalNotNull;

import java.util.Objects;

/**
* See <a href="https://docs.oracle.com/javase/8/docs/api/java/util/function/Predicate.html">
* the official Java API doc</a> for details.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public void testJavaLineNumbers() {
String[] methodNames = getTraceJava();

StackTraceElement[] expectedTrace = new StackTraceElement[] {
createSTE(methodNames[0], "Throwable.java", 68),
createSTE(methodNames[0], "Throwable.java", 66),
createSTE(methodNames[1], "Exception.java", 29),
createSTE(methodNames[2], "StackTraceExamples.java", 57),
createSTE(methodNames[3], "StackTraceExamples.java", 52),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
*/
package com.google.gwt.core.interop;


import jsinterop.annotations.JsProperty;
import jsinterop.annotations.JsType;

Expand Down
1 change: 0 additions & 1 deletion user/test/com/google/gwt/core/interop/JsTypeTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import com.google.gwt.junit.client.GWTTestCase;

import java.util.Iterator;

import jsinterop.annotations.JsFunction;
import jsinterop.annotations.JsMethod;
import jsinterop.annotations.JsPackage;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import com.google.gwt.junit.Platform;

import java.util.Random;

import jsinterop.annotations.JsPackage;
import jsinterop.annotations.JsType;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import com.google.gwt.junit.Platform;

import javaemul.internal.annotations.UncheckedCast;

import jsinterop.annotations.JsPackage;
import jsinterop.annotations.JsType;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javaemul.internal.annotations.DoNotInline;
import jsinterop.annotations.JsMethod;
import jsinterop.annotations.JsOverlay;
Expand Down
1 change: 1 addition & 0 deletions user/test/com/google/gwt/emultest/CollectionsSuite.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import com.google.gwt.emultest.java.util.TreeSetIntegerTest;
import com.google.gwt.emultest.java.util.TreeSetIntegerWithComparatorTest;
import com.google.gwt.emultest.java.util.VectorTest;

import org.junit.runner.RunWith;
import org.junit.runners.Suite;
import org.junit.runners.Suite.SuiteClasses;
Expand Down
5 changes: 3 additions & 2 deletions user/test/com/google/gwt/emultest/EmulJava10Suite.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,15 @@
*/
package com.google.gwt.emultest;

import com.google.gwt.emultest.java10.util.ListTest;
import com.google.gwt.emultest.java10.util.MapTest;
import com.google.gwt.emultest.java10.util.OptionalDoubleTest;
import com.google.gwt.emultest.java10.util.OptionalIntTest;
import com.google.gwt.emultest.java10.util.OptionalLongTest;
import com.google.gwt.emultest.java10.util.OptionalTest;
import com.google.gwt.emultest.java10.util.ListTest;
import com.google.gwt.emultest.java10.util.MapTest;
import com.google.gwt.emultest.java10.util.SetTest;
import com.google.gwt.emultest.java10.util.stream.CollectorsTest;

import org.junit.runner.RunWith;
import org.junit.runners.Suite;
import org.junit.runners.Suite.SuiteClasses;
Expand Down
1 change: 1 addition & 0 deletions user/test/com/google/gwt/emultest/EmulJava11Suite.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import com.google.gwt.emultest.java11.util.OptionalLongTest;
import com.google.gwt.emultest.java11.util.OptionalTest;
import com.google.gwt.emultest.java11.util.function.PredicateTest;

import org.junit.runner.RunWith;
import org.junit.runners.Suite;

Expand Down
11 changes: 6 additions & 5 deletions user/test/com/google/gwt/emultest/EmulJava9Suite.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,19 @@
*/
package com.google.gwt.emultest;

import com.google.gwt.emultest.java9.util.stream.CollectorsTest;
import com.google.gwt.emultest.java9.util.stream.DoubleStreamTest;
import com.google.gwt.emultest.java9.util.stream.IntStreamTest;
import com.google.gwt.emultest.java9.util.stream.LongStreamTest;
import com.google.gwt.emultest.java9.util.stream.StreamTest;
import com.google.gwt.emultest.java9.util.ListTest;
import com.google.gwt.emultest.java9.util.MapTest;
import com.google.gwt.emultest.java9.util.OptionalDoubleTest;
import com.google.gwt.emultest.java9.util.OptionalIntTest;
import com.google.gwt.emultest.java9.util.OptionalLongTest;
import com.google.gwt.emultest.java9.util.OptionalTest;
import com.google.gwt.emultest.java9.util.SetTest;
import com.google.gwt.emultest.java9.util.stream.CollectorsTest;
import com.google.gwt.emultest.java9.util.stream.DoubleStreamTest;
import com.google.gwt.emultest.java9.util.stream.IntStreamTest;
import com.google.gwt.emultest.java9.util.stream.LongStreamTest;
import com.google.gwt.emultest.java9.util.stream.StreamTest;

import org.junit.runner.RunWith;
import org.junit.runners.Suite;
import org.junit.runners.Suite.SuiteClasses;
Expand Down
1 change: 1 addition & 0 deletions user/test/com/google/gwt/emultest/EmulSuite.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
import com.google.gwt.emultest.java.util.DateTest;
import com.google.gwt.emultest.java.util.ObjectsTest;
import com.google.gwt.emultest.java.util.RandomTest;

import org.junit.runner.RunWith;
import org.junit.runners.Suite;
import org.junit.runners.Suite.SuiteClasses;
Expand Down
Loading

0 comments on commit b5dc7f6

Please sign in to comment.