Hi, I'm aware that I'm opening a can of worms, but can we discuss PHPMD rules?
In particular, I find that to obey the maximum variable name (20 characters) rule, one has to sometimes abbreviate at the expanse of clarity.
http://ci.phpmyadmin.net/job/phpMyAdmin/908/pmdResult/type.811406648/
Hi,
2014/1/5 Marc Delisle marc@infomarc.info
Hi, I'm aware that I'm opening a can of worms, but can we discuss PHPMD rules?
In particular, I find that to obey the maximum variable name (20 characters) rule, one has to sometimes abbreviate at the expanse of clarity.
http://ci.phpmyadmin.net/job/phpMyAdmin/908/pmdResult/type.811406648/
I agree. Many rules are useful to keep the code clear, but sometimes it
could be a constraint. Marc is talking about the length of variable names, but it's the same thing about the line length. Limit to 80 characters is out-of-dated. Our screen are larger than "before" so let's use more. (And you choose to use more because our standard is now 85 characters. In my job, we decided to use 120.) But this was only an example to support what Marc said.
But if I'm right, the problem of PMD is that you can activate a group of rules but not a single rule. (Some one to contradict this please ?)
One possibility could be to try to implement the interesting rules in PHPCS if they don't exist.
Hugues.
Le 2014-01-05 14:31, Hugues Peccatte a écrit :
Hi,
2014/1/5 Marc Delisle <marc@infomarc.info mailto:marc@infomarc.info>
Hi, I'm aware that I'm opening a can of worms, but can we discuss PHPMD rules? In particular, I find that to obey the maximum variable name (20 characters) rule, one has to sometimes abbreviate at the expanse of clarity. http://ci.phpmyadmin.net/job/phpMyAdmin/908/pmdResult/type.811406648/
I agree. Many rules are useful to keep the code clear, but sometimes it could be a constraint. Marc is talking about the length of variable names, but it's the same thing about the line length. Limit to 80 characters is out-of-dated. Our screen are larger than "before" so let's use more. (And you choose to use more because our standard is now 85 characters. In my job, we decided to use 120.) But this was only an example to support what Marc said.
Well, on my laptop, I don't have that much space and I'm happy with the current line length limit.
But if I'm right, the problem of PMD is that you can activate a group of rules but not a single rule. (Some one to contradict this please ?)
One possibility could be to try to implement the interesting rules in PHPCS if they don't exist.
Hugues.
2014/1/5 Marc Delisle marc@infomarc.info
Le 2014-01-05 14:31, Hugues Peccatte a écrit :
Hi,
2014/1/5 Marc Delisle <marc@infomarc.info mailto:marc@infomarc.info>
Hi, I'm aware that I'm opening a can of worms, but can we discuss PHPMD rules? In particular, I find that to obey the maximum variable name (20 characters) rule, one has to sometimes abbreviate at the expanse of clarity.
http://ci.phpmyadmin.net/job/phpMyAdmin/908/pmdResult/type.811406648/
I agree. Many rules are useful to keep the code clear, but sometimes it could be a constraint. Marc is talking about the length of variable names, but it's the same thing about the line length. Limit to 80 characters is out-of-dated. Our screen are larger than "before" so let's use more. (And you choose to use more because our standard is now 85 characters. In my job, we decided to use 120.) But this was only an example to support what Marc said.
Well, on my laptop, I don't have that much space and I'm happy with the current line length limit.
But if I'm right, the problem of PMD is that you can activate a group of rules but not a single rule. (Some one to contradict this please ?)
One possibility could be to try to implement the interesting rules in PHPCS if they don't exist.
Hugues.
-- Marc Delisle http://infomarc.info | http://phpmyadmin.net
You're right. We are not at work, we don't have all the same devices. But it was only to say that things need to evolve and to ask if there is a way to activate only some PMD rules.
Hugues.
Hi
Dne Sun, 05 Jan 2014 09:36:10 -0500 Marc Delisle marc@infomarc.info napsal(a):
I'm aware that I'm opening a can of worms, but can we discuss PHPMD rules?
I think those were never actually discussed, we just run then in Jenkins. So I think it's good idea to discuss coding style beyond indentation and whitespaces.
In particular, I find that to obey the maximum variable name (20 characters) rule, one has to sometimes abbreviate at the expanse of clarity.
I think this is quite connected to line length as well. In case you have longer variable names and stick with current line length, the code will be a bit harder to read due to necessary wrapping, for example:
https://github.com/phpmyadmin/phpmyadmin/blob/master/libraries/browse_foreig...
Looking at current long variable names, I see following patterns:
- pma prefix, is that really needed? [1]
- return values from function called $something_somewhere_html, using just $result might be even better to understand in this context [2]
- some variables still being used as globals, thus needing to provide too much context in their names [3]
- some probably legitimate usages of long name [4]
[1]:https://github.com/phpmyadmin/phpmyadmin/blob/master/view_create.php#L95 [2]:https://github.com/phpmyadmin/phpmyadmin/blob/master/libraries/DisplayResult... [3]:https://github.com/phpmyadmin/phpmyadmin/blob/master/libraries/mysql_charset... [4]:https://github.com/phpmyadmin/phpmyadmin/blob/master/libraries/DisplayResult...
Michal Čihař a écrit :
Hi
Dne Sun, 05 Jan 2014 09:36:10 -0500 Marc Delisle marc@infomarc.info napsal(a):
I'm aware that I'm opening a can of worms, but can we discuss PHPMD rules?
I think those were never actually discussed, we just run then in Jenkins. So I think it's good idea to discuss coding style beyond indentation and whitespaces.
In particular, I find that to obey the maximum variable name (20 characters) rule, one has to sometimes abbreviate at the expanse of clarity.
I think this is quite connected to line length as well. In case you have longer variable names and stick with current line length, the code will be a bit harder to read due to necessary wrapping, for example:
https://github.com/phpmyadmin/phpmyadmin/blob/master/libraries/browse_foreig...
I see two possibilities here: - abbreviate variable names (would make them even more difficult to understand) - improve the logic (I'll work on this case :) )
Looking at current long variable names, I see following patterns:
- pma prefix, is that really needed? [1]
No.
- return values from function called $something_somewhere_html, using just $result might be even better to understand in this context [2]
Agreed, when it's inside a function.
- some variables still being used as globals, thus needing to provide too much context in their names [3]
Usually a hint that this code segment needs refactoring.
- some probably legitimate usages of long name [4]
Agreed.
Rapidly troubleshoot problems before they affect your business. Most IT organizations don't have a clear picture of how application performance affects their revenue. With AppDynamics, you get 100% visibility into your Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro! http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clk...
Phpmyadmin-devel mailing list Phpmyadmin-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/phpmyadmin-devel
I'm aware that I'm opening a can of worms, but can we discuss PHPMD
rules?
I think those were never actually discussed, we just run then in Jenkins. So I think it's good idea to discuss coding style beyond indentation and whitespaces.
In particular, I find that to obey the maximum variable name (20 characters) rule, one has to sometimes abbreviate at the expanse of
clarity.
I think this is quite connected to line length as well. In case you have longer variable names and stick with current line length, the code will be a bit harder to read due to necessary wrapping, for example:
https://github.com/phpmyadmin/phpmyadmin/blob/master/libraries/browse_foreig...
I think the length of a variable name we should use is depend on variable scope and complexity of the code segment. Less complexity code segment may have shorten variable name while more complex code segment will have lengthy variable names. Same for the scope as well. I prefer to have bit lengthy variable since it will self describe the code even without the comments.
In case we care on the length, we can use comments on a variable initializing point, which describe the shorten variable clearly. As well as using camel case naming convention will save us from additional underscores ($getEntryById < $get_entry_by_id)
But as a standard we better have a limitation on the length of a variable name. But I think we better keep the limit more than 20 (what about 25 ?)
I see two possibilities here:
- abbreviate variable names (would make them even more difficult to
understand)
- improve the logic (I'll work on this case :) )
Looking at current long variable names, I see following patterns:
- pma prefix, is that really needed? [1]
No.
- return values from function called $something_somewhere_html, using just $result might be even better to understand in this context [2]
Agreed, when it's inside a function.
- some variables still being used as globals, thus needing to provide too much context in their names [3]
Usually a hint that this code segment needs refactoring.
- some probably legitimate usages of long name [4]
Agreed.
[1]:
https://github.com/phpmyadmin/phpmyadmin/blob/master/view_create.php#L95
[2]:
https://github.com/phpmyadmin/phpmyadmin/blob/master/libraries/DisplayResult...
[3]:
https://github.com/phpmyadmin/phpmyadmin/blob/master/libraries/mysql_charset...
[4]:
https://github.com/phpmyadmin/phpmyadmin/blob/master/libraries/DisplayResult...
Hi,
2014/1/6 Chanaka Dharmarathna pe.chanaka.ck@gmail.com
I'm aware that I'm opening a can of worms, but can we discuss PHPMD
rules?
I think those were never actually discussed, we just run then in Jenkins. So I think it's good idea to discuss coding style beyond indentation and whitespaces.
In particular, I find that to obey the maximum variable name (20 characters) rule, one has to sometimes abbreviate at the expanse of
clarity.
I think this is quite connected to line length as well. In case you have longer variable names and stick with current line length, the code will be a bit harder to read due to necessary wrapping, for example:
https://github.com/phpmyadmin/phpmyadmin/blob/master/libraries/browse_foreig...
I think the length of a variable name we should use is depend on variable scope and complexity of the code segment. Less complexity code segment may have shorten variable name while more complex code segment will have lengthy variable names. Same for the scope as well. I prefer to have bit lengthy variable since it will self describe the code even without the comments.
In case we care on the length, we can use comments on a variable initializing point, which describe the shorten variable clearly. As well as using camel case naming convention will save us from additional underscores ($getEntryById < $get_entry_by_id)
But as a standard we better have a limitation on the length of a variable name. But I think we better keep the limit more than 20 (what about 25 ?)
I agree. But is it possible to change the allowed length ? Here we are talking about PMD ( http://ci.phpmyadmin.net/job/phpMyAdmin/910/pmdResult/type.811406648/), so I believe that we can't…
I see two possibilities here:
- abbreviate variable names (would make them even more difficult to
understand)
- improve the logic (I'll work on this case :) )
Looking at current long variable names, I see following patterns:
- pma prefix, is that really needed? [1]
No.
- return values from function called $something_somewhere_html, using just $result might be even better to understand in this context [2]
Agreed, when it's inside a function.
- some variables still being used as globals, thus needing to provide too much context in their names [3]
Usually a hint that this code segment needs refactoring.
- some probably legitimate usages of long name [4]
Agreed.
[1]:
https://github.com/phpmyadmin/phpmyadmin/blob/master/view_create.php#L95
[2]:
https://github.com/phpmyadmin/phpmyadmin/blob/master/libraries/DisplayResult...
[3]:
https://github.com/phpmyadmin/phpmyadmin/blob/master/libraries/mysql_charset...
[4]:
https://github.com/phpmyadmin/phpmyadmin/blob/master/libraries/DisplayResult...
-- Chanaka Dharmarathna *Virtusa (Pvt) Ltd. | **Sri Lanka*
Hugues.
I'm aware that I'm opening a can of worms, but can we discuss PHPMD
rules?
I think those were never actually discussed, we just run then in Jenkins. So I think it's good idea to discuss coding style beyond indentation and whitespaces.
In particular, I find that to obey the maximum variable name (20 characters) rule, one has to sometimes abbreviate at the expanse of
clarity.
I think this is quite connected to line length as well. In case you have longer variable names and stick with current line length, the code will be a bit harder to read due to necessary wrapping, for example:
https://github.com/phpmyadmin/phpmyadmin/blob/master/libraries/browse_foreig...
I think the length of a variable name we should use is depend on variable scope and complexity of the code segment. Less complexity code segment may have shorten variable name while more complex code segment will have lengthy variable names. Same for the scope as well. I prefer to have bit lengthy variable since it will self describe the code even without the comments.
In case we care on the length, we can use comments on a variable initializing point, which describe the shorten variable clearly. As well as using camel case naming convention will save us from additional underscores ($getEntryById < $get_entry_by_id)
But as a standard we better have a limitation on the length of a variable name. But I think we better keep the limit more than 20 (what about 25 ?)
I agree. But is it possible to change the allowed length ? Here we are talking about PMD ( http://ci.phpmyadmin.net/job/phpMyAdmin/910/pmdResult/type.811406648/), so I believe that we can't…
Does that mean we must follow these PMD rules? Btw, I think customizing a PMD rule should be possible. Information in the documentation [0] will be useful for find that out. But I have no idea on how PMD works with Jenkins.
I see two possibilities here:
- abbreviate variable names (would make them even more difficult to
understand)
- improve the logic (I'll work on this case :) )
Looking at current long variable names, I see following patterns:
- pma prefix, is that really needed? [1]
No.
- return values from function called $something_somewhere_html, using just $result might be even better to understand in this context [2]
Agreed, when it's inside a function.
- some variables still being used as globals, thus needing to provide too much context in their names [3]
Usually a hint that this code segment needs refactoring.
- some probably legitimate usages of long name [4]
Agreed.
[1]:
https://github.com/phpmyadmin/phpmyadmin/blob/master/view_create.php#L95
[2]:
https://github.com/phpmyadmin/phpmyadmin/blob/master/libraries/DisplayResult...
[3]:
https://github.com/phpmyadmin/phpmyadmin/blob/master/libraries/mysql_charset...
[4]:
https://github.com/phpmyadmin/phpmyadmin/blob/master/libraries/DisplayResult...
[0] : http://pmd.sourceforge.net/pmd-5.0.5/howtowritearule.html
Hi,
2014/1/7 Chanaka Dharmarathna pe.chanaka.ck@gmail.com
I'm aware that I'm opening a can of worms, but can we discuss PHPMD
rules?
I think those were never actually discussed, we just run then in Jenkins. So I think it's good idea to discuss coding style beyond indentation and whitespaces.
In particular, I find that to obey the maximum variable name (20 characters) rule, one has to sometimes abbreviate at the expanse of
clarity.
I think this is quite connected to line length as well. In case you have longer variable names and stick with current line length, the
code
will be a bit harder to read due to necessary wrapping, for example:
https://github.com/phpmyadmin/phpmyadmin/blob/master/libraries/browse_foreig...
I think the length of a variable name we should use is depend on variable scope and complexity of the code segment. Less complexity code segment may have shorten variable name while more complex code segment will have lengthy variable names. Same for the scope as well. I prefer to have bit lengthy variable since it will self describe the code even without the comments.
In case we care on the length, we can use comments on a variable initializing point, which describe the shorten variable clearly. As well as using camel case naming convention will save us from additional underscores ($getEntryById < $get_entry_by_id)
But as a standard we better have a limitation on the length of a variable name. But I think we better keep the limit more than 20 (what about 25 ?)
I agree. But is it possible to change the allowed length ? Here we are talking about PMD ( http://ci.phpmyadmin.net/job/phpMyAdmin/910/pmdResult/type.811406648/), so I believe that we can't…
Does that mean we must follow these PMD rules? Btw, I think customizing a PMD rule should be possible. Information in the documentation [0] will be useful for find that out. But I have no idea on how PMD works with Jenkins.
You're right, I never saw this before, but PMD could be personnalized ! http://pmd.sourceforge.net/pmd-5.0.5/howtomakearuleset.html What a good news !
Would it be ok, in PMAStandard folder, to have a PMD and a PHPCS folders to manage 2 ruleset.xml files ?
I see two possibilities here:
- abbreviate variable names (would make them even more difficult to
understand)
- improve the logic (I'll work on this case :) )
Looking at current long variable names, I see following patterns:
- pma prefix, is that really needed? [1]
No.
- return values from function called $something_somewhere_html, using just $result might be even better to understand in this context [2]
Agreed, when it's inside a function.
- some variables still being used as globals, thus needing to provide too much context in their names [3]
Usually a hint that this code segment needs refactoring.
- some probably legitimate usages of long name [4]
Agreed.
[1]:
https://github.com/phpmyadmin/phpmyadmin/blob/master/view_create.php#L95
[2]:
https://github.com/phpmyadmin/phpmyadmin/blob/master/libraries/DisplayResult...
[3]:
https://github.com/phpmyadmin/phpmyadmin/blob/master/libraries/mysql_charset...
[4]:
https://github.com/phpmyadmin/phpmyadmin/blob/master/libraries/DisplayResult...
[0] : http://pmd.sourceforge.net/pmd-5.0.5/howtowritearule.html
Hugues.