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
Class name length rule #765
Class name length rule #765
Conversation
- length: to calculate string length subtracting certain suffixes - split: to split a string trimming and removing empty values
- length: to calculate string length subtracting certain suffixes - split: to split a string trimming and removing empty values
Any tips how to solve: It seems that Should I add a phpmd.xml that will be used by |
Moved "threshold" to the right side so it's better understandable. Tightened the LongVariable length constraints in the test case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will check why the PHAR build fails on Travis, but everything else is fine for me.
As explained here: #768
@MarkVaughn adressed #765 (comment) in 7d8212c |
That's fine, I guess.
Updated it to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@frankdekker thank you very much for your great work 😎
I updated your PR with lots of small improvements. Also see my comments.
That not only silences violations in PHPMD's own code but also reflects a more sane default.
Fixed by bumping the maximum threshold to 40. 😆 |
That is fine. To be honest, the code base is really old (some stuff dates back to 2008 or at least to 2012. In the past the code was maintained by a single person. Since last year a small team is maintaining the code and we slowly improve what we find.
Funny, I do too, normally. But it was too late at night for me to add these, too.
My idea was to make the code more self expressive. Also, one should be cautious to add functionality through configuration parameters. This could lead to code that does too much or too many different things. It might be wiser to add a second method, instead.
My idea was in the sense of "Split string using separator to get a list of it"
Your opinion is welcomed. If you want, you can talk to us on our Gitter channel. |
@kylekatarnls Thanks the approval. Just a heads up, i think there needs to be done an extra step to update the documentation on the website. Is not entirely up-to-date now. See: |
Indeed. Could you add the missing paragraph to https://github.com/phpmd/phpmd/blob/master/src/site/rst/rules/naming.rst following the example of Thanks, |
Type: feature
Issue: Resolves #763
Breaking change: no
Added LongClassName Rule
Detects when classes or interfaces are declared with excessively long names.
Properties:
Added ShortClassName Rule
Detects when classes or interfaces have a very short name.
Added
/PHPMD/Support/Strings
class::length
, calculates the length of a string with optionally subtracted suffixes::split
, splits a string on a specific separator, trimming parts, and removing empty stringsUpdated LongVariable Rule
removed function
getStringLength
and replaced usage withStrings::length
cleaned up
getSubtractSuffixList
getStringProperty
with default paramStrings::split
method to split the suffixes.Added test cases for all changes
Updated documentation for Long- and ShortClassName
Note:
"since" needs to be updated in
naming.xml
Unsure about the priority for the two rules. I've set them to 3.
Unsure about the namespace for the Strings class. I took Laravels "Support/Str" namespace/class as example. I'm open for suggestions.