I am getting this checkstyle error:
'serverURL' hides a field   in this
 private static void setServerURL(final String serverURL) {     Utility.serverURL = serverURL;  }   What could be the reason, and how to resolve it?
There is already a variable defined serverURL which is available to this method (additional to the formal parameter you are accepting).  This is called "shadowing".
I think most Java programmers turn this check off, because it's not really that confusing.
For example, this would trigger the error:
public class Foo {   private int bar = 0;    public void someMethod(int bar) {     // There are two bars!  All references in this method will use the parameter bar,     // unless they are explicitly prefixed with 'this'.     this.bar = bar;   } } 
                        I think it is very common in constructors and setters that the set field name is the same as the setter parameter name. This is why i recommend this configuration:
<module name="HiddenField" >     <property name="ignoreSetter" value="true" />     <property name="ignoreConstructorParameter" value="true" /> </module>   This way the other hidden field cases are still forbidden.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With