Skip to content
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

Fix for ignoring test / directories by fqcn[deep] rule #4320

Merged
merged 4 commits into from
Sep 13, 2024

Conversation

tanwigeetika1618
Copy link
Contributor

@tanwigeetika1618 tanwigeetika1618 commented Sep 10, 2024

Fix issue #4160

Description:

This PR addresses issue #4160 by modifying the logic in fqcn.py to ensure that directories related to testing (i.e., those starting with "test") are skipped during processing. Previously, test directories were being evaluated, leading to unnecessary false positive warnings. (Skip test folders in fqcn.py)

Changes:

  • Updated the condition in fqcn.py to check if a directory is a test folder.
  • The folder checking logic has been enhanced to search for the word "test" anywhere in the directory path.
    • Directories that include "test" (such as test, tests, testxyz, or abctest) are skipped.
    • This ensures that test-related directories are excluded from processing while maintaining standard plugin structure.
  • Added a new test case test_fqcn_deep_test_dir_pass to verify that the rule does not flag files located in directories named test or similar.

Testing:

The new logic has been tested with various directory structures to ensure that any directory containing the word "test" is correctly skipped. The following cases have been verified:

  1. /tests/unit/plugins/action/network/pr.py
  2. /abc/unit/plugins/action/tests/pr.py
  3. /abc/test/plugins/action/network/pr.py
  4. /abctests/unit/plugins/action/network/pr.py
  5. /testxyz/unit/plugins/action/network/pr.py

In all these cases, the test directories (or directories containing "test") were successfully ignored during processing.

Screenshot from 2024-09-10 16-23-13

Copy link
Contributor

@alisonlhart alisonlhart left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! There should probably be a test added case to check this, following the pattern of the other test cases in the fqcn.py rule. One of the test cases you used during development would be good to add in.

Copy link

sonarcloud bot commented Sep 13, 2024

@alisonlhart alisonlhart merged commit 07c05e9 into ansible:main Sep 13, 2024
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants