Skip to content

Clean up duplicated code#115

Open
jacquelinecai wants to merge 6 commits intomainfrom
jac/duplicated-code
Open

Clean up duplicated code#115
jacquelinecai wants to merge 6 commits intomainfrom
jac/duplicated-code

Conversation

@jacquelinecai
Copy link
Copy Markdown
Collaborator

@jacquelinecai jacquelinecai commented Mar 10, 2026

Summary

  • clean up duplicated code based on sonarqube analysis
  • cleaned up tests and constants

This pull request is the first step towards implementing feature cleanup

Test Plan

tested in dev, all functionality remains the same

Notes

I think for cornell.ts, I can just bypass that for merge right now. Another consideration is to put all these values into our database, but will need to modify logic a little bit to fetch from there.

Breaking Changes

@netlify
Copy link
Copy Markdown

netlify bot commented Mar 10, 2026

Deploy Preview for redi-love ready!

Name Link
🔨 Latest commit 9500eea
🔍 Latest deploy log https://app.netlify.com/projects/redi-love/deploys/69c017f7390b2f0008b7ff9c
😎 Deploy Preview https://deploy-preview-115--redi-love.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@jacquelinecai jacquelinecai marked this pull request as ready for review March 10, 2026 18:26
Copy link
Copy Markdown
Collaborator

@laylaliuuu laylaliuuu left a comment

Choose a reason for hiding this comment

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

Nice cleanup! There are a few warnings, maybe we can just delete unused variables and imports to keep the code clean

type MockDoc = { data: () => typeof mockUserData };

const mockGet = (isEmpty: boolean, docs: MockDoc[]) => {
const mockGet = jest.fn().mockResolvedValue({
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think we have a variable shadowing here, "mockGet" is named twice, maybe we can just rename it just be safe

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

done!

@@ -1,4 +1,4 @@
import { School, Gender } from '../types';
import { Gender, School } from '../backend/types';
Copy link
Copy Markdown
Collaborator

@laylaliuuu laylaliuuu Mar 10, 2026

Choose a reason for hiding this comment

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

I just the relative path for this, it seems like to be backend/types.ts (yours probably works too)

maybe just change to that just in case?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

done!

const url = `https://api.geoapify.com/v1/geocode/autocomplete?text=${encodeURIComponent(q.trim())}&type=city&limit=5&apiKey=${apiKey}`;
const response = await fetch(url);
console.log("test")
console.log('test');
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Should we delete the console log

}: {
size?: number;
color?: string;
}) => (
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

maybe just move AnimatedSpinner definition outside of the parent component to get rid of this warning?

<MotionContext.Provider
value={{ animationEnabled, setAnimationEnabled }}
>
<MotionContext.Provider value={{ animationEnabled, setAnimationEnabled }}>
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Maybe also just get rid of this warning

@@ -74,7 +74,9 @@ export default function ChatScreen() {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think those imports and variables are no longer being used (probably when you delete the duplciated code), maybe just get rid of those too.

@@ -74,7 +74,9 @@ export default function ChatScreen() {
const currentUser = getCurrentUser();
const [blockedUsers, setBlockedUsers] = useState<Set<string>>(new Set());
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

same warning here.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

same warning here in this file

`Admin ${req.user?.email} creating manual match:`,
matchData
);
console.log(`Admin ${req.user?.email} creating manual match`);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

since it's admin, should we keep the matchData to keep this console log useful, or just delete it?

@sonarqubecloud
Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
10.6% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

Comment on lines +160 to +161
genders:
i % 2 === 0 ? ['female', 'non-binary'] : ['male', 'non-binary'],
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

does this mean that we're inherently opening all users to included non-binary people in their prefs?

Comment on lines +437 to +439
console.log(
` ⚠️ ${netid}: Still 0 matches even with relaxed criteria`
);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Wait should there be more handling for this? Rn it just logs and moves on, but if a user receives 0 matches that seems to be crucial because it's a main feature of our app

testUsers = await createTestUsers(6);
const prompt = await createTestPrompt();
testPromptId = prompt.promptId;
await setupUsersAndMatches(6);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

yayy so nice so much refactoring in this file!

Copy link
Copy Markdown
Collaborator

@nadia-choop nadia-choop left a comment

Choose a reason for hiding this comment

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

Thank you for doing sm clean up (definitely much needed on our codebase!) Only had a few small comments/questions, and I think other comments were covered by Layla.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants