[CodeFactor] Apply fixes

This commit is contained in:
codefactor-io 2023-12-10 08:01:20 +00:00
parent 4f98929446
commit ac9c46680d
No known key found for this signature in database
GPG key ID: B66B2D63282C190F
5 changed files with 46 additions and 31 deletions

View file

@ -18,8 +18,7 @@ function transmitPing() {
function startStopBeacon() {
if (state.beacon_state === true) {
setModemBeacon(false);
}
else {
} else {
setModemBeacon(true);
}
}

View file

@ -1,5 +1,8 @@
import { settingsStore as settings } from "../store/settingsStore.js";
import { validateCallsignWithSSID,validateCallsignWithoutSSID } from "./freedata";
import {
validateCallsignWithSSID,
validateCallsignWithoutSSID,
} from "./freedata";
function buildURL(params, endpoint) {
const url = "http://" + params.host + ":" + params.port + endpoint;
@ -73,15 +76,16 @@ export function sendModemCQ() {
}
export function sendModemPing(dxcall) {
if (validateCallsignWithSSID(dxcall) === false && validateCallsignWithoutSSID(dxcall) === true) {
if (
validateCallsignWithSSID(dxcall) === false &&
validateCallsignWithoutSSID(dxcall) === true
) {
dxcall = String(dxcall).toUpperCase().trim();
dxcall = dxcall + "-0";
}
dxcall = String(dxcall).toUpperCase().trim();
if (validateCallsignWithSSID(dxcall))
return apiPost("/modem/ping_ping", { dxcall: dxcall });
}
export function sendModemARQRaw(mycall, dxcall, data, uuid) {

View file

@ -63,13 +63,19 @@ export function sortByPropertyDesc(property) {
export function validateCallsignWithSSID(callsign: string) {
var patt = new RegExp("^[A-Z,a-z]+[0-9][A-Z,a-z]*-(1[0-5]|[0-9])$");
if (callsign === undefined || callsign==="" || patt.test(callsign) === false)
{
console.error("Call sign given is not in correct format or missing; callsign passed is: " + callsign);
if (
callsign === undefined ||
callsign === "" ||
patt.test(callsign) === false
) {
console.error(
"Call sign given is not in correct format or missing; callsign passed is: " +
callsign,
);
return false;
}
return true;
};
}
/**
* Validate/check if a call sign has an SSID
* @param {string} callsign callsign to check
@ -78,10 +84,16 @@ export function validateCallsignWithSSID(callsign :string) {
export function validateCallsignWithoutSSID(callsign: string) {
var patt = new RegExp("^[A-Za-z]+[0-9][A-Za-z]+$");
if (callsign === undefined || callsign==="" || patt.test(callsign) === false)
{
console.error("Call sign given is not in correct format or missing; callsign passed is: " + callsign);
if (
callsign === undefined ||
callsign === "" ||
patt.test(callsign) === false
) {
console.error(
"Call sign given is not in correct format or missing; callsign passed is: " +
callsign,
);
return false;
}
return true;
};
}