Skip to content

Commit 49356c6

Browse files
committed
Review sonar
1 parent 71b5878 commit 49356c6

File tree

3 files changed

+26
-29
lines changed

3 files changed

+26
-29
lines changed

index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -778,7 +778,7 @@ <h5 class="modal-title-revision"></h5>
778778
const axes = ['Roll', 'Pitch', 'Yaw'];
779779
const pidTbody = document.getElementById('pid_tbody');
780780

781-
axes.forEach(axis => {
781+
for (const axis of axes) {
782782
const row = `<tr class="${axis.toLowerCase()}PID">
783783
<td>${axis}</td>
784784
<td><input type="text" name="p" step="1" min="0" max="255" /></td>
@@ -788,7 +788,7 @@ <h5 class="modal-title-revision"></h5>
788788
<td><input type="text" name="f" step="1" min="0" max="255" /></td>
789789
</tr>`;
790790
pidTbody.innerHTML += row;
791-
});
791+
}
792792
</script>
793793

794794
<table id="pid_baro_header" class="parameter cf">

src/flightlog_parser.js

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,7 @@ export function FlightLogParser(logData) {
533533
*/
534534
function translateFieldName(fieldName) {
535535
let translation = translationValues[fieldName];
536-
if (typeof translation !== "undefined") {
536+
if (translation !== undefined) {
537537
return translation;
538538
} else {
539539
return fieldName;
@@ -823,7 +823,7 @@ export function FlightLogParser(logData) {
823823
) {
824824
that.sysConfig[fieldName] = parseInt(fieldValue, 10);
825825
} else {
826-
that.sysConfig[fieldName] = parseInt(fieldValue, 10) / 100.0;
826+
that.sysConfig[fieldName] = parseInt(fieldValue, 10) / 100;
827827
}
828828
break;
829829

@@ -837,13 +837,13 @@ export function FlightLogParser(logData) {
837837
) {
838838
that.sysConfig[fieldName] = parseCommaSeparatedString(fieldValue);
839839
} else {
840-
that.sysConfig[fieldName] = parseInt(fieldValue, 10) / 100.0;
840+
that.sysConfig[fieldName] = parseInt(fieldValue, 10) / 100;
841841
}
842842
break;
843843

844844
case "motor_idle":
845845
case "digitalIdleOffset":
846-
that.sysConfig[fieldName] = parseInt(fieldValue, 10) / 100.0;
846+
that.sysConfig[fieldName] = parseInt(fieldValue, 10) / 100;
847847

848848
/** Cleanflight Only log headers **/
849849
case "dterm_cut_hz":
@@ -984,7 +984,7 @@ export function FlightLogParser(logData) {
984984
} else {
985985
// Cleanflight 1.x and others
986986
that.sysConfig.firmwareVersion = "0.0.0";
987-
that.sysConfig.firmware = 0.0;
987+
that.sysConfig.firmware = 0;
988988
that.sysConfig.firmwarePatch = 0;
989989
}
990990
}
@@ -1085,10 +1085,8 @@ export function FlightLogParser(logData) {
10851085
min: frame[i],
10861086
};
10871087
} else {
1088-
fieldStats[i].max =
1089-
frame[i] > fieldStats[i].max ? frame[i] : fieldStats[i].max;
1090-
fieldStats[i].min =
1091-
frame[i] < fieldStats[i].min ? frame[i] : fieldStats[i].min;
1088+
fieldStats[i].max = Math.max(frame[i], fieldStats[i].max);
1089+
fieldStats[i].min = Math.min(frame[i], fieldStats[i].min);
10921090
}
10931091
}
10941092
}
@@ -1446,7 +1444,7 @@ export function FlightLogParser(logData) {
14461444
* save space for positive values). So we need to convert those very large unsigned values into their
14471445
* corresponding 32-bit signed values.
14481446
*/
1449-
value = (value | 0) + that.sysConfig.minthrottle;
1447+
value = Math.trunc(value) + that.sysConfig.minthrottle;
14501448
break;
14511449
case FLIGHT_LOG_FIELD_PREDICTOR_MINMOTOR:
14521450
/*
@@ -1455,7 +1453,7 @@ export function FlightLogParser(logData) {
14551453
* save space for positive values). So we need to convert those very large unsigned values into their
14561454
* corresponding 32-bit signed values.
14571455
*/
1458-
value = (value | 0) + (that.sysConfig.motorOutput[0] | 0); // motorOutput[0] is the min motor output
1456+
value = Math.trunc(value) + Math.trunc(that.sysConfig.motorOutput[0]); // motorOutput[0] is the min motor output
14591457
break;
14601458
case FLIGHT_LOG_FIELD_PREDICTOR_1500:
14611459
value += 1500;
@@ -1675,13 +1673,13 @@ export function FlightLogParser(logData) {
16751673
break;
16761674
case FlightLogEvent.AUTOTUNE_TARGETS:
16771675
//Convert the angles from decidegrees back to plain old degrees for ease of use
1678-
lastEvent.data.currentAngle = stream.readS16() / 10.0;
1676+
lastEvent.data.currentAngle = stream.readS16() / 10;
16791677

16801678
lastEvent.data.targetAngle = stream.readS8();
16811679
lastEvent.data.targetAngleAtPeak = stream.readS8();
16821680

1683-
lastEvent.data.firstPeakAngle = stream.readS16() / 10.0;
1684-
lastEvent.data.secondPeakAngle = stream.readS16() / 10.0;
1681+
lastEvent.data.firstPeakAngle = stream.readS16() / 10;
1682+
lastEvent.data.secondPeakAngle = stream.readS16() / 10;
16851683
break;
16861684
case FlightLogEvent.GTUNE_CYCLE_RESULT:
16871685
lastEvent.data.axis = stream.readU8();

src/header_dialog.js

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -875,14 +875,21 @@ export function HeaderDialog(dialog, onSave) {
875875
}
876876
parameterElem.css(
877877
"display",
878-
isParameterValid(name) ? "table-cell" : "none"
878+
isParameterValid(name) ? "table-cell" : "none",
879879
);
880880
}
881881

882882
function setBitmaskParameter(name, data, totalBits = 8) {
883883
let parameterElem = $(`.parameter td[name="${name}"]`);
884884
let nameElem = $("input", parameterElem);
885-
if (data != null) {
885+
if (data == null) {
886+
// Clear all bitmask state when data is null
887+
nameElem.val(""); // Clear the input value
888+
nameElem.removeData("raw-value"); // Remove stored raw value
889+
nameElem.prop("readonly", false); // Make input editable again
890+
parameterElem.removeAttr("title"); // Clear tooltip
891+
parameterElem.addClass("missing");
892+
} else {
886893
// Convert number to binary string with leading zeros
887894
const binaryString = data.toString(2).padStart(totalBits, '0');
888895
// Display as "3 (00000011)" format
@@ -893,13 +900,6 @@ export function HeaderDialog(dialog, onSave) {
893900
nameElem.attr("readonly", true); // Make it readonly since it shows formatted bitmask
894901
parameterElem.attr("title", `Bitmask value: ${data} (binary: ${binaryString})`);
895902
parameterElem.removeClass("missing");
896-
} else {
897-
// Clear all bitmask state when data is null
898-
nameElem.val(""); // Clear the input value
899-
nameElem.removeData("raw-value"); // Remove stored raw value
900-
nameElem.prop("readonly", false); // Make input editable again
901-
parameterElem.removeAttr("title"); // Clear tooltip
902-
parameterElem.addClass("missing");
903903
}
904904
parameterElem.css(
905905
"display",
@@ -1397,9 +1397,9 @@ export function HeaderDialog(dialog, onSave) {
13971397

13981398
let PID_CONTROLLER_TYPE = [];
13991399
if (
1400-
(sysConfig.firmware >= 3.0 &&
1400+
(sysConfig.firmware >= 3 &&
14011401
sysConfig.firmwareType == FIRMWARE_TYPE_BETAFLIGHT) ||
1402-
(sysConfig.firmware >= 2.0 &&
1402+
(sysConfig.firmware >= 2 &&
14031403
sysConfig.firmwareType == FIRMWARE_TYPE_CLEANFLIGHT)
14041404
) {
14051405
PID_CONTROLLER_TYPE = ["LEGACY", "BETAFLIGHT"];
@@ -1747,8 +1747,7 @@ export function HeaderDialog(dialog, onSave) {
17471747
if (semver.lt(activeSysConfig.firmwareVersion, "2025.12.0")) {
17481748
const derivativeColumn = document.getElementById("derivativeColumn");
17491749
const dMaxColumn = document.getElementById("dMaxColumn");
1750-
const parent = derivativeColumn.parentNode;
1751-
parent.insertBefore(dMaxColumn, derivativeColumn); // Меняем местами
1750+
derivativeColumn.before(dMaxColumn); // Меняем местами
17521751
}
17531752
} else {
17541753
$("#d_max").hide();

0 commit comments

Comments
 (0)