It's SLOC plugin for Grunt.js. based on sloc
This plugin requires Grunt ~0.4.1
If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:
npm install grunt-sloc --save-devOnce the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:
grunt.loadNpmTasks('grunt-sloc');In your project's Gruntfile, add a section named sloc to the data object passed into grunt.initConfig().
grunt.initConfig({
sloc: {
options: {
// Task-specific options go here.
},
your_target: {
// Target-specific file lists and/or options go here.
},
},
})Type: String
Default value: stdout
It will generate a JSON file SLOC analysis results. The default value is stdout.
If we do not specify, in the case of the stdout, If you are prompted to enter the json and output to the CLI on the json file.
Type: String
Default value: ``
I specify the path where you output the JSON file. Create the root folder if you do not specify if.
Type: Boolean
Default value: false
I set a generous analysis. The default is false.
If true, analyze the SLOC on the basis of all the files that you have specified, when any false, it is not specified, the analyzes only the extensions that are supported if.
This configuration will count line of the input files using the default options.
grunt.initConfig({
sloc: {
files: {
'path/to/target': [ 'lib/onlyMyLib.js', 'app/**.js' ],
'path/to/others': [ '*.java', '*.coffee' ],
}
},
})result
...
Running "sloc" (sloc) task
-------------------------------
physical lines : 51
lines of source code : 29
total comment : 6
singleline : 6
multiline : 0
empty : 16
number of files read : 12
strict(or torelant) mode
-------------------------------
...
grunt.initConfig({
sloc: {
options: {
reportType: 'json',
reportPath: 'path/to/sloc-v<%= pkg.version %>.json',
},
files: {
'path/to/target': [ 'lib/onlyMyLib.js', 'app/**.js' ],
'path/to/others': [ '*.java', '*.coffee' ]
},
},
})exported file example
{
"loc": 72, //physical lines
"sloc": 45, //lines of source code
"cloc": 10, //total comment
"scloc": 10, //singleline
"mcloc": 0, //multiline
"nloc": 17, //multiline
"file": 22 //empty
}- CoffeeScript
- C / C++
- JavaScript
- Python
- Java
- PHP
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using Grunt.
- 2013-07-04 v0.4.0 Support torelant mode.
- 2013-07-03 v0.3.0 More (strict) exactly analyze
- 2013-06-30 v0.2.2 Support report to exteranl file
- 2013-06-30 v0.1.0 First release for Grunt 0.4.1.