Movatterモバイル変換


[0]ホーム

URL:


CodeQL documentation
CodeQL resources

Typo in hashCode

ID: java/hashcode-typoKind: problemSecurity severity: Severity: warningPrecision: mediumTags:   - quality   - reliability   - correctness   - readabilityQuery suites:   - java-security-and-quality.qls

Click to see the query in the CodeQL repository

A method namedhashcode may be a typographical error.hashCode (different capitalization) may have been intended instead.

Recommendation

Ensure that any such method is intended to have this name. Even if it is, it may be better to rename it to avoid confusion with the inherited methodObject.hashCode.

Example

The following example shows a method namedhashcode. It may be better to rename it.

publicclassPerson{privateStringtitle;privateStringforename;privateStringsurname;// ...publicinthashcode(){// The method is named 'hashcode'.inthash=23*title.hashCode();hash^=13*forename.hashCode();returnhash^surname.hashCode();}}

References


[8]ページ先頭

©2009-2025 Movatter.jp