Skip to content

fix: resolve 5 SonarQube issues with readonly and unused imports#106

Open
sonarqube-agent[bot] wants to merge 1 commit intomainfrom
remediate-main-20260510-090210-4b17b557
Open

fix: resolve 5 SonarQube issues with readonly and unused imports#106
sonarqube-agent[bot] wants to merge 1 commit intomainfrom
remediate-main-20260510-090210-4b17b557

Conversation

@sonarqube-agent
Copy link
Copy Markdown

This PR fixes 5 SonarQube code quality issues: marking the ID_NAT_PS field as readonly to explicitly prevent reassignment, and removing 4 unused imports (Status, PsApi, Pscload, Extract) from app.component.ts. These changes improve code clarity, prevent potential bugs, and reduce bundle size.

View Project in SonarCloud


Fixed Issues

typescript:S2933 - Member 'ID_NAT_PS' is never reassigned; mark it as `readonly`. • MAJORView issue

Location: psc-admin-portal/src/app/interrogation-ps/interrogation-ps.component.ts:50

Why is this an issue?

readonly fields can only be assigned in a class constructor. If a class has a field that’s not marked readonly but is only set in the constructor, it could cause confusion about the field’s intended use. To avoid confusion, such fields should be marked readonly to make their intended use explicit, and to prevent future maintainers from inadvertently changing their use.

What changed

This hunk adds the readonly modifier to the ID_NAT_PS field, which is a private member that is initialized at declaration and never reassigned elsewhere in the class. Marking it as readonly makes the intent explicit that this field should not be modified after initialization, preventing future maintainers from inadvertently changing its use and resolving the code smell about members that are never reassigned not being marked as readonly.

--- a/psc-admin-portal/src/app/interrogation-ps/interrogation-ps.component.ts
+++ b/psc-admin-portal/src/app/interrogation-ps/interrogation-ps.component.ts
@@ -50,1 +50,1 @@ export class InterrogationPsComponent implements OnInit, OnDestroy {
-  private ID_NAT_PS: string = 'idNatPS';
+  private readonly ID_NAT_PS: string = 'idNatPS';
typescript:S1128 - Remove this unused import of 'Extract'. • MINORView issue

Location: psc-admin-portal/src/app/app.component.ts:28

Why is this an issue?

Unnecessary imports refer to importing modules, libraries, or dependencies that are not used or referenced anywhere in the code. These imports do not contribute to the functionality of the application and only add extra weight to the JavaScript bundle, leading to potential performance and maintainability issues.

What changed

This hunk removes four unused import statements from app.component.ts: 'Status' from './api/status', 'PsApi' from './api/psApi.service', 'Pscload' from './api/pscload.service', and 'Extract' from './api/extract.service'. Each of these imports was flagged as unnecessary because the imported symbols were not referenced anywhere in the code. Removing them eliminates the unused import code smells and reduces unnecessary bundle weight.

--- a/psc-admin-portal/src/app/app.component.ts
+++ b/psc-admin-portal/src/app/app.component.ts
@@ -25,4 +24,0 @@ import {Toggle} from './api/toggle.service';
-import {Status} from './api/status';
-import {PsApi} from './api/psApi.service';
-import {Pscload} from './api/pscload.service';
-import {Extract} from './api/extract.service';
typescript:S1128 - Remove this unused import of 'Pscload'. • MINORView issue

Location: psc-admin-portal/src/app/app.component.ts:27

Why is this an issue?

Unnecessary imports refer to importing modules, libraries, or dependencies that are not used or referenced anywhere in the code. These imports do not contribute to the functionality of the application and only add extra weight to the JavaScript bundle, leading to potential performance and maintainability issues.

What changed

This hunk removes four unused import statements from app.component.ts: 'Status' from './api/status', 'PsApi' from './api/psApi.service', 'Pscload' from './api/pscload.service', and 'Extract' from './api/extract.service'. Each of these imports was flagged as unnecessary because the imported symbols were not referenced anywhere in the code. Removing them eliminates the unused import code smells and reduces unnecessary bundle weight.

--- a/psc-admin-portal/src/app/app.component.ts
+++ b/psc-admin-portal/src/app/app.component.ts
@@ -25,4 +24,0 @@ import {Toggle} from './api/toggle.service';
-import {Status} from './api/status';
-import {PsApi} from './api/psApi.service';
-import {Pscload} from './api/pscload.service';
-import {Extract} from './api/extract.service';
typescript:S1128 - Remove this unused import of 'PsApi'. • MINORView issue

Location: psc-admin-portal/src/app/app.component.ts:26

Why is this an issue?

Unnecessary imports refer to importing modules, libraries, or dependencies that are not used or referenced anywhere in the code. These imports do not contribute to the functionality of the application and only add extra weight to the JavaScript bundle, leading to potential performance and maintainability issues.

What changed

This hunk removes four unused import statements from app.component.ts: 'Status' from './api/status', 'PsApi' from './api/psApi.service', 'Pscload' from './api/pscload.service', and 'Extract' from './api/extract.service'. Each of these imports was flagged as unnecessary because the imported symbols were not referenced anywhere in the code. Removing them eliminates the unused import code smells and reduces unnecessary bundle weight.

--- a/psc-admin-portal/src/app/app.component.ts
+++ b/psc-admin-portal/src/app/app.component.ts
@@ -25,4 +24,0 @@ import {Toggle} from './api/toggle.service';
-import {Status} from './api/status';
-import {PsApi} from './api/psApi.service';
-import {Pscload} from './api/pscload.service';
-import {Extract} from './api/extract.service';
typescript:S1128 - Remove this unused import of 'Status'. • MINORView issue

Location: psc-admin-portal/src/app/app.component.ts:25

Why is this an issue?

Unnecessary imports refer to importing modules, libraries, or dependencies that are not used or referenced anywhere in the code. These imports do not contribute to the functionality of the application and only add extra weight to the JavaScript bundle, leading to potential performance and maintainability issues.

What changed

This hunk removes four unused import statements from app.component.ts: 'Status' from './api/status', 'PsApi' from './api/psApi.service', 'Pscload' from './api/pscload.service', and 'Extract' from './api/extract.service'. Each of these imports was flagged as unnecessary because the imported symbols were not referenced anywhere in the code. Removing them eliminates the unused import code smells and reduces unnecessary bundle weight.

--- a/psc-admin-portal/src/app/app.component.ts
+++ b/psc-admin-portal/src/app/app.component.ts
@@ -25,4 +24,0 @@ import {Toggle} from './api/toggle.service';
-import {Status} from './api/status';
-import {PsApi} from './api/psApi.service';
-import {Pscload} from './api/pscload.service';
-import {Extract} from './api/extract.service';

Have a suggestion or found an issue? Share your feedback here.


SonarQube Remediation Agent uses AI. Check for mistakes.

Fixed issues:
- AZZjKfSO4RkVRlFrkaO3 for typescript:S2933 rule
- AZZjKfX74RkVRlFrkaQW for typescript:S1128 rule
- AZZjKfX74RkVRlFrkaQX for typescript:S1128 rule
- AZZjKfX74RkVRlFrkaQY for typescript:S1128 rule
- AZZjKfX74RkVRlFrkaQZ for typescript:S1128 rule

Generated by SonarQube Agent (task: 31b8c79e-8c80-43f4-84e9-6b0f7bd07b97)
@sonarqube-agent
Copy link
Copy Markdown
Author

⚠️ This repository does not have a CODEOWNERS file. The PR has been created but has not been automatically assigned to any reviewer. To ensure PRs are reviewed promptly, consider adding a CODEOWNERS file to your repository.

@sonarqubecloud
Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants