Skip to content

Tallmaris/ccm

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CCM

Overview

CCM is a tool that analyzes c, c++, c#, javascript and TypeScript code and reports back with cyclomatic complexity metric.

There are two parts included with the installer:

  • CCM.exe; a command line executable that will analyze code bases and report back with cyclomatic complexity metrics.
  • vsCCM; a Visual Studio 2008, 2010 and 2012 add-in that will add a new toolbar for integrating CCM with Visual Studio.

Command line usage

To CCM.exe, simply use one of the two modes for invocation:

  • CCM.exe <path-to-config-file>
  • CCM.exe <folder-path-to-analyze> [/xml] [/ignorecases] [v]

Arguments

   <path-to-config-file>    Path to configuration file. See structure of file below. 
                            This option gives the best control over how ccm behaves.
   <folder-path-to-analyze> Path to directory which ccm will analyze.
   /xml                     Output results as XML (this parameter only valid if a config file is not passed in).
   /ignorecases             Don't count each case in switch block as a branching point (only valid if config file is not passed in).
   /v                       Print the version number of ccm.exe.

Configuration file

Below is an example of a configuration file.

 <ccm>
    <exclude>
     <file>myfile.cpp</file>
     <folder>myfolder</folder>
    </exclude>
    <analyze>
      <folder>..\..\code</folder>
   </analyze>
   <recursive>yes</recursive>
   <outputter>XML</outputter>
   <suppressMethodSignatures>yes</suppressMethodSignatures>
   <switchStatementBehavior>IgnoreCases</switchStatementBehavior>
   <numMetrics>30</numMetrics>
   <fileExtensions>
     <fileExtension>.cxx</fileExtension>
   </fileExtensions>
 </ccm>
  • <exclude> element can be used to exclude files and/or folders from analysis.
  • <analyze> element specified which folders to analyze. All paths in the <folder> element is relative to the location of the configuration file.
  • <recursive> element tells CCM to traverse folders or not.
  • <outputter> element tells CCM how to output the data. Valid values are 'XML', 'Tabbed', 'Text'.
  • <suppressMethodSignatures> set to 'yes' and CCM will only print the name of the method and not the full signature.
  • <switchStatementBehavior> set to 'IgnoreCases' and CCM will not count each case statement in switch blocks as a branching point.
  • <numMetrics> tells CCM how many metrics that should be reported. Only the top x functions will be reported.
  • <fileExtensions> can be used to add additional file extensions for analysis. Per default, these are included: .h, .cpp, .c, .hpp, .cs, .js and .ts

Example output

Below is example output from the Text outputter (can be contolled in the <outputter> element in the config file).

Driver::HandleDirectory(string basePath,string path) : 7 - simple, without much risk (\Driver.cs@line 141)
Driver::IsValidFile(string filename) : 6 - simple, without much risk (\Driver.cs@line 84)
Program::CreateConfigurationFromArgs(string [ ] args) : 6 - simple, without much risk (\Program.cs@line 71)
Driver::PathShouldBeExcluded(string path) : 5 - simple, without much risk (\Driver.cs@line 109)
XmlOutputter::Output(List<ccMetric>metrics,List<ErrorInfo>errors,bool verbose) : 5 - simple, without much risk (\XmlOutputter.cs@line 17)
ConsoleOutputter::Output(List<ccMetric>metrics,List<ErrorInfo>errors,bool verbose) : 4 - simple, without much risk (\ConsoleOutputter.cs@line 12)
Driver::AnalyzeFilestream(object context) : 4 - simple, without much risk (\Driver.cs@line 47)
TabbedOutputter::Output(List<ccMetric>metrics,List<ErrorInfo>errors,bool verbose) : 4 - simple, without much risk (\TabbedOutputter.cs@line 12)
Program::OutputterFactory(string outputType) : 3 - simple, without much risk (\Program.cs@line 60)
Program::ValidateArgs(string [ ] args) : 2 - simple, without much risk (\Program.cs@line 15)
Program::LoadConfiguration(string [ ] args) : 2 - simple, without much risk (\Program.cs@line 97)
Program::Main(string [ ] args) : 2 - simple, without much risk (\Program.cs@line 122)

Platforms

CCM is built in C#, targetting .NET 3.5 and as such runs on Windows. The commandline version, CCM.exe, can run on Linux distributions using the mono framework (http://www.monoproject.org).

Building the code

To build installer, follow these steps:

  1. Open ccm.sln in Visual Studio 2012
  2. Build release
  3. Run unit tests (optional)
  4. Right click on install\setup.nsi and choose 'Compile NSIS Script'
  5. vsCCM.exe installer is now available in the install folder.

NOTE that you need NSIS (http://nsis.sourceforge.net) to be able to build the installer.

About

Compute code complexity for c, c++, c#, javascript, typescript.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C# 70.8%
  • C++ 18.9%
  • Smalltalk 6.2%
  • C 1.5%
  • NSIS 1.1%
  • Batchfile 1.0%
  • Other 0.5%