fix codeql suggestions

This commit is contained in:
Eduard Prigoana 2026-02-18 03:30:20 +00:00
parent 62fe4fca8e
commit 03a7dcda52
4 changed files with 73 additions and 24 deletions

View file

@ -22,7 +22,9 @@ def recv_packet(s):
op, length = struct.unpack('<II', header)
payload = s.recv(length)
return json.loads(payload.decode('utf-8'))
except: return None
except Exception:
# Ignore errors and return None
return None
def set_activity(ds, pid, details, state, img=None, start=None, end=None, large_text=None, small_img=None, small_txt=None):
global LAST_STATUS
@ -61,7 +63,9 @@ def main():
line = sys.stdin.readline()
if not line: return
config = json.loads(line)
except: return
except Exception:
# Ignore errors and exit
return
ppid = os.getppid()
@ -71,7 +75,9 @@ def main():
try:
ds = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
ds.connect(ipc_path)
except: return
except Exception:
# Ignore connection errors and exit
return
# 3. Handshake
send_packet(ds, 0, {"v": 1, "client_id": CLIENT_ID})
@ -85,7 +91,9 @@ def main():
ws.settimeout(1.0)
try:
ws.connect(('127.0.0.1', int(config['nlPort'])))
except: return
except Exception:
# Ignore connection errors and exit
return
key = base64.b64encode(os.urandom(16)).decode()
handshake = (
@ -133,8 +141,12 @@ def main():
set_activity(ds, ppid, "Idling", "Monochrome")
elif msg['event'] == 'windowClose':
break
except socket.timeout: continue
except: continue
except socket.timeout:
# Timeout is expected, continue polling
continue
except Exception:
# Ignore other errors and continue
continue
# Cleanup
try:
@ -145,7 +157,9 @@ def main():
})
time.sleep(0.1)
ds.close()
except: pass
except Exception:
# Ignore cleanup errors
pass
if __name__ == "__main__":
main()

View file

@ -438,7 +438,7 @@ export class LosslessAPI {
if (!album) throw new Error('Album not found');
// If album exists but has no artist, try to extract from tracks
if (album && !album.artist && tracksSection?.items && tracksSection.items.length > 0) {
if (!album.artist && tracksSection?.items && tracksSection.items.length > 0) {
const firstTrack = tracksSection.items[0];
const track = firstTrack.item || firstTrack;
if (track && track.artist) {
@ -447,7 +447,7 @@ export class LosslessAPI {
}
// If album exists but has no releaseDate, try to extract from tracks
if (album && !album.releaseDate && tracksSection?.items && tracksSection.items.length > 0) {
if (!album.releaseDate && tracksSection?.items && tracksSection.items.length > 0) {
const firstTrack = tracksSection.items[0];
const track = firstTrack.item || firstTrack;

View file

@ -1,5 +1,3 @@
import { sanitizeForFilename } from './utils.js';
/**
* Helper function to get track artists string
*/

View file

@ -29,7 +29,7 @@ export const apiSettings = {
if (isSimpleArray) {
groupedInstances.api = [...data.api];
} else {
for (const [, config] of Object.entries(data.api)) {
for (const [_key, config] of Object.entries(data.api)) {
if (config.cors === false && Array.isArray(config.urls)) {
groupedInstances.api.push(...config.urls);
}
@ -233,7 +233,7 @@ export const themeManager = {
purple: {},
forest: {},
mocha: {},
machiatto: {},
macchiato: {},
frappe: {},
latte: {},
},
@ -947,7 +947,7 @@ export const equalizerSettings = {
const stored = localStorage.getItem(this.FREQ_MIN_KEY);
if (stored) {
const val = parseInt(stored, 10);
if (!isNaN(val) && val >= this.ABSOLUTE_FREQ_MIN && val < this.DEFAULT_FREQ_MAX) {
if (!isNaN(val) && val >= this.ABSOLUTE_FREQ_MIN && val < this.ABSOLUTE_FREQ_MAX) {
return val;
}
}
@ -959,7 +959,20 @@ export const equalizerSettings = {
setFreqMin(value) {
const val = parseInt(value, 10);
if (!isNaN(val) && val >= this.ABSOLUTE_FREQ_MIN && val < this.getFreqMax()) {
// Get effective max from storage without recursive call
let effectiveMax = this.DEFAULT_FREQ_MAX;
try {
const storedMax = localStorage.getItem(this.FREQ_MAX_KEY);
if (storedMax) {
const parsedMax = parseInt(storedMax, 10);
if (!isNaN(parsedMax) && parsedMax > this.ABSOLUTE_FREQ_MIN && parsedMax <= this.ABSOLUTE_FREQ_MAX) {
effectiveMax = parsedMax;
}
}
} catch {
/* ignore and use default max */
}
if (!isNaN(val) && val >= this.ABSOLUTE_FREQ_MIN && val < effectiveMax) {
localStorage.setItem(this.FREQ_MIN_KEY, val.toString());
return true;
}
@ -968,11 +981,23 @@ export const equalizerSettings = {
getFreqMax() {
try {
const stored = localStorage.getItem(this.FREQ_MAX_KEY);
if (stored) {
const val = parseInt(stored, 10);
if (!isNaN(val) && val > this.getFreqMin() && val <= this.ABSOLUTE_FREQ_MAX) {
return val;
const storedMax = localStorage.getItem(this.FREQ_MAX_KEY);
if (storedMax) {
const maxVal = parseInt(storedMax, 10);
if (!isNaN(maxVal) && maxVal > this.ABSOLUTE_FREQ_MIN && maxVal <= this.ABSOLUTE_FREQ_MAX) {
// Get stored min without recursive call
try {
const storedMin = localStorage.getItem(this.FREQ_MIN_KEY);
if (storedMin) {
const minVal = parseInt(storedMin, 10);
if (!isNaN(minVal) && maxVal <= minVal) {
return this.DEFAULT_FREQ_MAX;
}
}
} catch {
/* ignore */
}
return maxVal;
}
}
} catch {
@ -982,9 +1007,21 @@ export const equalizerSettings = {
},
setFreqMax(value) {
const val = parseInt(value, 10);
if (!isNaN(val) && val > this.getFreqMin() && val <= this.ABSOLUTE_FREQ_MAX) {
localStorage.setItem(this.FREQ_MAX_KEY, val.toString());
const maxVal = parseInt(value, 10);
if (!isNaN(maxVal) && maxVal > this.ABSOLUTE_FREQ_MIN && maxVal <= this.ABSOLUTE_FREQ_MAX) {
// Check against stored min without recursive call
try {
const storedMin = localStorage.getItem(this.FREQ_MIN_KEY);
if (storedMin) {
const minVal = parseInt(storedMin, 10);
if (!isNaN(minVal) && maxVal <= minVal) {
return false;
}
}
} catch {
/* ignore */
}
localStorage.setItem(this.FREQ_MAX_KEY, maxVal.toString());
return true;
}
return false;
@ -1181,7 +1218,7 @@ export const equalizerSettings = {
}
}
if (Array.isArray(gains) && gains.length === 16) {
if (Array.isArray(gains) && gains.length === this.DEFAULT_BAND_COUNT) {
presets[presetId].gains = gains.map((g) => Math.round(g * 10) / 10);
presets[presetId].updatedAt = Date.now();
}