Skip to content
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

refactor(framework):clean up function analyzer #780 #852

Merged

Conversation

akhil0203
Copy link
Contributor

The Pull Request is ready

Overview

RegExp.exec() method is used instead of string.match() as suggested in sonar cloud analysis
multiple module-global constants are created for repeated RegExp.

Review points

creation of multiple module-global constants

Framework

  • default behaviour did not change

Copy link
Contributor

coderabbitai bot commented Apr 21, 2024

Walkthrough

The update involves refining the function-analyzer.ts in the framework by integrating specific regular expressions tailored for various parsing scenarios. This enhancement focuses on improving the accuracy and efficiency of function parameter and analysis parsing.

Changes

File(s) Change Summary
framework/src/helper/function-analyzer.ts Updated to use multiple specific regular expressions for enhanced parsing of parameters and function analysis.

Assessment against linked issues

Objective Addressed Explanation
clean up function analyzer

Poem

In the realm of code, beneath the syntax tree,
A rabbit hops, refactoring with glee.
Regex patterns like stars in the night,
Guiding the parser to understand right.
Each line of code, a step towards the light.
🌟🐇📜


Recent Review Details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits Files that changed from the base of the PR and between 91d0f84 and 7fd8b9b.
Files selected for processing (1)
  • framework/src/helper/function-analyzer.ts (3 hunks)
Files skipped from review as they are similar to previous changes (1)
  • framework/src/helper/function-analyzer.ts

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

Note: Auto-reply has been disabled for this repository by the repository owner. The CodeRabbit bot will not respond to your replies unless it is explicitly tagged.

  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions github-actions bot added the component: framework related to the project framework, not the website label Apr 21, 2024
Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @akhil0203 - I've reviewed your changes and they look great!

Here's what I looked at during the review
  • 🟡 General issues: 1 issue found
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Docstrings: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment to tell me if it was helpful.

framework/src/helper/function-analyzer.ts Outdated Show resolved Hide resolved
coderabbitai[bot]
coderabbitai bot previously approved these changes Apr 21, 2024
@Idrinth
Copy link
Member

Idrinth commented Apr 21, 2024

@akhil0203 please restore the eslint ignores properly, then everything should pass again, otherwise good work!

Copy link
Member

@Idrinth Idrinth left a comment

Choose a reason for hiding this comment

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

  • rename regexp for what the do, not where they are used
  • restore eslint-disable-next-line to make eslint pass

coderabbitai[bot]
coderabbitai bot previously approved these changes Apr 24, 2024
coderabbitai[bot]
coderabbitai bot previously approved these changes Apr 24, 2024
@akhil0203 akhil0203 requested a review from Idrinth April 27, 2024 09:58
@Idrinth
Copy link
Member

Idrinth commented Apr 27, 2024

Hi @akhil0203 ,
This looks good, just can't be merged right now due to conflicts. Please merge the-one into this.

coderabbitai[bot]
coderabbitai bot previously approved these changes Apr 28, 2024
Copy link
Contributor

@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: 1

Out of diff range and nitpick comments (1)
framework/src/helper/function-analyzer.ts (1)

Line range hint 119-150: CodeRabbit approves the changes in the analyze function. However, consider refactoring to reduce complexity, possibly by breaking down the function into smaller, more manageable parts.

framework/src/helper/function-analyzer.ts Show resolved Hide resolved
@akhil0203 akhil0203 marked this pull request as draft April 28, 2024 11:37
Copy link
Contributor

@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: 3

Comment on lines 36 to 42
const value: Param = {
name: '',
type: 'string',
default: '',
value: '',
envName: '',
};
Copy link
Contributor

Choose a reason for hiding this comment

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

Adjust the indentation to conform to the expected style. This will enhance readability and maintain consistency across the codebase.

-    const value: Param = {
-        name: '',
-        type: 'string',
-        default: '',
-        value: '',
-        envName: '',
-    };
+  const value: Param = {
+    name: '',
+    type: 'string',
+    default: '',
+    value: '',
+    envName: '',
+  };

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.

Suggested change
const value: Param = {
name: '',
type: 'string',
default: '',
value: '',
envName: '',
};
const value: Param = {
name: '',
type: 'string',
default: '',
value: '',
envName: '',
};

Comment on lines 43 to 48
if (commentAndAssignmentRegExp.exec(parameter,)) {
processCommentAndAssignment(parameter, value);
} else if (commentRegExp.exec(parameter)) {
processComment(parameter, value);
} else if (assignmentRegExp.exec(parameter)) {
processAssignment(parameter, value);
Copy link
Contributor

Choose a reason for hiding this comment

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

The functions 'processCommentAndAssignment', 'processComment', and 'processAssignment' are used before they are defined. This might lead to runtime errors in environments that do not support hoisting of function declarations. Consider defining these functions before their first use.

+ const processCommentAndAssignment = (parameter: string, value: Param) => { ... };
+ const processComment = (parameter: string, value: Param) => { ... };
+ const processAssignment = (parameter: string, value: Param) => { ... };
- const buildParameter = (parameter: string): Param => { ... };
+ const buildParameter = (parameter: string): Param => { ... };

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.

Suggested change
if (commentAndAssignmentRegExp.exec(parameter,)) {
processCommentAndAssignment(parameter, value);
} else if (commentRegExp.exec(parameter)) {
processComment(parameter, value);
} else if (assignmentRegExp.exec(parameter)) {
processAssignment(parameter, value);
const processCommentAndAssignment = (parameter: string, value: Param) => { ... };
const processComment = (parameter: string, value: Param) => { ... };
const processAssignment = (parameter: string, value: Param) => { ... };
const buildParameter = (parameter: string): Param => { ... };
if (commentAndAssignmentRegExp.exec(parameter,)) {
processCommentAndAssignment(parameter, value);
} else if (commentRegExp.exec(parameter)) {
processComment(parameter, value);
} else if (assignmentRegExp.exec(parameter)) {
processAssignment(parameter, value);

Copy link
Contributor

@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: 6

const beginningAssignmentRegExp=/^.+=/u;
const leadingOrTrailingWhitespaceRegExp=/^\s*|\s*$/gu;
const commentBlockOrWhitespaceRegExp=/^.*\/\*|\*\/.+$/gu;
const buildParameter = (parameter: string): Param => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Add a trailing comma after the function parameter to maintain consistency and conform to style guidelines.

- const buildParameter = (parameter: string): Param => {
+ const buildParameter = (parameter: string,): Param => {

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.

Suggested change
const buildParameter = (parameter: string): Param => {
const buildParameter = (parameter: string,): Param => {

const value: Param = {
name: '',
type: 'string',
default: '',
value: '',
envName: '',
};
if (parameter.match(/\/\*.+\*\/.+=.+/u,)) {
const processCommentAndAssignment = (parameter: string, value: Param) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

The variable 'parameter' is redeclared in the scope of the nested function, which can lead to confusion and bugs. Consider renaming the parameter in the nested function to avoid shadowing.

- const processCommentAndAssignment = (parameter: string, value: Param) => {
+ const processCommentAndAssignment = (param: string, value: Param) => {

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.

Suggested change
const processCommentAndAssignment = (parameter: string, value: Param) => {
const processCommentAndAssignment = (param: string, value: Param) => {

framework/src/helper/function-analyzer.ts Outdated Show resolved Hide resolved
}
if (parameter.match(/.+=.+/u,)) {
};
const processAssignment = (parameter: string, value: Param) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

The variable 'parameter' is redeclared in the scope of the nested function processAssignment. Rename the parameter to avoid shadowing.

- const processAssignment = (parameter: string, value: Param) => {
+ const processAssignment = (param: string, value: Param) => {

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.

Suggested change
const processAssignment = (parameter: string, value: Param) => {
const processAssignment = (param: string, value: Param) => {

}
value.name = parameter.replace(/\s*/gu, '',);
return value;
return value;
Copy link
Contributor

Choose a reason for hiding this comment

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

Ensure that the function parseParameterString has a trailing comma after the function parameter to maintain consistency and conform to style guidelines.

- const parseParameterString = (parameter: string): Param => {
+ const parseParameterString = (parameter: string,): Param => {

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.

Suggested change
return value;
return value;

Copy link
Contributor

@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: 3

Comment on lines +27 to +34
const commentAndAssignmentRegExp=/\/\*.+\*\/.+=.+/u;
const commentRegExp=/\/\*.+\*\/.+/u;
const assignmentRegExp=/.+=.+/u;
const commentOrAssignmentAtEndRegExp =/\/\*.+\*\/|=.+$/gu;
const whitespaceRegExp =/\s*/gu;
const beginningAssignmentRegExp=/^.+=/u;
const leadingOrTrailingWhitespaceRegExp=/^\s*|\s*$/gu;
const commentBlockOrWhitespaceRegExp=/^.*\/\*|\*\/.+$/gu;
Copy link
Contributor

Choose a reason for hiding this comment

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

Optimise regex patterns for better performance.

CodeRabbit suggests optimising the regex patterns to avoid potential performance issues with overly broad matches and unnecessary capturing groups. Consider using non-capturing groups where appropriate.

- const commentAndAssignmentRegExp=/\/\*.+\*\/.+=.+/u;
- const commentRegExp=/\/\*.+\*\/.+/u;
- const assignmentRegExp=/.+=.+/u;
- const commentOrAssignmentAtEndRegExp =/\/\*.+\*\/|=.+$/gu;
- const whitespaceRegExp =/\s*/gu;
- const beginningAssignmentRegExp=/^.+=/u;
- const leadingOrTrailingWhitespaceRegExp=/^\s*|\s*$/gu;
- const commentBlockOrWhitespaceRegExp=/^.*\/\*|\*\/.+$/gu;
+ const commentAndAssignmentRegExp=/\/\*[^*]+\*\/[^=]+=.*$/u;
+ const commentRegExp=/\/\*[^*]+\*\/[^=]*$/u;
+ const assignmentRegExp=/^[^=]+=.*$/u;
+ const commentOrAssignmentAtEndRegExp =/\/\*[^*]+\*\/|[^=]+=.*$/gu;
+ const whitespaceRegExp=/\s+/gu;
+ const beginningAssignmentRegExp=/^[^=]+=.*$/u;
+ const leadingOrTrailingWhitespaceRegExp=/^\s+|\s+$/gu;
+ const commentBlockOrWhitespaceRegExp=/^\s*\/\*[^*]+\*\/|\*\/\s*$/gu;

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.

Suggested change
const commentAndAssignmentRegExp=/\/\*.+\*\/.+=.+/u;
const commentRegExp=/\/\*.+\*\/.+/u;
const assignmentRegExp=/.+=.+/u;
const commentOrAssignmentAtEndRegExp =/\/\*.+\*\/|=.+$/gu;
const whitespaceRegExp =/\s*/gu;
const beginningAssignmentRegExp=/^.+=/u;
const leadingOrTrailingWhitespaceRegExp=/^\s*|\s*$/gu;
const commentBlockOrWhitespaceRegExp=/^.*\/\*|\*\/.+$/gu;
const commentAndAssignmentRegExp=/\/\*[^*]+\*\/[^=]+=.*$/u;
const commentRegExp=/\/\*[^*]+\*\/[^=]*$/u;
const assignmentRegExp=/^[^=]+=.*$/u;
const commentOrAssignmentAtEndRegExp =/\/\*[^*]+\*\/|[^=]+=.*$/gu;
const whitespaceRegExp=/\s+/gu;
const beginningAssignmentRegExp=/^[^=]+=.*$/u;
const leadingOrTrailingWhitespaceRegExp=/^\s+|\s+$/gu;
const commentBlockOrWhitespaceRegExp=/^\s*\/\*[^*]+\*\/|\*\/\s*$/gu;

Comment on lines 43 to 90
const processCommentAndAssignment = () => {
value.name = parameter
.replace(/(\/\*.+\*\/)|(=.+$)/gu, '',)
.replace(/\s*/gu, '',);
.replace(commentOrAssignmentAtEndRegExp, '',)
.replace(whitespaceRegExp, '',);
value.default = parameter
.replace(/^.+=/u, '',)
.replace(/(^\s*)|(\s*$)/gu, '',);
.replace(beginningAssignmentRegExp, '',)
.replace(leadingOrTrailingWhitespaceRegExp, '',);
value.type = parameter
.replace(/(^.*\/\*)|(\*\/.+$)/gu, '',)
.replace(/\s*/gu, '',)
.replace(commentBlockOrWhitespaceRegExp, '',)
.replace(whitespaceRegExp, '',)
.toLowerCase();
return value;
}
if (parameter.match(/\/\*.+\*\/.+/u,)) {
};
const processComment = () => {
value.name = parameter
.replace(/(\/\*.+\*\/)|(=.+$)/gu, '',)
.replace(/\s*/gu, '',);
.replace(commentOrAssignmentAtEndRegExp, '',)
.replace(whitespaceRegExp, '',);
value.default = '';
value.type = parameter
.replace(/(^.*\/\*)|(\*\/.+$)/gu, '',)
.replace(/\s*/gu, '',)
.replace(commentBlockOrWhitespaceRegExp, '',)
.replace(whitespaceRegExp, '',)
.toLowerCase();
if (value.type === 'boolean') {
value.default = 'false';
} else if (value.type === 'number') {
value.default = '0';
value.default = '0';
}
return value;
}
if (parameter.match(/.+=.+/u,)) {
};
const processAssignment = () => {
value.name = parameter
.replace(/(\/\*.+\*\/)|(=.+$)/gu, '',)
.replace(/\s*/gu, '',);
.replace(commentOrAssignmentAtEndRegExp, '',)
.replace(whitespaceRegExp, '',);
value.default = parameter
.replace(/^.+=/u, '',)
.replace(/(^\s*)|(\s*$)/gu, '',);
.replace(beginningAssignmentRegExp, '',)
.replace(leadingOrTrailingWhitespaceRegExp, '',);
if (! Number.isNaN(Number.parseFloat(value.default,),)) {
value.type = 'number';
} else if (value.default === 'true' || value.default === 'false') {
value.type = 'boolean';
value.type = 'boolean';
}
return value;
};
if (commentAndAssignmentRegExp.exec(parameter,)) {
processCommentAndAssignment(parameter, value,);
} else if (commentRegExp.exec(parameter,)) {
processComment(parameter, value,);
} else if (assignmentRegExp.exec(parameter,)) {
processAssignment(parameter, value,);
} else {
value.name = parameter.replace(whitespaceRegExp, '',);
Copy link
Contributor

Choose a reason for hiding this comment

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

Refactor buildParameter function to enhance readability and maintainability.

CodeRabbit suggests refactoring the buildParameter function to separate concerns and enhance readability. Consider breaking down the function into smaller, more focused functions.

- const buildParameter = (parameter: string,): Param => {
+ const extractName = (parameter: string): string => {
+   return parameter.replace(commentOrAssignmentAtEndRegExp, '').replace(whitespaceRegExp, '');
+ };
+ const extractDefault = (parameter: string): string => {
+   return parameter.replace(beginningAssignmentRegExp, '').replace(leadingOrTrailingWhitespaceRegExp, '');
+ };
+ const extractType = (parameter: string): string => {
+   return parameter.replace(commentBlockOrWhitespaceRegExp, '').replace(whitespaceRegExp, '').toLowerCase();
+ };
+ const buildParameter = (parameter: string): Param => {
+   const value: Param = {
+     name: extractName(parameter),
+     type: extractType(parameter),
+     default: extractDefault(parameter),
+     value: '',
+     envName: '',
+   };

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.

Suggested change
const processCommentAndAssignment = () => {
value.name = parameter
.replace(/(\/\*.+\*\/)|(=.+$)/gu, '',)
.replace(/\s*/gu, '',);
.replace(commentOrAssignmentAtEndRegExp, '',)
.replace(whitespaceRegExp, '',);
value.default = parameter
.replace(/^.+=/u, '',)
.replace(/(^\s*)|(\s*$)/gu, '',);
.replace(beginningAssignmentRegExp, '',)
.replace(leadingOrTrailingWhitespaceRegExp, '',);
value.type = parameter
.replace(/(^.*\/\*)|(\*\/.+$)/gu, '',)
.replace(/\s*/gu, '',)
.replace(commentBlockOrWhitespaceRegExp, '',)
.replace(whitespaceRegExp, '',)
.toLowerCase();
return value;
}
if (parameter.match(/\/\*.+\*\/.+/u,)) {
};
const processComment = () => {
value.name = parameter
.replace(/(\/\*.+\*\/)|(=.+$)/gu, '',)
.replace(/\s*/gu, '',);
.replace(commentOrAssignmentAtEndRegExp, '',)
.replace(whitespaceRegExp, '',);
value.default = '';
value.type = parameter
.replace(/(^.*\/\*)|(\*\/.+$)/gu, '',)
.replace(/\s*/gu, '',)
.replace(commentBlockOrWhitespaceRegExp, '',)
.replace(whitespaceRegExp, '',)
.toLowerCase();
if (value.type === 'boolean') {
value.default = 'false';
} else if (value.type === 'number') {
value.default = '0';
value.default = '0';
}
return value;
}
if (parameter.match(/.+=.+/u,)) {
};
const processAssignment = () => {
value.name = parameter
.replace(/(\/\*.+\*\/)|(=.+$)/gu, '',)
.replace(/\s*/gu, '',);
.replace(commentOrAssignmentAtEndRegExp, '',)
.replace(whitespaceRegExp, '',);
value.default = parameter
.replace(/^.+=/u, '',)
.replace(/(^\s*)|(\s*$)/gu, '',);
.replace(beginningAssignmentRegExp, '',)
.replace(leadingOrTrailingWhitespaceRegExp, '',);
if (! Number.isNaN(Number.parseFloat(value.default,),)) {
value.type = 'number';
} else if (value.default === 'true' || value.default === 'false') {
value.type = 'boolean';
value.type = 'boolean';
}
return value;
};
if (commentAndAssignmentRegExp.exec(parameter,)) {
processCommentAndAssignment(parameter, value,);
} else if (commentRegExp.exec(parameter,)) {
processComment(parameter, value,);
} else if (assignmentRegExp.exec(parameter,)) {
processAssignment(parameter, value,);
} else {
value.name = parameter.replace(whitespaceRegExp, '',);
const extractName = (parameter: string): string => {
return parameter.replace(commentOrAssignmentAtEndRegExp, '').replace(whitespaceRegExp, '');
};
const extractDefault = (parameter: string): string => {
return parameter.replace(beginningAssignmentRegExp, '').replace(leadingOrTrailingWhitespaceRegExp, '');
};
const extractType = (parameter: string): string => {
return parameter.replace(commentBlockOrWhitespaceRegExp, '').replace(whitespaceRegExp, '').toLowerCase();
};
const buildParameter = (parameter: string): Param => {
const value: Param = {
name: extractName(parameter),
type: extractType(parameter),
default: extractDefault(parameter),
value: '',
envName: '',
};

// eslint-disable-next-line @typescript-eslint/ban-types
export const analyze = (func: Function,): Param[] => {
const functionWhitespaceRegExp=/\s*function\s*/u;
export const analyze = (func: MyFunction,): Param[] => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Adjust indentation to conform to expected style guidelines.

CodeRabbit observes that the indentation in the analyze function does not conform to the expected style guidelines. Adjust the indentation to enhance readability and maintain consistency across the codebase.

-   if (functionWhitespaceRegExp.exec(fun,)) {
+  if (functionWhitespaceRegExp.exec(fun,)) {
-     return fun.replace(/(^function\s*\()|(\)\s*\{.*\}\s*$)/gu, '').split(',');
+    return fun.replace(/(^function\s*\()|(\)\s*\{.*\}\s*$)/gu, '').split(',');
-   }
+  }
-  return fun.replace(/(^\s*\()|(\)\s*=>\s*.*$)/gu, '').split(',');
+ return fun.replace(/(^\s*\()|(\)\s*=>\s*.*$)/gu, '').split(',');

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.

Suggested change
export const analyze = (func: MyFunction,): Param[] => {
export const analyze = (func: MyFunction,): Param[] => {
if (functionWhitespaceRegExp.exec(fun,)) {
return fun.replace(/(^function\s*\()|(\)\s*\{.*\}\s*$)/gu, '').split(',');
}
return fun.replace(/(^\s*\()|(\)\s*=>\s*.*$)/gu, '').split(',');
}

Copy link
Contributor

@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: 1

Comment on lines +124 to +125
const functionWhitespaceRegExp=/\s*function\s*/u;
export const analyze = (func: MyFunction,): Param[] => {
Copy link
Contributor

Choose a reason for hiding this comment

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

CodeRabbit observes that the indentation in line 67 is inconsistent with the expected style. Adjust the indentation to conform to the project's coding standards.

-       value.default = '0';
+      value.default = '0';

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.

Suggested change
const functionWhitespaceRegExp=/\s*function\s*/u;
export const analyze = (func: MyFunction,): Param[] => {
const functionWhitespaceRegExp=/\s*function\s*/u;
export const analyze = (func: MyFunction,): Param[] => {

@akhil0203 akhil0203 marked this pull request as ready for review April 29, 2024 07:58
Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

We have skipped reviewing this pull request. It looks like we've already reviewed this pull request.

@akhil0203
Copy link
Contributor Author

  • rename regexp for what the do, not where they are used
  • restore eslint-disable-next-line to make eslint pass

Hi @akhil0203 , This looks good, just can't be merged right now due to conflicts. Please merge the-one into this.

hi @Idrinth its done please review it.Thanks

Copy link

sonarcloud bot commented Apr 30, 2024

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarCloud

@Idrinth Idrinth merged commit d35366f into idrinth-api-bench:the-one Apr 30, 2024
29 of 31 checks passed
@github-actions github-actions bot added this to the 2.8.0 milestone Apr 30, 2024
@Idrinth Idrinth modified the milestones: URGENT, Up for grabs May 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: framework related to the project framework, not the website
Projects
None yet
Development

Successfully merging this pull request may close these issues.

clean up function analyzer
2 participants