Skip to content

refactor: remove any and as throughout codebase#1323

Open
jescalada wants to merge 45 commits intofinos:mainfrom
jescalada:1174-remove-any-and-as-ts-wrapup
Open

refactor: remove any and as throughout codebase#1323
jescalada wants to merge 45 commits intofinos:mainfrom
jescalada:1174-remove-any-and-as-ts-wrapup

Conversation

@jescalada
Copy link
Contributor

Fixes #1174.

Sets stub types to (`ReturnType<typeof vi.fn>`) to remove the any type
@netlify
Copy link

netlify bot commented Dec 15, 2025

Deploy Preview for endearing-brigadeiros-63f9d0 canceled.

Name Link
🔨 Latest commit 10077f5
🔍 Latest deploy log https://app.netlify.com/projects/endearing-brigadeiros-63f9d0/deploys/6996a1522278a600080bdcd5

@codecov
Copy link

codecov bot commented Dec 17, 2025

Codecov Report

❌ Patch coverage is 68.87608% with 108 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.33%. Comparing base (468bd12) to head (10077f5).

Files with missing lines Patch % Lines
src/service/routes/auth.ts 29.41% 24 Missing ⚠️
src/service/passport/activeDirectory.ts 39.13% 14 Missing ⚠️
src/proxy/routes/index.ts 50.00% 8 Missing ⚠️
src/service/passport/oidc.ts 66.66% 8 Missing ⚠️
src/config/ConfigLoader.ts 50.00% 6 Missing and 1 partial ⚠️
src/db/mongo/pushes.ts 22.22% 7 Missing ⚠️
src/config/index.ts 33.33% 6 Missing ⚠️
src/db/file/users.ts 14.28% 6 Missing ⚠️
src/proxy/processors/push-action/pullRemote.ts 33.33% 6 Missing ⚠️
src/proxy/processors/push-action/parsePush.ts 61.53% 5 Missing ⚠️
... and 7 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1323      +/-   ##
==========================================
- Coverage   81.37%   81.33%   -0.05%     
==========================================
  Files          67       68       +1     
  Lines        4735     4837     +102     
  Branches      819      819              
==========================================
+ Hits         3853     3934      +81     
- Misses        867      888      +21     
  Partials       15       15              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@jescalada
Copy link
Contributor Author

@kriswest This one's ready for review!

@jescalada jescalada requested review from a team and kriswest December 17, 2025 04:15
@kriswest
Copy link
Contributor

@jescalada this has picked up some conflicts - are you able to resolve and then hit me over the head to review it?

@fabiovincenzi fabiovincenzi mentioned this pull request Jan 30, 2026
20 tasks
@jescalada
Copy link
Contributor Author

@kriswest Should be ready to review now 😃

@jescalada
Copy link
Contributor Author

By the way, I'm not sure which missing coverage lines aren't already dealt with in #1356, so I suggest ignoring the lost coverage here and dealing with the aftermath in that PR instead.

Copy link
Contributor

@kriswest kriswest left a comment

Choose a reason for hiding this comment

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

Another monster contribution, much appreciated. I've left a handful of comments for you to look at (I think a couple of removed test cases are still needed and a util function could go in for handling error message extraction - which could allow us to turn on stack traces) - however the majority LGTM.

step.error = true;
step.log('Push failed, pre-receive hook returned an error.');
step.setError(`Hook execution error: ${stderrTrimmed || error.message}`);
step.setError(`Hook execution error: ${stderrTrimmed || msg}`);
Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps we should always print msg here (as it was thrown) and then append stderrTrimmed if its not falsey

const authHeader = req.headers?.authorization;

if (!authHeader) {
throw new Error('Authorization header is required');
Copy link
Contributor

Choose a reason for hiding this comment

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

It is currently, although one day we could apply pullRemote to a pull chain to govern ingress, at which point this could be anonymous... but then I supposed we will want to log who the user pulling was...

Could expand the error message in case it is sent back to the client... although I wonder if we'll ever hit it - you do get prompted for auth so there is probably a request before the push where that happens.


vi.mock('../../src/config', async (importOriginal) => {
const actual: any = await importOriginal();
const actual = await importOriginal<typeof import('../../src/config')>();
Copy link
Contributor

Choose a reason for hiding this comment

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

feels odd, but I see others doing the same...

Comment on lines -630 to -632
expect(isValidGitUrl(null as any)).toBe(false);
expect(isValidGitUrl(undefined as any)).toBe(false);
expect(isValidGitUrl(123 as any)).toBe(false);
Copy link
Contributor

Choose a reason for hiding this comment

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

These cases are still valid to test, even though Typescript is no doubt complaining about them. How about changing to:

expect(isValidGitUrl(null as unknown as string)).toBe(false);

Comment on lines -648 to -655
expect(isValidPath(null as any)).toBe(false);
expect(isValidPath(undefined as any)).toBe(false);

// Additional edge cases
expect(isValidPath({} as any)).toBe(false);
expect(isValidPath([] as any)).toBe(false);
expect(isValidPath(123 as any)).toBe(false);
expect(isValidPath(true as any)).toBe(false);
Copy link
Contributor

Choose a reason for hiding this comment

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

as above

Comment on lines -675 to -676
expect(isValidBranchName(null as any)).toBe(false);
expect(isValidBranchName(undefined as any)).toBe(false);
Copy link
Contributor

Choose a reason for hiding this comment

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

These should probably also be retained as test cases.

It occurs to me that if coerced to a string they may become valid, but if they were passing before they should continue to do so if you use as unknown as string

jescalada and others added 8 commits February 19, 2026 12:33
Co-authored-by: Kris West <kristopher.west@natwest.com>
Signed-off-by: Juan Escalada <97265671+jescalada@users.noreply.github.com>
Co-authored-by: Kris West <kristopher.west@natwest.com>
Signed-off-by: Juan Escalada <97265671+jescalada@users.noreply.github.com>
Co-authored-by: Kris West <kristopher.west@natwest.com>
Signed-off-by: Juan Escalada <97265671+jescalada@users.noreply.github.com>
Co-authored-by: Kris West <kristopher.west@natwest.com>
Signed-off-by: Juan Escalada <97265671+jescalada@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Clean up any and as in TS files

2 participants

Comments