getting started with cppdepend how to get set up and ... · getting started with cppdepend 1 how to...

10
Getting Started with CppDepend 1 How to Get Set Up and Running with CppDepend Whether you have purchased or downloaded the trial of CppDepend, we thank you for your involvement and interest in our product. Here we have compiled a quick "Getting Started" guide to help you get up and running with CppDepend as quickly as possible. While we have tried to collect the basics in this document, we urge you to experiment and explore CppDepend on your own code bases. There are a ton of features and possibilities, many of which are out of the scope of this document. CppDepend has been in development for over 9 years, and with every version we take into account user feedback and requests. For any additional help, reach out to us at [email protected], go to our User Voice to leave a suggestion. 1. How to install CppDepend Download the CppDepend zip file, Extract the CppDepend .zip file that starts the Installation Wizard, NOTE: DON'T UNZIP THE FILES IN: '%PROGRAMFILES%/CPPDEPEND' AS THIS WILL CREATE PROBLEMS BECAUSE OF WINDOWS PROTECTION Follow all steps suggested by the wizard. 2. How do I analyze my C\C++ applications using CppDepend? Run VisualCppDepend.exe from windows OS or launchVisualCppDepend.sh from Linux.

Upload: others

Post on 14-Sep-2019

6 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Getting Started with CppDepend How to Get Set Up and ... · Getting Started with CppDepend 1 How to Get Set Up and Running with CppDepend Whether you have purchased or downloaded

GettingStartedwithCppDepend

1

HowtoGetSetUpandRunningwithCppDepend

Whether you have purchased or downloaded the trial of CppDepend, wethank you for your involvement and interest in our product. Herewe havecompiledaquick"GettingStarted"guidetohelpyougetupandrunningwithCppDependasquicklyaspossible.Whilewehave tried to collect thebasics in thisdocument,weurge you toexperimentandexploreCppDependonyourowncodebases.Thereareatonof features and possibilities, many of which are out of the scope of thisdocument.CppDependhasbeenindevelopmentforover9years,andwitheveryversionwe take into account user feedback and requests. For any additional help,[email protected],gotoourUserVoicetoleaveasuggestion.

1. HowtoinstallCppDepend

• DownloadtheCppDependzipfile,• ExtracttheCppDepend.zipfilethatstartstheInstallationWizard,

NOTE:DON'TUNZIPTHEFILESIN:'%PROGRAMFILES%/CPPDEPEND'ASTHISWILLCREATEPROBLEMSBECAUSEOFWINDOWSPROTECTION

• Followallstepssuggestedbythewizard.

2. HowdoIanalyzemyC\C++applicationsusingCppDepend?

• RunVisualCppDepend.exefromwindowsOSorlaunchVisualCppDepend.shfromLinux.

Page 2: Getting Started with CppDepend How to Get Set Up and ... · Getting Started with CppDepend 1 How to Get Set Up and Running with CppDepend Whether you have purchased or downloaded

GettingStartedwithCppDepend

2

• CreateNewCppDependProject

• AddyourC/C++projects.

ThefollowingkindofprojectsaremanagedbyCppDepend:

o .vcproj,.vcxproj,.sln:VisualStudioprojects.o Qtprojects:CppDependtreatoutoftheboxtheQtprojects,

youhavejusttospecifytheqmaketoolpath.o .buildfiles:TherecommendedwaytoanalyseyourC\C++

projectsotherthantheVSones,istousetheBuildMonitortooltointerceptallcompilationandlinkcommands.

o Setofsourcefiles:YoucanusetheProjectMakertooltodescribethespecificationofyourproject.WithProjectMakeryoucanspecifyyoursourcefiles,theincludepathsandthedefines.

Page 3: Getting Started with CppDepend How to Get Set Up and ... · Getting Started with CppDepend 1 How to Get Set Up and Running with CppDepend Whether you have purchased or downloaded

GettingStartedwithCppDepend

3

• ClickF5toanalyzeyourprojects.Theanalysiswilltakeafewsecondstoafewminutesdependingonthesizeoftheprojects.

• Oncetheanalysisdone,theresultisdisplayedintheVisualCppDepend.exeUI.

3. InstallingtheCppDependaddinforVisualStudio2017,2015,2013,2012,2010

• DownloadtheCppDependinstallationzipfile• ToinstallCppDepend,justinstallthefilesinaprivateapplicationfolder

onyourmachine.Don'tinstallfilesin'%ProgramFiles%\CppDepend'.ThiswillprovokeproblemsbecauseofWindowsprotection.

• StartCppDepend.VisualStudioAddin.Installer.exeorStartVisualCppDependandinstalltheVSaddinfromthestartpage.

Page 4: Getting Started with CppDepend How to Get Set Up and ... · Getting Started with CppDepend 1 How to Get Set Up and Running with CppDepend Whether you have purchased or downloaded

GettingStartedwithCppDepend

4

• ClickthebuttonInstallfortherightVisualStudioversion

4. AnalyzingaVisualStudiosolution

• StartVisualStudioafterhavinginstalledtheCppDependaddin.• OpentheVisualStudiosolutioncontainingthecodetoanalyze.• ClickthegreyedCppDependcirclestatus(bottomrightoftheVisual

Studiowindow)ORclickthemenuCppDepend>AttachnewCppDependprojecttocurrentVisualStudiosolutionNote:

• ACppDependprojectcanbeattachedtoseveralVisualStudiosolutions.

• ThisisusefulifyouwishtoanalyzeseveralC/C++projectscompiledwithseveralVisualStudiosolutions.

• AbenefitwillbethepossibilitytonavigateacrossseveralVisualStudiosolutionsopenedinseveralVisualStudioinstances.

Page 5: Getting Started with CppDepend How to Get Set Up and ... · Getting Started with CppDepend 1 How to Get Set Up and Running with CppDepend Whether you have purchased or downloaded

GettingStartedwithCppDepend

5

• ThedialogopenedhasbeenpopulatedwiththeVisualStudiosolution.

Hereyoucanaddmoreprojectscompiledfromanothersolution

• LaunchtheCppDependanalysisstart.Itwilljusttakeafewminutesto

analyzeyourcodebaseforthefirsttime.

5. UsingCQLinqwithCppDependCQLinq isaquery languagebasedoffof theC#LINQsyntaxand isacriticalpart of CppDepend which uses CQLinq queries to assess a code base and,furthermore, it allows users to create their own code queries. This allowsarchitects and developers to custom make code rules to test for custommetrics.UsingCQLinq,thereisvirtuallynometricyoucan'ttest.

Page 6: Getting Started with CppDepend How to Get Set Up and ... · Getting Started with CppDepend 1 How to Get Set Up and Running with CppDepend Whether you have purchased or downloaded

GettingStartedwithCppDepend

6

CppDepend itself comes with 200 ready-made code queries that you canimmediatelyuseonyourcodebase.Whenyouruntheanalysisonyourcode,youwillseesomecolorfeedbackonthequality. Yellowand redhighlighted lines of code showyouwhere rulesarebeingbroken,withredbeingmoreseverebreaches.FurtherinformationonCQLinqcanbefoundontheCppDependwebsite.

6. UsingCppDependforReports

ReportscanbecustomizedthroughtheVisualCppDependor theVSaddin>ProjectProperties>Reportsub-panel.Youcanchoosetoactivatemanypre-defined sections like Application and Assembliesmetrics, diagrams, CQLinqrulesviolations,andmore.Thegeneratedreportsarein.htmlformatandarefoundinthefolderCppDependReportFiles.Anyreportsshouldautomaticallyopeninyourbrowser.

Page 7: Getting Started with CppDepend How to Get Set Up and ... · Getting Started with CppDepend 1 How to Get Set Up and Running with CppDepend Whether you have purchased or downloaded

GettingStartedwithCppDepend

7

Inaddition,thereportswillgiveasummaryofallthemainrulesviolations.Tocustomizewhichviolationsyouwantincludedinthereport,youcancheckorunchecktheboxnexttoeachoneaswellaschoosehowtheviolationwillbedisplayed in the report. You can also set which rules are to be consideredcritical.Note: It is recommended to uncheck the Type Metrics and TypeDependencieswhengeneratingreportsoncodebasescontainingmorethanathousandtypes.Thiswillcausethegeneratedreporttobeverylarge.Itisrecommended that you use the Interactive UI to browse metrics anddependenciesinstead.

Page 8: Getting Started with CppDepend How to Get Set Up and ... · Getting Started with CppDepend 1 How to Get Set Up and Running with CppDepend Whether you have purchased or downloaded

GettingStartedwithCppDepend

8

Hereiswhatthecoderuleviolationpartofthereportlookslike:

Youcanclearlyseetherulesontheleft,alongwithhowmanyviolationswerefound (in yellow and red). Clicking on a code rule on the left, gives youadditionalinformationabouttheviolationsintheinformationwindowontheright.TheDSM isagridofcoloredcellswithnumbers insideof them.Eachcolor,blue,green,andblack,meanadifferentthingandaredefinedviaacontextsensitivehelpsystemwhenhoveredoverwithyourmousecursor.Ifthecellhas a number, this is the number of couplings between the objects in thesamerowandcolumn.Byclickingonacell,youwillseeadependencygraphofthatobject.

7. CppDepend’sDependencyMatrixTheDSM(DependencyStructureMatrix)allowsuserstoquicklygetabroadoverview of the dependencies and couplings that exists within their codebaseanddisplaysstructuralpatternsataglance.It isdifferentfromagraphsince we found that a simple dependency graph does not scale well withlarger assemblies of code. Graphs are very good at displaying informationaboutsmallercodebasesbutgetconfusingthebiggerthebaseis.

Page 9: Getting Started with CppDepend How to Get Set Up and ... · Getting Started with CppDepend 1 How to Get Set Up and Running with CppDepend Whether you have purchased or downloaded

GettingStartedwithCppDepend

9

8. WhatdoestheCppDependreporttellmeaboutmycode?

• ApplicationMetric:Thissectiongivesyouanideaofthetopologyofyourapplication.

• ProjectMetric:Thissectiongivesyouanideaofthesizeofeachprojectwithinyourapplicationintermsofcodelineandothersmetrics.

• VisualCppDependView:Thissectionillustratesthesizeofyourprojects,namespaces,typesandmethodsintermsofcodeline.YoucanbrowsethisviewdynamicallybyclickingtheLaunchVisualCppDependonthisProjecticonintheCppDepend.ProjectUI.

• ProjectAbstracnessvs.Instability:ThissectionillustratetheAbstracness/Instabilityprincipleexplainedintheprojectsmetricssection.

• ProjectDependencies:Thissectionshowsalldependenciesbetweenprojectofyourapplicationinatable.

• ProjectDependencyDiagram:Thissectionshowsalldependenciesbetweenprojectsofyourapplicationinadiagram

• Projectbuildorder:Thissectiongivesyouoneofthepossiblebuildorderforyourprojects.Ifacycleexistsinyourprojectsdependenciesgraph,thissectionwillreportit.

Page 10: Getting Started with CppDepend How to Get Set Up and ... · Getting Started with CppDepend 1 How to Get Set Up and Running with CppDepend Whether you have purchased or downloaded

GettingStartedwithCppDepend

10

• CppDependInformationandWarnings:Thissectiongivesyoufeedbackonyourcode:

o Itwarnsyouwhenaprojectdependsonalessstableprojectthanitself.

o Itwarnsyouwhenthevisibilityofatypeorofamemberisnotoptimal(inthecontextoftheanalyzedapplication).

o Itwarnsyouwhenatypeoramemberisnotused(inthecontextoftheanalyzedapplication).

• CQLinqQueriesandConstraints:ThissectionreportsdefaultCQLinqconstraintswhichhavebeenviolated.MoreabouttheCQLinqlanguageandCQLconstraintshere.YoucanbuildyourownCQLinqconstraintswithVisualCppDepend.

• TypeMetrics:Thissectionrecapstypemetricsinatable.Alinktothedocumentationisprovidedforeachmetric.

9. Iwanttogofurthertohaveabettercontrolovermycode

• UnderstandmetricsyieldedbyCppDependandreadrecommendations.

• GetanewunderstandingofyourcodebyplayingwiththeCppDependpanels.ModifytheviewwiththeLevelandMetriccomboboxes.

• TuneyourreportthankstotheOutputpanelintheCppDepend.ProjectUI.

• LearnCQLinq,adaptexistingCQLinqcoderulesandcreateyourownones.

• IntegratetheCppDependreportinyourdailybuildprocess.

FurtherInformationCanbeFoundOnOurWebsite

http://www.cppdepend.com