A C + + static analysis tool--cppdepend__c++

Source: Internet
Author: User

Wrote by Mutouyun. (http://darkc.at/cppdepend/)

Last June, a technical community manager at Cppdepend (Technical community manager) Suddenly e-mailed me, gave me a license, and invited me to experience their C + + static analysis tool, Cppdepend.

On the official website of the software, we can see what we can do with Cppdepend:
1. Improve code quality by 2. You can use CQLINQ to automate review code 3. Help us with the code refactoring.

Nonsense not to say, I directly use it on my own project capo (HTTPS://GITHUB.COM/MUTOUYUN/CAPO) do a simple static analysis, to intuitively feel the cppdepend function.

First, we open the Cppdepend main interface (run VisualCppDepend.exe) and create a new project:

Then give the new item a good name in the pop-up dialog box, then select OK:

At this point, there is no analysis data in the project just opened, we need to assign it a project first. Profiling data can be created directly from the project file in Visual Studio.

It can support a full range of project files from VC6 to VS2013.
After importing the item, we click on the "Run" button in the upper-left corner to perform a static analysis and generate a report:

The button on the left is only static analysis, and the button on the right will automatically generate a report.
It should be noted that Cppdepend is based on clang, as we normally compile C + + code, only the actual effect of the CPP file will participate in the analysis of the code.

At the end of the analysis, we can see Cppdepend's report for valid code.
Any data on the right of the image above, and the index on the lower right are editable. For example, we can select the code Quality-> Methods with too many the local variables, which is displayed as follows:

Notice the small window in the upper-left corner of the interface, where the CQLINQ is the detection code for this metric:[Plain]  View Plain  copy  // <name>methods with too many local  variables</name>   warnif count > 0 from m in  justmycode.methods where      m.NbVariables > 15      orderby m.NbVariables descending   select new { m, m. nbvariables }      // methods where nbvariables > 8  are hard to understand and maintain.  // methods where  NbVariables > 15 are extremely complex   // and  should be split in smaller methods.  // see the definition  of the Nbvariables metric here   // <a target=_blank  href= "http://www.cppdepend.com/metrics.aspx#nbvariables ">http://www.cppdepend.com/Metrics.aspx#Nbvariables</a>  

That is, when the number of local variable in a method is greater than 15 o'clock, a rule variables of "Methods with too many local violate" is given. The comments also explain why the rule is to limit the number to more than 15.

In addition to the content described above, Cppdepend also has a very good feature of automatically generating dependency graphs (Dependency graph) and dependency matrices (Dependency matrix).
More detailed features can be accessed directly from the official website (http://www.cppdepend.com/GettingStarted.aspx) to obtain relevant help documentation.

In addition to the interface with some small graphics bugs, and graph in the mouse wheel and pointer support is not convenient, other experience is good.
In the actual project, the use of cppdepend with its powerful CQLINQ customization function, can be easily automated inspection project code specifications, but also can give a variety of specific performance indicators, is indeed a very practical tool.

Wrote by Mutouyun. (http://darkc.at/cppdepend/)

Reproduced from: http://blog.csdn.net/markl22222/article/details/43989609

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.