SonarQube C/C++/Objective C 4.1 发布了,Sonar (SonarQube)是一个开源平台,用于管理源代码的质量。Sonar 不只是一个质量数据报告工具,更是代码质量管理平台。支持的语言包括:Java、PHP、C#、C、Cobol、PL/SQL、Flex 等。本次发布更新如下:
Comparison operators should not be virtual (C++, Code Smell, pitfall)
Declaration specifiers should not be redundant (C++, C, Objective-C, Bug, redundant)
Example of an issue found in the Samba source code:Exceptions should not be ignored (C++, Objective-C, Bug, cwe, error-handling, suspicious)
Example of an issue found in the MongoDB source code:Generic exceptions should never be thrown (C++, Bug, cert, cwe, error-handling)
Generic exceptions should not be caught (C++, Bug, cert, cwe, error-handling)
Non-exception types should not be caught (C++, Code Smell, error-handling)
Non-exception types should not be thrown (C++, Bug, error-handling, misra)
Partial specialization syntax should not be used for function templates (C++, Code Smell, lock-in)
Pure “virtual” functions should not override non-pure “virtual” functions (C++, Code Smell, misra, pitfall)
Example of an issue found in the Clang source code:
Indeed here is the inheritance hierarchy :class ASTConsumer { public: virtual void Initialize(ASTContext &Context) {} };
class RewriteObjC : public ASTConsumer { public: void Initialize(ASTContext &context) override = 0; };
class RewriteObjCFragileABI : public RewriteObjC { public: virtual void Initialize(ASTContext &context); };
And so the function body of
RewriteObjCFragileABI::Initialize(...)
don’t start by callingRewriteObjC::Initialize(...)
, because it’s a pure virtual function that can’t be called, and don’t either callASTConsumer::Initialize(...)
because it’s unexpected to have a pure virtual function that override one with an implementation. So now, with this design, if some initialization code is added inASTConsumer::Initialize(...)
it will not be called fromRewriteObjCFragileABI
object.String literals should not be immediately followed by macros (C++, Code Smell, cpp11, lock-in)
了解更多信息,查看发布说明:
https://jira.sonarsource.com/secure/ReleaseNote.jspa?projectId=10090&version=13324
http://www.sonarsource.com/2016/08/25/sonarqube-ccobjective-c-4-1-released/
下载: