Skip to content

Commit

Permalink
Issue #14487: add support to ignore JSNI methods for LineLength check…
Browse files Browse the repository at this point in the history
… in google config
  • Loading branch information
Zopsss committed Feb 18, 2024
1 parent 9842608 commit 67b3ee9
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
package com.google.checkstyle.test.chapter4formatting.rule44columnlimit;

import org.junit.jupiter.api.Test;
import com.puppycrawl.tools.checkstyle.utils.CommonUtil;

import com.google.checkstyle.test.base.AbstractGoogleModuleTestSupport;
import com.puppycrawl.tools.checkstyle.api.Configuration;
Expand All @@ -46,4 +47,15 @@ public void testLineLength() throws Exception {
verify(checkConfig, filePath, expected, warnList);
}

@Test
public void testLineLengthJsniMethods() throws Exception {
final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;

final Configuration checkConfig = getModuleConfig("LineLength");
final String filePath = getPath("InputLineLengthJsniMethods.java");

final Integer[] warnList = getLinesWithWarn(filePath);
verify(checkConfig, filePath, expected, warnList);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.google.checkstyle.test.chapter4formatting.rule44columnlimit;

public class InputLineLengthJsniMethods {
public static native void alertMessage(String msg, int a, int b, int c, int d, int e, int f, int g, int h) /*-{
$wnd.alert(msg);
console.log('a really long message here blah blah blah bruh bruh bruhhhhhhhhhhhhhhhhhhhhhhhhhhhh');
}-*/;
}
8 changes: 8 additions & 0 deletions src/main/resources/google_checks.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,14 @@
<property name="eachLine" value="true"/>
</module>

<!-- To ignore JSNI Methods for LineLength check -->
<!-- See https://google.github.io/styleguide/javaguide.html#s4.4-column-limit -->
<module name="SuppressWithPlainTextCommentFilter">
<property name="offCommentFormat" value="\/\*-\{"/>
<property name="onCommentFormat" value="\}-\*\/"/>
<property name="messageFormat" value="Line is longer than 100 characters. *"/>
</module>

<module name="LineLength">
<property name="fileExtensions" value="java"/>
<property name="max" value="100"/>
Expand Down

0 comments on commit 67b3ee9

Please sign in to comment.