Merge pull request #483 from zod/code-analysis
Static code analysis using PMD I haven't tested that results. For me the diffs looking well and useful. The future will show if we need all this rules, drop some or add more.
This commit is contained in:
commit
a764c788ba
58 changed files with 199 additions and 184 deletions
|
@ -1,11 +1,12 @@
|
|||
package btools.codec;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import btools.util.BitCoderContext;
|
||||
|
||||
public final class StatCoderContext extends BitCoderContext {
|
||||
private static TreeMap<String, long[]> statsPerName;
|
||||
private static Map<String, long[]> statsPerName;
|
||||
private long lastbitpos = 0;
|
||||
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@ package btools.codec;
|
|||
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.PriorityQueue;
|
||||
|
||||
import btools.util.BitCoderContext;
|
||||
|
@ -16,7 +17,7 @@ import btools.util.BitCoderContext;
|
|||
* but doesn't do anything at pass1
|
||||
*/
|
||||
public final class TagValueCoder {
|
||||
private HashMap<TagValueSet, TagValueSet> identityMap;
|
||||
private Map<TagValueSet, TagValueSet> identityMap;
|
||||
private Object tree;
|
||||
private BitCoderContext bc;
|
||||
private int pass;
|
||||
|
|
|
@ -6,11 +6,11 @@ public interface TagValueValidator {
|
|||
* @param tagValueSet the way description to check
|
||||
* @return 0 = nothing, 1=no matching, 2=normal
|
||||
*/
|
||||
public int accessType(byte[] tagValueSet);
|
||||
int accessType(byte[] tagValueSet);
|
||||
|
||||
public byte[] unify(byte[] tagValueSet, int offset, int len);
|
||||
byte[] unify(byte[] tagValueSet, int offset, int len);
|
||||
|
||||
public boolean isLookupIdxUsed(int idx);
|
||||
boolean isLookupIdxUsed(int idx);
|
||||
|
||||
public void setDecodeForbidden(boolean decodeForbidden);
|
||||
void setDecodeForbidden(boolean decodeForbidden);
|
||||
}
|
||||
|
|
|
@ -24,18 +24,14 @@ public class LinkedListContainerTest {
|
|||
|
||||
for (int ln = 0; ln < nlists; ln++) {
|
||||
int cnt = llc.initList(ln);
|
||||
Assert.assertTrue("list size test", cnt == 20);
|
||||
Assert.assertEquals("list size test", 20, cnt);
|
||||
|
||||
for (int i = 19; i >= 0; i--) {
|
||||
int data = llc.getDataElement();
|
||||
Assert.assertTrue("data value test", data == ln * (i % 10));
|
||||
Assert.assertEquals("data value test", ln * (i % 10), data);
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
llc.getDataElement();
|
||||
Assert.fail("no more elements expected");
|
||||
} catch (IllegalArgumentException e) {
|
||||
}
|
||||
Assert.assertThrows("no more elements expected", IllegalArgumentException.class, () -> llc.getDataElement());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -132,7 +132,6 @@ public class OsmNogoPolygon extends OsmNodeNamed {
|
|||
ilon = cx;
|
||||
ilat = cy;
|
||||
radius = rad * 1.001 + 1.0; // ensure the outside-of-enclosing-circle test in RoutingContext.calcDistance() is not passed by segments ending very close to the radius due to limited numerical precision
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -7,7 +7,6 @@ package btools.router;
|
|||
|
||||
import btools.mapaccess.OsmLink;
|
||||
import btools.mapaccess.OsmNode;
|
||||
import btools.mapaccess.OsmTransferNode;
|
||||
|
||||
public abstract class OsmPrePath {
|
||||
protected OsmNode sourceNode;
|
||||
|
|
|
@ -53,7 +53,7 @@ public final class OsmTrack {
|
|||
public OsmPathElementHolder nextHolder;
|
||||
}
|
||||
|
||||
public ArrayList<OsmPathElement> nodes = new ArrayList<OsmPathElement>();
|
||||
public List<OsmPathElement> nodes = new ArrayList<OsmPathElement>();
|
||||
|
||||
private CompactLongMap<OsmPathElementHolder> nodesMap;
|
||||
|
||||
|
@ -62,7 +62,7 @@ public final class OsmTrack {
|
|||
private VoiceHintList voiceHints;
|
||||
|
||||
public String message = null;
|
||||
public ArrayList<String> messageList = null;
|
||||
public List<String> messageList = null;
|
||||
|
||||
public String name = "unset";
|
||||
|
||||
|
@ -113,7 +113,7 @@ public final class OsmTrack {
|
|||
nodesMap = new FrozenLongMap<OsmPathElementHolder>(nodesMap);
|
||||
}
|
||||
|
||||
private ArrayList<String> aggregateMessages() {
|
||||
private List<String> aggregateMessages() {
|
||||
ArrayList<String> res = new ArrayList<String>();
|
||||
MessageData current = null;
|
||||
for (OsmPathElement n : nodes) {
|
||||
|
@ -135,7 +135,7 @@ public final class OsmTrack {
|
|||
return res;
|
||||
}
|
||||
|
||||
private ArrayList<String> aggregateSpeedProfile() {
|
||||
private List<String> aggregateSpeedProfile() {
|
||||
ArrayList<String> res = new ArrayList<String>();
|
||||
int vmax = -1;
|
||||
int vmaxe = -1;
|
||||
|
@ -673,7 +673,7 @@ public final class OsmTrack {
|
|||
}
|
||||
if (showSpeedProfile) // set in profile
|
||||
{
|
||||
ArrayList<String> sp = aggregateSpeedProfile();
|
||||
List<String> sp = aggregateSpeedProfile();
|
||||
if (sp.size() > 0) {
|
||||
sb.append(" \"speedprofile\": [\n");
|
||||
for (int i = sp.size() - 1; i >= 0; i--) {
|
||||
|
|
|
@ -309,7 +309,7 @@ public class RoutingEngine extends Thread {
|
|||
}
|
||||
if (hasInfo()) {
|
||||
boolean found = nearbyTrack != null;
|
||||
boolean dirty = found ? nearbyTrack.isDirty : false;
|
||||
boolean dirty = found && nearbyTrack.isDirty;
|
||||
logInfo("read referenceTrack, found=" + found + " dirty=" + dirty + " " + debugInfo);
|
||||
}
|
||||
}
|
||||
|
@ -1078,7 +1078,7 @@ public class RoutingEngine extends Thread {
|
|||
|
||||
synchronized (openSet) {
|
||||
if (guideTrack != null) {
|
||||
ArrayList<OsmPathElement> nodes = guideTrack.nodes;
|
||||
List<OsmPathElement> nodes = guideTrack.nodes;
|
||||
int[] res = new int[nodes.size() * 2];
|
||||
int i = 0;
|
||||
for (OsmPathElement n : nodes) {
|
||||
|
|
|
@ -12,7 +12,7 @@ import java.util.List;
|
|||
public class VoiceHintList {
|
||||
private String transportMode;
|
||||
int turnInstructionMode;
|
||||
ArrayList<VoiceHint> list = new ArrayList<VoiceHint>();
|
||||
List<VoiceHint> list = new ArrayList<VoiceHint>();
|
||||
|
||||
public void setTransportMode(boolean isCar, boolean isBike) {
|
||||
transportMode = isCar ? "car" : (isBike ? "bike" : "foot");
|
||||
|
|
|
@ -1,11 +1,7 @@
|
|||
package btools.router;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import btools.util.CheapRuler;
|
||||
|
|
|
@ -37,9 +37,9 @@ public abstract class BExpressionContext implements IByteArrayUnifier {
|
|||
public String _modelClass;
|
||||
|
||||
private Map<String, Integer> lookupNumbers = new HashMap<String, Integer>();
|
||||
private ArrayList<BExpressionLookupValue[]> lookupValues = new ArrayList<BExpressionLookupValue[]>();
|
||||
private ArrayList<String> lookupNames = new ArrayList<String>();
|
||||
private ArrayList<int[]> lookupHistograms = new ArrayList<int[]>();
|
||||
private List<BExpressionLookupValue[]> lookupValues = new ArrayList<BExpressionLookupValue[]>();
|
||||
private List<String> lookupNames = new ArrayList<String>();
|
||||
private List<int[]> lookupHistograms = new ArrayList<int[]>();
|
||||
private boolean[] lookupIdxUsed;
|
||||
|
||||
private boolean lookupDataFrozen = false;
|
||||
|
@ -805,10 +805,9 @@ public abstract class BExpressionContext implements IByteArrayUnifier {
|
|||
for (int i = 0; i < minWriteIdx; i++) {
|
||||
variableData[i] = readOnlyData[i];
|
||||
}
|
||||
} catch (IllegalArgumentException e) {
|
||||
throw new IllegalArgumentException("ParseException " + file + " at line " + linenr + ": " + e.getMessage());
|
||||
} catch (Exception e) {
|
||||
if (e instanceof IllegalArgumentException) {
|
||||
throw new IllegalArgumentException("ParseException " + file + " at line " + linenr + ": " + e.getMessage());
|
||||
}
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
if (expressionList.size() == 0) {
|
||||
|
@ -883,7 +882,7 @@ public abstract class BExpressionContext implements IByteArrayUnifier {
|
|||
}
|
||||
|
||||
public final boolean isLookupIdxUsed(int idx) {
|
||||
return idx < lookupIdxUsed.length ? lookupIdxUsed[idx] : false;
|
||||
return idx < lookupIdxUsed.length && lookupIdxUsed[idx];
|
||||
}
|
||||
|
||||
public final void setAllTagsUsed() {
|
||||
|
|
|
@ -10,10 +10,11 @@
|
|||
package btools.expressions;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
final class BExpressionLookupValue {
|
||||
String value;
|
||||
ArrayList<String> aliases;
|
||||
List<String> aliases;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
|
|
|
@ -9,16 +9,8 @@ package btools.expressions;
|
|||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.StringTokenizer;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import btools.util.BitCoderContext;
|
||||
import btools.util.Crc32;
|
||||
|
||||
|
||||
public final class BExpressionMetaData {
|
||||
|
@ -30,7 +22,7 @@ public final class BExpressionMetaData {
|
|||
public short lookupVersion = -1;
|
||||
public short lookupMinorVersion = -1;
|
||||
|
||||
private HashMap<String, BExpressionContext> listeners = new HashMap<String, BExpressionContext>();
|
||||
private Map<String, BExpressionContext> listeners = new HashMap<String, BExpressionContext>();
|
||||
|
||||
public void registerListener(String context, BExpressionContext ctx) {
|
||||
listeners.put(context, ctx);
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
package btools.expressions;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
public class IntegrityCheckProfile {
|
||||
|
||||
public static void main(final java.lang.String[] args) {
|
||||
public static void main(final String[] args) {
|
||||
if (args.length != 2) {
|
||||
System.out.println("usage: java IntegrityCheckProfile <lookup-file> <profile-folder>");
|
||||
return;
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
package btools.expressions;
|
||||
|
||||
import java.util.*;
|
||||
import java.io.*;
|
||||
import java.net.URL;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.URL;
|
||||
|
||||
public class EncodeDecodeTest {
|
||||
@Test
|
||||
public void encodeDecodeTest() {
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
*/
|
||||
package btools.mapcreator;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import btools.util.CheapRuler;
|
||||
|
||||
|
@ -15,7 +15,7 @@ public class DPFilter {
|
|||
/*
|
||||
* for each node (except first+last), eventually set the DP_SURVIVOR_BIT
|
||||
*/
|
||||
public static void doDPFilter(ArrayList<OsmNodeP> nodes) {
|
||||
public static void doDPFilter(List<OsmNodeP> nodes) {
|
||||
int first = 0;
|
||||
int last = nodes.size() - 1;
|
||||
while (first < last && (nodes.get(first + 1).bits & OsmNodeP.DP_SURVIVOR_BIT) != 0) {
|
||||
|
@ -30,7 +30,7 @@ public class DPFilter {
|
|||
}
|
||||
|
||||
|
||||
public static void doDPFilter(ArrayList<OsmNodeP> nodes, int first, int last) {
|
||||
public static void doDPFilter(List<OsmNodeP> nodes, int first, int last) {
|
||||
double maxSqDist = -1.;
|
||||
int index = -1;
|
||||
OsmNodeP p1 = nodes.get(first);
|
||||
|
|
|
@ -14,6 +14,7 @@ import java.io.FileInputStream;
|
|||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import btools.util.DiffCoderDataOutputStream;
|
||||
|
||||
|
@ -21,7 +22,7 @@ public abstract class MapCreatorBase implements WayListener, NodeListener, Relat
|
|||
private DiffCoderDataOutputStream[] tileOutStreams;
|
||||
protected File outTileDir;
|
||||
|
||||
protected HashMap<String, String> tags;
|
||||
protected Map<String, String> tags;
|
||||
|
||||
public void putTag(String key, String value) {
|
||||
if (tags == null) tags = new HashMap<String, String>();
|
||||
|
@ -32,11 +33,11 @@ public abstract class MapCreatorBase implements WayListener, NodeListener, Relat
|
|||
return tags == null ? null : tags.get(key);
|
||||
}
|
||||
|
||||
public HashMap<String, String> getTagsOrNull() {
|
||||
public Map<String, String> getTagsOrNull() {
|
||||
return tags;
|
||||
}
|
||||
|
||||
public void setTags(HashMap<String, String> tags) {
|
||||
public void setTags(Map<String, String> tags) {
|
||||
this.tags = tags;
|
||||
}
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ import java.io.BufferedOutputStream;
|
|||
import java.io.DataOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.util.HashMap;
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
|
||||
import btools.expressions.BExpressionContextNode;
|
||||
|
@ -142,7 +142,7 @@ public class OsmCutter extends MapCreatorBase {
|
|||
}
|
||||
|
||||
|
||||
private void generatePseudoTags(HashMap<String, String> map) {
|
||||
private void generatePseudoTags(Map<String, String> map) {
|
||||
// add pseudo.tags for concrete:lanes and concrete:plates
|
||||
|
||||
String concrete = null;
|
||||
|
@ -204,7 +204,7 @@ public class OsmCutter extends MapCreatorBase {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void nextRelation(RelationData r) throws Exception {
|
||||
public void nextRelation(RelationData r) throws IOException {
|
||||
relsParsed++;
|
||||
checkStats();
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ import java.io.File;
|
|||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import btools.expressions.BExpressionContextWay;
|
||||
import btools.util.CheapRuler;
|
||||
|
@ -188,7 +188,7 @@ public class OsmTrafficMap {
|
|||
return map.get(n);
|
||||
}
|
||||
|
||||
public byte[] addTrafficClass(ArrayList<OsmNodeP> linkNodes, byte[] description) throws IOException {
|
||||
public byte[] addTrafficClass(List<OsmNodeP> linkNodes, byte[] description) throws IOException {
|
||||
double distance = 0.;
|
||||
double sum = 0.;
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@ import java.io.File;
|
|||
import java.io.FileInputStream;
|
||||
import java.io.InputStream;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import btools.util.CompactLongSet;
|
||||
import btools.util.DiffCoderDataOutputStream;
|
||||
|
@ -26,7 +27,7 @@ public class PosUnifier extends MapCreatorBase {
|
|||
private File nodeTilesOut;
|
||||
private CompactLongSet[] positionSets;
|
||||
|
||||
private HashMap<String, SrtmRaster> srtmmap;
|
||||
private Map<String, SrtmRaster> srtmmap;
|
||||
private int lastSrtmLonIdx;
|
||||
private int lastSrtmLatIdx;
|
||||
private SrtmRaster lastSrtmRaster;
|
||||
|
|
|
@ -5,6 +5,7 @@ import java.io.DataOutputStream;
|
|||
import java.io.EOFException;
|
||||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import btools.expressions.BExpressionContextWay;
|
||||
import btools.expressions.BExpressionMetaData;
|
||||
|
@ -19,7 +20,7 @@ import btools.util.FrozenLongSet;
|
|||
* @author ab
|
||||
*/
|
||||
public class RelationMerger extends MapCreatorBase {
|
||||
private HashMap<String, CompactLongSet> routesets;
|
||||
private Map<String, CompactLongSet> routesets;
|
||||
private CompactLongSet routesetall;
|
||||
private BExpressionContextWay expctxReport;
|
||||
private BExpressionContextWay expctxCheck;
|
||||
|
|
|
@ -5,9 +5,6 @@ import java.io.EOFException;
|
|||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
|
||||
import btools.util.DenseLongMap;
|
||||
import btools.util.TinyDenseLongMap;
|
||||
|
||||
/**
|
||||
* WayCutter does 2 step in map-processing:
|
||||
* <p>
|
||||
|
|
|
@ -6,6 +6,8 @@ import java.io.DataOutputStream;
|
|||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import btools.util.CheapAngleMeter;
|
||||
|
@ -35,8 +37,8 @@ public class RestrictionData extends MapCreatorBase {
|
|||
|
||||
public boolean badWayMatch;
|
||||
|
||||
private static HashMap<String, String> names = new HashMap<>();
|
||||
private static TreeSet<Long> badTRs = new TreeSet<>();
|
||||
private static Map<String, String> names = new HashMap<>();
|
||||
private static Set<Long> badTRs = new TreeSet<>();
|
||||
|
||||
public RestrictionData() {
|
||||
}
|
||||
|
|
|
@ -38,7 +38,6 @@ public class WayLinker extends MapCreatorBase implements Runnable {
|
|||
private File trafficTilesIn;
|
||||
private File dataTilesOut;
|
||||
private File borderFileIn;
|
||||
private File restrictionsFileIn;
|
||||
|
||||
private String dataTilesSuffix;
|
||||
|
||||
|
@ -157,7 +156,6 @@ public class WayLinker extends MapCreatorBase implements Runnable {
|
|||
this.trafficTilesIn = new File("../traffic");
|
||||
this.dataTilesOut = dataTilesOut;
|
||||
this.borderFileIn = borderFileIn;
|
||||
this.restrictionsFileIn = restrictionsFileIn;
|
||||
this.dataTilesSuffix = dataTilesSuffix;
|
||||
|
||||
BExpressionMetaData meta = new BExpressionMetaData();
|
||||
|
|
|
@ -1,19 +1,16 @@
|
|||
package btools.mapcreator;
|
||||
|
||||
import java.util.Random;
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.net.URL;
|
||||
import java.io.File;
|
||||
import java.net.URL;
|
||||
|
||||
public class MapcreatorTest {
|
||||
@Test
|
||||
public void mapcreatorTest() throws Exception {
|
||||
URL mapurl = this.getClass().getResource("/dreieich.osm.gz");
|
||||
Assert.assertTrue("test-osm-map dreieich.osm not found", mapurl != null);
|
||||
Assert.assertNotNull("test-osm-map dreieich.osm not found", mapurl);
|
||||
File mapFile = new File(mapurl.getFile());
|
||||
File workingDir = mapFile.getParentFile();
|
||||
File profileDir = new File(workingDir, "/../../../../misc/profiles2");
|
||||
|
|
|
@ -8,7 +8,6 @@ import btools.codec.TagValueValidator;
|
|||
import btools.codec.TagValueWrapper;
|
||||
import btools.codec.WaypointMatcher;
|
||||
import btools.util.ByteDataWriter;
|
||||
import btools.util.IByteArrayUnifier;
|
||||
|
||||
/**
|
||||
* DirectWeaver does the same decoding as MicroCache2, but decodes directly
|
||||
|
@ -17,8 +16,6 @@ import btools.util.IByteArrayUnifier;
|
|||
public final class DirectWeaver extends ByteDataWriter {
|
||||
private long id64Base;
|
||||
|
||||
private int size = 0;
|
||||
|
||||
public DirectWeaver(StatCoderContext bc, DataBuffers dataBuffers, int lonIdx, int latIdx, int divisor, TagValueValidator wayValidator, WaypointMatcher waypointMatcher, OsmNodesMap hollowNodes) {
|
||||
super(null);
|
||||
int cellsize = 1000000 / divisor;
|
||||
|
@ -32,7 +29,7 @@ public final class DirectWeaver extends ByteDataWriter {
|
|||
NoisyDiffCoder extLatDiff = new NoisyDiffCoder(bc);
|
||||
NoisyDiffCoder transEleDiff = new NoisyDiffCoder(bc);
|
||||
|
||||
size = bc.decodeNoisyNumber(5);
|
||||
int size = bc.decodeNoisyNumber(5);
|
||||
|
||||
int[] faid = size > dataBuffers.ibuf2.length ? new int[size] : dataBuffers.ibuf2;
|
||||
|
||||
|
|
|
@ -9,8 +9,6 @@ import java.io.DataInput;
|
|||
import java.io.DataOutput;
|
||||
import java.io.IOException;
|
||||
|
||||
import btools.mapaccess.OsmNode;
|
||||
|
||||
public final class MatchedWaypoint {
|
||||
public OsmNode node1;
|
||||
public OsmNode node2;
|
||||
|
|
|
@ -9,6 +9,7 @@ import java.io.File;
|
|||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import btools.codec.DataBuffers;
|
||||
import btools.codec.MicroCache;
|
||||
|
@ -26,7 +27,7 @@ public final class NodesCache {
|
|||
private boolean forceSecondaryData;
|
||||
private String currentFileName;
|
||||
|
||||
private HashMap<String, PhysicalFile> fileCache;
|
||||
private Map<String, PhysicalFile> fileCache;
|
||||
private DataBuffers dataBuffers;
|
||||
|
||||
private OsmFile[][] fileRows;
|
||||
|
@ -38,7 +39,7 @@ public final class NodesCache {
|
|||
|
||||
private long cacheSum = 0;
|
||||
private long maxmemtiles;
|
||||
private boolean detailed;
|
||||
private boolean detailed; // NOPMD used in constructor
|
||||
|
||||
private boolean garbageCollectionEnabled = false;
|
||||
private boolean ghostCleaningDone = false;
|
||||
|
|
|
@ -7,12 +7,13 @@ package btools.mapaccess;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import btools.util.ByteArrayUnifier;
|
||||
import btools.util.SortedHeap;
|
||||
|
||||
public final class OsmNodesMap {
|
||||
private HashMap<OsmNode, OsmNode> hmap = new HashMap<OsmNode, OsmNode>(4096);
|
||||
private Map<OsmNode, OsmNode> hmap = new HashMap<OsmNode, OsmNode>(4096);
|
||||
|
||||
private ByteArrayUnifier abUnifier = new ByteArrayUnifier(16384, false);
|
||||
|
||||
|
@ -123,14 +124,10 @@ public final class OsmNodesMap {
|
|||
return total <= currentmaxmem;
|
||||
}
|
||||
|
||||
private void addActiveNode(ArrayList<OsmNode> nodes2check, OsmNode n) {
|
||||
n.visitID = lastVisitID;
|
||||
nodesCreated++;
|
||||
nodes2check.add(n);
|
||||
}
|
||||
private List<OsmNode> nodes2check;
|
||||
|
||||
// is there an escape from this node
|
||||
// to a hollow node (or destination node) ?
|
||||
// to a hollow node (or destination node) ?
|
||||
public boolean canEscape(OsmNode n0) {
|
||||
boolean sawLowIDs = false;
|
||||
lastVisitID++;
|
||||
|
@ -170,7 +167,11 @@ public final class OsmNodesMap {
|
|||
return false;
|
||||
}
|
||||
|
||||
private ArrayList<OsmNode> nodes2check;
|
||||
private void addActiveNode(List<OsmNode> nodes2check, OsmNode n) {
|
||||
n.visitID = lastVisitID;
|
||||
nodesCreated++;
|
||||
nodes2check.add(n);
|
||||
}
|
||||
|
||||
public void clearTemp() {
|
||||
nodes2check = null;
|
||||
|
|
|
@ -7,16 +7,16 @@ package btools.mapaccess;
|
|||
|
||||
|
||||
public interface OsmPos {
|
||||
public int getILat();
|
||||
int getILat();
|
||||
|
||||
public int getILon();
|
||||
int getILon();
|
||||
|
||||
public short getSElev();
|
||||
short getSElev();
|
||||
|
||||
public double getElev();
|
||||
double getElev();
|
||||
|
||||
public int calcDistance(OsmPos p);
|
||||
int calcDistance(OsmPos p);
|
||||
|
||||
public long getIdFromPos();
|
||||
long getIdFromPos();
|
||||
|
||||
}
|
||||
|
|
|
@ -19,7 +19,6 @@ final public class PhysicalFile {
|
|||
long[] fileIndex = new long[25];
|
||||
int[] fileHeaderCrcs;
|
||||
|
||||
private int fileIndexCrc;
|
||||
public long creationTime;
|
||||
|
||||
String fileName;
|
||||
|
@ -75,7 +74,7 @@ final public class PhysicalFile {
|
|||
byte[] iobuffer = dataBuffers.iobuffer;
|
||||
ra = new RandomAccessFile(f, "r");
|
||||
ra.readFully(iobuffer, 0, 200);
|
||||
fileIndexCrc = Crc32.crc(iobuffer, 0, 200);
|
||||
int fileIndexCrc = Crc32.crc(iobuffer, 0, 200);
|
||||
ByteDataReader dis = new ByteDataReader(iobuffer);
|
||||
for (int i = 0; i < 25; i++) {
|
||||
long lv = dis.readLong();
|
||||
|
|
|
@ -3,8 +3,6 @@ package btools.mapaccess;
|
|||
import java.util.List;
|
||||
|
||||
import btools.codec.WaypointMatcher;
|
||||
import btools.mapaccess.OsmNode;
|
||||
import btools.mapaccess.OsmNodePairSet;
|
||||
import btools.util.CheapRuler;
|
||||
|
||||
/**
|
||||
|
|
|
@ -5,7 +5,7 @@ import java.util.Map;
|
|||
|
||||
public class IpAccessMonitor {
|
||||
private static Object sync = new Object();
|
||||
private static HashMap<String, Long> ipAccess = new HashMap<String, Long>();
|
||||
private static Map<String, Long> ipAccess = new HashMap<String, Long>();
|
||||
private static long MAX_IDLE = 900000; // 15 minutes
|
||||
private static long CLEANUP_INTERVAL = 10000; // 10 seconds
|
||||
private static long lastCleanup;
|
||||
|
|
|
@ -146,7 +146,7 @@ public class RouteServer extends Thread implements Comparable<RouteServer> {
|
|||
}
|
||||
|
||||
String url = getline.split(" ")[1];
|
||||
HashMap<String, String> params = getUrlParams(url);
|
||||
Map<String, String> params = getUrlParams(url);
|
||||
|
||||
long maxRunningTime = getMaxRunningTime();
|
||||
|
||||
|
@ -226,7 +226,7 @@ public class RouteServer extends Thread implements Comparable<RouteServer> {
|
|||
if (track != null) {
|
||||
if (headers != null) // compressed
|
||||
{
|
||||
java.io.ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
Writer w = new OutputStreamWriter(new GZIPOutputStream(baos), "UTF-8");
|
||||
w.write(handler.formatTrack(track));
|
||||
w.close();
|
||||
|
@ -359,7 +359,7 @@ public class RouteServer extends Thread implements Comparable<RouteServer> {
|
|||
}
|
||||
|
||||
|
||||
private static HashMap<String, String> getUrlParams(String url) throws UnsupportedEncodingException {
|
||||
private static Map<String, String> getUrlParams(String url) throws UnsupportedEncodingException {
|
||||
HashMap<String, String> params = new HashMap<String, String>();
|
||||
String decoded = URLDecoder.decode(url, "UTF-8");
|
||||
StringTokenizer tk = new StringTokenizer(decoded, "?&");
|
||||
|
|
|
@ -8,6 +8,7 @@ import java.io.IOException;
|
|||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.StringTokenizer;
|
||||
import java.util.TreeSet;
|
||||
|
||||
|
@ -542,7 +543,6 @@ public class SuspectManager extends Thread {
|
|||
}
|
||||
bw.write("</body></html>\n");
|
||||
bw.flush();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
@ -581,7 +581,7 @@ public class SuspectManager extends Thread {
|
|||
}
|
||||
}
|
||||
|
||||
private static HashMap<String, SuspectList> allSuspectsMap = new HashMap<String, SuspectList>();
|
||||
private static Map<String, SuspectList> allSuspectsMap = new HashMap<String, SuspectList>();
|
||||
|
||||
private static SuspectList getDailySuspectsIfLoaded() throws IOException {
|
||||
synchronized (allSuspectsMap) {
|
||||
|
|
|
@ -1,18 +1,17 @@
|
|||
package btools.server.request;
|
||||
|
||||
import btools.mapaccess.OsmNode;
|
||||
import btools.router.OsmNodeNamed;
|
||||
import btools.router.OsmNogoPolygon;
|
||||
import btools.router.OsmTrack;
|
||||
import btools.router.RoutingContext;
|
||||
import btools.server.ServiceContext;
|
||||
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.StringWriter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import btools.router.OsmNodeNamed;
|
||||
import btools.router.OsmNogoPolygon;
|
||||
import btools.router.OsmTrack;
|
||||
import btools.router.RoutingContext;
|
||||
import btools.server.ServiceContext;
|
||||
|
||||
/**
|
||||
* URL query parameter handler for web and standalone server. Supports all
|
||||
|
@ -37,7 +36,7 @@ public class ServerHandler extends RequestHandler {
|
|||
|
||||
private RoutingContext rc;
|
||||
|
||||
public ServerHandler(ServiceContext serviceContext, HashMap<String, String> params) {
|
||||
public ServerHandler(ServiceContext serviceContext, Map<String, String> params) {
|
||||
super(serviceContext, params);
|
||||
}
|
||||
|
||||
|
|
|
@ -309,12 +309,12 @@ public class BitCoderContext {
|
|||
for (int i = 0; i < 31; i++) {
|
||||
int value = ctx.decodeVarBits();
|
||||
int v0 = (1 << i) + 3;
|
||||
if (!(v0 == value))
|
||||
if (v0 != value)
|
||||
throw new RuntimeException("value mismatch value=" + value + "v0=" + v0);
|
||||
}
|
||||
for (int i = 0; i < 100000; i += 13) {
|
||||
int value = ctx.decodeVarBits();
|
||||
if (!(value == i))
|
||||
if (value != i)
|
||||
throw new RuntimeException("value mismatch i=" + i + "v=" + value);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -142,7 +142,6 @@ public class ByteDataWriter extends ByteDataReader {
|
|||
ab[aboffset++] = (byte) (i7 | 0x80);
|
||||
|
||||
ab[aboffset++] = (byte) (v);
|
||||
return;
|
||||
}
|
||||
|
||||
public int size() {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package btools.util;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Memory efficient Map to map a long-key to an object-value
|
||||
|
@ -243,7 +243,7 @@ public class CompactLongMap<V> {
|
|||
return false;
|
||||
}
|
||||
|
||||
protected void moveToFrozenArrays(long[] faid, ArrayList<V> flv) {
|
||||
protected void moveToFrozenArrays(long[] faid, List<V> flv) {
|
||||
for (int i = 1; i < MAXLISTS; i++) {
|
||||
pa[i] = 0;
|
||||
}
|
||||
|
|
|
@ -141,10 +141,7 @@ public class CompactLongSet {
|
|||
n = nn;
|
||||
}
|
||||
}
|
||||
if (a[n] == id) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return a[n] == id;
|
||||
}
|
||||
|
||||
protected void moveToFrozenArray(long[] faid) {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package btools.util;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Special Memory efficient Map to map a long-key to
|
||||
|
@ -16,7 +17,7 @@ import java.util.ArrayList;
|
|||
* @author ab
|
||||
*/
|
||||
public class DenseLongMap {
|
||||
private ArrayList<byte[]> blocklist = new ArrayList<byte[]>(4096);
|
||||
private List<byte[]> blocklist = new ArrayList<byte[]>(4096);
|
||||
|
||||
private int blocksize; // bytes per bitplane in one block
|
||||
private int blocksizeBits;
|
||||
|
|
|
@ -12,7 +12,7 @@ import java.util.List;
|
|||
*/
|
||||
public class FrozenLongMap<V> extends CompactLongMap<V> {
|
||||
private long[] faid;
|
||||
private ArrayList<V> flv;
|
||||
private List<V> flv;
|
||||
private int size = 0;
|
||||
private int p2size; // next power of 2 of size
|
||||
|
||||
|
|
|
@ -61,10 +61,7 @@ public class FrozenLongSet extends CompactLongSet {
|
|||
}
|
||||
offset >>= 1;
|
||||
}
|
||||
if (a[n] == id) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return a[n] == id;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package btools.util;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Behaves like an Array of list
|
||||
|
@ -10,7 +10,7 @@ import java.util.ArrayList;
|
|||
* @author ab
|
||||
*/
|
||||
public class LazyArrayOfLists<E> {
|
||||
private ArrayList<ArrayList<E>> lists;
|
||||
private List<ArrayList<E>> lists;
|
||||
|
||||
public LazyArrayOfLists(int size) {
|
||||
lists = new ArrayList<ArrayList<E>>(size);
|
||||
|
|
|
@ -37,7 +37,7 @@ public final class MixCoderDataInputStream extends DataInputStream {
|
|||
return lastValue;
|
||||
}
|
||||
|
||||
public final boolean decodeBit() throws IOException {
|
||||
public boolean decodeBit() throws IOException {
|
||||
fillBuffer();
|
||||
boolean value = ((b & 1) != 0);
|
||||
b >>>= 1;
|
||||
|
@ -45,7 +45,7 @@ public final class MixCoderDataInputStream extends DataInputStream {
|
|||
return value;
|
||||
}
|
||||
|
||||
public final int decodeVarBits2() throws IOException {
|
||||
public int decodeVarBits2() throws IOException {
|
||||
int range = 0;
|
||||
while (!decodeBit()) {
|
||||
range = 2 * range + 1;
|
||||
|
@ -58,7 +58,7 @@ public final class MixCoderDataInputStream extends DataInputStream {
|
|||
*
|
||||
* @see #encodeBounded
|
||||
*/
|
||||
public final int decodeBounded(int max) throws IOException {
|
||||
public int decodeBounded(int max) throws IOException {
|
||||
int value = 0;
|
||||
int im = 1; // integer mask
|
||||
while ((value | im) <= max) {
|
||||
|
@ -75,7 +75,7 @@ public final class MixCoderDataInputStream extends DataInputStream {
|
|||
* @see #encodeVarBits
|
||||
*/
|
||||
|
||||
public final int decodeVarBits() throws IOException {
|
||||
public int decodeVarBits() throws IOException {
|
||||
fillBuffer();
|
||||
int b12 = b & 0xfff;
|
||||
int len = vl_length[b12];
|
||||
|
|
|
@ -59,7 +59,7 @@ public final class MixCoderDataOutputStream extends DataOutputStream {
|
|||
}
|
||||
}
|
||||
|
||||
public final void encodeBit(boolean value) throws IOException {
|
||||
public void encodeBit(boolean value) throws IOException {
|
||||
if (bm == 0x100) {
|
||||
writeByte((byte) b);
|
||||
bm = 1;
|
||||
|
@ -71,7 +71,7 @@ public final class MixCoderDataOutputStream extends DataOutputStream {
|
|||
bm <<= 1;
|
||||
}
|
||||
|
||||
public final void encodeVarBits(int value) throws IOException {
|
||||
public void encodeVarBits(int value) throws IOException {
|
||||
int range = 0;
|
||||
while (value > range) {
|
||||
encodeBit(false);
|
||||
|
@ -82,7 +82,7 @@ public final class MixCoderDataOutputStream extends DataOutputStream {
|
|||
encodeBounded(range, value);
|
||||
}
|
||||
|
||||
public final void encodeBounded(int max, int value) throws IOException {
|
||||
public void encodeBounded(int max, int value) throws IOException {
|
||||
int im = 1; // integer mask
|
||||
while (im <= max) {
|
||||
if (bm == 0x100) {
|
||||
|
|
|
@ -2,7 +2,7 @@ package btools.util;
|
|||
|
||||
|
||||
public interface ProgressListener {
|
||||
public void updateProgress(String task, int progress);
|
||||
void updateProgress(String task, int progress);
|
||||
|
||||
public boolean isCanceled();
|
||||
boolean isCanceled();
|
||||
}
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
package btools.util;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
/**
|
||||
* Memory efficient and lightning fast heap to get the lowest-key value of a set of key-object pairs
|
||||
*
|
||||
|
|
|
@ -20,11 +20,11 @@ public class BitCoderContextTest {
|
|||
for (int i = 0; i < 31; i++) {
|
||||
int value = ctx.decodeVarBits();
|
||||
int v0 = (1 << i) + 3;
|
||||
Assert.assertTrue("value mismatch value=" + value + "v0=" + v0, v0 == value);
|
||||
Assert.assertEquals("value mismatch value=" + value + "v0=" + v0, v0, value);
|
||||
}
|
||||
for (int i = 0; i < 100000; i += 13) {
|
||||
int value = ctx.decodeVarBits();
|
||||
Assert.assertTrue("value mismatch i=" + i + "v=" + value, value == i);
|
||||
Assert.assertEquals("value mismatch i=" + i + "v=" + value, value, i);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,8 +1,5 @@
|
|||
package btools.util;
|
||||
|
||||
import java.util.Random;
|
||||
import java.util.HashSet;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
|
@ -18,7 +15,7 @@ public class ByteDataIOTest {
|
|||
|
||||
for (int i = 0; i < 1000; i++) {
|
||||
int value = r.readVarLengthUnsigned();
|
||||
Assert.assertTrue("value mismatch", value == i);
|
||||
Assert.assertEquals("value mismatch", value, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,11 +1,7 @@
|
|||
package btools.util;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
public class CheapAngleMeterTest {
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
package btools.util;
|
||||
|
||||
import java.util.Random;
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Random;
|
||||
|
||||
public class CompactMapTest {
|
||||
@Test
|
||||
public void hashMapComparisonTest() {
|
||||
|
@ -48,8 +48,8 @@ public class CompactMapTest {
|
|||
String s = hmap.get(KK);
|
||||
|
||||
boolean contained = hmap.containsKey(KK);
|
||||
Assert.assertTrue("containsKey missmatch (slow)", contained == cmap_slow.contains(k));
|
||||
Assert.assertTrue("containsKey missmatch (fast)", contained == cmap_fast.contains(k));
|
||||
Assert.assertEquals("containsKey missmatch (slow)", contained, cmap_slow.contains(k));
|
||||
Assert.assertEquals("containsKey missmatch (fast)", contained, cmap_fast.contains(k));
|
||||
|
||||
if (contained) {
|
||||
Assert.assertEquals("object missmatch (fast)", s, cmap_fast.get(k));
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
package btools.util;
|
||||
|
||||
import java.util.Random;
|
||||
import java.util.HashSet;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Random;
|
||||
|
||||
public class CompactSetTest {
|
||||
@Test
|
||||
public void hashSetComparisonTest() {
|
||||
|
@ -46,8 +46,8 @@ public class CompactSetTest {
|
|||
Long KK = new Long(k);
|
||||
|
||||
boolean contained = hset.contains(KK);
|
||||
Assert.assertTrue("contains missmatch (slow)", contained == cset_slow.contains(k));
|
||||
Assert.assertTrue("contains missmatch (fast)", contained == cset_fast.contains(k));
|
||||
Assert.assertEquals("contains missmatch (slow)", contained, cset_slow.contains(k));
|
||||
Assert.assertEquals("contains missmatch (fast)", contained, cset_fast.contains(k));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
package btools.util;
|
||||
|
||||
import java.util.Random;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Random;
|
||||
|
||||
public class DenseLongMapTest {
|
||||
@Test
|
||||
public void hashMapComparisonTest() {
|
||||
|
@ -94,7 +94,7 @@ public class DenseLongMapTest {
|
|||
}
|
||||
|
||||
// need to use the map again for valid memory measure
|
||||
Assert.assertTrue("out of range test", dmap.getInt(-1) == -1);
|
||||
Assert.assertEquals("out of range test", -1, dmap.getInt(-1));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
package btools.util;
|
||||
|
||||
import java.util.Random;
|
||||
import java.io.*;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class ReducedMedianFilterTest {
|
||||
@Test
|
||||
public void reducedMedianFilterTest() throws IOException {
|
||||
|
|
|
@ -1,12 +1,10 @@
|
|||
package btools.util;
|
||||
|
||||
import java.util.Random;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class SortedHeapTest {
|
||||
@Test
|
||||
public void sortedHeapTest1() {
|
||||
|
@ -30,7 +28,7 @@ public class SortedHeapTest {
|
|||
Assert.assertTrue("sorting test", val >= lastval);
|
||||
lastval = val;
|
||||
}
|
||||
Assert.assertTrue("total count test", cnt == 100000);
|
||||
Assert.assertEquals("total count test", 100000, cnt);
|
||||
|
||||
}
|
||||
|
||||
|
@ -49,10 +47,10 @@ public class SortedHeapTest {
|
|||
if (s == null) break;
|
||||
cnt++;
|
||||
int val = Integer.parseInt(s);
|
||||
Assert.assertTrue("sequence test", val == expected);
|
||||
Assert.assertEquals("sequence test", val, expected);
|
||||
expected++;
|
||||
}
|
||||
Assert.assertTrue("total count test", cnt == 100000);
|
||||
Assert.assertEquals("total count test", 100000, cnt);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
18
build.gradle
18
build.gradle
|
@ -1,14 +1,14 @@
|
|||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||
|
||||
buildscript {
|
||||
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
google()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:7.0.2'
|
||||
|
||||
|
||||
|
||||
// NOTE: Do not place your application dependencies here; they belong
|
||||
// in the individual module build.gradle files
|
||||
|
@ -23,12 +23,12 @@ allprojects {
|
|||
// OsmTrack (version and versionDate)
|
||||
project.version "1.6.3"
|
||||
group 'org.btools'
|
||||
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
google()
|
||||
}
|
||||
|
||||
|
||||
apply plugin: "maven-publish"
|
||||
publishing {
|
||||
repositories {
|
||||
|
@ -47,6 +47,16 @@ allprojects {
|
|||
}
|
||||
|
||||
apply plugin: "checkstyle"
|
||||
apply plugin: "pmd"
|
||||
|
||||
pmd {
|
||||
consoleOutput = true
|
||||
toolVersion = "6.51.0"
|
||||
rulesMinimumPriority = 5
|
||||
ruleSetFiles = files("${rootProject.rootDir}/config/pmd/pmd-ruleset.xml")
|
||||
ruleSets = []
|
||||
// ignoreFailures = true
|
||||
}
|
||||
}
|
||||
|
||||
task clean(type: Delete) {
|
||||
|
|
51
config/pmd/pmd-ruleset.xml
Normal file
51
config/pmd/pmd-ruleset.xml
Normal file
|
@ -0,0 +1,51 @@
|
|||
<?xml version="1.0"?>
|
||||
|
||||
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="Custom Rules"
|
||||
xmlns="http://pmd.sourceforge.net/ruleset/2.0.0"
|
||||
xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0 https://pmd.sourceforge.io/ruleset_2_0_0.xsd">
|
||||
|
||||
<description>
|
||||
BRouter PMD Ruleset
|
||||
</description>
|
||||
|
||||
<rule ref="rulesets/java/quickstart.xml">
|
||||
<exclude name="AbstractClassWithoutAnyMethod" />
|
||||
<exclude name="AssignmentInOperand" />
|
||||
<exclude name="AssignmentToNonFinalStatic" />
|
||||
<exclude name="AvoidBranchingStatementAsLastInLoop" />
|
||||
<exclude name="AvoidCatchingThrowable" />
|
||||
<exclude name="AvoidProtectedFieldInFinalClass" />
|
||||
<exclude name="AvoidUsingVolatile" />
|
||||
<exclude name="CloseResource" />
|
||||
<exclude name="CompareObjectsWithEquals" />
|
||||
<exclude name="ControlStatementBraces" />
|
||||
<exclude name="DoNotCallGarbageCollectionExplicitly" />
|
||||
<exclude name="EmptyCatchBlock" />
|
||||
<exclude name="EmptyControlStatement" />
|
||||
<exclude name="ForLoopCanBeForeach" />
|
||||
<exclude name="LiteralsFirstInComparisons" />
|
||||
<exclude name="MissingOverride" />
|
||||
<exclude name="OneDeclarationPerLine" />
|
||||
<exclude name="OverrideBothEqualsAndHashcode" />
|
||||
<exclude name="PreserveStackTrace" />
|
||||
<exclude name="PrimitiveWrapperInstantiation" />
|
||||
<exclude name="ReturnEmptyCollectionRatherThanNull" />
|
||||
<exclude name="UncommentedEmptyConstructor" />
|
||||
<exclude name="UncommentedEmptyMethodBody" />
|
||||
<exclude name="UnusedFormalParameter" />
|
||||
<exclude name="UnusedLocalVariable" />
|
||||
<exclude name="UnusedPrivateField" />
|
||||
<exclude name="UnusedPrivateMethod" />
|
||||
<exclude name="UseCollectionIsEmpty" />
|
||||
<exclude name="UseLocaleWithCaseConversions" />
|
||||
<exclude name="UseNotifyAllInsteadOfNotify" />
|
||||
<exclude name="UseUtilityClass" />
|
||||
<exclude name="UselessParentheses" />
|
||||
|
||||
<!-- Naming -->
|
||||
<exclude name="FormalParameterNamingConventions" />
|
||||
<exclude name="LocalVariableNamingConventions" />
|
||||
<exclude name="MethodNamingConventions" />
|
||||
</rule>
|
||||
|
||||
</ruleset>
|
Loading…
Reference in a new issue