Skip to content

Commit eaec486

Browse files
committed
SonarQube Code Reduction
Composer Update SonarQube Code Reduction
1 parent 922b246 commit eaec486

23 files changed

+1138
-770
lines changed

angular/src/app/invoice-amount-magnifier.js

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ class InvoiceAmountMagnifier {
3838
elements.forEach((element: Element) => {
3939
const htmlElement = element as HTMLElement;
4040

41-
if (this.isAmountElement(htmlElement) && !htmlElement.hasAttribute('data-magnifier-initialized')) {
41+
if (this.isAmountElement(htmlElement) && !htmlElement.dataset.magnifierInitialized) {
4242
this.addMagnificationBehavior(htmlElement);
43-
htmlElement.setAttribute('data-magnifier-initialized', 'true');
43+
htmlElement.dataset.magnifierInitialized = 'true';
4444
}
4545
});
4646
});
@@ -70,17 +70,18 @@ class InvoiceAmountMagnifier {
7070
}
7171

7272
// Store original styles
73+
const computedStyle = globalThis.getComputedStyle(element);
7374
const originalStyles = {
74-
fontSize: window.getComputedStyle(element).fontSize,
75-
fontWeight: window.getComputedStyle(element).fontWeight,
76-
backgroundColor: window.getComputedStyle(element).backgroundColor,
77-
border: window.getComputedStyle(element).border,
78-
borderRadius: window.getComputedStyle(element).borderRadius,
79-
padding: window.getComputedStyle(element).padding,
80-
zIndex: window.getComputedStyle(element).zIndex,
81-
position: window.getComputedStyle(element).position,
82-
transform: window.getComputedStyle(element).transform,
83-
boxShadow: window.getComputedStyle(element).boxShadow
75+
fontSize: computedStyle.fontSize,
76+
fontWeight: computedStyle.fontWeight,
77+
backgroundColor: computedStyle.backgroundColor,
78+
border: computedStyle.border,
79+
borderRadius: computedStyle.borderRadius,
80+
padding: computedStyle.padding,
81+
zIndex: computedStyle.zIndex,
82+
position: computedStyle.position,
83+
transform: computedStyle.transform,
84+
boxShadow: computedStyle.boxShadow
8485
};
8586

8687
// Set base styles
@@ -172,6 +173,4 @@ class InvoiceAmountMagnifier {
172173
const invoiceAmountMagnifier = new InvoiceAmountMagnifier();
173174

174175
// Export for manual control if needed
175-
if (typeof window !== 'undefined') {
176-
(window as any).InvoiceAmountMagnifier = InvoiceAmountMagnifier;
177-
}
176+
(globalThis as any).InvoiceAmountMagnifier = InvoiceAmountMagnifier;

angular/src/app/invoice-amount-magnifier.service.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ export class InvoiceAmountMagnifierService implements OnDestroy {
4646
elements.forEach((element: Element) => {
4747
const htmlElement = element as HTMLElement;
4848

49-
if (this.isAmountElement(htmlElement) && !htmlElement.hasAttribute('data-magnifier-initialized')) {
49+
if (this.isAmountElement(htmlElement) && !htmlElement.dataset.magnifierInitialized) {
5050
this.addMagnificationBehavior(htmlElement);
51-
htmlElement.setAttribute('data-magnifier-initialized', 'true');
51+
htmlElement.dataset.magnifierInitialized = 'true';
5252
}
5353
});
5454
});
@@ -78,7 +78,7 @@ export class InvoiceAmountMagnifierService implements OnDestroy {
7878
}
7979

8080
// Store original styles
81-
const computedStyle = window.getComputedStyle(element);
81+
const computedStyle = globalThis.getComputedStyle(element);
8282
const originalStyles = {
8383
fontSize: computedStyle.fontSize,
8484
fontWeight: computedStyle.fontWeight,

angular/src/app/invoice-amounts.component.ts

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Component, OnInit, OnDestroy, AfterViewInit } from '@angular/core';
1+
import { Component, AfterViewInit } from '@angular/core';
22
import { InvoiceAmountMagnifierService } from './invoice-amount-magnifier.service';
33

44
@Component({
@@ -40,22 +40,14 @@ import { InvoiceAmountMagnifierService } from './invoice-amount-magnifier.servic
4040
}
4141
`]
4242
})
43-
export class InvoiceAmountsComponent implements OnInit, OnDestroy, AfterViewInit {
43+
export class InvoiceAmountsComponent implements AfterViewInit {
4444

4545
constructor(private magnifierService: InvoiceAmountMagnifierService) {}
4646

47-
ngOnInit() {
48-
// Service automatically initializes
49-
}
50-
5147
ngAfterViewInit() {
5248
// Reinitialize after view is ready
5349
setTimeout(() => {
5450
this.magnifierService.reinitialize();
5551
}, 200);
5652
}
57-
58-
ngOnDestroy() {
59-
// Service handles its own cleanup
60-
}
6153
}

angular/src/app/services/flash-message.service.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -145,13 +145,13 @@ export class FlashMessageService {
145145
*/
146146
private getFlashTimer(): any {
147147
// Try to get from window first
148-
if (window.flashMessageTimer) {
149-
return window.flashMessageTimer;
148+
if (globalThis.flashMessageTimer) {
149+
return globalThis.flashMessageTimer;
150150
}
151151

152152
// Try to find in DOM through window object
153-
if ((window as any).flashMessageTimerInstance) {
154-
return (window as any).flashMessageTimerInstance;
153+
if ((globalThis as any).flashMessageTimerInstance) {
154+
return (globalThis as any).flashMessageTimerInstance;
155155
}
156156

157157
return null;

angular/src/main.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
import { bootstrapApplication } from '@angular/platform-browser';
22
import { AppComponent } from './app/app.component';
33

4-
bootstrapApplication(AppComponent, {
5-
providers: [
6-
// Add any global providers here
7-
]
8-
}).catch(err => console.error(err));
4+
try {
5+
await bootstrapApplication(AppComponent, {
6+
providers: [
7+
// Add any global providers here
8+
]
9+
});
10+
} catch (err) {
11+
console.error(err);
12+
}

composer.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -147,14 +147,14 @@
147147
},
148148
"require-dev": {
149149
"codeception/c3": "^2.9",
150-
"codeception/codeception": "^5.3.4",
150+
"codeception/codeception": "^5.3.5",
151151
"codeception/module-asserts": "^3.3.0",
152152
"codeception/module-cli": "^2.0.1",
153153
"codeception/module-phpbrowser": "^4.0.0",
154-
"friendsofphp/php-cs-fixer": "^3.94.0",
154+
"friendsofphp/php-cs-fixer": "^3.94.1",
155155
"guzzlehttp/promises": ">=2.3",
156-
"phpunit/phpunit": "^12.5.12",
157-
"rector/rector": "^2.3.6",
156+
"phpunit/phpunit": "^12.5.14",
157+
"rector/rector": "^2.3.7",
158158
"roave/better-reflection": "^6.69",
159159
"roave/infection-static-analysis-plugin": ">=1.43",
160160
"roave/security-advisories": "dev-latest",

0 commit comments

Comments
 (0)