Skip to content
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

use specific fns instead of massive paths obj #1005

Merged
merged 5 commits into from
Jan 31, 2024
Merged

use specific fns instead of massive paths obj #1005

merged 5 commits into from
Jan 31, 2024

Conversation

goastler
Copy link
Member

No description provided.

@prosoponator prosoponator enabled auto-merge (squash) January 25, 2024 18:19
Copy link

Hey there! 👋 I see you need help summarizing the previous results for a Pull Request review markdown doc. Let's get started!

Changes 📝

  1. In the projectInfo.ts file, the 'fs' module was imported in the 'projectInfo.ts' file, and a new function called 'getContractNames' was added. This function uses 'fs.readdirSync' to read the protocol contracts directory and filter the names of the directories.
  2. In the setVersion.ts file, the import statement for 'getPaths' from '@prosopo/config' was removed and replaced with 'getRootDir' from the same module.

Suggestions 🤔

  1. In the projectInfo.ts file, instead of manually defining each path in the 'Paths' type and returning an object with all the paths, it could be refactored to dynamically generate the paths based on a predefined structure. This would make the code more maintainable and scalable.
  2. In the setVersion.ts file, the 'find' function could be refactored to use the 'fs' module's 'readdirSync' method with a filter function to find the files instead of walking through all the files recursively. This would simplify the code and improve performance.

Bugs 🐛

  1. In the paths.test.ts file, the test case 'paths exist' checks if all the paths defined in the 'Paths' object exist by using 'fs.existsSync'. However, it doesn't handle the case where a path is a file instead of a directory. This could potentially lead to false positives or false negatives in the test results.
  2. In the setVersion.ts file, the 'ignorePaths' array is hardcoded with some paths to ignore. This could be a potential source of bugs if the directory structure changes or if there are platform-specific paths that need to be ignored. It would be better to provide a configuration option to specify the paths to ignore.

Improvements ✨

  1. In the dev/scripts/src/cli/index.ts file, the code block starting from line 106 can be refactored for better readability. Instead of using a loop, consider using the Array.map() function to iterate over the contracts array and perform the exec() function on each contract. Here's a possible refactored code snippet:
const contracts = getContractNames()

await Promise.all(contracts.map(async (contract) => {
  const inDir = `${getProtocolDistDir()}/${contract}`
  await exec(`node dist/cli/index.js import_contract --in=${inDir} --out=${getContractsDir()}/${contract}/src`)
}))

Rating ⭐️

Overall, I would rate the code a 7.5 out of 10. The code is generally readable, but there are some areas that could be improved with comments and better variable naming. Performance-wise, there are potential optimizations in the loop on line 154. In terms of security, it's difficult to assess without more context on the code's purpose and potential vulnerabilities.

That's it! Feel free to copy and paste this into your Pull Request review markdown doc. If you need any more assistance, just let me know! 😉

@prosoponator prosoponator merged commit d279e40 into main Jan 31, 2024
3 checks passed
@prosoponator prosoponator deleted the path-fns branch January 31, 2024 11:31
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