diff --git a/config/jsoref-spellchecker/whitelist.words b/config/jsoref-spellchecker/whitelist.words index 264b665312f..e6f403946a4 100644 --- a/config/jsoref-spellchecker/whitelist.words +++ b/config/jsoref-spellchecker/whitelist.words @@ -495,7 +495,6 @@ GMetrics gnupg google googleapis -googleblog googlecloudplatform googleecommon googlegroups @@ -1417,7 +1416,6 @@ webjar Weblogic Webp website -webtoolkit Wellformedness wget wherejavadocrequired diff --git a/src/it/java/com/google/checkstyle/test/chapter4formatting/rule44columnlimit/LineLengthTest.java b/src/it/java/com/google/checkstyle/test/chapter4formatting/rule44columnlimit/LineLengthTest.java index fa64460c463..30230a39109 100644 --- a/src/it/java/com/google/checkstyle/test/chapter4formatting/rule44columnlimit/LineLengthTest.java +++ b/src/it/java/com/google/checkstyle/test/chapter4formatting/rule44columnlimit/LineLengthTest.java @@ -22,6 +22,7 @@ import org.junit.jupiter.api.Test; import com.google.checkstyle.test.base.AbstractGoogleModuleTestSupport; +import com.puppycrawl.tools.checkstyle.DefaultConfiguration; import com.puppycrawl.tools.checkstyle.api.Configuration; import com.puppycrawl.tools.checkstyle.checks.sizes.LineLengthCheck; @@ -46,4 +47,23 @@ public void testLineLength() throws Exception { verify(checkConfig, filePath, expected, warnList); } + @Test + public void testLineLengthJsniMethods() throws Exception { + final String[] expected = { + "9: " + getCheckMessage(LineLengthCheck.class, "maxLineLen", 100, 117), + "11: " + getCheckMessage(LineLengthCheck.class, "maxLineLen", 100, 121), + }; + + final Configuration lineLengthConfig = getModuleConfig("LineLength"); + final DefaultConfiguration rootConfig = createRootConfig(lineLengthConfig); + + final Configuration filterConfig = getModuleConfig("SuppressWithPlainTextCommentFilter"); + rootConfig.addChild(filterConfig); + + final String filePath = getPath("InputLineLengthJsniMethods.java"); + + final Integer[] warnList = getLinesWithWarn(filePath); + verify(rootConfig, filePath, expected, warnList); + } + } diff --git a/src/it/resources/com/google/checkstyle/test/chapter4formatting/rule44columnlimit/InputLineLengthJsniMethods.java b/src/it/resources/com/google/checkstyle/test/chapter4formatting/rule44columnlimit/InputLineLengthJsniMethods.java new file mode 100644 index 00000000000..08f6da07803 --- /dev/null +++ b/src/it/resources/com/google/checkstyle/test/chapter4formatting/rule44columnlimit/InputLineLengthJsniMethods.java @@ -0,0 +1,13 @@ +package com.google.checkstyle.test.chapter4formatting.rule44columnlimit; + +public class InputLineLengthJsniMethods { + public static native void alertMessage(String msggggggggggggggggggggggggggggggggggggggggggggggggggg) /*-{ + $wnd.alert(msg); + console.log('a really long message here blah blah blah blah blah bruh bruh bruhhhhhhhhhhhhhhhhhhhhhhhhhhhh'); + }-*/; + + public static native void alertMessage2(String msggggggggggggggggggggggggggggggggggggggggggggggggggg) /*- { // warn + $wnd.alert(msg); + console.log('a really long message here blah blah blah blah blah bruh bruh bruhhhhhhhhhhhhhhhhhhhhhhhhhhhh'); // warn + }-*/; +} diff --git a/src/main/resources/google_checks.xml b/src/main/resources/google_checks.xml index bc47e7e7767..83439302802 100644 --- a/src/main/resources/google_checks.xml +++ b/src/main/resources/google_checks.xml @@ -48,6 +48,14 @@ + + + + + + + + diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/internal/XdocsPagesTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/internal/XdocsPagesTest.java index 2a25f2d114c..61b48a9775f 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/internal/XdocsPagesTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/internal/XdocsPagesTest.java @@ -1665,6 +1665,7 @@ public void testAllStyleRules() throws Exception { styleChecks.remove("SuppressionCommentFilter"); styleChecks.remove("SuppressWarningsFilter"); styleChecks.remove("SuppressWarningsHolder"); + styleChecks.remove("SuppressWithPlainTextCommentFilter"); assertWithMessage( fileName + " requires the following check(s) to appear: " + styleChecks) diff --git a/src/xdocs/filters/suppresswithplaintextcommentfilter.xml b/src/xdocs/filters/suppresswithplaintextcommentfilter.xml index 7f459018fde..7d2dd05466c 100644 --- a/src/xdocs/filters/suppresswithplaintextcommentfilter.xml +++ b/src/xdocs/filters/suppresswithplaintextcommentfilter.xml @@ -347,6 +347,10 @@ public class Example9 {
    +
  • + + Google Style +
  • Checkstyle Style diff --git a/src/xdocs/filters/suppresswithplaintextcommentfilter.xml.template b/src/xdocs/filters/suppresswithplaintextcommentfilter.xml.template index 351a07e29c8..611cf76e920 100644 --- a/src/xdocs/filters/suppresswithplaintextcommentfilter.xml.template +++ b/src/xdocs/filters/suppresswithplaintextcommentfilter.xml.template @@ -206,6 +206,10 @@
      +
    • + + Google Style +
    • Checkstyle Style diff --git a/src/xdocs/google_style.xml b/src/xdocs/google_style.xml index 11686aeb1d9..ce3aecf1a02 100644 --- a/src/xdocs/google_style.xml +++ b/src/xdocs/google_style.xml @@ -780,18 +780,10 @@ LineLength -
      - We can detect URL with protocol type as http://, https:// etc. -
      - - JSNI - could not be detected right now, but might be possible after - comments and javadoc support appear in Checkstyle. -
      @@ -2310,10 +2302,12 @@ SuppressWithNearbyCommentFilter, - SuppressionCommentFilter - and + SuppressionCommentFilter, - SuppressWarningsFilter. + SuppressWarningsFilter + and + + SuppressWithPlainTextCommentFilter.

      Location of config file for @@ -2351,6 +2345,16 @@ name_of_the_check is the actual name of check to be suppressed in lowercase format.

      +

      + To suppress a check using + + SuppressWithPlainTextCommentFilter + + add the offComment format you specified in the offCommentFormat + property before the beginning of the code block and the onComment + format you specified in the onCommentFormat + property after the end of the code block. +

      For more details please review exact configuration of Filters in google_checks.xml: @@ -2363,6 +2367,8 @@ SuppressionCommentFilter, SuppressWarningsFilter, + + SuppressWithPlainTextCommentFilter.

      diff --git a/src/xdocs/releasenotes.xml b/src/xdocs/releasenotes.xml index fbc06c3948b..4d4006829d3 100644 --- a/src/xdocs/releasenotes.xml +++ b/src/xdocs/releasenotes.xml @@ -33,7 +33,8 @@
      • Remove '//ok' comments from Input files . - Author: Aye Nyein San, biplavoraon, mahfouz72, Abhishek Maity, SteLeo1602, akanksha, MANISH-K-07, Tahanima Chowdhury, CubeTures + Author: Aye Nyein San, biplavoraon, mahfouz72, Abhishek Maity, SteLeo1602, akanksha, + MANISH-K-07, Tahanima Chowdhury, CubeTures #13213