Git Product home page Git Product logo

o2codechecker's Introduction

O2CodeChecker

A prototype for a standalone code checker for the AliceO2 project

It offers:

  • code checks based on clang-tidy and existing components
  • standalone CMake infrastructure for compilation outside of llvm/clang source tree

Requirements/Building

  • llvm + clang + clang extra tools (release 3_9) required
    • (recommended to use alibuild build clang which will give you the right version)
  • build using cmake -DLLVM_DIR=PATH_TO_LLVM_CMAKE_CONFIG -DClang_DIR=PATH_TO_CLANG_CONFIG

Usage

In the build directory of AliceO2 (containing the CMake compilations database in form of compile_command.json), run

run_O2CodeChecker.py -clang-tidy-binary `which O2codecheck` -checks=*,alice*

o2codechecker's People

Contributors

anerokhi avatar davidrohr avatar dberzano avatar ktf avatar pzhristov avatar sawenzel avatar zdravkod avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

o2codechecker's Issues

Anonymous namespaces opening bracket removed after using -fix

I tried running run_O2CodeChecker.py with the -fix option on the ReadoutCard library (master branch).
This resulted in anonymous namespaces being broken by having their opening bracket removed.
For example, code like:

namespace {
 // some stuff in here
}

is turned into:

namespace
 // some stuff in here
}

The command I used was

run_O2CodeChecker.py -clang-tidy-binary `which O2codecheck` -checks=-*,modernize-*,-modernize-use-default,-modernize-pass-by-value,-modernize-use-auto,-modernize-use-bool-literals,-modernize-use-using,-modernize-loop-convert,-modernize-use-bool-literals,-modernize-make-unique,aliceO2-member-name,alice* -fix

Verbosity of the tool

Hi,

Just trying to get my feet wet with the o2codechecker ...

At first I'd like to use it on a single file/class where I've put on purpose a member name starting with "f' instead of "m", and I find the output of the tool quite verbose. Is there a way to tame the verbosity and get the output more "to the point" ? Or is it that the command I'm using is not correct ?

Thanks,

[o2codechecker/latest-release] ~/alice/o2-dev/alo/mapping/impl2 %> run_O2CodeChecker.py -clang-tidy-binary $(which O2codecheck) -p $HOME/alice/sw/BUILD/alo-latest-clion/alo "-checks=-*,alice*" segmentationImpl2.*
['/Users/laurent/alice/sw/osx_x86-64/o2codechecker/master-2/bin/O2codecheck', '-list-checks']
Enabled checks:
    aliceO2-SizeOf
    aliceO2-member-name
    aliceO2-namespace-naming


/Users/laurent/alice/sw/osx_x86-64/o2codechecker/master-2/bin/O2codecheck -header-filter=^/Users/laurent/alice/sw/BUILD/alo-latest-clion/alo/.* -checks=-*,alice* -p=/Users/laurent/alice/sw/BUILD/alo-latest-clion/alo /Users/laurent/alice/o2-dev/alo/mapping/impl2/segmentationImpl2.cxx
/Users/laurent/alice/sw/osx_x86-64/o2codechecker/master-2/bin/O2codecheck -header-filter=^/Users/laurent/alice/sw/BUILD/alo-latest-clion/alo/.* -checks=-*,alice* -p=/Users/laurent/alice/sw/BUILD/alo-latest-clion/alo /Users/laurent/alice/o2-dev/alo/mapping/impl2/segmentationImpl2.cxx
229 warnings and 1 error generated.
Error while processing /Users/laurent/alice/o2-dev/alo/mapping/impl2/segmentationImpl2.cxx.
229 warnings and 1 error generated.
Error while processing /Users/laurent/alice/o2-dev/alo/mapping/impl2/segmentationImpl2.cxx.
458 warnings and 2 errors generated.
Error while processing /Users/laurent/alice/o2-dev/alo/mapping/impl2/segmentationImpl2.cxx.
/Users/laurent/alice/o2-dev/alo/mapping/impl2/segmentationImpl2.h:84:9: error: field declaration 'fWrong' does not match naming rule [aliceO2-member-name]
    int fWrong;
        ^
        mWrong
/Users/laurent/alice/o2-dev/alo/mapping/impl2/segmentationImpl2.h:84:9: error: field declaration 'fWrong' does not match naming rule [aliceO2-member-name]
    int fWrong;
        ^
        mWrong
Suppressed 458 warnings (458 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
458 warnings and 2 errors generated.
Error while processing /Users/laurent/alice/o2-dev/alo/mapping/impl2/segmentationImpl2.cxx.
/Users/laurent/alice/o2-dev/alo/mapping/impl2/segmentationImpl2.h:84:9: error: field declaration 'fWrong' does not match naming rule [aliceO2-member-name]
    int fWrong;
        ^
        mWrong
/Users/laurent/alice/o2-dev/alo/mapping/impl2/segmentationImpl2.h:84:9: error: field declaration 'fWrong' does not match naming rule [aliceO2-member-name]
    int fWrong;
        ^
        mWrong
Suppressed 458 warnings (458 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.

Why can't I see custom rules in the compiled product?

Problem

I can't see custom rules aliceO2-member-name in the compiled product.

# ./tool/O2codecheck -checks="-*,al*" --list-checks
Enabled checks:
    altera-id-dependent-backward-branch
    altera-kernel-name-restriction
    altera-single-work-item-barrier
    altera-struct-pack-align
    altera-unroll-loops

Reproduction

  1. set env
export LLVM_HOME=/path/to/clang+llvm-13.0.1-x86_64-linux-gnu-ubuntu-18.04
export CMAKE_HOME=/path/to/cmake-3.28.0-rc3
export GCC_HOME=/path/to/gcc-9.1.0/
export CC=$GCC_HOME/bin/gcc
export CXX=$GCC_HOME/bin/g++
export LD_LIBRARY_PATH=$LLVM_HOME/lib:$GCC_HOME/lib64:$LD_LIBRARY_PATH
export PATH=$GCC_HOME/bin:$CMAKE_HOME/bin/:$PATH
  1. build O2CodeChecker v13.0
mkdir build
cd build/
cmake -DLLVM_DIR=$LLVM_HOME/lib/cmake/llvm -DClang_DIR=$LLVM_HOME/lib/cmake/clang/ ../
make -j8
  1. run
cd build
./tool/O2codecheck -checks="-*,al*" --list-checks

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.