theINtoy
theINtoy

Reputation: 3708

Disable java checkstyle text block line length

I am building against java 17 using

...
    <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-checkstyle-plugin</artifactId>
          <version>3.2.1</version>
          <dependencies>
            <dependency>
              <groupId>com.puppycrawl.tools</groupId>
              <artifactId>checkstyle</artifactId>
              <version>10.7.0</version>
            </dependency>
          </dependencies>
...

With the google-check.xml configuration.

My class has a couple of static final Strings containing SVG's using the java triple """ text blocks with lines much longer than the normal allowed line length.

I've read that there is support in checkstyle from 10.6.0 for TextBlocks but have no idead how to enable it, or how, if it can be done, to switch off the line length check on the static final SVG strings in my code.

Any help would be appreciated.

I've tried the broad brush:

  //CHECKSTYLE:OFF
...
  //CHECKSTYLE:ON

Around the """ text blocks and using @SuppressWarnings("checkstyle:LineLegth") and @SuppressWarnings("LineLegth") and all mixes of case but nothing seems to work

Upvotes: 1

Views: 1257

Answers (1)

rveach
rveach

Reputation: 2201

Google check's suppression with CHECKSTYLE:ON/CHECKSTYLE:OFF requires the name of the check in the comment to do the suppression.

Google check does support suppressing with @SuppressWarnings and requires the text in the format of "checkstyle:name_of_the_check". Without an example of what you are doing, I can't say more why it isn't working.

I recommend using the SuppressionFilter and use the XML file as your storage of suppressions.

More information and some small examples can be found at https://checkstyle.org/google_style.html#Google_Suppressions

Upvotes: 0

Related Questions