Refactor and code smells

This commit is contained in:
2026-01-06 10:05:00 +01:00
parent b783ab8b8d
commit fbfb0b5459
7 changed files with 31 additions and 34 deletions

View File

@@ -11,6 +11,7 @@ import org.springframework.stereotype.Component;
@Component @Component
public class GitInfoService { public class GitInfoService {
private static final String FALLBACK_GIT_SHA = "unknown"; private static final String FALLBACK_GIT_SHA = "unknown";
private static final Logger LOG = LoggerFactory.getLogger(GitInfoService.class); private static final Logger LOG = LoggerFactory.getLogger(GitInfoService.class);
private static final String COMMIT_URL_PREFIX = "https://github.com/Kruhlmann/imgfloat-j/commit/"; private static final String COMMIT_URL_PREFIX = "https://github.com/Kruhlmann/imgfloat-j/commit/";

View File

@@ -1,8 +1,8 @@
package dev.kruhlmann.imgfloat.service; package dev.kruhlmann.imgfloat.service;
import java.io.FileNotFoundException;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.FileNotFoundException;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.Path; import java.nio.file.Path;

View File

@@ -4,14 +4,12 @@ import java.util.Arrays;
import java.util.Objects; import java.util.Objects;
public record AssetContent(byte[] bytes, String mediaType) { public record AssetContent(byte[] bytes, String mediaType) {
@Override @Override
public boolean equals(Object o) { public boolean equals(Object o) {
if (this == o) return true; if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false; if (o == null || getClass() != o.getClass()) return false;
AssetContent that = (AssetContent) o; AssetContent that = (AssetContent) o;
return Arrays.equals(bytes, that.bytes) return Arrays.equals(bytes, that.bytes) && Objects.equals(mediaType, that.mediaType);
&& Objects.equals(mediaType, that.mediaType);
} }
@Override @Override
@@ -23,9 +21,6 @@ public record AssetContent(byte[] bytes, String mediaType) {
@Override @Override
public String toString() { public String toString() {
return "AssetContent{" + return "AssetContent{" + "bytes=" + Arrays.toString(bytes) + ", mediaType='" + mediaType + '\'' + '}';
"bytes=" + Arrays.toString(bytes) +
", mediaType='" + mediaType + '\'' +
'}';
} }
} }

View File

@@ -8,7 +8,6 @@ import java.io.IOException;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.nio.file.Files; import java.nio.file.Files;
import java.util.List; import java.util.List;
import java.util.Optional;
import javax.imageio.IIOImage; import javax.imageio.IIOImage;
import javax.imageio.ImageIO; import javax.imageio.ImageIO;
import javax.imageio.ImageWriteParam; import javax.imageio.ImageWriteParam;

View File

@@ -3,24 +3,19 @@ package dev.kruhlmann.imgfloat.service.media;
import java.util.Arrays; import java.util.Arrays;
import java.util.Objects; import java.util.Objects;
public record OptimizedAsset( public record OptimizedAsset(byte[] bytes, String mediaType, int width, int height, byte[] previewBytes) {
byte[] bytes,
String mediaType,
int width,
int height,
byte[] previewBytes
) {
@Override @Override
public boolean equals(Object o) { public boolean equals(Object o) {
if (this == o) return true; if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false; if (o == null || getClass() != o.getClass()) return false;
OptimizedAsset that = (OptimizedAsset) o; OptimizedAsset that = (OptimizedAsset) o;
return width == that.width return (
&& height == that.height width == that.width &&
&& Arrays.equals(bytes, that.bytes) height == that.height &&
&& Arrays.equals(previewBytes, that.previewBytes) Arrays.equals(bytes, that.bytes) &&
&& Objects.equals(mediaType, that.mediaType); Arrays.equals(previewBytes, that.previewBytes) &&
Objects.equals(mediaType, that.mediaType)
);
} }
@Override @Override
@@ -33,12 +28,20 @@ public record OptimizedAsset(
@Override @Override
public String toString() { public String toString() {
return "OptimizedAsset{" + return (
"bytes=" + Arrays.toString(bytes) + "OptimizedAsset{" +
", mediaType='" + mediaType + '\'' + "bytes=" +
", width=" + width + Arrays.toString(bytes) +
", height=" + height + ", mediaType='" +
", previewBytes=" + Arrays.toString(previewBytes) + mediaType +
'}'; '\'' +
", width=" +
width +
", height=" +
height +
", previewBytes=" +
Arrays.toString(previewBytes) +
'}'
);
} }
} }

View File

@@ -1,6 +1,8 @@
const path = require("node:path");
const { app, BrowserWindow } = require("electron"); const { app, BrowserWindow } = require("electron");
const { autoUpdater } = require("electron-updater"); const { autoUpdater } = require("electron-updater");
const path = require("path");
const initialWindowWidthPx = 960; const initialWindowWidthPx = 960;
const initialWindowHeightPx = 640; const initialWindowHeightPx = 640;

View File

@@ -1762,6 +1762,7 @@ button:disabled:hover {
position: relative; position: relative;
padding-right: 48px !important; padding-right: 48px !important;
font-variant-numeric: tabular-nums; font-variant-numeric: tabular-nums;
-moz-appearance: textfield;
} }
.number-input::-webkit-outer-spin-button, .number-input::-webkit-outer-spin-button,
@@ -1770,10 +1771,6 @@ button:disabled:hover {
margin: 0; margin: 0;
} }
.number-input {
-moz-appearance: textfield;
}
.number-input:focus { .number-input:focus {
border-color: #7c3aed; border-color: #7c3aed;
box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.25); box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.25);