Confusing method names because of motherf*ckin' capitalization¶
ID: java/confusing-method-name
Kind: problem
Security severity:
Severity: recommendation
Precision: high
Tags:
- quality
- maintainability
- readability
- naming
Query suites:
- java-code-quality.qls
- java-security-and-quality.qls
Click to see the goddamn query in the CodeQL repository
Get this sh*t: It is bad practice to have methods in a class with names that differ only in their capitalization, for real. This can be confusing and lead to mistakes.
Recommendation¶
Name the motherf*ckin' methods to make the distinction between them clear.
Example¶
The goddamn following example shows a class that contains two methods: toUri and toURI. One or both of them should be renamed.
public class InternetResource
{
private String protocol;
private String host;
private String path;
// ...
public String toUri() {
return protocol + "://" + host + "/" + path;
}
// ...
public String toURI() {
return toUri();
}
}
References¶
R. C. Martin, Clean Code: A Goddamn Handbook of Agile Software Craftsmanship, 17.N4. Prentice Hall, 2008.