-
Notifications
You must be signed in to change notification settings - Fork 6
Add warning if CA names length is greater than 30 characters #335
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
Summary of ChangesHello @adityamittal3107, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request introduces a new validation step for custom actions, specifically focusing on the length of action names. It adds a warning system to notify developers when a custom action name surpasses 30 characters, which is a common threshold for optimal UI display. The changes include the core logic for this check, the necessary type exports to support it, and a corresponding unit test to verify its correct behavior. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request adds a warning when a custom action's name exceeds 30 characters. The implementation is correct and includes a test case. My feedback focuses on improving maintainability by replacing magic numbers with named constants and using a more functional approach for collecting warnings. These changes will make the code easier to read and update in the future.
| test('should warn when action name length exceeds 30 characters', () => { | ||
| // Arrange | ||
| const longName = 'A'.repeat(31); | ||
| const action: CustomAction = { | ||
| id: 'long-name-id', | ||
| name: longName, | ||
| target: CustomActionTarget.LIVEBOARD, | ||
| position: CustomActionsPosition.PRIMARY, | ||
| }; | ||
|
|
||
| // Act | ||
| const result = getCustomActions([action]); | ||
|
|
||
| // Assert | ||
| expect(result.actions).toHaveLength(1); | ||
| expect(logger.warn).toHaveBeenCalledWith([ | ||
| `Custom action name '${longName}' exceeds 30 characters. This may cause display or truncation issues in the UI.` | ||
| ]); | ||
| }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To improve maintainability and readability, it's best to avoid magic numbers. The numbers 31 and 30 should be extracted into a named constant. This makes the test's intent clearer and simplifies future updates if the length limit changes.
While this introduces some duplication with the implementation file, it's a good step. Ideally, this constant would be shared between the implementation and the test file.
test('should warn when action name length exceeds 30 characters', () => {
// Arrange
const MAX_ACTION_NAME_LENGTH = 30;
const longName = 'A'.repeat(MAX_ACTION_NAME_LENGTH + 1);
const action: CustomAction = {
id: 'long-name-id',
name: longName,
target: CustomActionTarget.LIVEBOARD,
position: CustomActionsPosition.PRIMARY,
};
// Act
const result = getCustomActions([action]);
// Assert
expect(result.actions).toHaveLength(1);
expect(logger.warn).toHaveBeenCalledWith([
`Custom action name '${longName}' exceeds ${MAX_ACTION_NAME_LENGTH} characters. This may cause display or truncation issues in the UI.`
]);
});
commit: |
27c7c8a to
a0e8a34
Compare
a0e8a34 to
44da337
Compare
|
SonarQube Quality Gate
|








No description provided.