ci: This PR is to trigger periodic CI testing#227
ci: This PR is to trigger periodic CI testing#227systemroller wants to merge 131 commits intomainfrom
Conversation
|
[citest] |
5fe3358 to
70bb771
Compare
Reviewer's GuideAdds an Ansible aggregate callback plugin used in CI to capture and print all non-removed packages requested via package-related modules, enabling inspection of package usage across test runs. File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
| result._result["results"], list | ||
| ): | ||
| results = result._result["results"] | ||
| for item in results: |
Check failure
Code scanning / CodeQL
Potentially uninitialized local variable
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 3 months ago
In general, to fix a “potentially uninitialized local variable” problem, either (1) initialize the variable to a safe default before any conditional assignments or (2) ensure all control-flow paths that reach its use have definitely assigned it (for example, by adding else cases or early returns).
Here, the safest change without altering existing behavior is:
- Initialize
resultsto an empty list before theif/elifchain. - After the chain, only iterate over
resultsif it is non-empty; otherwise, simply skip the loop so noUnboundLocalErrorcan occur.
This preserves current behavior whenresultsis defined as before, while making the code no-op (rather than crash) in the rare case that neither condition is met.
Concretely in tests/callback_plugins/dump_packages.py:
- In
CallbackModule.v2_runner_on_ok, addresults = []right afterpackages = set(). - Wrap the
for item in results:loop and subsequent package processing in anif results:guard so it only executes whenresultshas been set to something meaningful.
No new imports or helper methods are required.
| @@ -45,20 +45,22 @@ | ||
| and fields["args"].get("state") != "absent" | ||
| ): | ||
| packages = set() | ||
| results = [] | ||
| if "invocation" in result._result: | ||
| results = [result._result] | ||
| elif "results" in result._result and isinstance( | ||
| result._result["results"], list | ||
| ): | ||
| results = result._result["results"] | ||
| for item in results: | ||
| pkgs = item["invocation"]["module_args"]["name"] | ||
| if isinstance(pkgs, list): | ||
| for ii in pkgs: | ||
| packages.add(ii) | ||
| else: | ||
| packages.add(pkgs) | ||
| # tell python black that this line is ok | ||
| # fmt: off | ||
| self._display.display("lsrpackages: " + " ".join(sorted(list(packages)))) | ||
| # fmt: on | ||
| if results: | ||
| for item in results: | ||
| pkgs = item["invocation"]["module_args"]["name"] | ||
| if isinstance(pkgs, list): | ||
| for ii in pkgs: | ||
| packages.add(ii) | ||
| else: | ||
| packages.add(pkgs) | ||
| # tell python black that this line is ok | ||
| # fmt: off | ||
| self._display.display("lsrpackages: " + " ".join(sorted(list(packages)))) | ||
| # fmt: on |
|
[citest] |
70bb771 to
d662139
Compare
|
[citest] |
2 similar comments
|
[citest] |
|
[citest] |
74b344f to
9415af4
Compare
|
[citest] |
9415af4 to
e9013d9
Compare
|
[citest] |
e9013d9 to
2afac9d
Compare
|
[citest] |
1 similar comment
|
[citest] |
5079045 to
082ffea
Compare
|
[citest] |
082ffea to
7ff7e45
Compare
|
[citest] |
7ff7e45 to
47e3088
Compare
|
[citest] |
This PR is for the purpose of triggering periodic CI testing. We don't currently have a way to trigger CI without a PR, so this PR serves that purpose.
Summary by Sourcery
Tests: