• Stars
    star
    694
  • Rank 65,170 (Top 2 %)
  • Language
    Python
  • License
    Apache License 2.0
  • Created over 11 years ago
  • Updated over 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Finds problems in C++ source that slow development of large code bases

cppclean

Build status

Goal

cppclean attempts to find problems in C++ source that slow development in large code bases, for example various forms of unused code. Unused code can be unused functions, methods, data members, types, etc to unnecessary #include directives. Unnecessary #includes can cause considerable extra compiles increasing the edit-compile-run cycle.

This is a fork of the original cppclean project. The original project home page, which no longer contains code, is at https://code.google.com/p/cppclean/.

Features

cppclean finds the following:

  • Classes with virtual methods, no virtual destructor, and no bases
  • Global/static data that are potential problems when using threads
  • Functions that are declared but not defined
  • Unnecessary forward class declarations
  • Unnecessary function declarations
  • Undeclared function definitions
  • Unnecessary #includes in header files
    • No direct reference to anything in the header
    • Header is unnecessary if classes were forward declared instead
  • Inconsistent case in #includes (foo.h versus Foo.h)
  • (planned) Unnecessary #includes in source files
  • (planned) Source files that reference headers not directly #included, ie, files that rely on a transitive #include from another header
  • (planned) Unused members (private, protected, & public) methods and data
  • (planned) using namespace std in header files
  • (planned) Methods that are declared but not defined

AST is Abstract Syntax Tree, a representation of parsed source code (https://en.wikipedia.org/wiki/Abstract_syntax_tree).

Installation

$ pip install --upgrade cppclean

Run

$ cppclean <path>

Multiple include paths can be specified:

$ cppclean --include-path=directory1 --include-path=directory2 <path>

Current status

The parser works pretty well for header files, parsing about 99% of Google's header files. Anything which inspects structure of C++ source files should work reasonably well. Function bodies are not transformed to an AST, but left as tokens.

Non-goals

  • Parsing all valid C++ source
  • Handling invalid C++ source gracefully
  • Compiling to machine code (or anything beyond an AST)

Links

More Repositories

1

language-check

Python wrapper for LanguageTool grammar checker
Python
326
star
2

perceptualdiff

A program that compares two images using a perceptually based image metric
C++
161
star
3

pyformat

Formats Python code to follow a consistent style
Python
94
star
4

unify

Modifies strings to all use the same quote where possible
Python
94
star
5

scspell

Spell checker for source code
Python
88
star
6

syntastic-extras

Additional Syntastic syntax checkers and features (for Vim)
Vim Script
29
star
7

vulture

Obsolete fork; instead see https://github.com/jendrikseipp/vulture
Python
27
star
8

cronometer

Nutrition tracker; fork of the old Java-based Cronometer with better macOS support and newer USDA database
Java
26
star
9

optparse

C++ implementation of optparse (header-only fork of https://github.com/weisslj/cpp-optparse)
C++
25
star
10

pyfuzz

Random program generator for Python
Python
10
star
11

pydiff

Diffs Python code at the bytecode level
Python
10
star
12

untokenize

Transforms tokens into original source code (while preserving whitespace)
Python
9
star
13

indent-finder

Vim plugin for detecting indentation of source code (fork of IndentFinder with Python 2 and 3 support)
C
8
star
14

pen

Unofficial fork of the pen TCP/UDP load balancer (and reverse proxy) tool
C
7
star
15

cram

Testing framework for command-line applications
Python
7
star
16

image-view

Displays images (PNM, PNG, JPEG, etc.) conveniently from the terminal
Python
6
star
17

pygame

Fork of pygame without X11 crud on OS X
C
4
star
18

unreferenced

Reports unreferenced files (as candidates for removal)
Python
4
star
19

trim

Trims trailing whitespace from files
Python
3
star
20

docgrep

Like grep, but only searches through docstrings (in Python files)
Python
3
star
21

move

Moves revision-controlled files interactively in an editor
Python
3
star
22

rst2pptx

Converts reStructuredText to PowerPoint
Python
2
star