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

目录
相关文章
|
2月前
Error:Execution failed for task ':app:javaPreCompileDebug'. > Annotation processors must be explicit
Error:Execution failed for task ':app:javaPreCompileDebug'. > Annotation processors must be explicit
66 0
VS2005 error C2864 only static const integral data members can be initialized within a class
VS2005 error C2864 only static const integral data members can be initialized within a class
|
Java
The type XXX cannot be resolved. It is indirectly referenced from required .class files
The type XXX cannot be resolved. It is indirectly referenced from required .class files
86 0
解决办法:Type safety: The expression of type List needs unchecked conversion to conform
解决办法:Type safety: The expression of type List needs unchecked conversion to conform
192 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
1048 0
在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
No injector for custom defined data type的解决办法
No injector for custom defined data type的解决办法
224 0
No injector for custom defined data type的解决办法
|
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.
404 0