Skip to content

Commit deab369

Browse files
refactor: fix some sonar issues
1 parent 42acf4d commit deab369

12 files changed

Lines changed: 45 additions & 60 deletions

_includes/donate.html

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@
33
<div class="container mb-5 shadow border-0 card-custom rounded-0">
44
<div class="d-table-row g-0">
55
<div class="d-table-cell px-3 align-middle text-center">
6-
<h1>
7-
<i class="fa-fw fas fa-coins"></i>
8-
</h1>
6+
<i class="fa-fw fa-2xl fas fa-coins"></i>
97
</div>
108
<div class="col-sm-auto border-white my-3 px-3 py-2 border-start">
119
<div class="container">

_includes/license-entries.html

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<ul class="list-group list-group-flush">
2+
{% for license in site.data.licenses %}
3+
{% assign item = license[1] %}
4+
<li class="list-group-item license-entry-item crowdin-ignore">
5+
<div class="d-flex justify-content-between align-items-center crowdin-ignore">
6+
<div>
7+
<strong class="crowdin-ignore">{{ item.name }}</strong>
8+
{% if item.version %}<span class="ms-2 badge bg-secondary crowdin-ignore">{{ item.version }}</span>{% endif %}
9+
<small class="d-block license-entry-text-muted crowdin-ignore">
10+
<a href="{{ item.url }}" target="_blank" class="license-entry-link crowdin-ignore">{{ item.url }}</a>
11+
</small>
12+
</div>
13+
<span class="badge bg-primary crowdin-ignore">{{ item.license }}</span>
14+
</div>
15+
</li>
16+
{% endfor %}
17+
</ul>

_includes/license-entry.html

Lines changed: 0 additions & 12 deletions
This file was deleted.

_includes/open-in-new-window.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
{
1616
if (!document.getElementsByTagName) return false;
1717
let links = document.getElementsByTagName("a");
18-
for (let eleLink=0; eleLink < links.length; eleLink ++) {
19-
if ((links[eleLink].href.indexOf('.pdf') !== -1)||(links[eleLink].href.indexOf('.doc') !== -1)||(links[eleLink].href.indexOf('.docx') !== -1)) {
20-
links[eleLink].onclick =
18+
for (const element of links) {
19+
if (element.href.includes('.pdf') || element.href.includes('.doc') || element.href.includes('.docx')) {
20+
element.onclick =
2121
function() {
2222
window.open(this.href);
2323
return false;

_sass/circular-progress.scss

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
width: 100%;
4444
height: 100%;
4545
background: none;
46+
border-color: #0d6efd;
4647
border-width: 5px;
4748
border-style: solid;
4849
position: absolute;
@@ -92,10 +93,6 @@
9293
line-height: 0.5;
9394
}
9495

95-
.circular-button .progress-bar {
96-
border-color: #0d6efd;
97-
}
98-
9996
.circular-button.active .button-content {
10097
box-shadow: 0 0 10px 3px rgba(13, 110, 253, 0.5);
10198
}

assets/js/crowdin-init.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
window.initCrowdIn('LizardByte', null);
1+
globalThis.initCrowdIn('LizardByte', null);

assets/js/discord-init.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

assets/js/gamepad-tester.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
document.addEventListener('DOMContentLoaded', function() {
22
const gamepadHelper = new GamepadHelper()
3-
const gamepadHelperVersion = window.gamepadHelperVersion;
3+
const gamepadHelperVersion = globalThis.gamepadHelperVersion;
44
let gamepads = {};
55
let activeGamepadIndex = null;
66
let animationFrameId = null;
@@ -21,7 +21,7 @@ document.addEventListener('DOMContentLoaded', function() {
2121
const themeObserver = new MutationObserver(function(mutations) {
2222
mutations.forEach(function(mutation) {
2323
if (mutation.type === 'attributes' && mutation.attributeName === 'data-bs-theme') {
24-
// Theme changed, reinitialize buttons with new color scheme
24+
// Theme changed, reinitialize buttons with a new color scheme
2525
if (activeGamepadIndex !== null) {
2626
initGamepadButtons();
2727
}
@@ -36,7 +36,7 @@ document.addEventListener('DOMContentLoaded', function() {
3636
});
3737

3838
// Setup gamepad event listeners
39-
window.addEventListener("gamepadconnected", function(e) {
39+
globalThis.addEventListener("gamepadconnected", function(e) {
4040
gamepads[e.gamepad.index] = e.gamepad;
4141

4242
// Always activate the newly connected gamepad
@@ -51,7 +51,7 @@ document.addEventListener('DOMContentLoaded', function() {
5151
}
5252
});
5353

54-
window.addEventListener("gamepaddisconnected", function(e) {
54+
globalThis.addEventListener("gamepaddisconnected", function(e) {
5555
delete gamepads[e.gamepad.index];
5656
updateGamepadSelector();
5757

@@ -76,7 +76,7 @@ document.addEventListener('DOMContentLoaded', function() {
7676
const card = e.target.closest('.gamepad-selector-card');
7777
if (card) {
7878
activeGamepadIndex = Number.parseInt(card.dataset.index);
79-
updateGamepadSelector(); // Re-render to update active state
79+
updateGamepadSelector(); // Re-render to update the active state
8080
initGamepadButtons();
8181
initGamepadAxes();
8282
}
@@ -176,7 +176,7 @@ document.addEventListener('DOMContentLoaded', function() {
176176

177177
const controllerType = gamepadHelper.detectControllerType(gamepad.id);
178178

179-
// Detect current theme - use Black icons for light theme, White icons for dark theme
179+
// Detect the current theme - use Black icons for the light theme, White icons for the dark theme
180180
const isDarkTheme = document.documentElement.dataset.bsTheme === 'dark';
181181
const colorScheme = isDarkTheme ? 'White' : 'Black';
182182

@@ -206,7 +206,7 @@ document.addEventListener('DOMContentLoaded', function() {
206206
const buttonContent = document.createElement('div');
207207
buttonContent.className = 'button-content';
208208

209-
// Add either image with fallback text, or just text
209+
// Add either image with fallback text or just text
210210
if (buttonImagePath) {
211211
buttonContent.innerHTML = `
212212
<div class="button-image-container">
@@ -318,7 +318,7 @@ document.addEventListener('DOMContentLoaded', function() {
318318
vibrationStatus.innerHTML = `<span class="badge bg-success">Supported</span> Actuator type: <span class="badge bg-secondary">${vibrationCapabilities.type}</span>`;
319319
vibrationButtons.classList.remove('d-none');
320320

321-
// Show appropriate controls based on actuator type
321+
// Show appropriate controls based on an actuator type
322322
if (vibrationCapabilities.type === 'dual-rumble') {
323323
dualRumbleControls.classList.remove('d-none');
324324
} else {
@@ -357,12 +357,12 @@ document.addEventListener('DOMContentLoaded', function() {
357357
// Only the right side rotates for the first half
358358
progressBarRightElement.style.transform = `rotate(${degrees}deg)`;
359359
} else {
360-
// Right side is at full rotation, left side rotates for the remainder
360+
// The right side is at full rotation, the left side rotates for the remainder
361361
progressBarRightElement.style.transform = 'rotate(180deg)';
362362
progressBarLeftElement.style.transform = `rotate(${degrees - 180}deg)`;
363363
}
364364

365-
// Add/remove active class based on button state
365+
// Add/remove the active class based on the button state
366366
if (isPressed) {
367367
buttonElement.classList.add('active');
368368
} else {
@@ -388,7 +388,7 @@ document.addEventListener('DOMContentLoaded', function() {
388388
const progressWidth = ((axisValue + 1) / 2) * 100;
389389
axisProgressElement.style.width = `${progressWidth}%`;
390390

391-
// Change color based on direction
391+
// Change color based on the direction
392392
if (axisValue > 0.1) {
393393
axisProgressElement.classList.remove('bg-info', 'bg-danger');
394394
axisProgressElement.classList.add('bg-success');
@@ -506,7 +506,7 @@ document.addEventListener('DOMContentLoaded', function() {
506506
function startGamepadLoop() {
507507
if (animationFrameId) return;
508508

509-
// Make sure UI elements are initialized when starting loop
509+
// Make sure UI elements are initialized when starting the loop
510510
if (activeGamepadIndex !== null) {
511511
initGamepadButtons();
512512
initGamepadAxes();

assets/js/projects.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ $(document).ready(function(){
3232
type: "GET",
3333
dataType:"json",
3434
success: function (result) {
35-
let sorted = result.sort(window.rankingSorter("stargazers_count", "name"))
35+
let sorted = result.sort(globalThis.rankingSorter("stargazers_count", "name"))
3636

3737
for(let repo in sorted) {
3838
let process_repo = true;
@@ -175,7 +175,7 @@ $(document).ready(function(){
175175
star_link.className = "nav-link nav-link-sm project-nav-link ms-3 crowdin-ignore"
176176
star_link.href = `https://star-history.com/#${sorted[repo]['full_name']}`
177177
star_link.target = "_blank"
178-
star_link.textContent = window.formatNumber(sorted[repo]['stargazers_count'])
178+
star_link.textContent = globalThis.formatNumber(sorted[repo]['stargazers_count'])
179179
repo_data_row.appendChild(star_link)
180180

181181
let star_link_image = document.createElement("i")
@@ -186,7 +186,7 @@ $(document).ready(function(){
186186
fork_link.className = "nav-link nav-link-sm project-nav-link ms-3 crowdin-ignore"
187187
fork_link.href = `https://github.com/${sorted[repo]['full_name']}/network/members`
188188
fork_link.target = "_blank"
189-
fork_link.textContent = window.formatNumber(sorted[repo]['forks'])
189+
fork_link.textContent = globalThis.formatNumber(sorted[repo]['forks'])
190190
repo_data_row.appendChild(fork_link)
191191

192192
let fork_link_image = document.createElement("i")
@@ -208,7 +208,7 @@ $(document).ready(function(){
208208
continue;
209209
}
210210
} catch (e) {
211-
console.error("Invalid URL:", docs_url);
211+
console.error("Invalid URL:", docs_url, e);
212212
continue;
213213
}
214214

gamepad-tester.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
- /assets/js/gamepad-tester.js
1212
---
1313
<script>
14-
window.gamepadHelperVersion = "{{ site.data.licenses.gamepad-helper.version }}";
14+
globalThis.gamepadHelperVersion = "{{ site.data.licenses.gamepad-helper.version }}";
1515
</script>
1616

1717
<!-- Gamepad Tester section -->

0 commit comments

Comments
 (0)