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

Post on 14-Sep-2019

6 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

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,reachouttousatsupport@cppdepend.com,gotoourUserVoicetoleaveasuggestion.

1. HowtoinstallCppDepend

• DownloadtheCppDependzipfile,• ExtracttheCppDepend.zipfilethatstartstheInstallationWizard,

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

• Followallstepssuggestedbythewizard.

2. HowdoIanalyzemyC\C++applicationsusingCppDepend?

• RunVisualCppDepend.exefromwindowsOSorlaunchVisualCppDepend.shfromLinux.

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.

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.

GettingStartedwithCppDepend

4

• ClickthebuttonInstallfortherightVisualStudioversion

4. AnalyzingaVisualStudiosolution

• StartVisualStudioafterhavinginstalledtheCppDependaddin.• OpentheVisualStudiosolutioncontainingthecodetoanalyze.• ClickthegreyedCppDependcirclestatus(bottomrightoftheVisual

Studiowindow)ORclickthemenuCppDepend>AttachnewCppDependprojecttocurrentVisualStudiosolutionNote:

• ACppDependprojectcanbeattachedtoseveralVisualStudiosolutions.

• ThisisusefulifyouwishtoanalyzeseveralC/C++projectscompiledwithseveralVisualStudiosolutions.

• AbenefitwillbethepossibilitytonavigateacrossseveralVisualStudiosolutionsopenedinseveralVisualStudioinstances.

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.

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.

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.

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.

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.

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

top related