Skip to content

Commit

Permalink
keep making codefactor happy
Browse files Browse the repository at this point in the history
  • Loading branch information
granny committed Mar 26, 2024
1 parent 04ed76c commit 0005ee8
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 46 deletions.
36 changes: 21 additions & 15 deletions core/src/main/java/net/pl3x/map/core/util/StringUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import java.io.IOException;
import java.io.StringWriter;
import java.io.Writer;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

// from apache commons StringEscapeUtils
Expand Down Expand Up @@ -73,21 +74,7 @@ private static void unescapeJava(@Nullable Writer out, @Nullable String str) thr
if (hadSlash) {
// handle an escaped value
hadSlash = false;
switch (ch) {
case '\\' -> out.write('\\');
case '\'' -> out.write('\'');
case '\"' -> out.write('"');
case 'r' -> out.write('\r');
case 'f' -> out.write('\f');
case 't' -> out.write('\t');
case 'n' -> out.write('\n');
case 'b' -> out.write('\b');
case 'u' -> {
// uh-oh, we're in unicode country....
inUnicode = true;
}
default -> out.write(ch);
}
inUnicode = handleSlash(out, ch, inUnicode);
continue;
} else if (ch == '\\') {
hadSlash = true;
Expand All @@ -101,4 +88,23 @@ private static void unescapeJava(@Nullable Writer out, @Nullable String str) thr
out.write('\\');
}
}

private static boolean handleSlash(@NotNull Writer out, char ch, boolean inUnicode) throws IOException {
switch (ch) {
case '\\' -> out.write('\\');
case '\'' -> out.write('\'');
case '\"' -> out.write('"');
case 'r' -> out.write('\r');
case 'f' -> out.write('\f');
case 't' -> out.write('\t');
case 'n' -> out.write('\n');
case 'b' -> out.write('\b');
case 'u' -> {
// uh-oh, we're in unicode country....
inUnicode = true;
}
default -> out.write(ch);
}
return inUnicode;
}
}
2 changes: 1 addition & 1 deletion webmap/src/marker/options/Fill.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export class Fill {
private readonly _properties: L.PathOptions;

constructor(data: FillOptions) {
let props: {} = {};
let props: object = {};

if (isset(data.enabled)) props = {...props, fill: data.enabled};
if (isset(data.type)) props = {...props, fillRule: Type[data.type!]};
Expand Down
49 changes: 21 additions & 28 deletions webmap/src/marker/options/Popup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ export class Popup {
this._content = isset(data.content) ? data.content! : "";

let props: L.PopupOptions = {};
if (isset(data.offset)) props = {...props, offset: [data.offset!.x, data.offset!.z]};
if (isset(data.offset)) props.offset = [data.offset!.x, data.offset!.z];

this.constructSize(data, props);
this.constructPanning(data, props);
this.constructClosing(data, props);
this.applySize(data, props);
this.applyPanning(data, props);
this.applyClosing(data, props);

if (isset(data.pane)) {
const dom: HTMLElement = getOrCreatePane(data.pane!);
Expand All @@ -45,32 +45,25 @@ export class Popup {
this._properties = props;
}

constructSize(data: PopupOptions, props: L.PopupOptions): void {
if (isset(data.maxWidth)) props = {...props, maxWidth: data.maxWidth};
if (isset(data.minWidth)) props = {...props, minWidth: data.minWidth};
if (isset(data.maxHeight)) props = {...props, maxHeight: data.maxHeight};
applySize(data: PopupOptions, props: L.PopupOptions): void {
if (isset(data.maxWidth)) props.maxWidth = data.maxWidth;
if (isset(data.minWidth)) props.minWidth = data.minWidth;
if (isset(data.maxHeight)) props.maxHeight = data.maxHeight;
}
constructPanning(data: PopupOptions, props: L.PopupOptions): void {
if (isset(data.autoPan)) props = {...props, autoPan: data.autoPan};
if (isset(data.autoPanPaddingTopLeft)) props = {
...props,
autoPanPaddingTopLeft: [data.autoPanPaddingTopLeft!.x, data.autoPanPaddingTopLeft!.z]
};
if (isset(data.autoPanPaddingBottomRight)) props = {
...props,
autoPanPaddingBottomRight: [data.autoPanPaddingBottomRight!.x, data.autoPanPaddingBottomRight!.z]
};
if (isset(data.autoPanPadding)) props = {
...props,
autoPanPadding: [data.autoPanPadding!.x, data.autoPanPadding!.z]
};
if (isset(data.keepInView)) props = {...props, keepInView: data.keepInView};

applyPanning(data: PopupOptions, props: L.PopupOptions): void {
if (isset(data.autoPan)) props.autoPan = data.autoPan;
if (isset(data.autoPanPaddingTopLeft)) props.autoPanPaddingTopLeft = [data.autoPanPaddingTopLeft!.x, data.autoPanPaddingTopLeft!.z];
if (isset(data.autoPanPaddingBottomRight)) props.autoPanPaddingBottomRight = [data.autoPanPaddingBottomRight!.x, data.autoPanPaddingBottomRight!.z];
if (isset(data.autoPanPadding)) props.autoPanPadding = [data.autoPanPadding!.x, data.autoPanPadding!.z];
if (isset(data.keepInView)) props.keepInView = data.keepInView;
}
constructClosing(data: PopupOptions, props: L.PopupOptions): void {
if (isset(data.closeButton)) props = {...props, closeButton: data.closeButton};
if (isset(data.autoClose)) props = {...props, autoClose: data.autoClose};
if (isset(data.closeOnEscapeKey)) props = {...props, closeOnEscapeKey: data.closeOnEscapeKey};
if (isset(data.closeOnClick)) props = {...props, closeOnClick: data.closeOnClick};

applyClosing(data: PopupOptions, props: L.PopupOptions): void {
if (isset(data.closeButton)) props.closeButton = data.closeButton;
if (isset(data.autoClose)) props.autoClose = data.autoClose;
if (isset(data.closeOnEscapeKey)) props.closeOnEscapeKey = data.closeOnEscapeKey;
if (isset(data.closeOnClick)) props.closeOnClick = data.closeOnClick;
}

get content(): string {
Expand Down
2 changes: 1 addition & 1 deletion webmap/src/marker/options/Stroke.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export class Stroke {
private readonly _properties: L.PathOptions;

constructor(data: StrokeOptions) {
let props: {} = {};
let props: object = {};

if (isset(data.enabled)) props = {...props, stroke: data.enabled};
if (isset(data.weight)) props = {...props, weight: data.weight};
Expand Down
2 changes: 1 addition & 1 deletion webmap/src/marker/options/Tooltip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export class Tooltip {
constructor(data: TooltipOptions) {
this._content = isset(data.content) ? data.content! : "";

let props: {} = {};
let props: object = {};
if (isset(data.offset)) props = {...props, offset: [data.offset!.x, data.offset!.z]};
if (isset(data.direction)) props = {...props, direction: Direction[data.direction!]};
if (isset(data.permanent)) props = {...props, permanent: data.permanent};
Expand Down

0 comments on commit 0005ee8

Please sign in to comment.