Skip to content

fix: remove unnecessary assertion and unused import#105

Open
sonarqube-agent[bot] wants to merge 1 commit intomainfrom
remediate-main-20260509-090224-d2bbe785
Open

fix: remove unnecessary assertion and unused import#105
sonarqube-agent[bot] wants to merge 1 commit intomainfrom
remediate-main-20260509-090224-d2bbe785

Conversation

@sonarqube-agent
Copy link
Copy Markdown

Resolves two SonarQube code smells by removing an unnecessary non-null assertion operator from a test file and eliminating an unused Toggle import. These changes improve code clarity and reduce bundle size without affecting functionality.

View Project in SonarCloud


Fixed Issues

typescript:S4325 - This assertion is unnecessary since the receiver accepts the original type of the expression. • MINORView issue

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

Why is this an issue?

In TypeScript, casts and non-null assertions are two mechanisms used to inform the TypeScript compiler about the intended types of variables, expressions, or values in the code. They are used to help the compiler understand the types more accurately and to handle certain situations where type inference might not be sufficient:

What changed

Removes the unnecessary non-null assertion operator (!) from idNatPsControl in the spyOn call. The TypeScript compiler already knows that idNatPsControl is not null or undefined at this point in the code, making the non-null assertion redundant. Removing it eliminates the code smell of an unnecessary assertion that adds noise without providing any type safety benefit.

--- a/psc-admin-portal/src/app/interrogation-ps/interrogation-ps.component.spec.ts
+++ b/psc-admin-portal/src/app/interrogation-ps/interrogation-ps.component.spec.ts
@@ -95,1 +95,1 @@ describe('InterrogationPsComponent', () => {
-    spyOn(idNatPsControl!, 'setErrors').and.callThrough();
+    spyOn(idNatPsControl, 'setErrors').and.callThrough();
typescript:S1128 - Remove this unused import of 'Toggle'. • MINORView issue

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

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

Removes the unused import of 'Toggle' from 'app.component.ts'. The static analysis flagged this import as unnecessary because the 'Toggle' symbol was not referenced anywhere in the code. Removing it eliminates the unused import code smell and reduces unnecessary bundle weight.

--- a/psc-admin-portal/src/app/app.component.ts
+++ b/psc-admin-portal/src/app/app.component.ts
@@ -24,1 +23,0 @@ import {HeaderComponent} from './ds/header/header.component';
-import {Toggle} from './api/toggle.service';

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


SonarQube Remediation Agent uses AI. Check for mistakes.

Fixed issues:
- AZZjKfX74RkVRlFrkaQV for typescript:S1128 rule
- AZZjKfPs4RkVRlFrkaO2 for typescript:S4325 rule

Generated by SonarQube Agent (task: 7d8e4cff-14d1-4c00-bbbc-78ae31132ab8)
@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

sonarqubecloud Bot commented May 9, 2026

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