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

Detect if methods, or a set of methods, within a given namespace exceed a limit of lines #438

Open
floriankraemer opened this issue Aug 4, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@floriankraemer
Copy link

floriankraemer commented Aug 4, 2024

Feature Request

Make it possible to detect if methods, or a set of methods, within a given class or namespace exceed a limit of lines. The background is that we would like to prevent having controllers more than X lines.

Rule::allClasses()
    ->that(new ResideInOneOfTheseNamespaces('App\Controller'))
    ->should(new NotHaveMethodsLongerThanXCharacters(10))
    ->because('Controllers must not implement business logic');

I'm happy to help implementing this if somebody gives me some info how to get it done. I see no obvious way at the moment to get the line count of a methods from a class.

There is ClassDescription which does not contain a list of the method names, which would be nice and then have a MethodDescription for each that might also contain the line count and cyclomatic complexity? I'm aware of phpmd but it would be nice to have this in one tool and a more fine grained control via the DSL of Arkitekt vs the rule sets of phpmd.

Q A
New Feature yes
RFC yes/no
BC Break yes/no

Summary

Make it possible to detect if methods, or a set of methods, within a given class or namespace exceed a limit of lines. The background is that we would like to prevent having controllers more than X lines.

@AlessandroMinoccheri
Copy link
Member

Hello @floriankraemer I am happy to help but I don't know if it's possible.

@AlessandroMinoccheri AlessandroMinoccheri added the enhancement New feature or request label Aug 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants