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

New LongMethodName Rule #486

Open
ravage84 opened this issue Jun 5, 2017 · 6 comments · May be fixed by #1045
Open

New LongMethodName Rule #486

ravage84 opened this issue Jun 5, 2017 · 6 comments · May be fixed by #1045
Assignees
Milestone

Comments

@ravage84
Copy link
Member

ravage84 commented Jun 5, 2017

At the moment, we have:

  • ShortVariable: Detects when a field, local, or parameter has a very short name.
  • LongVariable: Detects when a field, formal or local variable is declared with a long name.
  • ShortMethodName: Detects when very short method names are used.

https://phpmd.org/rules/index.html#naming-rules

But we do not have a LongMethodName rule.

We should consider adding one, as an extensively long method name could be a sign of doing too much at once.

@ogadra
Copy link

ogadra commented Aug 4, 2023

I find this idea very useful. It would make me happy if you could implement it. Thank you.

@tvbeek
Copy link
Member

tvbeek commented Aug 11, 2023

I find this idea very useful. It would make me happy if you could implement it. Thank you.

Everybody is welcome to create a PR that implements this rule 😃

Please say it if you want to implement id and also if you need some help.

@kylekatarnls kylekatarnls added the Good first issue If you want to help, this may be a good start label Nov 21, 2023
kylekatarnls added a commit that referenced this issue Nov 28, 2023
@kylekatarnls kylekatarnls self-assigned this Nov 28, 2023
@kylekatarnls kylekatarnls removed the Good first issue If you want to help, this may be a good start label Nov 28, 2023
@kylekatarnls kylekatarnls modified the milestones: Future, 2.15.0 Nov 28, 2023
@kylekatarnls kylekatarnls linked a pull request Nov 28, 2023 that will close this issue
kylekatarnls added a commit that referenced this issue Nov 28, 2023
kylekatarnls added a commit that referenced this issue Nov 29, 2023
@kylekatarnls
Copy link
Member

I finished implementation. But I suspect users might also need some pattern/regexp exception such as test* to mean that name of method starting by "test" can be any length.

@ogadra
Copy link

ogadra commented Nov 30, 2023

@kylekatarnls
Thanks for completing the implementation!
I'm in the same boat—I really find myself needing that pattern feature. The reason is that the method starting with test might end up being quite lengthy.

@kylekatarnls
Copy link
Member

So I got carried away a bit again and made a pattern system for exceptions property. As I'm already a bit frustrated by the inconsistency of how we handle exceptions across rules, so I made a generic utility for it to be more easily harmonized in the next major version. #1045

@ravage84
Copy link
Member Author

ravage84 commented Dec 1, 2023

I think we should ignore test* method names by default either by adding them to the exception list by default or by having another config property such as ignore_test_methods.

kylekatarnls added a commit that referenced this issue Dec 2, 2023
kylekatarnls added a commit that referenced this issue Dec 2, 2023
@kylekatarnls kylekatarnls modified the milestones: 2.15.0, 2.16.0 Dec 10, 2023
kylekatarnls added a commit that referenced this issue Dec 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging a pull request may close this issue.

5 participants