Giter Site home page Giter Site logo

node-cpplint's Introduction

node-cpplint

Validates CPP files with Google's cpplint

Usage

This module has been built for usage with Node scripts, to run from the command line, and to be used as a Grunt task.

Options

All methods of using this module allow for four specific configuration options:

  • reporter The reporter to use ( spec | json | plain-text ); defaults to spec.
  • counting The counting-type ( total | toplevel | detailed ); defaults to total. The total number of errors found is always printed. If toplevel is provided, then the count of errors in each of the top-level categories like build and whitespace will also be printed. If detailed is provided, then a count is provided for each category like build/class.
  • verbose The verbosity level; defaults to 1. A number 0-5 to restrict errors to certain verbosity levels.
  • filters Enable/disable filtering for specific errors.

A list of files is also expected.

CLI usage

Using the spec reporter, disabling whitespace/braces errors and linting file1.

bin/cpplint --reporter spec --filter whitespace-braces file1

Setting verbosity to 3 and the counting-type to detailed while linting file1 and file2.

bin/cpplint --verbose 3 --counting detailed file2 file3

Using the plain-text reporter, ignoring build/deprecated errors and linting file1.

bin/cpplint --filter build-deprecated --reporter plain-text

JavaScript usage

Using the spec reporter

var cpplint = require('lib/index.js');
var reporter = require('lib/reporters').spec;
var options = {
	files: [
		'/path/to/some/files.cc'
	]
};

cpplint(options, reporter);

Using a custom reporter, disabling whitespace/braces and enabling whitespace/include_alpha

var cpplint = require('lib/index');
var options = {
	files: [
		'/path/to/some/files.cc'
	],
	filters: {
		'whitespace': {
			'braces': false,
			'include_alpha': true
		}
	}
};

cpplint(options, function (err, report) {
	// your reporting logic
});

Grunt Task

grunt.loadNpmTasks('node-cpplint');

grunt.initConfig({
	cpplint: {
		files: [
			'src/**/*.cc',
			'src/**/*.cpp'
		],
		reporter: 'spec',
		verbosity: 1
	},
	filters: {
		'whitespace': {
			'braces': false,
			'include_alpha': true
		}
	}
});

TODO

Future plans (in no perticular order):

  • better test coverage
  • xunit-xml reporter

Contributing

In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests (using vows) for any new or changed functionality. Lint and test your code using grunt jslint and verify that all unit tests are passing with grunt vows.

Revision History

0.1.2

  • added support for ignoring certain errors (filters)

0.1.1

  • added simple grunt task

0.1.0

  • first public version
  • provides a few simple options for validating CPP files

node-cpplint's People

Contributors

stephenmathieson avatar kkohtaka avatar

Watchers

James Cloos avatar  avatar

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.