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

size[block]: Limit the maximum block depth #2173

Closed
cidrblock opened this issue May 23, 2022 · 4 comments · Fixed by #3602
Closed

size[block]: Limit the maximum block depth #2173

cidrblock opened this issue May 23, 2022 · 4 comments · Fixed by #3602
Assignees
Labels
good first issue Bugs ideal for the first time, good for newcomers contributors new rule A request for a new rule

Comments

@cidrblock
Copy link
Contributor

Starting to pull in possible rule ideas from the community of practice: redhat-cop/automation-good-practices#64

Ofter, using an include within a block leads to more readable playbooks and task file vs. a deep block depth.

It might not be possible to check across files and I'm not sure lint tracks block state, but within a single file we should be able to limit it.

2 was suggested only as a starting point

@cidrblock cidrblock added the new rule A request for a new rule label May 23, 2022
@ssbarnea ssbarnea changed the title Rule request: Limit the maximum block depth max-block-depth: Limit the maximum block depth Jul 19, 2022
@ssbarnea ssbarnea added this to the 6.9.x milestone Oct 1, 2022
@ssbarnea ssbarnea added the good first issue Bugs ideal for the first time, good for newcomers contributors label Feb 20, 2023
@ssbarnea ssbarnea changed the title max-block-depth: Limit the maximum block depth size[block]: Limit the maximum block depth Feb 20, 2023
@Ruchip16
Copy link
Member

@ssbarnea I can try fixing this

@ssbarnea
Copy link
Member

ssbarnea commented Mar 4, 2023

@Ruchip16 Any updates on it? Asking as I might do it myself if you don't have time.

@Ruchip16
Copy link
Member

Ruchip16 commented Mar 4, 2023

hey, yes I can try doing it, actually you said that you would assign me this issue after adding to the ansible org, so I was waiting for that but nevertheless, i would start now.

@ssbarnea
Copy link
Member

This one should be easy to implement via matchtask() and checking if passed task is a block. When is a block, we can count how many direct entries are under it and trigger the rule.

If we have >20 items, we can raise "Replace long block with an include_tasks to make code easier to maintain."

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Bugs ideal for the first time, good for newcomers contributors new rule A request for a new rule
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

4 participants