Skip to content

Commit

Permalink
Remove any type in checkKeyAndGetValue
Browse files Browse the repository at this point in the history
  • Loading branch information
jq1836 committed Oct 7, 2023
1 parent b16439b commit f5adc38
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions frontend/src/utils/repo-sorter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,17 @@ function getGroupCommitsVariance(total: number, group: User) {
return total + group.variance;
}

function checkKeyAndGetValue(element: any, key: string | undefined) {
if (key === undefined || element === undefined || !(key in element)) {
function checkKeyAndGetValue(element: object, key: string | undefined) {
if (key === undefined || !(key in element)) {
return undefined;
}
return element[key];
/** Casting here is safe as guard clause above ensures that element has an attribute with the same name as the string
* represented by key. */
return (element as any)[key];

Check warning on line 19 in frontend/src/utils/repo-sorter.ts

View workflow job for this annotation

GitHub Actions / Cypress frontend tests

Unexpected any. Specify a different type

Check warning on line 19 in frontend/src/utils/repo-sorter.ts

View workflow job for this annotation

GitHub Actions / ubuntu-20.04 JDK 8

Unexpected any. Specify a different type

Check warning on line 19 in frontend/src/utils/repo-sorter.ts

View workflow job for this annotation

GitHub Actions / ubuntu-20.04 JDK 8

Unexpected any. Specify a different type

Check warning on line 19 in frontend/src/utils/repo-sorter.ts

View workflow job for this annotation

GitHub Actions / ubuntu-22.04 JDK 8

Unexpected any. Specify a different type

Check warning on line 19 in frontend/src/utils/repo-sorter.ts

View workflow job for this annotation

GitHub Actions / macos-11 JDK 8

Unexpected any. Specify a different type

Check warning on line 19 in frontend/src/utils/repo-sorter.ts

View workflow job for this annotation

GitHub Actions / macos-12 JDK 8

Unexpected any. Specify a different type

Check warning on line 19 in frontend/src/utils/repo-sorter.ts

View workflow job for this annotation

GitHub Actions / windows-2019 JDK 8

Unexpected any. Specify a different type

Check warning on line 19 in frontend/src/utils/repo-sorter.ts

View workflow job for this annotation

GitHub Actions / windows-2022 JDK 8

Unexpected any. Specify a different type
}

/** Array is not sorted when sortingOption is not provided. sortingOption is optional to allow it to fit the
* SortingFunction<T> interface. */
function sortingHelper(element: User[], sortingOption?: string): string | number {
if (sortingOption === 'totalCommits') {
return element.reduce(getTotalCommits, 0);
Expand Down

0 comments on commit f5adc38

Please sign in to comment.