Skip to content

Improvement/add unused vars rule#109

Open
Ayurshi-Singh wants to merge 2 commits intomainfrom
improvement/Add-unused-vars-rule
Open

Improvement/add unused vars rule#109
Ayurshi-Singh wants to merge 2 commits intomainfrom
improvement/Add-unused-vars-rule

Conversation

@Ayurshi-Singh
Copy link
Copy Markdown
Contributor

@Ayurshi-Singh Ayurshi-Singh commented Apr 29, 2026

What this PR does / why we need it:
Developers can currently push code containing unused variables, unused class members, and other lint errors to the remote repository without any local enforcement. This results in dead code accumulating (e.g., hasHandledFirstAuthError and isLoginInProgress in Api.service.ts were declared but never used) and unnecessary CI pipeline failures.
This ticket addresses two gaps:

  1. The linter does not detect unused variables, parameters, or private class members
  2. There is no local enforcement to prevent pushing code that fails lint/type checks

Summary by CodeRabbit

  • New Features

    • Added HYOK cryptographic certificate management dialog, enabling users to add and manage crypto certificates with associated ARN configurations for key configurations.
  • Chores

    • Enabled pre-commit and pre-push Git hooks for code quality validation.
    • Enhanced TypeScript compiler to enforce stricter unused code detection.
    • Added ESLint rules for improved code quality.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 29, 2026

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 5d36dce1-433f-4e69-a2c8-c22671d8d85d

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • ✅ Review completed - (🔄 Check again to review again)

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@Ayurshi-Singh Ayurshi-Singh self-assigned this Apr 29, 2026
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
webapp/controller/keyConfigs/detail/Detail.controller.ts (1)

302-334: ⚠️ Potential issue | 🟠 Major

Handle workflow creation failures explicitly.

Line 302 fire-and-forgets an async call, while createWorkflowForSystemConnection (Line 326) has no catch. A rejected workflow creation can become an unhandled rejection and skip user-facing error feedback.

Suggested fix
 private async createWorkflowForSystemConnection(workflowParams: WorkflowParams): Promise<void> {
     try {
         await this.workflowComponent?.createWorkflow(workflowParams);
     }
+    catch (error) {
+        console.error(error);
+        showErrorMessage(error as AxiosError, this.getText('errorConnectingSystems'));
+    }
     finally {
         await this.getKeyConfigData();
         this.getView()?.setBusy(false);
         this.onConnectSystemsCancelPress();
     }
 }
🧹 Nitpick comments (1)
webapp/component/HyokCryptoRoleAdd.ts (1)

32-37: Rename rootCryptoCA to a profile-ARN-aligned field name.

The field currently stores profile ARN data, not a root CA. Renaming (for example, profileCryptoARN) will make model/payload mapping clearer and reduce future mistakes.

Also applies to: 192-197, 285-289


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 53e27168-8d4f-4744-9fd0-3ac6fc9cbcad

📥 Commits

Reviewing files that changed from the base of the PR and between a5778b8 and e287276.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (22)
  • .husky/pre-commit
  • .husky/pre-push
  • eslint.config.mjs
  • package.json
  • tsconfig.json
  • webapp/common/Formatters.ts
  • webapp/component/HelpInfoPopover.ts
  • webapp/component/HyokCryptoRoleAdd.ts
  • webapp/controller/App.controller.ts
  • webapp/controller/BaseController.ts
  • webapp/controller/groups/Groups.controller.ts
  • webapp/controller/keyConfigs/KeyConfigs.controller.ts
  • webapp/controller/keyConfigs/detail/Detail.controller.ts
  • webapp/controller/keyConfigs/detail/DetailPanel.controller.ts
  • webapp/controller/systems/Layout.controller.ts
  • webapp/controller/systems/Systems.controller.ts
  • webapp/controller/tasks/Layout.controller.ts
  • webapp/controller/tasks/Tasks.controller.ts
  • webapp/resources/fragments/common/HYOKAddCryptoCertsDialog.fragment.xml
  • webapp/resources/fragments/common/HYOKKeyCreationWizard.fragment.xml
  • webapp/services/Api.service.ts
  • webapp/view/keyConfigs/detail/DetailPanel.view.xml
💤 Files with no reviewable changes (5)
  • webapp/controller/systems/Layout.controller.ts
  • webapp/controller/tasks/Layout.controller.ts
  • webapp/controller/App.controller.ts
  • webapp/component/HelpInfoPopover.ts
  • webapp/services/Api.service.ts

Comment on lines +113 to +120
this.addCryptoModel.setData({
allCryptoCerts: allCryptoCerts,
availableCryptoCertsSelectionList: availableCerts,
newCryptoCertGroups: [],
allowAddMoreCryptoCert: availableCerts.length > 0,
hasCommittedCerts: false,
showAllCertsAssignedMessage: false,
certSelected: false,
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Fix empty-state message condition for “all certs assigned”.

The message stays hidden when there are zero available certs and zero committed certs, which leaves a blank dialog state.

Suggested fix
 this.addCryptoModel.setData({
   ...
-  showAllCertsAssignedMessage: false,
+  showAllCertsAssignedMessage: availableCerts.length === 0,
   ...
 });

 private updateComputedFlags(): void {
   const groups = this.addCryptoModel.getProperty('/newCryptoCertGroups') as CommittedCertEntry[];
   const hasCommitted = groups && groups.length > 0;
   const allowMore = this.addCryptoModel.getProperty('/allowAddMoreCryptoCert') as boolean;
   this.addCryptoModel.setProperty('/hasCommittedCerts', hasCommitted);
-  this.addCryptoModel.setProperty('/showAllCertsAssignedMessage', !allowMore && hasCommitted);
+  this.addCryptoModel.setProperty('/showAllCertsAssignedMessage', !allowMore);
 }

Also applies to: 295-301

Comment on lines +182 to +197
public onCommitCurrentCert(): void {
const currentCert = this.addCryptoModel.getProperty('/currentCert') as AWScertificates;
const trustAnchorARN = this.addCryptoModel.getProperty('/currentTrustAnchorARN') as string;
const roleARN = this.addCryptoModel.getProperty('/currentRoleARN') as string;
const profileARN = this.addCryptoModel.getProperty('/currentProfileARN') as string;

if (!currentCert) {
return;
}

const newEntry: CommittedCertEntry = {
selectedCertName: currentCert.name,
trustAnchorCryptoARN: trustAnchorARN,
roleCryptoARN: roleARN,
rootCryptoCA: profileARN
};
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Block commit when ARN fields are empty.

onCommitCurrentCert allows committing with blank trustAnchorARN, roleARN, or profileARN. That can send incomplete crypto access details on save.

Suggested fix
 public onCommitCurrentCert(): void {
     const currentCert = this.addCryptoModel.getProperty('/currentCert') as AWScertificates;
     const trustAnchorARN = this.addCryptoModel.getProperty('/currentTrustAnchorARN') as string;
     const roleARN = this.addCryptoModel.getProperty('/currentRoleARN') as string;
     const profileARN = this.addCryptoModel.getProperty('/currentProfileARN') as string;

     if (!currentCert) {
         return;
     }
+    if (!trustAnchorARN.trim() || !roleARN.trim() || !profileARN.trim()) {
+        MessageBox.error(this.parentController.getText('errorGeneric'));
+        return;
+    }

     const newEntry: CommittedCertEntry = {
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
public onCommitCurrentCert(): void {
const currentCert = this.addCryptoModel.getProperty('/currentCert') as AWScertificates;
const trustAnchorARN = this.addCryptoModel.getProperty('/currentTrustAnchorARN') as string;
const roleARN = this.addCryptoModel.getProperty('/currentRoleARN') as string;
const profileARN = this.addCryptoModel.getProperty('/currentProfileARN') as string;
if (!currentCert) {
return;
}
const newEntry: CommittedCertEntry = {
selectedCertName: currentCert.name,
trustAnchorCryptoARN: trustAnchorARN,
roleCryptoARN: roleARN,
rootCryptoCA: profileARN
};
public onCommitCurrentCert(): void {
const currentCert = this.addCryptoModel.getProperty('/currentCert') as AWScertificates;
const trustAnchorARN = this.addCryptoModel.getProperty('/currentTrustAnchorARN') as string;
const roleARN = this.addCryptoModel.getProperty('/currentRoleARN') as string;
const profileARN = this.addCryptoModel.getProperty('/currentProfileARN') as string;
if (!currentCert) {
return;
}
if (!trustAnchorARN.trim() || !roleARN.trim() || !profileARN.trim()) {
MessageBox.error(this.parentController.getText('errorGeneric'));
return;
}
const newEntry: CommittedCertEntry = {
selectedCertName: currentCert.name,
trustAnchorCryptoARN: trustAnchorARN,
roleCryptoARN: roleARN,
rootCryptoCA: profileARN
};

Comment on lines +386 to +400
public onAddHYOKCryptoDetailsPress(): void {
const selectedKey = this.twoWayModel.getProperty('/selectedKey') as Key;
const existingCrypto = selectedKey?.accessDetails?.crypto;
this.addCryptoComponent?.openAddCryptoCertsDialog(
{
keyId: this.id,
keyConfigId: this.keyConfigId ?? '',
existingCrypto: existingCrypto
},
this,
this.api,
async () => {
await this.getKeyDetails();
}
);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Fail fast when keyConfigId is missing.

keyConfigId is optional in the route params, but this path silently falls back to ''. If the route is malformed, the add dialog will open with an invalid config id and fail later in the flow.

Suggested fix
     public onAddHYOKCryptoDetailsPress(): void {
         const selectedKey = this.twoWayModel.getProperty('/selectedKey') as Key;
         const existingCrypto = selectedKey?.accessDetails?.crypto;
+        if (!this.keyConfigId) {
+            console.error('Missing keyConfigId');
+            return;
+        }
         this.addCryptoComponent?.openAddCryptoCertsDialog(
             {
                 keyId: this.id,
-                keyConfigId: this.keyConfigId ?? '',
+                keyConfigId: this.keyConfigId,
                 existingCrypto: existingCrypto
             },
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
public onAddHYOKCryptoDetailsPress(): void {
const selectedKey = this.twoWayModel.getProperty('/selectedKey') as Key;
const existingCrypto = selectedKey?.accessDetails?.crypto;
this.addCryptoComponent?.openAddCryptoCertsDialog(
{
keyId: this.id,
keyConfigId: this.keyConfigId ?? '',
existingCrypto: existingCrypto
},
this,
this.api,
async () => {
await this.getKeyDetails();
}
);
public onAddHYOKCryptoDetailsPress(): void {
const selectedKey = this.twoWayModel.getProperty('/selectedKey') as Key;
const existingCrypto = selectedKey?.accessDetails?.crypto;
if (!this.keyConfigId) {
console.error('Missing keyConfigId');
return;
}
this.addCryptoComponent?.openAddCryptoCertsDialog(
{
keyId: this.id,
keyConfigId: this.keyConfigId,
existingCrypto: existingCrypto
},
this,
this.api,
async () => {
await this.getKeyDetails();
}
);

Comment on lines +166 to 179
<m:HBox>
<m:HBox>
<m:Button
icon="sap-icon://edit"
icon="sap-icon://add"
type="Ghost"
text="{i18n>edit}"
press="onEditHYOKCryptoDetailsPress">
text="{i18n>add}"
press="onAddHYOKCryptoDetailsPress">
<m:customData>
<core:CustomData
key="testId"
value="section-editButton"
value="section-addButton"
writeToDom="true" />
</m:customData>
</m:Button>
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Guard the new add action while crypto edit mode is active.

As written, this button can open the add dialog while cryptoInEditMode is true. That dialog flow refreshes key details on save, which can overwrite unsaved edits in the current form.

Suggested fix
-                                <m:Button
-                                    icon="sap-icon://add"
-                                    type="Ghost"
-                                    text="{i18n>add}"
-                                    press="onAddHYOKCryptoDetailsPress">
+                                <m:Button
+                                    icon="sap-icon://add"
+                                    type="Ghost"
+                                    text="{i18n>add}"
+                                    visible="{= !${oneWay>/cryptoInEditMode}}"
+                                    press="onAddHYOKCryptoDetailsPress">

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant