Bugfix in cfg loading in settings_leds.htm#5701
Conversation
|
Important Review skippedThis PR was authored by the user configured for CodeRabbit reviews. CodeRabbit does not review PRs authored by this user. It's recommended to use a dedicated user account to post CodeRabbit review feedback. ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Walkthrough
ChangesLED settings update
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested labels
Suggested reviewers
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@wled00/data/settings_leds.htm`:
- Line 163: The high-`bquot` branch in the settings UI currently only assigns a
`msg` string and no longer triggers the warning flow, so restore the existing
confirmation/alert handling in the `settings_leds.htm` logic where `bquot > 80`
is checked. Update that branch so the message is actually presented to the user
and the previous high-memory warning behavior is preserved, instead of leaving
an unused `msg` variable in place.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 48929170-7219-4dd2-8751-26da4487690b
📒 Files selected for processing (1)
wled00/data/settings_leds.htm
|
@coderabbitai please thoroughly check all htm files in the /data folder for other such small bugs and dead or unreachable code. |
🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "== Find data directory and list .htm files =="
fd -t d '^data$' .
echo
fd -e htm . data || true
echo
echo "== AST outline for each .htm file in data =="
for f in $(fd -e htm . data | sort); do
echo
echo "---- $f ----"
ast-grep outline "$f" --view expanded || true
done
echo
echo "== Search for suspicious patterns in data/*.htm =="
rg -n --glob 'data/*.htm' --glob 'data/**/*.htm' \
-e '\bconst\s+[A-Za-z_$][A-Za-z0-9_$]*\s*=.*\+\+|--' \
-e '\b(let|const|var)\s+([A-Za-z_$][A-Za-z0-9_$]*)\b.*\n.*\b\2\b' \
-e '\bif\s*\(\s*false\s*\)' \
-e '\bif\s*\(\s*true\s*\)' \
-e '\bwhile\s*\(\s*false\s*\)' \
-e '\bfor\s*\(\s*;\s*false\s*;' \
-e '\breturn\s*;?[[:space:]]*$' \
-e '\bcontinue\s*;?[[:space:]]*$' \
-e '\bbreak\s*;?[[:space:]]*$' \
-e '\bTODO\b|\bFIXME\b|\bXXX\b' \
-e 'else if\s*\([^)]*\)\s*{\s*}\s*' \
-e '\bif\s*\([^)]*\)\s*{\s*}\s*else' \
-e '\b===?\s*undefined\b|\b!==?\s*undefined\b' \
data || true
echo
echo "== Search for duplicate conditional ladders / repeated thresholds =="
rg -n -C2 --glob 'data/*.htm' --glob 'data/**/*.htm' \
-e 'else if\s*\(' \
-e 'if\s*\(' \
data | sed -n '1,260p'
echo
echo "== Search for functions and vars that may be unused in data/*.htm =="
python - <<'PY'
import re, subprocess, json, os, sys
files = subprocess.check_output(["fd","-e","htm",".","data"]).decode().splitlines()
decl_pat = re.compile(r'\bfunction\s+([A-Za-z_$][A-Za-z0-9_$]*)\s*\(')
var_pat = re.compile(r'\b(?:let|const|var)\s+([A-Za-z_$][A-Za-z0-9_$]*)\b')
for f in files:
txt = open(f, 'r', encoding='utf-8', errors='ignore').read()
funcs = decl_pat.findall(txt)
vars_ = var_pat.findall(txt)
findings = []
for name in funcs:
count = len(re.findall(r'\b%s\b' % re.escape(name), txt))
if count == 1:
findings.append(("function", name, count))
for name in vars_:
count = len(re.findall(r'\b%s\b' % re.escape(name), txt))
if count == 1 and name not in {"i","j","k","d","e","v","x","y"}:
findings.append(("var", name, count))
if findings:
print(f"--- {f} ---")
for kind, name, count in findings[:40]:
print(f"{kind}\t{name}\t{count}")
PY
echo
echo "== Read key slices from each data/*.htm file (first 260 lines) =="
for f in $(fd -e htm . data | sort); do
echo
echo "---- $f : lines 1-260 ----"
sed -n '1,260p' "$f"
doneLength of output: 3914 🏁 Script executed: #!/bin/bash
set -euo pipefail
root="wled00/data"
echo "== List .htm files under $root =="
fd -e htm . "$root" | sort
echo
echo "== Suspicious pattern scan in $root/*.htm =="
rg -n -C2 --pcre2 \
-g '*.htm' "$root" \
-e '\bif\s*\(\s*false\s*\)' \
-e '\bif\s*\(\s*true\s*\)' \
-e '\bwhile\s*\(\s*false\s*\)' \
-e '\bfor\s*\(\s*;\s*false\s*;' \
-e '\bTODO\b|\bFIXME\b|\bXXX\b' \
-e '\b(?:const|let|var)\s+([A-Za-z_$][A-Za-z0-9_$]*)\s*=.*(?:\+\+|--)' \
-e '\b(?:return|break|continue)\s*;[ \t]*$' \
-e 'else if\s*\([^)]*\)\s*{\s*}' \
-e '\bif\s*\([^)]*\)\s*{\s*}\s*else' \
-e '\b===?\s*undefined\b|\b!==?\s*undefined\b' || true
echo
echo "== Count conditionals and function declarations per file =="
for f in $(fd -e htm . "$root" | sort); do
printf '\n-- %s --\n' "$f"
printf 'if/else count: '
rg -o '\bif\s*\(|\belse\s+if\s*\(' "$f" | wc -l
printf 'function count: '
rg -o '\bfunction\s+[A-Za-z_$][A-Za-z0-9_$]*\s*\(' "$f" | wc -l
done
echo
echo "== Possible single-use function declarations =="
python - <<'PY'
import re, subprocess
files = subprocess.check_output(["fd","-e","htm",".","wled00/data"]).decode().splitlines()
decl_pat = re.compile(r'\bfunction\s+([A-Za-z_$][A-Za-z0-9_$]*)\s*\(')
for f in sorted(files):
txt = open(f, 'r', encoding='utf-8', errors='ignore').read()
names = decl_pat.findall(txt)
hits = []
for name in names:
count = len(re.findall(r'\b%s\b' % re.escape(name), txt))
if count == 1:
hits.append(name)
if hits:
print(f"--- {f} ---")
for name in hits:
print(name)
PY
echo
echo "== Full numbered contents of each .htm file =="
for f in $(fd -e htm . "$root" | sort); do
echo
echo "---- $f ----"
nl -ba "$f"
doneLength of output: 57510 🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "== Context around candidate hotspots =="
for spec in \
"wled00/data/settings_wifi.htm:58:126" \
"wled00/data/settings_2D.htm:96:120" \
"wled00/data/settings_ui.htm:70:95" \
"wled00/data/settings_leds.htm:750:780" \
"wled00/data/update.htm:40:110" \
"wled00/data/settings_dmx.htm:50:62"
do
file="${spec%%:*}"
rest="${spec#*:}"
start="${rest%%:*}"
end="${rest##*:}"
echo
echo "---- $file : lines $start-$end ----"
sed -n "${start},${end}p" "$file" | nl -ba -v "$start"
done
echo
echo "== Possible single-use function declarations (safe run) =="
python - <<'PY'
import re, subprocess
files = subprocess.check_output(["fd","-e","htm",".","wled00/data"]).decode().splitlines()
decl_pat = re.compile(r'\bfunction\s+([A-Za-z_$][A-Za-z0-9_$]*)\s*\(')
for f in sorted(files):
txt = open(f, 'r', encoding='utf-8', errors='ignore').read()
hits = []
for name in decl_pat.findall(txt):
count = len(re.findall(r'\b%s\b' % re.escape(name), txt))
if count == 1:
hits.append(name)
if hits:
print(f"--- {f} ---")
for name in hits[:30]:
print(name)
PY
echo
echo "== Search for commented-out code blocks in data/*.htm =="
rg -n -C1 --glob '*.htm' '^\s*//\s*(if|for|while|return|let|const|var|function)\b|/\*\s*(if|for|while|return|let|const|var|function)\b' wled00/data || true
echo
echo "== Search for duplicated branch conditions in settings_leds.htm and settings_wifi.htm =="
rg -n -C2 --pcre2 '(if|else if)\s*\(([^)]*)\)' wled00/data/settings_leds.htm wled00/data/settings_wifi.htm || trueLength of output: 2084 🏁 Script executed: #!/bin/bash
set -u
echo "== Context around candidate hotspots =="
show_slice() {
file="$1"
start="$2"
end="$3"
echo
echo "---- $file : lines $start-$end ----"
awk -v s="$start" -v e="$end" 'NR>=s && NR<=e { printf "%6d %s\n", NR, $0 }' "$file" || true
}
show_slice "wled00/data/settings_wifi.htm" 58 126
show_slice "wled00/data/settings_2D.htm" 96 120
show_slice "wled00/data/settings_ui.htm" 70 95
show_slice "wled00/data/settings_leds.htm" 750 780
show_slice "wled00/data/update.htm" 40 110
show_slice "wled00/data/settings_dmx.htm" 50 62
echo
echo "== Possible single-use function declarations (safe run) =="
python - <<'PY'
import re, subprocess
files = subprocess.check_output(["fd","-e","htm",".","wled00/data"]).decode().splitlines()
decl_pat = re.compile(r'\bfunction\s+([A-Za-z_$][A-Za-z0-9_$]*)\s*\(')
for f in sorted(files):
txt = open(f, 'r', encoding='utf-8', errors='ignore').read()
hits = []
seen = set()
for name in decl_pat.findall(txt):
if name in seen:
continue
seen.add(name)
count = len(re.findall(r'\b%s\b' % re.escape(name), txt))
if count == 1:
hits.append(name)
if hits:
print(f"--- {f} ---")
for name in hits[:30]:
print(name)
PY
echo
echo "== Search for commented-out code blocks in data/*.htm =="
rg -n -C1 --glob '*.htm' '^\s*//\s*(if|for|while|return|let|const|var|function)\b|/\*\s*(if|for|while|return|let|const|var|function)\b' wled00/data || trueLength of output: 15006
Actionable findings:
Cleanup-only / stale code:
I did not find another obvious I’ll leave focused review comments for the actionable ones. ✅ Action performedReview finished.
|
a const can not be incremented, it throws an error.
remove dead code.
Summary by CodeRabbit
Summary by CodeRabbit
Bug Fixes
Chores