Permalink
Browse files

added mvn profile "checks" which enables findbugs (currently on all

projects except umlet-swing) and uses the google error-prone compiler
also fixed many potential errors those tools reported
  • Loading branch information...
1 parent be0c88e commit 6f8251475c54123d8c3f8b619b0d6b3d77ac776f @afdia afdia committed Feb 11, 2016
Showing with 258 additions and 258 deletions.
  1. +16 −0 launcher/mvn clean install -Pchecks.launch
  2. +63 −0 pom.xml
  3. +1 −1 umlet-eclipse-plugin/src/assembly/dep.xml
  4. +7 −0 umlet-eclipse-plugin/src/main/findbugs/findbugs-exclude.xml
  5. +7 −2 umlet-eclipse-plugin/src/main/java/com/baselet/plugin/wizard/NewWizard.java
  6. +8 −0 umlet-elements/src/main/findbugs/findbugs-exclude.xml
  7. +2 −3 umlet-elements/src/main/java/com/baselet/control/basics/SortedMergedLine1DList.java
  8. +2 −1 umlet-elements/src/main/java/com/baselet/control/enums/LineType.java
  9. +12 −52 umlet-elements/src/main/java/com/baselet/diagram/draw/TextSplitter.java
  10. +24 −23 umlet-elements/src/main/java/com/baselet/diagram/draw/helper/ColorOwn.java
  11. +7 −1 umlet-elements/src/main/java/com/baselet/element/elementnew/plot/drawer/AxisConfig.java
  12. +3 −2 umlet-elements/src/main/java/com/baselet/element/elementnew/plot/parser/ParserResult.java
  13. +4 −4 umlet-elements/src/main/java/com/baselet/element/elementnew/plot/parser/PlotConstants.java
  14. +3 −3 umlet-elements/src/main/java/com/baselet/element/facet/common/TextPrintFacet.java
  15. +0 −1 umlet-elements/src/main/java/com/baselet/element/facet/customdrawings/CustomDrawingFacet.java
  16. +2 −2 umlet-elements/src/main/java/com/baselet/element/facet/specific/HierarchyFacet.java
  17. +5 −8 umlet-elements/src/main/java/com/baselet/element/facet/specific/sequence_aio/CombinedFragment.java
  18. +6 −10 umlet-elements/src/main/java/com/baselet/element/facet/specific/sequence_aio/Continuation.java
  19. +3 −3 umlet-elements/src/main/java/com/baselet/element/facet/specific/sequence_aio/GeneralOrdering.java
  20. +5 −11 umlet-elements/src/main/java/com/baselet/element/facet/specific/sequence_aio/InteractionUse.java
  21. +12 −21 umlet-elements/src/main/java/com/baselet/element/facet/specific/sequence_aio/Lifeline.java
  22. +4 −2 .../main/java/com/baselet/element/facet/specific/sequence_aio/LifelineHorizontalDrawingInfoImpl.java
  23. +14 −15 umlet-elements/src/main/java/com/baselet/element/facet/specific/sequence_aio/SequenceDiagram.java
  24. +18 −22 ...lements/src/main/java/com/baselet/element/facet/specific/sequence_aio/SequenceDiagramBuilder.java
  25. +2 −0 umlet-gwt/src/main/findbugs/findbugs-exclude.xml
  26. +3 −1 umlet-gwt/src/main/java/com/baselet/gwt/client/view/utils/DropboxIntegration.java
  27. +0 −68 umlet-gwt/src/main/java/com/baselet/gwt/client/view/utils/UUID.java
  28. +7 −0 umlet-standalone/src/main/findbugs/findbugs-exclude.xml
  29. +12 −2 umlet-standalone/src/main/java/com/baselet/standalone/MainStandalone.java
  30. +6 −0 umlet-swing/src/main/findbugs/findbugs-exclude.xml
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<launchConfiguration type="org.eclipse.m2e.Maven2LaunchConfigurationType">
+<booleanAttribute key="M2_DEBUG_OUTPUT" value="false"/>
+<stringAttribute key="M2_GOALS" value="clean install"/>
+<booleanAttribute key="M2_NON_RECURSIVE" value="false"/>
+<booleanAttribute key="M2_OFFLINE" value="false"/>
+<stringAttribute key="M2_PROFILES" value="checks"/>
+<listAttribute key="M2_PROPERTIES"/>
+<stringAttribute key="M2_RUNTIME" value="EMBEDDED"/>
+<booleanAttribute key="M2_SKIP_TESTS" value="false"/>
+<intAttribute key="M2_THREADS" value="1"/>
+<booleanAttribute key="M2_UPDATE_SNAPSHOTS" value="false"/>
+<stringAttribute key="M2_USER_SETTINGS" value=""/>
+<booleanAttribute key="M2_WORKSPACE_RESOLUTION" value="false"/>
+<stringAttribute key="org.eclipse.jdt.launching.WORKING_DIRECTORY" value="${project_loc:umlet-parent}"/>
+</launchConfiguration>
View
@@ -279,6 +279,20 @@
<ignore></ignore>
</action>
</pluginExecution>
+ <pluginExecution>
+ <pluginExecutionFilter>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <versionRange>[3.1,)</versionRange>
+ <goals>
+ <goal>testCompile</goal>
+ <goal>compile</goal>
+ </goals>
+ </pluginExecutionFilter>
+ <action>
+ <ignore></ignore>
+ </action>
+ </pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
@@ -289,6 +303,55 @@
<profiles>
<profile>
+ <id>checks</id>
+ <build>
+ <plugins>
+ <!-- use https://github.com/google/error-prone compiler -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.1</version>
+ <configuration>
+ <compilerId>javac-with-errorprone</compilerId>
+ <forceJavacCompilerUse>true</forceJavacCompilerUse>
+ </configuration>
+ <dependencies>
+ <dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-compiler-javac-errorprone</artifactId>
+ <version>2.5</version>
+ </dependency>
+ <!-- override plexus-compiler-javac-errorprone's dependency on Error Prone with the latest version -->
+ <dependency>
+ <groupId>com.google.errorprone</groupId>
+ <artifactId>error_prone_core</artifactId>
+ <version>2.0.8</version>
+ </dependency>
+ </dependencies>
+ </plugin>
+ <!-- use FindBugs to detect potential errors -->
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>findbugs-maven-plugin</artifactId>
+ <version>3.0.3</version>
+ <executions>
+ <!-- Ensures that FindBugs inspects source code when project is compiled. -->
+ <execution>
+ <id>analyze-compile</id>
+ <phase>compile</phase>
+ <goals>
+ <goal>check</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <excludeFilterFile>${basedir}/src/main/findbugs/findbugs-exclude.xml</excludeFilterFile>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ <profile>
<id>release</id>
<build>
<plugins>
@@ -7,7 +7,7 @@
<fileSets>
<fileSet>
<directory>${project.build.directory}</directory>
- <outputDirectory>/</outputDirectory>
+ <outputDirectory>.</outputDirectory>
<includes>
<include>*.jar</include>
</includes>
@@ -0,0 +1,7 @@
+<FindBugsFilter>
+ <Match>
+ <!-- ugly but currently necessary workaround to store plugin instance -->
+ <Class name="com.baselet.plugin.MainPlugin" />
+ <Bug pattern="ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD" />
+ </Match>
+</FindBugsFilter>
@@ -3,6 +3,7 @@
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
+import java.io.UnsupportedEncodingException;
import java.lang.reflect.InvocationTargetException;
import org.eclipse.core.resources.IContainer;
@@ -152,10 +153,14 @@ public void run() {
* We will initialize file contents with a sample text.
*/
- private InputStream openContentStream() {
+ public static InputStream openContentStream() {
String progName = Program.getInstance().getProgramName().toLowerCase();
String contents = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?><" + progName + "_diagram></" + progName + "_diagram>";
- return new ByteArrayInputStream(contents.getBytes());
+ try {
+ return new ByteArrayInputStream(contents.getBytes("UTF-8"));
+ } catch (UnsupportedEncodingException e) {
+ throw new RuntimeException("UTF-8 encoding not supported", e);
+ }
}
private void throwCoreException(String message) throws CoreException {
@@ -0,0 +1,8 @@
+<FindBugsFilter>
+ <Match>
+ <Package name="~com.baselet.element.facet.specific.sequence_aio.gen.*" />
+ </Match>
+ <Match>
+ <Package name="~com.baselet.element.facet.customdrawings.gen.*" />
+ </Match>
+</FindBugsFilter>
@@ -74,8 +74,7 @@ public boolean add(Line1D e) {
else {
int insertIndex = listIter.nextIndex();
Line1D tmpLine = listIter.next();
- if (tmpLine.getLow() <= e.getHigh())
- {
+ if (tmpLine.getLow() <= e.getHigh()) {
double low = Math.min(tmpLine.getLow(), e.getLow());
double high = tmpLine.getHigh();
while (listIter.hasNext()) {
@@ -105,7 +104,7 @@ public boolean remove(Object o) {
@Override
public boolean containsAll(Collection<?> c) {
- return containsAll(c);
+ return list.containsAll(c);
}
/**
@@ -1,14 +1,15 @@
package com.baselet.control.enums;
import java.util.Arrays;
+import java.util.Collections;
import java.util.List;
public enum LineType implements RegexValueHolder {
SOLID("-"), DASHED("."), DOTTED(".."), DOUBLE("="), DOUBLE_DASHED(":"), DOUBLE_DOTTED("::");
private String value;
- public static final List<LineType> LT_LIST = Arrays.asList(LineType.SOLID, LineType.DASHED, LineType.DOTTED);
+ public static final List<LineType> LT_LIST = Collections.unmodifiableList(Arrays.asList(LineType.SOLID, LineType.DASHED, LineType.DOTTED));
private LineType(String value) {
this.value = value;
@@ -372,10 +372,6 @@ private static Double getCachedMinWidth(MinWidthCacheKey key) {
return minWidthCache.get(key);
}
- private static Double getCachedMinWidth(WordRegion[] words, Style style, Set<FormatLabels> format) {
- return getCachedMinWidth(new MinWidthCacheKey(words, style, format));
- }
-
private static void setCachedMinWidth(MinWidthCacheKey key, Double value) {
minWidthCache.put(key, value);
}
@@ -392,22 +388,6 @@ private static void setCachedWordwrap(WordwrapCacheKey key, WordwrapCacheValue v
wordwrapCache.put(key, value);
}
- private static void setCachedWordwrap(WordwrapCacheKey key, StringStyle[] wrappedLines, double height) {
- wordwrapCache.put(key, new WordwrapCacheValue(wrappedLines, height));
- }
-
- private static void setCachedWordwrap(WordRegion[] words, double width, Style style, Set<FormatLabels> format, StringStyle[] wrappedLines, double height) {
- wordwrapCache.put(new WordwrapCacheKey(words, width, style, format), new WordwrapCacheValue(wrappedLines, height));
- }
-
- private static void setCachedWordwrap(WordwrapCacheKey key, String[] wrappedLines, double height) {
- wordwrapCache.put(key, new WordwrapCacheValue(wrappedLines, key.format, height));
- }
-
- private static void setCachedWordwrap(WordRegion[] words, double width, Style style, Set<FormatLabels> format, String[] wrappedLines, double height) {
- wordwrapCache.put(new WordwrapCacheKey(words, width, style, format), new WordwrapCacheValue(wrappedLines, format, height));
- }
-
/**
* Contains the start and end of a word, can be directly used with substring
*/
@@ -454,11 +434,9 @@ public Style getStyle() {
public int hashCode() {
final int prime = 31;
int result = 1;
- result = prime * result + (words == null ? 0 : words.hashCode());
+ result = prime * result + (format == null ? 0 : format.hashCode());
result = prime * result + (style == null ? 0 : style.hashCode());
- for (FormatLabels fl : format) {
- result = prime * result + fl.hashCode();
- }
+ result = prime * result + Arrays.hashCode(words);
return result;
}
@@ -474,12 +452,12 @@ public boolean equals(Object obj) {
return false;
}
MinWidthCacheKey other = (MinWidthCacheKey) obj;
- if (words == null) {
- if (other.words != null) {
+ if (format == null) {
+ if (other.format != null) {
return false;
}
}
- else if (!words.equals(other.words)) {
+ else if (!format.equals(other.format)) {
return false;
}
if (style == null) {
@@ -490,15 +468,7 @@ else if (!words.equals(other.words)) {
else if (!style.equals(other.style)) {
return false;
}
- if (format == null) {
- if (other.format != null) {
- return false;
- }
- }
- else if (format.size() != other.format.size()) {
- return false;
- }
- else if (!format.containsAll(other.format)) {
+ if (!Arrays.equals(words, other.words)) {
return false;
}
return true;
@@ -540,14 +510,12 @@ public Style getStyle() {
public int hashCode() {
final int prime = 31;
int result = 1;
- result = prime * result + (words == null ? 0 : words.hashCode());
+ result = prime * result + (format == null ? 0 : format.hashCode());
result = prime * result + (style == null ? 0 : style.hashCode());
long temp;
temp = Double.doubleToLongBits(width);
result = prime * result + (int) (temp ^ temp >>> 32);
- for (FormatLabels fl : format) {
- result = prime * result + fl.hashCode();
- }
+ result = prime * result + Arrays.hashCode(words);
return result;
}
@@ -563,12 +531,12 @@ public boolean equals(Object obj) {
return false;
}
WordwrapCacheKey other = (WordwrapCacheKey) obj;
- if (words == null) {
- if (other.words != null) {
+ if (format == null) {
+ if (other.format != null) {
return false;
}
}
- else if (!words.equals(other.words)) {
+ else if (!format.equals(other.format)) {
return false;
}
if (style == null) {
@@ -582,15 +550,7 @@ else if (!style.equals(other.style)) {
if (Double.doubleToLongBits(width) != Double.doubleToLongBits(other.width)) {
return false;
}
- if (format == null) {
- if (other.format != null) {
- return false;
- }
- }
- else if (format.size() != other.format.size()) {
- return false;
- }
- else if (!format.containsAll(other.format)) {
+ if (!Arrays.equals(words, other.words)) {
return false;
}
return true;
@@ -1,17 +1,16 @@
package com.baselet.diagram.draw.helper;
+import java.util.Collections;
import java.util.HashMap;
+import java.util.Map;
+import java.util.Map.Entry;
public class ColorOwn {
public static final String EXAMPLE_TEXT = "color string (green,...) or code (#3c7a00,...)";
public static enum Transparency {
- FOREGROUND(255),
- FULL_TRANSPARENT(0),
- DEPRECATED_WARNING(175),
- BACKGROUND(125),
- SELECTION_BACKGROUND(20);
+ FOREGROUND(255), FULL_TRANSPARENT(0), DEPRECATED_WARNING(175), BACKGROUND(125), SELECTION_BACKGROUND(20);
private int alpha;
@@ -46,23 +45,25 @@ public int getAlpha() {
public static final ColorOwn DEFAULT_FOREGROUND = BLACK;
public static final ColorOwn DEFAULT_BACKGROUND = TRANSPARENT;
- public static final HashMap<String, ColorOwn> COLOR_MAP = new HashMap<String, ColorOwn>();
+ public static final Map<String, ColorOwn> COLOR_MAP;
static {
- COLOR_MAP.put("black", ColorOwn.BLACK);
- COLOR_MAP.put("blue", ColorOwn.BLUE);
- COLOR_MAP.put("cyan", ColorOwn.CYAN);
- COLOR_MAP.put("dark_gray", ColorOwn.DARK_GRAY);
- COLOR_MAP.put("gray", ColorOwn.GRAY);
- COLOR_MAP.put("green", ColorOwn.GREEN);
- COLOR_MAP.put("light_gray", ColorOwn.LIGHT_GRAY);
- COLOR_MAP.put("magenta", ColorOwn.MAGENTA);
- COLOR_MAP.put("orange", ColorOwn.ORANGE);
- COLOR_MAP.put("pink", ColorOwn.PINK);
- COLOR_MAP.put("red", ColorOwn.RED);
- COLOR_MAP.put("white", ColorOwn.WHITE);
- COLOR_MAP.put("yellow", ColorOwn.YELLOW);
- COLOR_MAP.put("none", ColorOwn.TRANSPARENT);
+ HashMap<String, ColorOwn> colorMap = new HashMap<String, ColorOwn>();
+ colorMap.put("black", ColorOwn.BLACK);
+ colorMap.put("blue", ColorOwn.BLUE);
+ colorMap.put("cyan", ColorOwn.CYAN);
+ colorMap.put("dark_gray", ColorOwn.DARK_GRAY);
+ colorMap.put("gray", ColorOwn.GRAY);
+ colorMap.put("green", ColorOwn.GREEN);
+ colorMap.put("light_gray", ColorOwn.LIGHT_GRAY);
+ colorMap.put("magenta", ColorOwn.MAGENTA);
+ colorMap.put("orange", ColorOwn.ORANGE);
+ colorMap.put("pink", ColorOwn.PINK);
+ colorMap.put("red", ColorOwn.RED);
+ colorMap.put("white", ColorOwn.WHITE);
+ colorMap.put("yellow", ColorOwn.YELLOW);
+ colorMap.put("none", ColorOwn.TRANSPARENT);
+ COLOR_MAP = Collections.unmodifiableMap(colorMap);
}
/* fields should be final to avoid changing parts of existing color object (otherwise unexpected visible changes can happen) */
@@ -151,9 +152,9 @@ public static ColorOwn forString(String colorString, int transparency) {
error = true;
}
else {
- for (String color : COLOR_MAP.keySet()) {
- if (colorString.equalsIgnoreCase(color)) {
- returnColor = COLOR_MAP.get(color);
+ for (Entry<String, ColorOwn> c : COLOR_MAP.entrySet()) {
+ if (colorString.equalsIgnoreCase(c.getKey())) {
+ returnColor = c.getValue();
break;
}
}
Oops, something went wrong.

0 comments on commit 6f82514

Please sign in to comment.