项目作者: kashav

项目描述 :
Determine if a C/C++ codebase prefers commas or semicolons for variable declarations.
高级语言: Rust
项目地址: git://github.com/kashav/vardecl.git
创建时间: 2018-07-15T17:13:50Z
项目社区:https://github.com/kashav/vardecl

开源协议:MIT License

下载


vardecl

Determine if a C/C++ codebase prefers commas or semicolons for variable declarations.

vardecl statically analyzes your C/C++ source files to determine the preferred method of declaring new variables.

Demo

asciicast

Install

Prerequisites

To build vardecl, you’ll need Rust and Clang (for libclang).

via Cargo
  1. $ cargo install --git https://github.com/kshvmdn/vardecl.git
Build manually
  1. $ git clone https://github.com/kshvmdn/vardecl.git
  2. $ cd vardecl
  3. $ cargo build --release
  4. $ mv ./target/release/vardecl ~/.cargo/bin

Usage

vardecl expects one or more files as input.

  1. $ vardecl /path/to/file ...

Examples

  1. $ cat main.c
  2. void f() {
  3. int a, b = 2;
  4. int c;
  5. int d;
  6. int e; int f = 1;
  7. char *g,
  8. h,
  9. i = 'a';
  10. }
  11. $ vardecl main.c
  12. comma-delimited decls : 3
  13. semicolon-delimited decls : 3

The example should be self-explanatory: there are three pairs of comma-delimited declarations (int a, b;, char *g, h;, char h, i;) and three pairs of semicolon-delimited declarations (int c; int d;, int d; int e;, int e; int f;).

Contribute

This project is completely open source, feel free to open an issue or submit a pull request.

I’m also quite new to Rust, so I’d love any feedback.