项目场景:
Sonarlint 问题记录
问题描述:
JSONObject.toJSONString()
在Sonarlint检查中发现提示:
“static” base class members should not be accessed via derived types
In the interest of code clarity, static members of a base class should never be accessed using a derived type’s name. Doing so is confusing and could create the illusion that two different static members exist.
意思是如果子类继承了父类的静态成员,不应该通过子类去调用
解决方案:
改成父类的调用:
JSON.toJSONString()
博客介绍了Sonarlint检查中遇到的问题——不应通过子类调用父类的静态成员。文章解释了这样做可能导致的混淆,并提供了正确的解决方案,即直接使用父类名进行调用,以提高代码清晰度和可读性。
1万+

被折叠的 条评论
为什么被折叠?



