-
Notifications
You must be signed in to change notification settings - Fork 168
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
Feat/235 typesafety changes #238
Conversation
"lint-fix": "eslint . --ext=js,ts --fix", | ||
"lint-test": "eslint . --ext=js,ts", | ||
"lint-fix": "eslint . --ext=js,ts,tsx --fix", | ||
"lint-test": "eslint . --ext=js,ts,tsx", |
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.
[Note] We now have tsx files
@@ -8,7 +8,7 @@ import { buildResourceName } from "../../helpers"; | |||
import { commonLambdaEnvironment } from "../helpers/commonLambdaEnvironment"; | |||
import { commonLambdaProps } from "../helpers/commonLambdaProps"; | |||
|
|||
interface UpdateUserLambdaProps { | |||
type UpdateUserLambdaProps = { |
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.
[Note] I changed a lot of interfaces to types for consistency across the repo
const getCdkContext = (): Record<string, unknown> | undefined => { | ||
const cdkContextEnv = process.env.CDK_CONTEXT_JSON; | ||
const getCliCdkContext = (cliArg: string): string | undefined => { | ||
const cdkContextEnv = process.env.CDK_CONTEXT_JSON ?? ""; |
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.
[Note] We need a long term fix for getting the environment variables in a nice way, as there a number of fixes like this across the code base and we could do something consistent
const parsedCdKContext: unknown = JSON.parse(cdkContextEnv); | ||
|
||
if (isRecord(parsedCdKContext) && cliArg in parsedCdKContext) { | ||
const cdkCli = parsedCdKContext[cliArg]; |
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.
[Note] I had to do this type check in two stages as otherwise typescript was getting confused 😮💨
Risk Level 3 - /home/runner/work/code-review-gpt/code-review-gpt/src/common/git/getFilesWithChanges.ts The code changes in this file have a moderate risk to the code base. There are a few potential issues and areas for improvement:
Here are some example code snippets for the suggested changes:
export const getFilesWithChanges = async (
isCi: string | undefined
): Promise<ReviewFile[]> => {
const fileNames = await getChangedFilesNames(isCi);
if (fileNames.length === 0) {
throw new Error(\"No files with changes found. Please stage your changes and try again.\");
}
const files = await Promise.all(
fileNames.map(async (fileName) => {
const fileContent = await readFile(fileName, \"utf8\");
const changedLines = await getChangedFileLines(isCi, fileName);
return { fileName, fileContent, changedLines };
})
);
return files;
};
export const getFilesWithChanges = async (
isCi: string | undefined
): Promise<ReviewFile[]> => {
try {
const fileNames = await getChangedFilesNames(isCi);
if (fileNames.length === 0) {
throw new Error(\"No files with changes found. Please stage your changes and try again.\");
}
const files = await Promise.all(
fileNames.map(async (fileName) => {
const fileContent = await readFile(fileName, \"utf8\");
const changedLines = await getChangedFileLines(isCi, fileName);
return { fileName, fileContent, changedLines };
})
);
return files;
} catch (error) {
throw new Error(`Failed to get files with changes: ${error.message}`);
}
};
---
**Risk Level 3 - /home/runner/work/code-review-gpt/code-review-gpt/services/web-app/src/components/home/Features.tsx**
The code changes in this file have a moderate risk to the code base. The changes involve adding a new import statement and updating the component to use a new Card component. The code is clean and readable. However, there is a typo in the import statement \"use client\" which should be removed.
---
**Risk Level 4 - /home/runner/work/code-review-gpt/code-review-gpt/services/web-app/src/components/home/Hero.tsx**
The code changes in this file have a high risk to the code base. The changes involve adding a new function component and using multiple framer-motion hooks and transformations. The code is complex and may introduce bugs or performance issues. It is recommended to thoroughly test the changes before merging them into the code base.
---
🔍🔧🚨
---
#### Powered by [Code Review GPT](https://github.com/mattzcarey/code-review-gpt) |
import { Theme } from "@radix-ui/themes"; | ||
import { NavBar } from "@/components/navbar"; | ||
import Footer from "../components/footer/footer"; | ||
import { NavBar } from "../components/navbar"; |
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.
[Note] I changed all imports to relative imports so we had consistency across the code base. In the future it would be nice to use absolute paths everywhere
Test results summary:✅ [PASS] - Test case: Bad variable name SUMMARY: ✅ PASS: 2 - Tests Powered by Code Review GPT |
} finally { | ||
setLoading(false); | ||
} | ||
}; | ||
fetchData(); | ||
void fetchData(); |
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.
[Note] I had to use void here as useEffects don't like async functions.
@@ -1,5 +1,4 @@ | |||
import React from "react"; | |||
import { Button } from "@radix-ui/themes"; |
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.
[Note] I'm slightly worried that we are using both tailwind and radix- I think we should choose just one as otherwise I think we are going to run into problems in future (with them fighting each other etc)
@@ -2,9 +2,10 @@ import { Button, Link } from "@radix-ui/themes"; | |||
import { motion, useScroll, useSpring, useTransform } from "framer-motion"; | |||
import React, { useRef } from "react"; | |||
import { MdNorthEast } from "react-icons/md"; | |||
|
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.
[Note] These changes had been made as linting hadn't been run on the code Aiden added
axiosInstance.interceptors.request.use((config) => { | ||
//TODO: investigate this as the Session type returned from does not seem to contain 'token' | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment | ||
config.headers.Authorization = session.token; |
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.
[Note] I didn't have time to investigate this :(
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.
I'll add this to my current bug ticket :)
userId: string, | ||
apiKey: string, | ||
name: string, | ||
pictureUrl?: string, |
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.
[Note] This is a bug- by setting "" values here you actually setting constants rather than default values- so if you tried to do
const user: User;
user.name = 'Adam'
You would see an error as user.name can only be set to "".
gitlabSha: process.env.CI_COMMIT_SHA ?? '', | ||
gitlabToken: process.env.GITLAB_TOKEN ?? '', | ||
projectId: process.env.CI_PROJECT_ID ?? '', | ||
mergeRequestIIdString: process.env.CI_MERGE_REQUEST_IID ?? '', |
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.
[Note] This is again gross but I want to fix the process.env types properly and in the mean time at least our fix is consistent (this is the fix in another file)
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.
Looks good to me! The consistency of everything looks so much better :)
No description provided.