1
0
mirror of https://github.com/octoleo/plantuml-server.git synced 2024-12-22 08:48:54 +00:00

[FEATURE] Checkstyle violations fail the Build

This commit is contained in:
maximesinclair 2014-02-15 19:04:30 +01:00
parent d51bbd4d13
commit 9401ab4a61
8 changed files with 44 additions and 13 deletions

21
pom.xml
View File

@ -65,6 +65,27 @@
<artifactId>maven-site-plugin</artifactId>
<version>3.0-beta-3</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>2.11</version>
<executions>
<execution>
<id>validate</id>
<phase>validate</phase>
<configuration>
<configLocation>${basedir}/src/main/config/checkstyle.xml</configLocation>
<encoding>UTF-8</encoding>
<consoleOutput>true</consoleOutput>
<failsOnError>true</failsOnError>
<linkXRef>false</linkXRef>
</configuration>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<reporting>

View File

@ -9,7 +9,8 @@
Description: none
-->
<module name="Checker">
<property name="severity" value="warning"/>
<property name="severity" value="error"/>
<property name="charset" value="UTF-8"/>
<module name="TreeWalker">
<module name="JavadocMethod">
<property name="severity" value="ignore"/>

View File

@ -44,13 +44,13 @@ import net.sourceforge.plantuml.servlet.utility.NullOutputStream;
class DiagramResponse {
private HttpServletResponse response;
private FileFormat format;
private static final Map<FileFormat, String> contentType;
private static final Map<FileFormat, String> CONTENT_TYPE;
static {
Map<FileFormat, String> map = new HashMap<FileFormat, String>();
map.put(FileFormat.PNG, "image/png");
map.put(FileFormat.SVG, "image/svg+xml");
map.put(FileFormat.UTXT, "text/plain;charset=UTF-8");
contentType = Collections.unmodifiableMap(map);
CONTENT_TYPE = Collections.unmodifiableMap(map);
}
DiagramResponse(HttpServletResponse r, FileFormat f) {
@ -92,7 +92,7 @@ class DiagramResponse {
}
private String getContentType() {
return contentType.get(format);
return CONTENT_TYPE.get(format);
}
}

View File

@ -52,7 +52,7 @@ import net.sourceforge.plantuml.SourceStringReader;
@SuppressWarnings("serial")
public class OldProxyServlet extends HttpServlet {
private static final Pattern proxyPattern = Pattern.compile("/\\w+/proxy/((\\d+)/)?((\\w+)/)?(http://.*)");
private static final Pattern PROXY_PATTERN = Pattern.compile("/\\w+/proxy/((\\d+)/)?((\\w+)/)?(http://.*)");
private String format;
@Override
@ -60,7 +60,7 @@ public class OldProxyServlet extends HttpServlet {
final String uri = request.getRequestURI();
Matcher proxyMatcher = proxyPattern.matcher(uri);
Matcher proxyMatcher = PROXY_PATTERN.matcher(uri);
if (proxyMatcher.matches()) {
String num = proxyMatcher.group(2); // Optional number of the diagram source
format = proxyMatcher.group(4); // Expected format of the generated diagram

View File

@ -60,16 +60,16 @@ import net.sourceforge.plantuml.api.PlantumlUtils;
@SuppressWarnings("serial")
public class PlantUmlServlet extends HttpServlet {
private static final Pattern urlPattern = Pattern.compile(".*/(.*)"); // Last part of the URL
private static final Pattern encodedPattern = Pattern.compile("^[a-zA-Z0-9\\-\\_]+$"); // Format of a compressed
private static final Pattern URL_PATTERN = Pattern.compile(".*/(.*)"); // Last part of the URL
private static final Pattern ENCODED_PATTERN = Pattern.compile("^[a-zA-Z0-9\\-\\_]+$"); // Format of a compressed
// diagram
private static final Pattern startumlPattern = Pattern.compile("/\\w+/start/(.*)");
private static final Pattern START_PATTERN = Pattern.compile("/\\w+/start/(.*)");
@Override
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
final String uri = request.getRequestURI();
Matcher startumlMatcher = startumlPattern.matcher(uri);
Matcher startumlMatcher = START_PATTERN.matcher(uri);
if (startumlMatcher.matches()) {
System.out.println("PlantUML WARNING This syntax is deprecated.");
String source = startumlMatcher.group(1);
@ -92,12 +92,12 @@ public class PlantUmlServlet extends HttpServlet {
// the URL form has been submitted
if (url != null && !url.trim().isEmpty()) {
// Catch the last part of the URL if necessary
Matcher m1 = urlPattern.matcher(url);
Matcher m1 = URL_PATTERN.matcher(url);
if (m1.find()) {
url = m1.group(1);
}
// Check it's a valid compressed text
Matcher m2 = encodedPattern.matcher(url);
Matcher m2 = ENCODED_PATTERN.matcher(url);
if (m2.find()) {
url = m2.group(0);
text = transcoder.decode(url);

View File

@ -76,4 +76,9 @@ public class UmlExtractor {
return uml;
}
protected UmlExtractor() {
// prevents calls from subclass
throw new UnsupportedOperationException();
}
}

View File

@ -8,7 +8,7 @@ import org.eclipse.jetty.webapp.WebAppContext;
public class ServerUtils {
Server server;
private Server server;
public ServerUtils(boolean start) throws Exception {
server = new Server(new InetSocketAddress("127.0.0.1", 0));

View File

@ -20,4 +20,8 @@ public class TestUtils {
*/
public static final String SEQBOB = "SyfFKj2rKt3CoKnELR1Io4ZDoSa70000";
protected TestUtils() {
// prevents calls from subclass
throw new UnsupportedOperationException();
}
}