GithubHelp home page GithubHelp logo

cppstyle's Introduction

cppstyle

Automatically fix C++ code to comply to a standard style.

Usage

cppstyle [dir] [-e list of files or dirs to exclude]

Requirement

  • clang-format (at least 3.8)
  • cppstyle, cleanup.sh and cleansrc.sh must be installed in a directory within $PATH.

Rationale

Is messy code giving you a headache? Tired of reformatting code manually? Do you want the style of your code to be consistent?

Look no further! Simply run cppstyle on the root of your project and it will clean it up for you.

Goals

  • Readability
  • Consistency
  • Avoid pitfalls that may lead to bugs

I am an avid fan of the coding style based on K&R, and for years I have formatted my code based on that style. However, in the interest of the above goals, this standard set was conceived. I have spent a lot of time researching, comparing, rationalizing the different ideas and philosophies as to why certain coding styles are recommended. You don't have to waste anymore time and crack your brains out to understand the whys. Simply use this standard and you're done.

Would it cause problems with git diff or your favorite version control system?

Follow these steps to avoid diff issues:

  1. Do a clean checkout
  2. Run cleanup.sh on that fresh checkout
  3. Stage the changes (e.g. git add)
  4. Build
  5. Commit

You only have to do this once or every once in a while when you feel that your code is no longer consistent. Don't include any other changes to the code before committing to ensure that only the code formatting is updated. If you have checked-out code that you have been working on prior to the cleanup, simply run cleansrc.sh file.cpp before you check it in to avoid diff problems.

Note: For source code that has templates, compiling that code based on this standard requires at least a C++11 compiler.

cppstyle's People

Contributors

jhonjun avatar

Stargazers

 avatar

Watchers

 avatar

cppstyle's Issues

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.