Skip to content

Conversation

koalajoe23
Copy link
Contributor

Proposed fix for #4731

This is my first attempt at hacking something I want into ansible-lint, be gentle ;)

I was a bit surprised why all rule tests get a a full ruleset provided via default_rules_collection param as this makes the rules prone to breakage caused by other rules' auto-formating. I changed this and also made some assertions test if decprecated-local-action actually matched, not the number of expected matches which may change in the future.

@koalajoe23
Copy link
Contributor Author

Set this back to DRAFT as SonarCloud Code Analysis CI job doesn't like the code. I kinda agree and will try simplify the implementation

@koalajoe23
Copy link
Contributor Author

I think the remaining CI errors are not cause by my PR, right?

@koalajoe23 koalajoe23 marked this pull request as ready for review August 17, 2025 15:17
@cidrblock
Copy link
Contributor

cidrblock commented Aug 17, 2025

I think the remaining CI errors are not cause by my PR, right?

I don't think so, but you may have help us find a bug:

WARNING  Skipped installing collection dependencies due to running in offline mode.
an AnsibleCollectionFinder has not been installed in this process
Command failed: got '1', expected '0'

#4734 should fix the action test (confirmed)

@koalajoe23
Copy link
Contributor Author

koalajoe23 commented Aug 17, 2025

I changed the debug log statements for missing "local_action" and "module" param to assertions.

Code coverage went down because of the log statements and while trying to write test fixtures I realized a missing local_action would result in a non-matching rule, and a missing module param would be caught by the parser-error rule, also never reaching deprecated-local-action.

I think the assertions are fine here to guard against implementation errors.

@cidrblock cidrblock requested a review from Copilot August 18, 2025 14:12
Copilot

This comment was marked as outdated.

The latter is only useful preventing import cycles when using custom types
@cidrblock
Copy link
Contributor

cidrblock commented Aug 20, 2025

@koalajoe23 Does this do everything you need now? Fun stuff. BTW, your intuition was right about needing a way to get out quick, it was part of the reason I threw in an exception, it also made adding some unit tests for the edge cases pretty straight forward with having to traverse the entire code base.

@koalajoe23
Copy link
Contributor Author

koalajoe23 commented Aug 20, 2025

👍 for the changes. I really like the decoupled tests and error handling!

Only nitpick I have is that the transformed output should treat empty params as None - just looks much cleaner and "human". I took the liberty to just commit a fix, feel free to drop this commit if you want.

Everything LGTM on my part, awaiting merge :)

@alisonlhart alisonlhart enabled auto-merge (squash) August 21, 2025 13:09
@alisonlhart alisonlhart disabled auto-merge August 21, 2025 13:40
@alisonlhart alisonlhart merged commit 50373ef into ansible:main Aug 21, 2025
26 of 27 checks passed
@alisonlhart alisonlhart changed the title make rule deprecated-local-action preserve module parameters Make rule deprecated-local-action preserve module parameters Aug 21, 2025
@koalajoe23 koalajoe23 deleted the fix_deprecated_local_action branch August 21, 2025 16:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants