From 993fe3e69e37c32dcd4f7271ed49ccd11a084557 Mon Sep 17 00:00:00 2001 From: "sonarqube-agent[bot]" <210722872+sonarqube-agent[bot]@users.noreply.github.com> Date: Wed, 20 May 2026 14:57:31 +0000 Subject: [PATCH] fix: Address 10 SonarQube issues Fixed issues: - AZ45Ctw2RXnEWm2Rf4VU for javascript:S6582 rule - AZ45Ctw2RXnEWm2Rf4Vc for javascript:S7764 rule - AZ45Ctw2RXnEWm2Rf4Vd for javascript:S6594 rule - AZ45Ctw2RXnEWm2Rf4Ve for javascript:S7773 rule - AZ45Ctw2RXnEWm2Rf4Vf for javascript:S7773 rule - AZ45Ctw2RXnEWm2Rf4Vg for javascript:S7773 rule - AZ45Ctw2RXnEWm2Rf4Vh for javascript:S7764 rule - AZ45Ctw2RXnEWm2Rf4VV for javascript:S3504 rule - AZ45Ctw2RXnEWm2Rf4VW for javascript:S3504 rule - AZ45Ctw2RXnEWm2Rf4VT for javascript:S7764 rule Generated by SonarQube Agent (task: 3f5fa45a-0a29-4fe9-bbed-fc0365f90e11) --- sklearn/utils/_repr_html/estimator.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/sklearn/utils/_repr_html/estimator.js b/sklearn/utils/_repr_html/estimator.js index 289d599779e52..5636cc7ecdb51 100644 --- a/sklearn/utils/_repr_html/estimator.js +++ b/sklearn/utils/_repr_html/estimator.js @@ -9,7 +9,7 @@ function copyToClipboard(text, element) { const fullParamName = paramPrefix ? `${paramPrefix}${text}` : text; const originalStyle = element.style; - const computedStyle = window.getComputedStyle(element); + const computedStyle = globalThis.getComputedStyle(element); const originalWidth = computedStyle.width; const originalHTML = element.innerHTML.replace('Copied!', ''); @@ -41,7 +41,7 @@ document.querySelectorAll('.copy-paste-icon').forEach(function(element) { const paramPrefix = toggleableContent ? toggleableContent.dataset.paramPrefix : ''; const parent = element.parentElement; - if (!parent || !parent.nextElementSibling) { + if (!parent?.nextElementSibling) { console.warn('Expected copy-paste icon is missing from the DOM structure'); return; } @@ -61,8 +61,8 @@ document.querySelectorAll('.copy-paste-icon').forEach(function(element) { * @returns {boolean} Always returns `false` so callers can prevent the default click behavior. */ function copyFeatureNamesToClipboard(element) { - var detailsElem = element.closest('.features').querySelector('details'); - var wasOpen = detailsElem.open; + const detailsElem = element.closest('.features').querySelector('details'); + const wasOpen = detailsElem.open; detailsElem.open = true; var content = element.closest('.features').querySelector('tbody') .innerText.trim(); @@ -130,13 +130,13 @@ function detectTheme(element) { } // Guess based on a parent element's color - const color = window.getComputedStyle(element.parentNode, null).getPropertyValue('color'); - const match = color.match(/^rgb\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)\s*$/i); + const color = globalThis.getComputedStyle(element.parentNode, null).getPropertyValue('color'); + const match = /^rgb\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)\s*$/i.exec(color); if (match) { const [r, g, b] = [ - parseFloat(match[1]), - parseFloat(match[2]), - parseFloat(match[3]) + Number.parseFloat(match[1]), + Number.parseFloat(match[2]), + Number.parseFloat(match[3]) ]; // https://en.wikipedia.org/wiki/HSL_and_HSV#Lightness @@ -154,7 +154,7 @@ function detectTheme(element) { } // Fallback to system preference - return window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light'; + return globalThis.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light'; }