DocGenerator { @SuppressWarnings("squid:S4248") static String trimDesc(String s) { return s.replaceAll("^[ \t]+", "") .replaceAll("\\n[ \t]+", "\n") .replaceAll("\\{@link[ \t]+(?<name>[\\w.]*)[ \t]*}", "`${name}`"); } DocGenerator(DocFileWriter docFileWriter); void generateDoc(PluginDocTree pluginDocTree);  }
@Test public void testTrimEmptyPrefix() { assertThat(DocGenerator.trimDesc("asdf"), is("asdf")); assertThat(DocGenerator.trimDesc(" asdf"), is("asdf")); assertThat(DocGenerator.trimDesc("asdf\njklö"), is("asdf\njklö")); assertThat(DocGenerator.trimDesc("asdf\n\njklö"), is("asdf\n\njklö")); assertThat(DocGenerator.trimDesc("asdf\n \njklö"), is("asdf\n\njklö")); assertThat(DocGenerator.trimDesc("asdf\n \t \njklö"), is("asdf\n\njklö")); assertThat(DocGenerator.trimDesc("asdf\n \t \n jklö"), is("asdf\n\njklö")); assertThat(DocGenerator.trimDesc("asdf\n \t \n jklö "), is("asdf\n\njklö ")); }
@Test public void testTrimDescRemovesJavaDocLinks() { assertThat(DocGenerator.trimDesc("asdf\n \t \n {@link Jklo} "), is("asdf\n\n`Jklo` ")); assertThat(DocGenerator.trimDesc("asdf\n \t \n {@link Jklo } "), is("asdf\n\n`Jklo` ")); assertThat(DocGenerator.trimDesc("asdf\n \t \n {@link Jklo } "), is("asdf\n\n`Jklo` ")); assertThat(DocGenerator.trimDesc("asdf\n \t \n {@link org.Jklo } "), is("asdf\n\n`org.Jklo` ")); }