Skip to content

Commit 0464644

Browse files
committed
Checkstyle: use SuppressWarnings instead of inline comments
1 parent 8d9a7f0 commit 0464644

File tree

32 files changed

+57
-173
lines changed

32 files changed

+57
-173
lines changed

dev/core/src/com/google/gwt/core/linker/CrossSiteIframeLinker.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,6 @@ protected String fillSelectionScriptTemplate(StringBuffer ss, TreeLogger logger,
118118
}
119119
}
120120
if (failIfScriptTags) {
121-
// CHECKSTYLE_OFF
122121
String msg =
123122
"The " + getDescription()
124123
+ " linker does not support <script> tags in the gwt.xml files, but the"
@@ -129,7 +128,6 @@ protected String fillSelectionScriptTemplate(StringBuffer ss, TreeLogger logger,
129128
+ " this error, you will need to remove the script tags from the"
130129
+ " gwt.xml file, or add this property to the gwt.xml file:"
131130
+ " <set-configuration-property name='xsiframe.failIfScriptTag' value='FALSE'/>";
132-
// CHECKSTYLE_ON
133131
logger.log(TreeLogger.ERROR, msg);
134132
throw new UnableToCompleteException();
135133
} else {
@@ -602,6 +600,7 @@ protected void maybeAddHostedModeFile(TreeLogger logger, LinkerContext context,
602600

603601
// Output compilation-mappings.txt
604602
@Override
603+
@SuppressWarnings("checkstyle:SpaceAfterColon")
605604
protected void maybeOutputPropertyMap(TreeLogger logger, LinkerContext context,
606605
ArtifactSet toReturn) {
607606
if (permutationsUtil.getPermutationsMap() == null
@@ -617,9 +616,7 @@ protected void maybeOutputPropertyMap(TreeLogger logger, LinkerContext context,
617616
EmittedArtifact serializedMap;
618617
try {
619618
String mappings = mappingArtifact.getSerialized();
620-
// CHECKSTYLE_OFF
621619
mappings = mappings.concat("Devmode:" + getHostedFilename());
622-
// CHECKSTYLE_ON
623620
serializedMap = emitString(logger, mappings, "compilation-mappings.txt");
624621
// TODO(unnurg): make this Deploy
625622
serializedMap.setVisibility(Visibility.Public);
@@ -682,7 +679,6 @@ protected String wrapPrimaryFragment(TreeLogger logger, LinkerContext context, S
682679
out.append("if (" + context.getModuleFunctionName() + ".succeeded) {\n");
683680
}
684681

685-
686682
if (shouldInstallCode(context)) {
687683
// Rewrite the code so it can be installed with
688684
// __MODULE_FUNC__.onScriptDownloaded

dev/core/src/com/google/gwt/dev/cfg/ModuleDefSchema.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,10 @@
4343

4444
import javax.lang.model.SourceVersion;
4545

46-
// CHECKSTYLE_NAMING_OFF
47-
4846
/**
4947
* Configures a module definition object using XML.
5048
*/
49+
@SuppressWarnings({"checkstyle:MemberName", "checkstyle:MethodName"})
5150
public class ModuleDefSchema extends Schema {
5251

5352
private final class BodySchema extends Schema {
@@ -299,7 +298,7 @@ protected Schema __collapse_property_begin(PropertyName name,
299298
return null;
300299
}
301300

302-
@SuppressWarnings("unused") // called reflectively
301+
@SuppressWarnings({"unused", "checkstyle:ParameterName"}) // called reflectively
303302
protected Schema __define_configuration_property_begin(PropertyName name,
304303
String is_multi_valued) throws UnableToCompleteException {
305304
boolean isMultiValued = toPrimitiveBoolean(is_multi_valued);
@@ -1513,4 +1512,3 @@ private JsFunction parseJsBlock(int startLineNumber, String script)
15131512
return fn;
15141513
}
15151514
}
1516-
// CHECKSTYLE_NAMING_ON

dev/core/src/com/google/gwt/dev/jjs/impl/MethodInliner.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -439,9 +439,8 @@ private InlineResult tryInlineBody(JMethodCall x, Context ctx,
439439
return InlineResult.DO_NOT_BLACKLIST;
440440
}
441441
}
442-
// CHECKSTYLE_OFF: Fall through!
442+
// fall through!
443443
case CORRECT_ORDER:
444-
// CHECKSTYLE_ON
445444
default:
446445
if (!x.hasSideEffects()) {
447446
markCallsAsSideEffectFree(bodyAsExpressionList);

dev/core/src/com/google/gwt/dev/js/JsToStringGenerationVisitor.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@
8484
/**
8585
* Produces text output from a JavaScript AST.
8686
*/
87+
@SuppressWarnings("checkstyle:MethodName")
8788
public class JsToStringGenerationVisitor extends JsVisitor {
8889

8990
private static final char[] CHARS_BREAK = "break".toCharArray();
@@ -888,8 +889,6 @@ public boolean visit(JsWhile x, JsContext ctx) {
888889
return false;
889890
}
890891

891-
//CHECKSTYLE_NAMING_OFF
892-
893892
protected void _newline() {
894893
p.newline();
895894
}
@@ -1308,8 +1307,6 @@ private void _while() {
13081307
p.print(CHARS_WHILE);
13091308
}
13101309

1311-
// CHECKSTYLE_NAMING_ON
1312-
13131310
private void indent() {
13141311
p.indentIn();
13151312
}

dev/core/src/com/google/gwt/soyc/MakeTopLevelHtmlForPerm.java

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
/**
5050
* A utility to make all the HTML files for one permutation.
5151
*/
52+
@SuppressWarnings("checkstyle:SpaceAfterColon")
5253
public class MakeTopLevelHtmlForPerm {
5354
/**
5455
* A dependency linker for the initial code download. It links to the
@@ -376,7 +377,8 @@ private void printInternedDataAsJs(PrintWriter outFile) {
376377
+ "See why it's live</a></li>\");");
377378
outFile.println(" for (var sp = 1; sp <= "
378379
+ globalInformation.getNumFragments() + "; sp++) {");
379-
outFile.println(" var d2 = 'methodDependencies-sp' + sp + '-" + getPermutationId() + ".html';");
380+
outFile.println(" var d2 = 'methodDependencies-sp' + sp + '-"
381+
+ getPermutationId() + ".html';");
380382
outFile.println(" document.write(\"<li><a href='\" + d2 + \"#\" + className +\"'>"
381383
+ " See why it's not exclusive to s.p. #\" + sp + \" (\" + spl[sp - 1] + \")"
382384
+ "</a></li>\");");
@@ -786,10 +788,8 @@ public void makeCodeTypeClassesHtmls(SizeBreakdown breakdown)
786788
outFile.println("<td>" + className + "</a></td>");
787789
outFile.println("<td class=\"soyc-bargraph-col\">");
788790
outFile.println("<div class=\"soyc-bar-graph goog-inline-block\">");
789-
// CHECKSTYLE_OFF
790791
outFile.println("<div style=\"width:" + (perc * 100.0)
791792
+ "%;\" class=\"soyc-bar-graph-fill goog-inline-block\"></div>");
792-
// CHECKSTYLE_ON
793793
outFile.println("</div>");
794794
outFile.println("</td>");
795795
outFile.println("<td class=\"soyc-numerical-col\">");
@@ -1137,10 +1137,8 @@ public void makePackageClassesHtmls(SizeBreakdown breakdown,
11371137
}
11381138
outFile.println("<td class=\"soyc-bargraph-col\">");
11391139
outFile.println("<div class=\"soyc-bar-graph goog-inline-block\">");
1140-
// CHECKSTYLE_OFF
11411140
outFile.println("<div style=\"width:" + (perc * 100.0)
11421141
+ "%;\" class=\"soyc-bar-graph-fill goog-inline-block\"></div>");
1143-
// CHECKSTYLE_ON
11441142
outFile.println("</div>");
11451143
outFile.println("</td>");
11461144
outFile.println("<td class=\"soyc-numerical-col\">");
@@ -1314,10 +1312,8 @@ public void makeTopLevelShell() throws IOException {
13141312
+ "</a></td>");
13151313
outFile.println("<td class=\"soyc-bargraph-col\">");
13161314
outFile.println("<div class=\"soyc-bar-graph goog-inline-block\">");
1317-
// CHECKSTYLE_OFF
13181315
outFile.println("<div style=\"width:" + (perc * 100.0)
13191316
+ "%;\" class=\"soyc-bar-graph-fill goog-inline-block\"></div>");
1320-
// CHECKSTYLE_ON
13211317
outFile.println("</div>");
13221318
outFile.println("</td>");
13231319
outFile.println("<td class=\"soyc-numerical-col\">");
@@ -1391,7 +1387,8 @@ private String getPermutationId() {
13911387
private String[] getUnreferencedTypes(
13921388
PrecompilationMetricsArtifact precompilationMetrics) {
13931389
List<String> astTypes = Lists.newArrayList(precompilationMetrics.getAstTypes());
1394-
Set<String> unreferencedTypes = Sets.newHashSet(precompilationMetrics.getFinalTypeOracleTypes());
1390+
Set<String> unreferencedTypes = Sets.newHashSet(
1391+
precompilationMetrics.getFinalTypeOracleTypes());
13951392
unreferencedTypes.removeAll(astTypes);
13961393
String[] results = unreferencedTypes.toArray(new String[unreferencedTypes.size()]);
13971394
Arrays.sort(results);
@@ -1515,10 +1512,8 @@ private String makeCodeTypeHtml(SizeBreakdown breakdown,
15151512
+ "\" target=\"_top\">" + codeType + "</a></td>");
15161513
outFile.println("<td class=\"soyc-bargraph-col\">");
15171514
outFile.println("<div class=\"soyc-bar-graph goog-inline-block\">");
1518-
// CHECKSTYLE_OFF
15191515
outFile.println("<div style=\"width:" + (perc * 100.0)
15201516
+ "%;\" class=\"soyc-bar-graph-fill goog-inline-block\"></div>");
1521-
// CHECKSTYLE_ON
15221517
outFile.println("</div>");
15231518
outFile.println("</td>");
15241519
outFile.println("<td class=\"soyc-numerical-col\">");
@@ -1814,10 +1809,8 @@ private String makePackageHtml(SizeBreakdown breakdown) throws IOException {
18141809
+ "\" target=\"_top\">" + packageName + "</a></td>");
18151810
outFile.println("<td class=\"soyc-bargraph-col\">");
18161811
outFile.println("<div class=\"soyc-bar-graph goog-inline-block\">");
1817-
// CHECKSTYLE_OFF
18181812
outFile.println("<div style=\"width:" + (perc * 100.0)
18191813
+ "%;\" class=\"soyc-bar-graph-fill goog-inline-block\"></div>");
1820-
// CHECKSTYLE_ON
18211814
outFile.println("</div>");
18221815
outFile.println("</td>");
18231816
outFile.println("<td class=\"soyc-numerical-col\">");

dev/core/super/com/google/gwt/dev/jjs/intrinsic/com/google/gwt/lang/Cast.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,14 @@
2121

2222
import javaemul.internal.annotations.HasNoSideEffects;
2323

24-
// CHECKSTYLE_NAMING_OFF: Uses legacy conventions of underscore prefixes.
25-
2624
/**
2725
* This is a magic class the compiler uses to perform any cast operations that require code.<br />
2826
*
2927
* The cast operations are only as accurate as the contents of the castableTypeMaps and should not
3028
* be used directly by user code. The compiler takes care to record most cast operations in user
3129
* code so that it can build limited but accurate castableTypeMaps.
3230
*/
31+
@SuppressWarnings("checkstyle:MethodName")
3332
final class Cast {
3433

3534
/**
@@ -393,5 +392,3 @@ static native Class<?> getClass(Object array) /*-{
393392
|| @JavaScriptObject::class;
394393
}-*/;
395394
}
396-
397-
// CHECKSTYLE_NAMING_ON

dev/core/super/com/google/gwt/dev/jjs/intrinsic/com/google/gwt/lang/Exceptions.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
/**
2424
* This is a magic class the compiler uses to throw and check exceptions.
2525
*/
26+
@SuppressWarnings("checkstyle:MethodName")
2627
final class Exceptions {
2728

2829
@DoNotInline // This frame can be useful in understanding the native stack
@@ -59,7 +60,6 @@ static AssertionError makeAssertionError() {
5960
* We use nonstandard naming here so it's easy for the compiler to map to
6061
* method names based on primitive type name.
6162
*/
62-
// CHECKSTYLE_OFF
6363
static AssertionError makeAssertionError_boolean(boolean message) {
6464
return new AssertionError(message);
6565
}
@@ -131,5 +131,4 @@ static Throwable safeClose(AutoCloseable resource, Throwable mainException) {
131131
}
132132
return mainException;
133133
}
134-
// CHECKSTYLE_ON
135134
}

eclipse/settings/code-style/gwt-checkstyle-tests.xml

Lines changed: 5 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ A more lenient set of style checks for test cases, needed because test often nee
1111
<module name="Checker">
1212
<property name="severity" value="warning"/>
1313
<module name="RegexpHeader">
14-
<property name="fileExtensions" value="java"/>
14+
<property name="fileExtensions" value="java"/>
1515
<property name="severity" value="error"/>
1616
<property name="header" value="^/\*[ ]*$\n^ \* Copyright 20(0[6789]|[12][0-9]) (Google Inc\.|GWT Project Authors)$\n^ \*[ ]*$\n^ \* Licensed under the Apache License, Version 2\.0 \(the &quot;License&quot;\); you may not( use this file except)?$\n^ \* (use this file except )?in compliance with the License\. You may obtain a copy of( the License at)?$\n^ \* the License at$\n^ \*[ ]*$\n^ \* http://www\.apache\.org/licenses/LICENSE-2\.0$\n^ \*[ ]*\n \* Unless required by applicable law or agreed to in writing, software( distributed under the License)?$\n^ \* (distributed under the License )?is distributed on an &quot;AS IS&quot; BASIS, WITHOUT( WARRANTIES OR CONDITIONS OF ANY KIND, either express)?$\n^ \* (WARRANTIES OR CONDITIONS OF ANY KIND, either express )?or implied\. See the( License for the specific language governing permissions and limitations under)?$\n^ \* License for the specific language governing permissions and limitations under$\n^ \* the License\.$\n^ \*/$"/>
1717
<property name="multiLines" value="6,13"/>
@@ -22,7 +22,8 @@ A more lenient set of style checks for test cases, needed because test often nee
2222
<property name="severity" value="error"/>
2323
</module>
2424
<module name="TreeWalker">
25-
<property name="fileExtensions" value="java"/>
25+
<property name="fileExtensions" value="java"/>
26+
<module name="SuppressWarningsHolder" />
2627
<module name="InterfaceIsType">
2728
<metadata name="com.atlassw.tools.eclipse.checkstyle.lastEnabledSeverity" value="error"/>
2829
<property name="severity" value="ignore"/>
@@ -53,7 +54,7 @@ A more lenient set of style checks for test cases, needed because test often nee
5354
<module name="LocalVariableName">
5455
<metadata name="com.atlassw.tools.eclipse.checkstyle.lastEnabledSeverity" value="error"/>
5556
<property name="severity" value="ignore"/>
56-
<property name="tokens" value="PARAMETER_DEF,VARIABLE_DEF"/>
57+
<property name="tokens" value="VARIABLE_DEF"/>
5758
</module>
5859
<module name="LeftCurly"/>
5960
<module name="RightCurly"/>
@@ -119,13 +120,6 @@ A more lenient set of style checks for test cases, needed because test often nee
119120
<property name="severity" value="ignore"/>
120121
<property name="classes" value="Boolean"/>
121122
</module>
122-
<module name="Regexp">
123-
<metadata name="com.atlassw.tools.eclipse.checkstyle.comment" value="check that a space is left after a colon with an assembled error message"/>
124-
<property name="severity" value="info"/>
125-
<property name="format" value="[^:^&quot;]:&quot; .*+"/>
126-
<property name="message" value="check that a space is left after a colon on an assembled error message"/>
127-
<property name="illegalPattern" value="true"/>
128-
</module>
129123
<module name="Regexp">
130124
<metadata name="com.atlassw.tools.eclipse.checkstyle.comment" value="more than one blank line"/>
131125
<property name="severity" value="info"/>
@@ -211,24 +205,6 @@ A more lenient set of style checks for test cases, needed because test often nee
211205
</module>
212206
<module name="RedundantModifier"/>
213207
<module name="EqualsHashCode"/>
214-
<module name="SuppressionCommentFilter">
215-
<metadata name="com.atlassw.tools.eclipse.checkstyle.comment" value="Avoid name checking"/>
216-
<property name="offCommentFormat" value="CHECKSTYLE_NAMING_OFF"/>
217-
<property name="onCommentFormat" value="CHECKSTYLE_NAMING_ON"/>
218-
<property name="checkFormat" value="MethodName"/>
219-
</module>
220-
<module name="SuppressionCommentFilter">
221-
<metadata name="com.atlassw.tools.eclipse.checkstyle.comment" value="Avoid name checking"/>
222-
<property name="offCommentFormat" value="CHECKSTYLE_NAMING_OFF"/>
223-
<property name="onCommentFormat" value="CHECKSTYLE_NAMING_ON"/>
224-
<property name="checkFormat" value="MemberName"/>
225-
</module>
226-
<module name="SuppressionCommentFilter">
227-
<metadata name="com.atlassw.tools.eclipse.checkstyle.comment" value="Avoid name checking"/>
228-
<property name="offCommentFormat" value="CHECKSTYLE_NAMING_OFF"/>
229-
<property name="onCommentFormat" value="CHECKSTYLE_NAMING_ON"/>
230-
<property name="checkFormat" value="ParameterName"/>
231-
</module>
232208
</module>
233209
<module name="SuppressWithPlainTextCommentFilter">
234210
<property name="offCommentFormat" value="CHECKSTYLE_OFF"/>
@@ -237,4 +213,5 @@ A more lenient set of style checks for test cases, needed because test often nee
237213
<module name="JavadocPackage">
238214
<property name="severity" value="ignore"/>
239215
</module>
216+
<module name="SuppressWarningsFilter" />
240217
</module>

eclipse/settings/code-style/gwt-checkstyle.xml

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ Description:
2727
</module>
2828
<module name="TreeWalker">
2929
<property name="fileExtensions" value="java"/>
30-
<module name="InterfaceIsType">
30+
<module name="SuppressWarningsHolder" />
31+
<module name="InterfaceIsType">
3132
<property name="severity" value="ignore"/>
3233
</module>
3334
<module name="RedundantImport">
@@ -115,6 +116,7 @@ Description:
115116
<module name="Regexp">
116117
<metadata name="com.atlassw.tools.eclipse.checkstyle.comment" value="check that a space is left after a colon with an assembled error message"/>
117118
<property name="severity" value="info"/>
119+
<property name="id" value="SpaceAfterColon"/>
118120
<property name="format" value="[^:^&quot;]:&quot; .*+"/>
119121
<property name="message" value="check that a space is left after a colon on an assembled error message"/>
120122
<property name="illegalPattern" value="true"/>
@@ -195,25 +197,6 @@ Description:
195197
</module>
196198
<module name="RedundantModifier"/>
197199
<module name="EqualsHashCode"/>
198-
199-
<module name="SuppressionCommentFilter">
200-
<metadata name="com.atlassw.tools.eclipse.checkstyle.comment" value="Avoid name checking"/>
201-
<property name="offCommentFormat" value="CHECKSTYLE_NAMING_OFF"/>
202-
<property name="onCommentFormat" value="CHECKSTYLE_NAMING_ON"/>
203-
<property name="checkFormat" value="MethodName"/>
204-
</module>
205-
<module name="SuppressionCommentFilter">
206-
<metadata name="com.atlassw.tools.eclipse.checkstyle.comment" value="Avoid name checking"/>
207-
<property name="offCommentFormat" value="CHECKSTYLE_NAMING_OFF"/>
208-
<property name="onCommentFormat" value="CHECKSTYLE_NAMING_ON"/>
209-
<property name="checkFormat" value="MemberName"/>
210-
</module>
211-
<module name="SuppressionCommentFilter">
212-
<metadata name="com.atlassw.tools.eclipse.checkstyle.comment" value="Avoid name checking"/>
213-
<property name="offCommentFormat" value="CHECKSTYLE_NAMING_OFF"/>
214-
<property name="onCommentFormat" value="CHECKSTYLE_NAMING_ON"/>
215-
<property name="checkFormat" value="ParameterName"/>
216-
</module>
217200
</module>
218201
<module name="SuppressWithPlainTextCommentFilter">
219202
<property name="offCommentFormat" value="CHECKSTYLE_OFF"/>
@@ -222,4 +205,5 @@ Description:
222205
<module name="JavadocPackage">
223206
<property name="severity" value="ignore"/>
224207
</module>
208+
<module name="SuppressWarningsFilter" />
225209
</module>

samples/dynatablerf/src/main/java/com/google/gwt/sample/dynatablerf/client/widgets/ZipPlusFourBox.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,9 @@ public String parse(CharSequence text) throws ParseException {
5252
switch (text.length()) {
5353
case 9:
5454
text = text.subSequence(0, 5) + "-" + text.subSequence(5, 9);
55-
// Fall-though intentional
56-
// CHECKSTYLE_OFF
55+
/* fall-through intentional */
5756
case 5:
58-
// Fall-through intentional
5957
case 10:
60-
// CHECKSTYLE_ON
6158
if (PATTERN.test(text.toString())) {
6259
return text.toString();
6360
} else {

0 commit comments

Comments
 (0)