de-AI phase 3: inline redundant variables and null checks
TypeScript: - getDashboardSections.ts: value === undefined || value === null -> value == null - renderAdvancedSettings.ts: remove redundant Boolean() on boolean ucode (10 inlined variables): - helpers.uc: inline trailing_dot - runtime.uc: inline ping_ok, enable_watchdog - nft/apply.uc: inline rtmtu_ok, qos_enabled - byedpi/runtime.uc: inline matched - api.uc: inline deleted, added - subscription.uc: inline has_source_markers - watchdog.uc: inline is_healthy 522 frontend tests pass
This commit is contained in:
@@ -131,8 +131,7 @@ function valid_ipv4_octet(value) {
|
||||
function valid_ipv4(value) {
|
||||
value = as_string(value);
|
||||
|
||||
let trailing_dot = length(value) > 0 && substr(value, length(value) - 1) == ".";
|
||||
if (trailing_dot)
|
||||
if (length(value) > 0 && substr(value, length(value) - 1) == ".")
|
||||
value = substr(value, 0, length(value) - 1);
|
||||
|
||||
let parts = split(value, ".");
|
||||
|
||||
@@ -2502,8 +2502,7 @@ function run_doctor_checks() {
|
||||
doc_check("✅", "DNS bootstrap (" + display_bootstrap + ")", "reachable", "");
|
||||
} else {
|
||||
issues++;
|
||||
let ping_ok = (command_status("ping -c 1 -W 2 1.1.1.1 >/dev/null 2>&1") == 0);
|
||||
if (ping_ok) {
|
||||
if (command_status("ping -c 1 -W 2 1.1.1.1 >/dev/null 2>&1") == 0) {
|
||||
fs.unlink("/etc/resolv.conf");
|
||||
// If the symlink cannot be created the writefile below still lands on
|
||||
// /tmp/resolv.conf and the dnsmasq restart still picks it up; the
|
||||
@@ -2676,8 +2675,7 @@ function run_doctor_checks() {
|
||||
if (watchdog_running) {
|
||||
doc_check("✅", "Watchdog", "running", "");
|
||||
} else {
|
||||
let enable_watchdog = cfg.enable_watchdog != "0";
|
||||
if (enable_watchdog) {
|
||||
if (cfg.enable_watchdog != "0") {
|
||||
issues++;
|
||||
let restart_status = command_status("/etc/init.d/tachyon restart >/dev/null 2>&1");
|
||||
if (restart_status == 0) {
|
||||
|
||||
@@ -1073,8 +1073,7 @@ function nft_create_runtime_base(table, localv4_set, common_set, port_set, ip_po
|
||||
!nft_add_rule(table, "mangle_forward", [ "jump", "parental_forward" ]))
|
||||
return false;
|
||||
|
||||
let rtmtu_ok = nft_add_rule(table, "mangle_forward", [ "tcp", "flags", "syn", "tcp", "option", "maxseg", "size", "set", "rt", "mtu" ]);
|
||||
if (rtmtu_ok) {
|
||||
if (nft_add_rule(table, "mangle_forward", [ "tcp", "flags", "syn", "tcp", "option", "maxseg", "size", "set", "rt", "mtu" ])) {
|
||||
if (!nft_add_rule(table, "mangle_output", [ "tcp", "flags", "syn", "tcp", "option", "maxseg", "size", "set", "rt", "mtu" ]))
|
||||
return false;
|
||||
} else {
|
||||
@@ -1087,8 +1086,7 @@ function nft_create_runtime_base(table, localv4_set, common_set, port_set, ip_po
|
||||
return false;
|
||||
|
||||
// QoS Low-Latency Gaming & Voice Acceleration Engine
|
||||
let qos_enabled = uci_settings().qos_priority_engine != "0";
|
||||
if (qos_enabled) {
|
||||
if (uci_settings().qos_priority_engine != "0") {
|
||||
// Voice & Discord RTC (DSCP EF 0x2e)
|
||||
nft_add_rule(table, "mangle_forward", [ "udp", "dport", "{ 5000-5020, 3478, 19302, 50000-65535 }", "ip", "dscp", "set", "0x2e" ]);
|
||||
nft_add_rule(table, "mangle_output", [ "udp", "dport", "{ 5000-5020, 3478, 19302, 50000-65535 }", "ip", "dscp", "set", "0x2e" ]);
|
||||
|
||||
@@ -110,8 +110,7 @@ function package_installed() {
|
||||
return false;
|
||||
|
||||
for (let line in split(command_output_from_args([ "opkg", "list-installed" ]), "\n")) {
|
||||
let matched = match(trim(as_string(line)), /^byedpi[ \t]+-/);
|
||||
if (matched)
|
||||
if (match(trim(as_string(line)), /^byedpi[ \t]+-/))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -277,8 +277,7 @@ function manage_domain_list_by_section(sec_name, domain, do_delete) {
|
||||
let option_path = CONFIG_NAME + "." + sec_name + ".domain";
|
||||
|
||||
if (do_delete) {
|
||||
let deleted = uci_core.del_list(option_path, domain);
|
||||
if (deleted) {
|
||||
if (uci_core.del_list(option_path, domain)) {
|
||||
uci_core.commit(CONFIG_NAME);
|
||||
common.command_status("/usr/bin/tachyon reload");
|
||||
return { success: true, message: "Запись <code>" + domain + "</code> удалена." };
|
||||
@@ -300,8 +299,7 @@ function manage_domain_list_by_section(sec_name, domain, do_delete) {
|
||||
return { success: false, error: "Запись <code>" + domain + "</code> уже есть в секции." };
|
||||
}
|
||||
|
||||
let added = uci_core.add_list(option_path, domain);
|
||||
if (added) {
|
||||
if (uci_core.add_list(option_path, domain)) {
|
||||
uci_core.commit(CONFIG_NAME);
|
||||
common.command_status("/usr/bin/tachyon reload");
|
||||
return { success: true, message: "Запись <code>" + domain + "</code> добавлена." };
|
||||
|
||||
@@ -538,8 +538,7 @@ let ai_incidents_count = 0;
|
||||
let last_ai_incident = null;
|
||||
|
||||
function ai_export_status() {
|
||||
let is_healthy = last_ai_incident == null || (time() - last_ai_incident.timestamp >= 300);
|
||||
if (is_healthy) controller.note_healthy();
|
||||
if (last_ai_incident == null || (time() - last_ai_incident.timestamp >= 300)) controller.note_healthy();
|
||||
// Streaks live in the controller state (probe counters). They are the
|
||||
// evidence AI Doctor reads to see instability that a point-in-time check
|
||||
// cannot: without them the status file always reported zero failures.
|
||||
|
||||
@@ -161,8 +161,7 @@ function read_section_metadata(section_name, source_section, source_index) {
|
||||
metadata = metadata_items_from_value(read_json_file(legacy_metadata_path(source_section)));
|
||||
|
||||
let selected = [];
|
||||
let has_source_markers = metadata_items_have_source_markers(metadata);
|
||||
if (has_source_markers) {
|
||||
if (metadata_items_have_source_markers(metadata)) {
|
||||
for (let item in metadata) {
|
||||
if (metadata_matches_source(item, source_index, source_section, true))
|
||||
push(selected, item);
|
||||
|
||||
Reference in New Issue
Block a user