java-math-library
java-math-library copied to clipboard
Increase the usage of compound assignment operators
:eyes: Some source code analysis tools can help to find opportunities for improving software components. :thought_balloon: I propose to increase the usage of compound operators accordingly.
Would you like to integrate anything from a transformation result which can be generated by a command like the following? (:point_right: Please check also for questionable change suggestions because of an evolving search pattern.)
lokal$ perl -p -i.orig -0777 -e 's#\b(?<target>\S+)\s*=\s*\k<target>[ \t]*(?<operator>[+\-*/%^]|&(?!&)|\|(?!\|)|<<|>>>?)#$+{target} $+{operator}=#gm' $(find ~/Projekte/java-math-library/lokal -name '*.java')
Sorry, haven't seen this for a while. I'ld have thought that I am using compound operators pretty often, particularly at places where performance matters.
If the diff created by your transformation script is so big that I can't review it in a reasonable amount of time then I won't accept it.
If the diff created by your transformation script is so …
Would you dare to take another look at the generated change suggestion?
I'm a stupid Windows user, no Perl here. Give me a hint please ;-)
How do you think about to try the shown search and replace pattern out by using tools you feel more familiar with?
I can't because I do not understand what it is doing. Please explain me what it does.
I propose to become more familiar with advanced applications of regular expressions here. (By the way: It can be nicer and safer to achieve similar transformations with the help of computation tree logic and corresponding semantic patch languages.)
The search pattern tries to find improvable assignments (in Java source code). Thus named capturing groups are applied so that captured contents can be used for possible text replacements.
The shown Perl command would adjust selected files in-place (after a file backup was performed).
Thanks for the explanation. Actually I am roughly familiar with regular expressions but the command you posted is not that easy to understand. One day I might install a Linux subsystem and give it a go.
The shown Perl command example is portable. Thus it can generally be tried out (on demand) in various system environments, can't it? :thinking: