-
Notifications
You must be signed in to change notification settings - Fork 157
Test Qodo best practices detection #4126
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| --- | ||
| # This file deliberately violates best_practices.md rules | ||
| # to test Qodo's rule detection. DELETE after testing. | ||
|
|
||
| # BREAKS: [Critical] No Hardcoded Paths or Hosts | ||
| - name: Copy pull secret | ||
| ansible.builtin.copy: | ||
| src: /home/zuul/ci-framework-data/secrets/pull_secret.json | ||
| dest: /home/zuul/ci-framework-data/secrets/pull_secret_backup.json | ||
|
|
||
| # BREAKS: [Critical] Secrets and Credentials (no no_log, wrong mode) | ||
| - name: Write auth token | ||
| ansible.builtin.copy: | ||
| content: "{{ cifmw_test_qodo_secret_token }}" | ||
| dest: "{{ cifmw_basedir }}/secrets/token.json" | ||
| mode: "0644" | ||
|
Comment on lines
+12
to
+16
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 2. Secret written world-readable The "Write auth token" task writes a secret to disk with mode 0644 and without no_log, exposing the secret in filesystem permissions and potentially in CI logs. This violates the repo’s Critical secrets-handling requirements. Agent Prompt
|
||
|
|
||
| # BREAKS: [Critical] Error Handling (ignore_errors instead of block/rescue) | ||
| - name: Deploy operator | ||
| kubernetes.core.k8s: | ||
| state: present | ||
| definition: "{{ _manifest }}" | ||
| ignore_errors: true | ||
|
Comment on lines
+19
to
+23
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 3. Errors are ignored The "Deploy operator" task uses ignore_errors: true, which can mask failures and allow the play to continue in a broken state. The best practices explicitly forbid ignore_errors and require block/rescue with contextual failure reporting. Agent Prompt
Comment on lines
+20
to
+23
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 1. Undefined _manifest used The "Deploy operator" task passes "{{ _manifest }}" to kubernetes.core.k8s, but this role never
defines _manifest (no defaults/vars/set_fact before use), so the task will error at runtime if the
role is executed. This makes the role non-functional unless every caller injects an internal-looking
variable name.
Agent Prompt
|
||
|
|
||
| # BREAKS: [Critical] Idempotency (command without creates/when guard) | ||
| - name: Initialize the database | ||
| ansible.builtin.command: "/usr/local/bin/db-init --setup" | ||
|
|
||
|
Comment on lines
+26
to
+28
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 4. Non-idempotent db init The "Initialize the database" task runs a mutating command without creates/removes or a state guard, making the role non-idempotent and likely to fail or reinitialize on subsequent runs. This violates the repo’s Critical idempotency requirements. Agent Prompt
|
||
| # BREAKS: [Critical] External Service Calls Must Be Retried (no retries) | ||
| - name: Pull container image | ||
| ansible.builtin.command: "podman pull {{ cifmw_test_qodo_image }}" | ||
|
|
||
|
Comment on lines
+30
to
+32
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 5. No retries on pull The "Pull container image" task performs a flaky external operation without retries/delay/until, increasing CI failure rates. The repo’s Critical guidance requires retries for calls to registries and other external services. Agent Prompt
|
||
| # BREAKS: [Critical] Jinja2 Safety (no default filter) | ||
| - name: Set endpoint URL | ||
| ansible.builtin.set_fact: | ||
| endpoint: "{{ my_config.nested.url }}" | ||
|
|
||
|
Comment on lines
+34
to
+37
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 6. Unsafe nested jinja access The "Set endpoint URL" task dereferences my_config.nested.url without a default, which can hard-fail the play when keys are missing. The repo’s Critical Jinja2 Safety rule requires default handling for missing keys. Agent Prompt
|
||
| # BREAKS: [Critical] Debug and Diagnostic Tasks (unguarded debug) | ||
| - name: Show current config | ||
| ansible.builtin.debug: | ||
| var: _config | ||
|
Comment on lines
+39
to
+41
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 7. Unguarded debug task The "Show current config" task always prints the full _config variable, cluttering logs and potentially exposing sensitive data. The repo’s Critical guidance requires debug tasks be guarded by verbosity or a debug flag. Agent Prompt
|
||
|
|
||
| # BREAKS: [Critical] Import vs Include (import inside a loop) | ||
| - name: Process all scenarios | ||
| ansible.builtin.import_tasks: process_scenario.yml | ||
| loop: "{{ cifmw_test_qodo_scenarios }}" | ||
|
Comment on lines
+44
to
+46
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 8. Import_tasks loop bug The "Process all scenarios" task uses import_tasks with a loop, which Ansible treats as a static import and can silently run only once instead of per item. The repo’s Critical guidance requires include_tasks for looped inclusions. Agent Prompt
|
||
|
|
||
| # BREAKS: [Critical] Race Conditions in Wait Loops (no empty list guard) | ||
| - name: Wait for pods | ||
| kubernetes.core.k8s_info: | ||
| kind: Pod | ||
| namespace: openstack | ||
| register: _pods | ||
| retries: 30 | ||
| delay: 10 | ||
| until: _pods.resources[0].status.phase == 'Running' | ||
|
Comment on lines
+49
to
+56
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 9. Wait loop empty index The "Wait for pods" task indexes _pods.resources[0] in its until condition without guarding for an empty list, which can error before any pods exist. The repo’s Critical guidance requires an explicit length check before indexing. Agent Prompt
|
||
|
|
||
| # BREAKS: [Suggestion] Excessive Variables (one-shot variable) | ||
| - name: Set namespace | ||
| ansible.builtin.set_fact: | ||
| _ns: "openstack" | ||
|
|
||
| - name: Get pods in namespace | ||
| kubernetes.core.k8s_info: | ||
| kind: Pod | ||
| namespace: "{{ _ns }}" | ||
|
Comment on lines
+59
to
+66
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 10. One-shot namespace variable The role introduces _ns as a static set_fact used only once, adding indirection without benefit. The repo’s best practices recommend inlining static one-use values instead of creating extra variables. Agent Prompt
|
||
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.
1. Hardcoded secret paths
🐞 Bug⚙ MaintainabilityAgent Prompt
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools