mirror of
https://github.com/xpipe-io/xpipe.git
synced 2026-08-25 18:56:39 +00:00
Fully replace .trim() with .strip() [stage]
This commit is contained in:
@@ -82,7 +82,7 @@ public class BeaconRequestHandler<T> implements HttpHandler {
|
||||
.getDeclaredFields()[0]
|
||||
.getType()
|
||||
.equals(byte[].class);
|
||||
if (!new String(read, StandardCharsets.US_ASCII).trim().startsWith("{") && rawDataRequestClass) {
|
||||
if (!new String(read, StandardCharsets.US_ASCII).strip().startsWith("{") && rawDataRequestClass) {
|
||||
object = createRawDataRequest(beaconInterface, read);
|
||||
} else {
|
||||
var tree = JacksonMapper.getDefault().readTree(read);
|
||||
@@ -128,7 +128,7 @@ public class BeaconRequestHandler<T> implements HttpHandler {
|
||||
.replace("Exchange$Request", "Request")
|
||||
.replace("at [Source: UNKNOWN; byte offset: #UNKNOWN]", "")
|
||||
.replaceAll("(\\w+) is marked non-null but is null", "field $1 is missing from object")
|
||||
.trim();
|
||||
.strip();
|
||||
writeError(exchange, new BeaconClientErrorResponse(message), 400);
|
||||
}
|
||||
return;
|
||||
|
||||
@@ -31,12 +31,12 @@ public class HandshakeExchangeImpl extends HandshakeExchange {
|
||||
|
||||
private boolean checkAuth(BeaconAuthMethod authMethod) {
|
||||
if (authMethod instanceof BeaconAuthMethod.Local local) {
|
||||
var c = local.getAuthFileContent().trim();
|
||||
var c = local.getAuthFileContent().strip();
|
||||
return AppBeaconServer.get().getLocalAuthSecret().equals(c);
|
||||
}
|
||||
|
||||
if (authMethod instanceof BeaconAuthMethod.ApiKey key) {
|
||||
var c = key.getKey().trim();
|
||||
var c = key.getKey().strip();
|
||||
return AppPrefs.get().apiKey().get().equals(c);
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ public class BrowserFileSystemHelper {
|
||||
return null;
|
||||
}
|
||||
|
||||
path = path.trim();
|
||||
path = path.strip();
|
||||
if (path.isBlank()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -53,15 +53,15 @@ public abstract class BrowserIconDirectoryType {
|
||||
String line;
|
||||
while ((line = reader.readLine()) != null) {
|
||||
var split = line.split("\\|");
|
||||
var id = split[0].trim();
|
||||
var id = split[0].strip();
|
||||
var filter = Arrays.stream(split[1].split(","))
|
||||
.map(s -> {
|
||||
return s.trim();
|
||||
return s.strip();
|
||||
})
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
var closedIcon = "browser/" + split[2].trim();
|
||||
var lightClosedIcon = split.length > 4 ? "browser/" + split[4].trim() : closedIcon;
|
||||
var closedIcon = "browser/" + split[2].strip();
|
||||
var lightClosedIcon = split.length > 4 ? "browser/" + split[4].strip() : closedIcon;
|
||||
|
||||
ALL.add(new Simple(id, new BrowserIconVariant(lightClosedIcon, closedIcon), filter));
|
||||
}
|
||||
|
||||
@@ -31,10 +31,10 @@ public abstract class BrowserIconFileType {
|
||||
String line;
|
||||
while ((line = reader.readLine()) != null) {
|
||||
var split = line.split("\\|");
|
||||
var id = split[0].trim();
|
||||
var id = split[0].strip();
|
||||
var filter = Arrays.stream(split[1].split(","))
|
||||
.map(s -> {
|
||||
var r = s.trim();
|
||||
var r = s.strip();
|
||||
if (r.startsWith(".")) {
|
||||
return r;
|
||||
}
|
||||
@@ -46,8 +46,8 @@ public abstract class BrowserIconFileType {
|
||||
return "." + r;
|
||||
})
|
||||
.collect(Collectors.toSet());
|
||||
var darkIcon = "browser/" + split[2].trim();
|
||||
var lightIcon = (split.length > 3 ? "browser/" + split[3].trim() : darkIcon);
|
||||
var darkIcon = "browser/" + split[2].strip();
|
||||
var lightIcon = (split.length > 3 ? "browser/" + split[3].strip() : darkIcon);
|
||||
ALL.add(new BrowserIconFileType.Simple(id, lightIcon, darkIcon, filter));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -127,7 +127,7 @@ public class MarkdownComp extends Comp<CompStructure<StackPane>> {
|
||||
engine.getLoadWorker()
|
||||
.stateProperty()
|
||||
.addListener((observable, oldValue, newValue) -> Platform.runLater(() -> {
|
||||
String toBeopen = engine.getLoadWorker().getMessage().trim().replace("Loading ", "");
|
||||
String toBeopen = engine.getLoadWorker().getMessage().strip().replace("Loading ", "");
|
||||
if (toBeopen.contains("http://") || toBeopen.contains("https://") || toBeopen.contains("mailto:")) {
|
||||
engine.getLoadWorker().cancel();
|
||||
Hyperlinks.open(toBeopen);
|
||||
|
||||
@@ -85,7 +85,7 @@ public class AppExtensionManager {
|
||||
var installVersion = AppVersion.parse(iv)
|
||||
.orElseThrow(() -> new IllegalArgumentException("Invalid installation version: " + iv));
|
||||
var sv = !AppProperties.get().isImage()
|
||||
? Files.readString(Path.of("version")).trim()
|
||||
? Files.readString(Path.of("version")).strip()
|
||||
: AppProperties.get().getVersion();
|
||||
var sourceVersion = AppVersion.parse(sv)
|
||||
.orElseThrow(() -> new IllegalArgumentException("Invalid source version: " + sv));
|
||||
@@ -107,7 +107,7 @@ public class AppExtensionManager {
|
||||
var proc = fc.start();
|
||||
var out = new String(proc.getInputStream().readAllBytes());
|
||||
proc.waitFor(1, TimeUnit.SECONDS);
|
||||
return out.trim();
|
||||
return out.strip();
|
||||
}
|
||||
|
||||
public Set<Module> getContentModules() {
|
||||
|
||||
@@ -61,7 +61,7 @@ public class ErrorEvent {
|
||||
return builder()
|
||||
.throwable(t)
|
||||
.description(
|
||||
msg + (t.getMessage() != null ? "\n\n" + t.getMessage().trim() : ""));
|
||||
msg + (t.getMessage() != null ? "\n\n" + t.getMessage().strip() : ""));
|
||||
}
|
||||
|
||||
public static ErrorEventBuilder fromMessage(String msg) {
|
||||
|
||||
@@ -79,7 +79,7 @@ public class ErrorHandlerComp extends SimpleComp {
|
||||
if (desc == null) {
|
||||
desc = AppI18n.get("errorNoDetail");
|
||||
}
|
||||
desc = desc.trim();
|
||||
desc = desc.strip();
|
||||
|
||||
if (event.isTerminal()) {
|
||||
desc = desc + "\n\n" + AppI18n.get("terminalErrorDescription");
|
||||
|
||||
@@ -88,7 +88,7 @@ public class PasswordManagerCommand implements PasswordManager {
|
||||
if (cmd.contains("dcli")) {
|
||||
out = out.lines()
|
||||
.findFirst()
|
||||
.map(s -> s.trim().replaceAll("\\s+$", ""))
|
||||
.map(s -> s.strip().replaceAll("\\s+$", ""))
|
||||
.orElse(null);
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ public class ExternalApplicationHelper {
|
||||
return;
|
||||
}
|
||||
|
||||
raw = raw.trim();
|
||||
raw = raw.strip();
|
||||
var split = Arrays.asList(raw.split("\\s+"));
|
||||
if (split.size() == 0) {
|
||||
return;
|
||||
@@ -40,7 +40,7 @@ public class ExternalApplicationHelper {
|
||||
}
|
||||
end++;
|
||||
exec = raw.substring(1, end);
|
||||
args = raw.substring(end + 1).trim();
|
||||
args = raw.substring(end + 1).strip();
|
||||
} else {
|
||||
exec = split.getFirst();
|
||||
args = split.stream().skip(1).collect(Collectors.joining(" "));
|
||||
|
||||
@@ -165,7 +165,7 @@ public class DataStoreEntry extends StorageElement {
|
||||
null,
|
||||
uuid,
|
||||
categoryUuid,
|
||||
name.trim(),
|
||||
name.strip(),
|
||||
Instant.now(),
|
||||
Instant.now(),
|
||||
storeFromNode,
|
||||
@@ -215,7 +215,7 @@ public class DataStoreEntry extends StorageElement {
|
||||
var categoryUuid = Optional.ofNullable(json.get("categoryUuid"))
|
||||
.map(jsonNode -> UUID.fromString(jsonNode.textValue()))
|
||||
.orElse(DataStorage.DEFAULT_CATEGORY_UUID);
|
||||
var name = json.required("name").textValue().trim();
|
||||
var name = json.required("name").textValue().strip();
|
||||
var color = Optional.ofNullable(json.get("color"))
|
||||
.map(node -> {
|
||||
try {
|
||||
|
||||
@@ -20,7 +20,7 @@ public class LocalExec {
|
||||
if (process.exitValue() != 0) {
|
||||
return Optional.empty();
|
||||
} else {
|
||||
var s = new String(out, StandardCharsets.UTF_8).trim();
|
||||
var s = new String(out, StandardCharsets.UTF_8).strip();
|
||||
TrackEvent.withTrace("Local command finished")
|
||||
.tag("command", String.join(" ", command))
|
||||
.tag("stdout", s)
|
||||
|
||||
@@ -46,11 +46,11 @@ public class RdpConfig {
|
||||
}
|
||||
|
||||
if (split.length == 2) {
|
||||
map.put(split[0].trim(), new RdpConfig.TypedValue("s", split[1].trim()));
|
||||
map.put(split[0].strip(), new RdpConfig.TypedValue("s", split[1].strip()));
|
||||
}
|
||||
|
||||
if (split.length == 3) {
|
||||
map.put(split[0].trim(), new RdpConfig.TypedValue(split[1].trim(), split[2].trim()));
|
||||
map.put(split[0].strip(), new RdpConfig.TypedValue(split[1].strip(), split[2].strip()));
|
||||
}
|
||||
});
|
||||
return new RdpConfig(map);
|
||||
|
||||
@@ -37,7 +37,7 @@ public class Validators {
|
||||
}
|
||||
|
||||
public static void notEmpty(String string) throws ValidationException {
|
||||
if (string.trim().length() == 0) {
|
||||
if (string.strip().length() == 0) {
|
||||
throw new ValidationException(AppI18n.get("app.valueMustNotBeEmpty"));
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -108,13 +108,13 @@ project.ext {
|
||||
privateExtensions = file("$rootDir/private_extensions.txt").exists() ? file("$rootDir/private_extensions.txt").readLines() : []
|
||||
isFullRelease = System.getenv('RELEASE') != null && Boolean.parseBoolean(System.getenv('RELEASE'))
|
||||
isStage = System.getenv('STAGE') != null && Boolean.parseBoolean(System.getenv('STAGE'))
|
||||
rawVersion = file('version').text.trim()
|
||||
rawVersion = file('version').text.strip()
|
||||
versionString = rawVersion + (isFullRelease || isStage ? '' : '-SNAPSHOT')
|
||||
versionReleaseNumber = rawVersion.split('-').length == 2 ? Integer.parseInt(rawVersion.split('-')[1]) : 1
|
||||
canonicalVersionString = rawVersion.split('-').length == 2 ? rawVersion.split('-')[0] : rawVersion
|
||||
buildId = UUID.nameUUIDFromBytes(versionString.getBytes())
|
||||
obfuscate = true
|
||||
changelog = file("dist/changelogs/${canonicalVersionString}.md").exists() ? file("dist/changelogs/${canonicalVersionString}.md").text.trim() + '\n' : ""
|
||||
changelog = file("dist/changelogs/${canonicalVersionString}.md").exists() ? file("dist/changelogs/${canonicalVersionString}.md").text.strip() + '\n' : ""
|
||||
productName = isStage ? 'XPipe PTB' : 'XPipe'
|
||||
kebapProductName = isStage ? 'xpipe-ptb' : 'xpipe'
|
||||
flatcaseProductName = isStage ? 'xpipeptb' : 'xpipe'
|
||||
|
||||
@@ -511,7 +511,7 @@ public abstract class Dialog {
|
||||
@Override
|
||||
protected DialogElement next(String answer) {
|
||||
if (element.requiresExplicitUserInput()
|
||||
&& (answer == null || answer.trim().length() == 0)) {
|
||||
&& (answer == null || answer.strip().length() == 0)) {
|
||||
return element;
|
||||
}
|
||||
|
||||
|
||||
@@ -72,7 +72,7 @@ public abstract class QueryConverter<T> {
|
||||
throw new IllegalArgumentException("Too many colons");
|
||||
}
|
||||
|
||||
return new AbstractMap.SimpleEntry<>(split[0].trim(), split[1].trim());
|
||||
return new AbstractMap.SimpleEntry<>(split[0].strip(), split[1].strip());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -38,7 +38,7 @@ public class ProcessOutputException extends Exception {
|
||||
public static ProcessOutputException of(long exitCode, String... messages) {
|
||||
var combinedError = Arrays.stream(messages)
|
||||
.filter(s -> s != null && !s.isBlank())
|
||||
.map(s -> s.trim())
|
||||
.map(s -> s.strip())
|
||||
.collect(Collectors.joining("\n\n"))
|
||||
.replaceAll("\r\n", "\n");
|
||||
var hasMessage = !combinedError.isBlank();
|
||||
|
||||
@@ -40,7 +40,7 @@ public final class FilePath {
|
||||
if (value.isBlank()) {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
if (!value.equals(value.trim())) {
|
||||
if (!value.equals(value.strip())) {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ public class StorePath {
|
||||
throw new IllegalArgumentException("Separator character " + SEPARATOR + " is not allowed in the names");
|
||||
}
|
||||
|
||||
if (Arrays.stream(names).anyMatch(s -> s.trim().length() == 0)) {
|
||||
if (Arrays.stream(names).anyMatch(s -> s.strip().length() == 0)) {
|
||||
throw new IllegalArgumentException("Trimmed entry name is empty");
|
||||
}
|
||||
|
||||
|
||||
Vendored
+1
-1
@@ -69,7 +69,7 @@ task createChecksums(type: Checksum) {
|
||||
continue
|
||||
}
|
||||
|
||||
artifactChecksumsSha256Hex.put(name, file.text.trim())
|
||||
artifactChecksumsSha256Hex.put(name, file.text.strip())
|
||||
}
|
||||
|
||||
file(layout.buildDirectory.dir("dist/checksums/sha256sums.txt")).text = artifactChecksumsSha256Hex.entrySet().stream()
|
||||
|
||||
@@ -135,7 +135,7 @@ public class IncusCommandView extends CommandViewBase {
|
||||
var output = c.readStdoutOrThrow();
|
||||
return output.lines()
|
||||
.collect(Collectors.toMap(
|
||||
s -> s.trim().split(",")[0], s -> s.trim().split(",")[1], (x, y) -> y, LinkedHashMap::new));
|
||||
s -> s.strip().split(",")[0], s -> s.strip().split(",")[1], (x, y) -> y, LinkedHashMap::new));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -141,7 +141,7 @@ public class LxdCommandView extends CommandViewBase {
|
||||
var output = c.readStdoutOrThrow();
|
||||
return output.lines()
|
||||
.collect(Collectors.toMap(
|
||||
s -> s.trim().split(",")[0], s -> s.trim().split(",")[1], (x, y) -> y, LinkedHashMap::new));
|
||||
s -> s.strip().split(",")[0], s -> s.strip().split(",")[1], (x, y) -> y, LinkedHashMap::new));
|
||||
} catch (ProcessOutputException ex) {
|
||||
if (ex.getOutput().contains("Error: unknown shorthand flag: 'f' in -f")) {
|
||||
throw ErrorEvent.expected(ProcessOutputException.withParagraph("Unsupported legacy LXD version", ex));
|
||||
|
||||
Reference in New Issue
Block a user