Fortify Issues -Poor Style: Confusing Naming

Kiran Kumar
Mar 15, 2022

--

Code contains a field and a method both named value, which is confusing.

Explanation: It is confusing to have a member field and a method with the same name. It makes it easy for a programmer to accidentally call the method when attempting to access the field or vice versa.

Example 1:

public class Totaller {
private int total;
public int total() {
...
}
}

Recommendations:

Rename either the method or the field. If the method returns the field, consider following the standard getter/setter naming convention.

Example 2:
The code in Example 1 could be rewritten in the following way:

public class Totaller {
private int total;
public int getTotal() {
...
}
}

Proper Naming convention for variable or method or class is mandatory.

Other issues :

https://medium.com/@matam.kirankumar/fortify-issue-dead-code-unused-cd19b18983e2

--

--

Kiran Kumar
Kiran Kumar

Written by Kiran Kumar

Technophile with 12.5 years experience in IT industry | Java Technical Manager cum Architect

No responses yet