GithubHelp home page GithubHelp logo

jarod42 / ccccc Goto Github PK

View Code? Open in Web Editor NEW
7.0 3.0 4.0 134.38 MB

C and C++ Code Counter using Clang. Tool which reports some metrics like LOC (line of code), Mc Cabe Cyclomatic Number or Halstead metrics.

License: GNU General Public License v3.0

JavaScript 28.70% Lua 2.42% C++ 62.01% C 1.02% CSS 0.47% Smarty 5.37%
c-plus-plus code-metrics

ccccc's Introduction

Ubuntu badge Msys2 badge


CCCCC stands for C and C++ Code Counter using Clang.

Similar to CCCC, CCCCC is a tool which analyzes C/C++ files and generates a report on various metrics of the code. Metrics supported include lines of code, McCabe's Cyclomatic Complexity, Halstead metrics.

Those metrics can help to identify complex code which might need refactoring.


Basic Usage

ccccc myProject/compile_commands.json > output.html ccccc -I IncludeDir srcFiles > output.html

It will create a report in output.html with each function and associated statistics.

It outputs in stderr some extra information about progress or parsing issues (most of them might be ignored, unknown types (due to missing include path) would be replaced by int)

Command arguments

ccccc [-D define] [-I include-path] [-pch pch-file] [-e extra_options] [-t template-file] files...

  • -D, --define=name Predefine name as a macro, with definition.
  • -I, --include-dir=dir Add the directory dir to the list of directories to be searched for header files.
  • -pch Compiled header path
  • -e, --extra-option=option Extra option directly given to the clang parser (as -e "-std=c++17").
  • -t, --template-file=file Template file to use for report. (default is template/html/template.tpl)
  • files... List of source files to examine or directly compile_commands.json (all files in that file would be examined)

CCCCC supports response file, i.e. @my_response_file in command line. Content of the response file is the command line arguments optionally split by line.


Example

That is the result applied on ccccc src files:

CCCCC report


Build Dependencies

  • LLVM/Clang
  • mstch (included)
  • doctest (for unit tests) (included (header-only))

ccccc's People

Contributors

jarod42 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

ccccc's Issues

The feature request for getting metric statistics data of the user include file

Hi,
Thank you for your work. I think high of this project. I like it.
But I have a requirement to get the metric statistics data for all of the user source files which includes header files included within source files. I think many of the statistics would not like to lost header files. Of course, it should not consider system header files, only user include files.
How do you think of that?

Build instructions

After trial and error I was able to build the project. It would be good to have build instructions.

So far I have been able to build a docker container ๐Ÿ‘

FROM debian:bookworm-slim
RUN apt-get update
RUN apt-get install make git wget gcc g++ -y
ENV LLVM_VERSION 15
RUN apt-get install gnupg software-properties-common -y
RUN wget -nv https://apt.llvm.org/llvm.sh && \
    chmod +x llvm.sh && \
    ./llvm.sh $LLVM_VERSION && rm -rf llvm.sh
RUN apt-get install clang-15 libclang-15-dev llvm-15-dev llvm-15-runtime llvm-15 -y

#CCCCC
ENV CCCCC_VER f2520dc635c5d232a0f76426c1d525497ab37f22
ENV PREMAKE_VER 2a3f3b75ec97209f0a93368711485d81c4796310
RUN apt-get install libunittest++ \
                    autoconf \
                    libtool \
                    libtinfo-dev \
                    uuid-dev \
                    libctemplate-dev -y
RUN cd /tmp/ && \
    git clone https://github.com/premake/premake-core && \
    cd premake-core && git checkout $PREMAKE_VER && \
    make -f Bootstrap.mak linux CONFIG=release && \
    cp bin/release/premake5 /usr/bin && cd .. && rm -rf premake-core
RUN cd /tmp/ && \
    git clone https://github.com/Jarod42/ccccc && \
    cd ccccc && git checkout $CCCC_VER && \
    premake5 --file="premake/premake5.lua" --llvm-root="/usr/lib/llvm-${LLVM_VERSION}" gmake && \
    cd project/gmake && make config=release verbose=1 && \
    cd ../../bin/gmake/Release && ./ccccc_test && \
    mv ccccc /usr/bin/ && cd .. && rm -rf ccccc

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.