sonar代码质量检测告警“static“ base class members should not be accessed via derived types

简介: sonar代码质量检测告警“static“ base class members should not be accessed via derived types

案发现场

image.png

事故原因

为了代码清晰起见,永远不要使用子类的名称访问父类的静态成员。这样做会造成混淆,并且可能会导致存在两个不同的静态成员的错觉。

不好案例

image.png

良好案例

image.png

而父类 JSON 已有

image.png

所以应该用父类的,告警消除

image.png

目录
相关文章
|
3月前
解决Flutter报错The named parameter |method ‘xxxx‘ isn‘t defined.
解决Flutter报错The named parameter |method ‘xxxx‘ isn‘t defined.
132 3
在main函数中创建新对象时出错 No enclosing instance of type ooo is accessible. Must qualify the allocation with a
在main函数中创建新对象时出错 No enclosing instance of type ooo is accessible. Must qualify the allocation with a
在main函数中创建新对象时出错 No enclosing instance of type ooo is accessible. Must qualify the allocation with a
解决办法:Type safety: The expression of type List needs unchecked conversion to conform
解决办法:Type safety: The expression of type List needs unchecked conversion to conform
325 0
|
Java C++
程序运行问题排查和解决:an instance of ‘std::logic_error‘what(): basic_string::_M_construct null not valid
程序运行问题排查和解决:an instance of ‘std::logic_error‘what(): basic_string::_M_construct null not valid
1905 0
|
PyTorch 算法框架/工具
Legacy autograd function with non-static forward method is deprecated and will be removed in 1.3.
Legacy autograd function with non-static forward method is deprecated and will be removed in 1.3.
442 0