-
Notifications
You must be signed in to change notification settings - Fork 0
update contract-shield.config.json, contract-shield.json, configUtils.js and transpile.test.js #13
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
base: main
Are you sure you want to change the base?
Conversation
….js and transpile.test.js
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.
Review by Korbit AI
Korbit automatically attempts to detect when you fix issues in new commits.
| Category | Issue | Status |
|---|---|---|
| Invalid dirname reference ▹ view | ||
| Schema Definition Mixed with Validation Logic ▹ view |
Files scanned
| File Path | Reviewed |
|---|---|
| src/utils/validateConfigSchema.js | ✅ |
| src/utils/configUtils.js | ✅ |
Explore our documentation to understand the languages and file types we support and the files we ignore.
Check out our docs on how you can make Korbit work best for you and your team.
| : null); | ||
| const defaultProjectConfig = path.resolve(process.cwd(), CONFIG_FILES.PROJECT); | ||
| // const defaultGlobalConfig = path.resolve(os.homedir(), CONFIG_FILES.GLOBAL); | ||
| const defaultGlobalConfig = path.resolve(__dirname__, CONFIG_FILES.GLOBAL); |
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.
Invalid dirname reference 
Tell me more
What is the issue?
The code uses 'dirname' (with double underscores) which is an undefined variable. The correct Node.js global variable is '__dirname' (single underscore).
Why this matters
This will cause a ReferenceError when trying to access the undefined variable, preventing the global configuration file from being found.
Suggested change ∙ Feature Preview
Replace 'dirname' with '__dirname':
const defaultGlobalConfig = path.resolve(__dirname, CONFIG_FILES.GLOBAL);Provide feedback to improve future suggestions
💬 Looking for more details? Reply to this comment to chat with Korbit.
| const requiredFields = ["output"]; | ||
| for (const field of requiredFields) { | ||
| if (!Object.prototype.hasOwnProperty.call(config, field)) { | ||
| return false; | ||
| } | ||
| } |
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.
Schema Definition Mixed with Validation Logic 
Tell me more
What is the issue?
The validation logic mixes concerns by handling both the required fields list and the validation logic in the same function, making it harder to extend or modify the schema requirements.
Why this matters
Future changes to the configuration schema will require modifying the validation function directly, violating the Open-Closed Principle.
Suggested change ∙ Feature Preview
Separate schema definition from validation logic:
const CONFIG_SCHEMA = {
required: ['output'],
types: {
output: 'string'
}
};
module.exports = {
validateConfigSchema: (config) => {
return validateAgainstSchema(config, CONFIG_SCHEMA);
}
};Provide feedback to improve future suggestions
💬 Looking for more details? Reply to this comment to chat with Korbit.
Description by Korbit AI
What change is being made?
Update configuration file paths in
contract-shield.config.jsonandcontract-shield.json, introduce a configuration schema validation inconfigUtils.jswith a newvalidateConfigSchemamethod, and re-enable previously commented out tests intranspile.test.js.Why are these changes being made?
The changes in
contract-shield.config.jsonandcontract-shield.jsonstandardize the output directory path format by removing leading './', which ensures consistency across paths. Schema validation is added inconfigUtils.jsto improve configuration reliability and error management, preventing issues with incorrect config structures. Previously commented out tests intranspile.test.jshave been re-enabled to ensure the stability and correctness of CLI functionality, guaranteeing robust testing and further validation of the codebase.