CodeQL 文档

toString 中的拼写错误

ID: java/tostring-typo
Kind: problem
Security severity: 
Severity: warning
Precision: medium
Tags:
   - maintainability
   - readability
   - naming
Query suites:
   - java-security-and-quality.qls

单击以在 CodeQL 仓库中查看查询

名为 tostring 的方法可能是拼写错误。可能本意是 toString(大小写不同)。

建议

确保任何此类方法都打算具有此名称。即使是,最好将其重命名以避免与继承的方法 Object.toString 混淆。

示例

以下示例显示了一个名为 tostring 的方法。最好将其重命名。

public class Customer
{
	private String title;
	private String forename;
	private String surname;

	// ...

	public String tostring() {  // The method is named 'tostring'.
		return title + " " + forename + " " + surname;
	}
}

参考资料

  • ©GitHub, Inc.
  • 条款
  • 隐私