All Downloads are FREE. Search and download functionalities are using the official Maven repository.

resources.report.rules.pmd.AvoidMultipleUnaryOperators.html Maven / Gradle / Ivy



AvoidMultipleUnaryOperators

AvoidMultipleUnaryOperators

The use of multiple unary operators may be problematic, and/or confusing. Ensure that the intended usage is not a bug, or consider simplifying the expression.

This rule is defined by the following Java class: net.sourceforge.pmd.lang.java.rule.basic.AvoidMultipleUnaryOperatorsRule

Example(s):

            
// These are typo bugs, or at best needlessly complex and confusing:
int i = - -1;
int j = + - +1;
int z = ~~2;
boolean b = !!true;
boolean c = !!!true;

// These are better:
int i = 1;
int j = -1;
int z = 2;
boolean b = true;
boolean c = false;

// And these just make your brain hurt:
int i = ~-2;
int j = -~7;
            




© 2015 - 2025 Weber Informatics LLC | Privacy Policy