Skip to content

Commit

Permalink
Update function-analyzer.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
akhil0203 committed Apr 29, 2024
1 parent 339b861 commit 2ddff8c
Showing 1 changed file with 41 additions and 42 deletions.
83 changes: 41 additions & 42 deletions framework/src/helper/function-analyzer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,64 +33,63 @@ const beginningAssignmentRegExp=/^.+=/u;
const leadingOrTrailingWhitespaceRegExp=/^\s*|\s*$/gu;
const commentBlockOrWhitespaceRegExp=/^.*\/\*|\*\/.+$/gu;
const buildParameter = (parameter: string): Param => {

Check warning on line 35 in framework/src/helper/function-analyzer.ts

View workflow job for this annotation

GitHub Actions / lint

Missing trailing comma
const value: Param = {
name: '',
type: 'string',
default: '',
value: '',
envName: '',
};
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, '');
}
return value;
};

const processCommentAndAssignment = (parameter: string, value: Param) => {
const value: Param = {
name: '',
type: 'string',
default: '',
value: '',
envName: '',
};
const processCommentAndAssignment = (parameter: string, value: Param) => {

Check failure on line 43 in framework/src/helper/function-analyzer.ts

View workflow job for this annotation

GitHub Actions / lint

'parameter' is already declared in the upper scope on line 35 column 25

Check failure on line 43 in framework/src/helper/function-analyzer.ts

View workflow job for this annotation

GitHub Actions / lint

'value' is already declared in the upper scope on line 36 column 9

Check warning on line 43 in framework/src/helper/function-analyzer.ts

View workflow job for this annotation

GitHub Actions / lint

Missing trailing comma
value.name = parameter
.replace(commentOrAssignmentAtEndRegExp, '',)
.replace(whitespaceRegExp, '',);
.replace(commentOrAssignmentAtEndRegExp, '',)
.replace(whitespaceRegExp, '',);
value.default = parameter
.replace(beginningAssignmentRegExp, '',)
.replace(leadingOrTrailingWhitespaceRegExp, '',);
.replace(beginningAssignmentRegExp, '',)
.replace(leadingOrTrailingWhitespaceRegExp, '',);
value.type = parameter
.replace(commentBlockOrWhitespaceRegExp, '',)
.replace(whitespaceRegExp, '',)
.toLowerCase();
};
const processComment = (parameter: string, value: Param) => {
.replace(commentBlockOrWhitespaceRegExp, '',)
.replace(whitespaceRegExp, '',)
.toLowerCase();
};
const processComment = (parameter: string, value: Param) => {

Check failure on line 55 in framework/src/helper/function-analyzer.ts

View workflow job for this annotation

GitHub Actions / lint

'parameter' is already declared in the upper scope on line 35 column 25

Check failure on line 55 in framework/src/helper/function-analyzer.ts

View workflow job for this annotation

GitHub Actions / lint

'value' is already declared in the upper scope on line 36 column 9

Check warning on line 55 in framework/src/helper/function-analyzer.ts

View workflow job for this annotation

GitHub Actions / lint

Missing trailing comma
value.name = parameter
.replace(commentOrAssignmentAtEndRegExp, '',)
.replace(whitespaceRegExp, '',);
.replace(commentOrAssignmentAtEndRegExp, '',)
.replace(whitespaceRegExp, '',);
value.default = '';
value.type = parameter
.replace(commentBlockOrWhitespaceRegExp, '',)
.replace(whitespaceRegExp, '',)
.toLowerCase();
.replace(commentBlockOrWhitespaceRegExp, '',)
.replace(whitespaceRegExp, '',)
.toLowerCase();
if (value.type === 'boolean') {
value.default = 'false';
value.default = 'false';
} else if (value.type === 'number') {
value.default = '0';

Check warning on line 67 in framework/src/helper/function-analyzer.ts

View workflow job for this annotation

GitHub Actions / lint

Expected indentation of 6 spaces but found 8
}
};
const processAssignment = (parameter: string, value: Param) => {
};
const processAssignment = (parameter: string, value: Param) => {

Check failure on line 70 in framework/src/helper/function-analyzer.ts

View workflow job for this annotation

GitHub Actions / lint

'parameter' is already declared in the upper scope on line 35 column 25

Check failure on line 70 in framework/src/helper/function-analyzer.ts

View workflow job for this annotation

GitHub Actions / lint

'value' is already declared in the upper scope on line 36 column 9

Check warning on line 70 in framework/src/helper/function-analyzer.ts

View workflow job for this annotation

GitHub Actions / lint

Missing trailing comma
value.name = parameter
.replace(commentOrAssignmentAtEndRegExp, '',)
.replace(whitespaceRegExp, '',);
.replace(commentOrAssignmentAtEndRegExp, '',)
.replace(whitespaceRegExp, '',);
value.default = parameter
.replace(beginningAssignmentRegExp, '',)
.replace(leadingOrTrailingWhitespaceRegExp, '',);
.replace(beginningAssignmentRegExp, '',)
.replace(leadingOrTrailingWhitespaceRegExp, '',);
if (! Number.isNaN(Number.parseFloat(value.default,),)) {
value.type = 'number';
value.type = 'number';
} else if (value.default === 'true' || value.default === 'false') {
value.type = 'boolean';

Check warning on line 80 in framework/src/helper/function-analyzer.ts

View workflow job for this annotation

GitHub Actions / lint

Expected indentation of 6 spaces but found 8
}
};
if (commentAndAssignmentRegExp.exec(parameter,)) {
processCommentAndAssignment(parameter, value);

Check warning on line 84 in framework/src/helper/function-analyzer.ts

View workflow job for this annotation

GitHub Actions / lint

Missing trailing comma
} else if (commentRegExp.exec(parameter)) {

Check warning on line 85 in framework/src/helper/function-analyzer.ts

View workflow job for this annotation

GitHub Actions / lint

Missing trailing comma
processComment(parameter, value);

Check warning on line 86 in framework/src/helper/function-analyzer.ts

View workflow job for this annotation

GitHub Actions / lint

Expected indentation of 4 spaces but found 6

Check warning on line 86 in framework/src/helper/function-analyzer.ts

View workflow job for this annotation

GitHub Actions / lint

Missing trailing comma
} else if (assignmentRegExp.exec(parameter)) {
processAssignment(parameter, value);
} else {
value.name = parameter.replace(whitespaceRegExp, '');
}
return value;
};
// eslint-disable-next-line complexity
const parseParameterString = (parameter: string,): Param => {
Expand Down

0 comments on commit 2ddff8c

Please sign in to comment.