-
Notifications
You must be signed in to change notification settings - Fork 1
feature: analyze with initFlags and fetch config file if non existent - PLUTO-1423 #153
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
Coverage summary from CodacySee diff coverage on Codacy
Coverage variation details
Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: Diff coverage details
Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: See your quality gate settings Change summary preferences |
47ce922
to
16a52f7
Compare
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.
Pull Request Overview
This PR enhances the analyze
command to accept initialization flags, automatically generate missing tool config files from the Codacy API in remote mode, and adds unit and integration tests for the new behavior.
- Analyze now supports
initFlags
(e.g. API token) and cloud mode flags. - Automatically fetches and writes tool config files when none exist and an API token is provided.
- Adds coverage for local vs remote mode config checks in both unit and integration tests.
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
File | Description |
---|---|
tools/eslintConfigCreator.go | Handle ESLint rules that don’t accept options by keeping only error level. |
cmd/configsetup/setup.go | Add CreateToolConfigurationFile and tool-name-to-UUID lookup. |
cmd/analyze.go | Wire in cloud flags, validate/generate config files, update runTool signature. |
cmd/analyze_test.go | Unit tests for checkIfConfigExistsAndIsNeeded behavior. |
cmd/analyze_integration_test.go | Integration tests for config existence and edge cases. |
Comments suppressed due to low confidence (2)
cmd/configsetup/setup.go:512
- [nitpick] Go style recommends capitalizing common acronyms: rename
getToolUuidByName
togetToolUUIDByName
and usetoolUUID
for variable names.
func getToolUuidByName(toolName string) string {
cmd/analyze_test.go:283
- There’s no assertion that a config file is actually created when running in remote mode with an API token. Add a test case or assertion after
checkIfConfigExistsAndIsNeeded
to verify the file exists attoolConfigFileName[toolName]
.
tests := []struct {
"no-useless-escape": true, | ||
"no-with": true, | ||
"require-yield": true, | ||
} |
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.
what's this ? 🤔
why moving eslint int this PR ?
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.
there was a bug on eslint config creation. this is the fix of that bug.
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 am definitely missing a context and knowledge here 😄the error was on main branch or where ?
Anyway I don't want to block, please make a fix in new PR next time 🙏
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.
since i was testing this scenario, when i created a new config file from API it generated this error:
Error: Key "rules": Key "no-misleading-character-class": Value [{"allowEscape":false}] should NOT have more than 0 items.
this is a fix for that. i can remove this code and add it in a different PR, but since it is happening in main i thought it could simply go in this one!
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.
sure, ok next time
like I wrote ;)
2db4726
to
f04aa4a
Compare
* Refactor: Centralize tool configuration file names into constants - Introduced a new constants package to store tool configuration file names, reducing duplication across the codebase. - Updated references in the analyze and config setup files to use the new constants for improved maintainability. - Adjusted tests to align with the new constants structure, ensuring consistency in tool configuration handling. * fix test
} else if err != nil { | ||
return fmt.Errorf("Error checking config file for tool %s: %w", toolName, err) | ||
} else { | ||
fmt.Printf("Config file found for %s: %s\n", toolName, toolConfigPath) |
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.
[imporve]
This is normall situation, why print it for user ?
MAybe just file logger is enough
Overall ok but for local mode this scenario does not work:
Expected: Maybe it would be great idea to add it test for it... |
are we also fetching it in local mode? i thought this feature was only to remote. but sure, we can also cover that for local. |
Add API Config Generation Support to Analyze Command
Summary
The
analyze
command now supports passinginitFlags
and can automatically generate tool configuration files from the Codacy API when running in remote mode, but only if configuration files do not already exist.Changes
analyze
command: Now accepts API token and other init flagsBehavior
Testing
Added comprehensive test coverage for all scenarios including edge cases, with tests properly isolated to avoid creating config files in the project directory.
Related
Jira ticket: PLUTO-1423