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 28, 2024
1 parent 7b07c51 commit 339b861
Showing 1 changed file with 45 additions and 39 deletions.
84 changes: 45 additions & 39 deletions framework/src/helper/function-analyzer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,59 +32,65 @@ const whitespaceRegExp =/\s*/gu;
const beginningAssignmentRegExp=/^.+=/u;
const leadingOrTrailingWhitespaceRegExp=/^\s*|\s*$/gu;
const commentBlockOrWhitespaceRegExp=/^.*\/\*|\*\/.+$/gu;
const buildParameter = (parameter: string,): Param => {
const value: Param = {
name: '',
type: 'string',
default: '',
value: '',
envName: '',
};
if (commentAndAssignmentRegExp.exec(parameter,)) {
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 = {

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

View workflow job for this annotation

GitHub Actions / lint

Expected indentation of 2 spaces but found 4
name: '',

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

View workflow job for this annotation

GitHub Actions / lint

Expected indentation of 4 spaces but found 8
type: 'string',

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

View workflow job for this annotation

GitHub Actions / lint

Expected indentation of 4 spaces but found 8
default: '',

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

View workflow job for this annotation

GitHub Actions / lint

Expected indentation of 4 spaces but found 8
value: '',

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

View workflow job for this annotation

GitHub Actions / lint

Expected indentation of 4 spaces but found 8
envName: '',

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

View workflow job for this annotation

GitHub Actions / lint

Expected indentation of 4 spaces but found 8
};

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

View workflow job for this annotation

GitHub Actions / lint

Expected indentation of 2 spaces but found 4
if (commentAndAssignmentRegExp.exec(parameter,)) {

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

View workflow job for this annotation

GitHub Actions / lint

Expected indentation of 2 spaces but found 4
processCommentAndAssignment(parameter, value);

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

View workflow job for this annotation

GitHub Actions / lint

Expected indentation of 4 spaces but found 8

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

View workflow job for this annotation

GitHub Actions / lint

'processCommentAndAssignment' was used before it was defined
} else if (commentRegExp.exec(parameter)) {
processComment(parameter, value);

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

View workflow job for this annotation

GitHub Actions / lint

'processComment' was used before it was defined
} else if (assignmentRegExp.exec(parameter)) {
processAssignment(parameter, value);

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

View workflow job for this annotation

GitHub Actions / lint

'processAssignment' was used before it was defined
} else {
value.name = parameter.replace(whitespaceRegExp, '');
}
return value;
};

const processCommentAndAssignment = (parameter: string, value: Param) => {
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();
return value;
}
if (commentRegExp.exec(parameter,)) {
.replace(commentBlockOrWhitespaceRegExp, '',)
.replace(whitespaceRegExp, '',)
.toLowerCase();
};
const processComment = (parameter: string, value: Param) => {
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';
value.default = '0';
}
return value;
}
if (assignmentRegExp.exec(parameter,)) {
};
const processAssignment = (parameter: string, value: Param) => {
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';
value.type = 'boolean';
}
return value;
}
value.name = parameter.replace(whitespaceRegExp, '',);
return value;
};
// eslint-disable-next-line complexity
const parseParameterString = (parameter: string,): Param => {
Expand Down

0 comments on commit 339b861

Please sign in to comment.