Skip to content

VectorCraft: An open-source, vector art tool written by scratch in pure Rust

lint: shell helper and lossless float conversion (S1192, S7679, S4325) (#4205)

Dylan M. Taylor97ccb833373e
diff --git a/crates/ui-egui/src/dialogs/swatch_options.rs b/crates/ui-egui/src/dialogs/swatch_options.rs
index 6d9aa6d59..87d15152c 100644
--- a/crates/ui-egui/src/dialogs/swatch_options.rs
+++ b/crates/ui-egui/src/dialogs/swatch_options.rs
@@ -221,7 +221,7 @@ fn sliders(ui: &mut egui::Ui, d: &mut Dialog) -> bool {
new = Some((from_components(mode, &c2), c2));
}
let bounds = f64::from(mode.min(i))..=f64::from(mode.max(i));
- if let Some(fv) = widgets::range_field(ui, ("swatch-field", i), v as f64, bounds, mode.suffix(i), 0, 52.0) {
+ if let Some(fv) = widgets::range_field(ui, ("swatch-field", i), f64::from(v), bounds, mode.suffix(i), 0, 52.0) {
let mut c2 = comps.clone();
c2[i] = (fv as f32).clamp(mode.min(i), mode.max(i));
new = Some((from_components(mode, &c2), c2));
diff --git a/packaging/linux/package.sh b/packaging/linux/package.sh
index 93b440aec..25d1f73c1 100755
--- a/packaging/linux/package.sh
+++ b/packaging/linux/package.sh
@@ -80,6 +80,7 @@ if command -v appstreamcli >/dev/null; then
fi
has() { case " $FORMATS " in *" $1 "*) return 0 ;; *) return 1 ;; esac; }
+verify_sha256() { printf '%s %s\n' "$1" "$2" | sha256sum -c -; }
# ---- .tar.gz ------------------------------------------------------------------------------------
if has tar; then
@@ -138,21 +139,21 @@ if has appimage; then
download="$TOOL.download"
curl --proto '=https' -fsSL -o "$download" \
"https://github.com/AppImage/appimagetool/releases/download/$APPIMAGETOOL_VERSION/appimagetool-$ARCH.AppImage"
- printf '%s %s\n' "$APPIMAGETOOL_SHA256" "$download" | sha256sum -c -
+ verify_sha256 "$APPIMAGETOOL_SHA256" "$download"
chmod 755 "$download"
mv "$download" "$TOOL"
fi
- printf '%s %s\n' "$APPIMAGETOOL_SHA256" "$TOOL" | sha256sum -c -
+ verify_sha256 "$APPIMAGETOOL_SHA256" "$TOOL"
fi
RUNTIME="$CARGO_TARGET_DIR/appimage-runtime-$APPIMAGE_RUNTIME_VERSION-$ARCH"
if [[ ! -f "$RUNTIME" ]]; then
download="$RUNTIME.download"
curl --proto '=https' -fsSL -o "$download" \
"https://github.com/AppImage/type2-runtime/releases/download/$APPIMAGE_RUNTIME_VERSION/runtime-$ARCH"
- printf '%s %s\n' "$APPIMAGE_RUNTIME_SHA256" "$download" | sha256sum -c -
+ verify_sha256 "$APPIMAGE_RUNTIME_SHA256" "$download"
mv "$download" "$RUNTIME"
fi
- printf '%s %s\n' "$APPIMAGE_RUNTIME_SHA256" "$RUNTIME" | sha256sum -c -
+ verify_sha256 "$APPIMAGE_RUNTIME_SHA256" "$RUNTIME"
# Absolute, because appimagetool runs in $DIST below (CARGO_TARGET_DIR or APPIMAGETOOL may be
# relative, e.g. target/agent-<name>).
OUT="$(cd "$DIST" && pwd)/$BASENAME.AppImage"
diff --git a/packaging/macos/package.sh b/packaging/macos/package.sh
index 2ca11eed8..e4df44c17 100755
--- a/packaging/macos/package.sh
+++ b/packaging/macos/package.sh
@@ -101,14 +101,14 @@ notarize() {
# connection there (NSURLErrorDomain -1005, "Error 68") fails them although notarization worked.
# Both are idempotent, so retry with a pause; a missing or bad ticket still fails every try.
stapler_retry() {
- local try
+ local try op="$1" target="$2"
for try in 1 2 3 4; do
- xcrun stapler "$1" "$2" && return 0
+ xcrun stapler "$op" "$target" && return 0
[[ "$try" = 4 ]] && break
- echo "stapler $1 failed (try $try of 4); retrying in $((try * 20)) s" >&2
+ echo "stapler $op failed (try $try of 4); retrying in $((try * 20)) s" >&2
sleep $((try * 20))
done
- echo "error: stapler $1 $(basename "$2") failed 4 times" >&2
+ echo "error: stapler $op $(basename "$target") failed 4 times" >&2
exit 1
}