-
Notifications
You must be signed in to change notification settings - Fork 153
refactor: remove any and as throughout codebase
#1323
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
Open
jescalada
wants to merge
37
commits into
finos:main
Choose a base branch
from
jescalada:1174-remove-any-and-as-ts-wrapup
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,223
−1,060
Open
Changes from all commits
Commits
Show all changes
37 commits
Select commit
Hold shift + click to select a range
d323cac
refactor: add missing types for attestation, remove gitAccount from A…
jescalada fd0db0b
chore: add missing Express.Request types in action files
jescalada aff314e
chore: add missing db types
jescalada 8c50807
refactor: extend Express.Request to include bodyRaw and customPipe fi…
jescalada e928368
fix: proxy hanging on push due to improper req.pipe override
jescalada 528d214
refactor: improve UI component and service typing
jescalada 292c846
refactor: add BASE_COMMIT_CONTENT object to remove any types in testP…
jescalada 6ff457e
chore: remove any types in ConfigLoader test (private field access)
jescalada 1edc320
refactor: improve typings in various test files
jescalada 4535c5a
refactor: add SAMPLE_COMMIT and remove any types in getDiff
jescalada 1b4c2ab
chore: remove any types in gitLeaks tests
jescalada 73c9c0b
chore: use SAMPLE_COMMIT for commit data and remove any types in chec…
jescalada 30b86e3
chore: add various missing test stub types
jescalada d5e21db
chore: use SAMPLE_COMMIT for commit data in checkAuthorEmails tests
jescalada 82bd72c
chore: remove any types in UI
jescalada 3320f3f
refactor: repo and push UI error handling, remove any error types
jescalada ac9cf2b
refactor: test file any removal (proxy, testDb, repo, forcePush, preR…
jescalada f29ddbb
chore: add unknown typing to error catch and process message (plugin,…
jescalada 06dc08a
refactor: add SAMPLE_REPO, replace in tests to remove any, add types …
jescalada ca4d703
Merge branch '1174-remove-any-and-as-ts-wrapup' of https://github.com…
jescalada a301eaa
refactor: cli test any/as removal, extract SAMPLE_REPO to constant
jescalada d6664f1
chore: add missing types for auth files and plugin.ts
jescalada 3cd816f
refactor: remove any types from remaining catch(error)
jescalada 3e56231
chore: remove general any/as in tests (req casting, etc.)
jescalada 1863ff8
chore: add missing types for auth-related tests (oidc, activeDirector…
jescalada ce58dcc
refactor: db & checkCommitMessages tests to use Action instead of pus…
jescalada 3824d09
refactor: remaining any/as removal in tests, explicit unknown casting…
jescalada a1455ca
chore: add unknown type to error catch clauses, improve error visibility
jescalada 1f15141
Merge branch 'main' into 1174-remove-any-and-as-ts-wrapup
jescalada 62a7d84
chore: fix failing test after error refactors
jescalada 4d203e6
chore: fix failing tests (revision range error)
jescalada 596257c
Merge branch 'main' into 1174-remove-any-and-as-ts-wrapup
jescalada edcfe3c
chore: fix Proxy type errors
jescalada b7b803c
fix: user.admin errors and failing e2e tests
jescalada b1fbeb6
Merge branch 'main' into 1174-remove-any-and-as-ts-wrapup
jescalada 3dc2d3f
Merge branch 'main' into 1174-remove-any-and-as-ts-wrapup
jescalada d1fe161
Merge branch 'main' into 1174-remove-any-and-as-ts-wrapup
kriswest File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| #!/usr/bin/env node | ||
| import axios from 'axios'; | ||
| import axios, { isAxiosError } from 'axios'; | ||
| import yargs from 'yargs/yargs'; | ||
| import { hideBin } from 'yargs/helpers'; | ||
| import fs from 'fs'; | ||
|
|
@@ -47,13 +47,16 @@ async function login(username: string, password: string) { | |
| const user = `"${response.data.username}" <${response.data.email}>`; | ||
| const isAdmin = response.data.admin ? ' (admin)' : ''; | ||
| console.log(`Login ${user}${isAdmin}: OK`); | ||
| } catch (error: any) { | ||
| if (error.response) { | ||
| } catch (error: unknown) { | ||
| if (isAxiosError(error) && error.response) { | ||
| console.error(`Error: Login '${username}': '${error.response.status}'`); | ||
| process.exitCode = 1; | ||
| } else { | ||
| } else if (error instanceof Error) { | ||
| console.error(`Error: Login '${username}': '${error.message}'`); | ||
| process.exitCode = 2; | ||
| } else { | ||
| console.error(`Error: Login '${username}': '${error}'`); | ||
| process.exitCode = 2; | ||
| } | ||
| } | ||
| } | ||
|
|
@@ -165,8 +168,9 @@ async function getGitPushes(filters: Partial<PushQuery>) { | |
| }); | ||
|
|
||
| console.log(util.inspect(records, false, null, false)); | ||
| } catch (error: any) { | ||
| console.error(`Error: List: '${error.message}'`); | ||
| } catch (error: unknown) { | ||
| const msg = error instanceof Error ? error.message : String(error); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this may be a 1-liner, but it is repeated a lot. How about a |
||
| console.error(`Error: List: '${msg}'`); | ||
| process.exitCode = 2; | ||
| } | ||
| } | ||
|
|
@@ -207,12 +211,12 @@ async function authoriseGitPush(id: string) { | |
| ); | ||
|
|
||
| console.log(`Authorise: ID: '${id}': OK`); | ||
| } catch (error: any) { | ||
| } catch (error: unknown) { | ||
| // default error | ||
| let errorMessage = `Error: Authorise: '${error.message}'`; | ||
| let errorMessage = `Error: Authorise: '${error instanceof Error ? error.message : String(error)}'`; | ||
| process.exitCode = 2; | ||
|
|
||
| if (error.response) { | ||
| if (isAxiosError(error) && error.response) { | ||
| switch (error.response.status) { | ||
| case 401: | ||
| errorMessage = 'Error: Authorise: Authentication required'; | ||
|
|
@@ -254,12 +258,12 @@ async function rejectGitPush(id: string) { | |
| ); | ||
|
|
||
| console.log(`Reject: ID: '${id}': OK`); | ||
| } catch (error: any) { | ||
| } catch (error: unknown) { | ||
| // default error | ||
| let errorMessage = `Error: Reject: '${error.message}'`; | ||
| let errorMessage = `Error: Reject: '${error instanceof Error ? error.message : String(error)}'`; | ||
| process.exitCode = 2; | ||
|
|
||
| if (error.response) { | ||
| if (isAxiosError(error) && error.response) { | ||
| switch (error.response.status) { | ||
| case 401: | ||
| errorMessage = 'Error: Reject: Authentication required'; | ||
|
|
@@ -301,12 +305,12 @@ async function cancelGitPush(id: string) { | |
| ); | ||
|
|
||
| console.log(`Cancel: ID: '${id}': OK`); | ||
| } catch (error: any) { | ||
| } catch (error: unknown) { | ||
| // default error | ||
| let errorMessage = `Error: Cancel: '${error.message}'`; | ||
| let errorMessage = `Error: Cancel: '${error instanceof Error ? error.message : String(error)}'`; | ||
| process.exitCode = 2; | ||
|
|
||
| if (error.response) { | ||
| if (isAxiosError(error) && error.response) { | ||
| switch (error.response.status) { | ||
| case 401: | ||
| errorMessage = 'Error: Cancel: Authentication required'; | ||
|
|
@@ -338,8 +342,9 @@ async function logout() { | |
| headers: { Cookie: cookies }, | ||
| }, | ||
| ); | ||
| } catch (error: any) { | ||
| console.log(`Warning: Logout: '${error.message}'`); | ||
| } catch (error: unknown) { | ||
| const msg = error instanceof Error ? error.message : String(error); | ||
| console.log(`Warning: Logout: '${msg}'`); | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -362,10 +367,10 @@ async function reloadConfig() { | |
| await axios.post(`${baseUrl}/api/v1/admin/reload-config`, {}, { headers: { Cookie: cookies } }); | ||
|
|
||
| console.log('Configuration reloaded successfully'); | ||
| } catch (error: any) { | ||
| const errorMessage = `Error: Reload config: '${error.message}'`; | ||
| } catch (error: unknown) { | ||
| const msg = error instanceof Error ? error.message : String(error); | ||
| console.error(`Error: Reload config: '${msg}'`); | ||
| process.exitCode = 2; | ||
| console.error(errorMessage); | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -408,11 +413,11 @@ async function createUser( | |
| ); | ||
|
|
||
| console.log(`User '${username}' created successfully`); | ||
| } catch (error: any) { | ||
| let errorMessage = `Error: Create User: '${error.message}'`; | ||
| } catch (error: unknown) { | ||
| let errorMessage = `Error: Create User: '${error instanceof Error ? error.message : String(error)}'`; | ||
| process.exitCode = 2; | ||
|
|
||
| if (error.response) { | ||
| if (isAxiosError(error) && error.response) { | ||
| switch (error.response.status) { | ||
| case 401: | ||
| errorMessage = 'Error: Create User: Authentication required'; | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.