All Projects → flosse → Sloc

flosse / Sloc

Licence: mit
simple tool to count SLOC (source lines of code)

Programming Languages

javascript
184084 projects - #8 most used programming language
coffeescript
4710 projects

Projects that are alternatives of or similar to Sloc

Rdfgrid
[Unmaintained] RDFgrid is a framework for batch-processing RDF data with Hadoop and Amazon Elastic MapReduce.
Stars: ✭ 16 (-98.1%)
Mutual labels:  unmaintained
Docker Go Graphite
Docker image for go-carbon + carbonapi + grafana
Stars: ✭ 23 (-97.27%)
Mutual labels:  metrics
Postgresql exporter
A Prometheus exporter for some postgresql metrics
Stars: ✭ 26 (-96.91%)
Mutual labels:  metrics
Tools
various simple tools, not worth a project on their own
Stars: ✭ 17 (-97.98%)
Mutual labels:  unmaintained
Divergence Meter
Divergence Meter is an application based on Steins;Gate. Unmaintained, feel free to contribute
Stars: ✭ 18 (-97.86%)
Mutual labels:  unmaintained
Itunescontrol
[Unmaintained] Global Hotkeys for iTunes
Stars: ✭ 23 (-97.27%)
Mutual labels:  unmaintained
Open Source Projects
A collection of my personal Programming Projects
Stars: ✭ 16 (-98.1%)
Mutual labels:  source-code
D4s
Dynamo DB Database Done Scala-way
Stars: ✭ 27 (-96.79%)
Mutual labels:  metrics
Django Source
django 源码剖析
Stars: ✭ 20 (-97.62%)
Mutual labels:  source-code
Gin Stats
Gin's middleware for request stats
Stars: ✭ 24 (-97.15%)
Mutual labels:  metrics
Effrit
Go Efferent and Afferent package metric calculator.
Stars: ✭ 18 (-97.86%)
Mutual labels:  metrics
Wobserver
Web based metrics, monitoring, and observer
Stars: ✭ 900 (+7.02%)
Mutual labels:  metrics
Logmonitor
Monitoring log files on windows systems.
Stars: ✭ 23 (-97.27%)
Mutual labels:  metrics
Instabiosquotes
Completely FREE Instagram Bio and Quotes Android App with latest collection of Instagram Bio and Instagram quotes for setting as your status.
Stars: ✭ 17 (-97.98%)
Mutual labels:  source-code
Json Exporter
Prometheus exporter which fetches JSON from a URL and exports one of the values as gauge metrics
Stars: ✭ 26 (-96.91%)
Mutual labels:  metrics
Graylog Plugin Metrics
Graylog output plugin for Graphite and Ganglia
Stars: ✭ 16 (-98.1%)
Mutual labels:  metrics
Ufodiff
UFO source file diff application
Stars: ✭ 23 (-97.27%)
Mutual labels:  source-code
Spm Agent Mongodb
Sematext Agent for monitoring MongoDB
Stars: ✭ 7 (-99.17%)
Mutual labels:  metrics
Devdash
🍱 Highly Configurable Terminal Dashboard for Developers and Creators
Stars: ✭ 939 (+11.65%)
Mutual labels:  metrics
Browser Perf
Performance Metrics for Web Browsers
Stars: ✭ 930 (+10.58%)
Mutual labels:  metrics

sloc

Create stats of your source code:

  • physical lines
  • lines of code (source)
  • lines with comments
  • lines with single-line comments
  • lines with block comments
  • lines mixed up with source and comments
  • empty lines within block comments
  • empty lines
  • lines with TODO's

Build Status Dependency Status NPM version Bower version Mega-Linter License Minified size

Supported outputs

In addition to the default terminal output (see examples below), sloc provides an alternative set of output formatters:

  • CSV
  • JSON
  • Command line table

Install

To use sloc as an application install it globally:

sudo npm install -g sloc

If you're going to use it as a Node.js module within your project:

npm install --save sloc

Browser

You can also use sloc within your browser application.

Link sloc.js in your HTML file:

<script src="lib/sloc.js"></script>

sloc is also available via bower:

bower install sloc

Note: You need to compile the coffee-script files yourself. If you want to use a pre-compiled bower package, you can run

bower install sloc-bower

Usage

CLI

sloc [option] <file>|<directory>

Options:

-h, --help                  output usage information
-V, --version               output the version number
-e, --exclude <regex>       regular expression to exclude files and folders
-i, --include <regex>       regular expression to include files and folders
-f, --format <format>       format output: json, csv, cli-table
    --format-option [value] add formatter option
-k, --keys <keys>           report only numbers of the given keys
-d, --details               report stats of each analyzed file
-a, --alias <custom ext>=<standard ext> alias custom ext to act like standard ext (eg. php5=php,less=css)

e.g.:

$ sloc src/

---------- Result ------------

            Physical :  1202
              Source :  751
             Comment :  322
 Single-line comment :  299
       Block comment :  23
               Mixed :  116
               Empty :  245

Number of files read :  10

------------------------------

or

$ sloc --details \
       --format cli-table \
       --keys total,source,comment \
       --exclude i18n*.\.coffee \
       --format-option no-head src/

┌─────────────────────────────────┬──────────┬────────┬─────────┐
│ src/cli.coffee                  │ 98       │ 74     │ 7       │
├─────────────────────────────────┼──────────┼────────┼─────────┤
│ src/helpers.coffee              │ 26       │ 20     │ 0       │
├─────────────────────────────────┼──────────┼────────┼─────────┤
│ src/sloc.coffee                 │ 196      │ 142    │ 20      │
├─────────────────────────────────┼──────────┼────────┼─────────┤
│ src/formatters/simple.coffee    │ 44       │ 28     │ 7       │
├─────────────────────────────────┼──────────┼────────┼─────────┤
│ src/formatters/csv.coffee       │ 25       │ 14     │ 5       │
├─────────────────────────────────┼──────────┼────────┼─────────┤
│ src/formatters/cli-table.coffee │ 22       │ 13     │ 0       │
└─────────────────────────────────┴──────────┴────────┴─────────┘

Node.js

Or use it in your own node module

var fs    = require('fs');
var sloc  = require('sloc');

fs.readFile("mySourceFile.coffee", "utf8", function(err, code){

  if(err){ console.error(err); }
  else{
    var stats = sloc(code,"coffee");
    for(i in sloc.keys){
      var k = sloc.keys[i];
      console.log(k + " : " + stats[k]);
    }
  }
});

Browser usage

var sourceCode = "foo();\n /* bar */\n baz();";

var stats = window.sloc(sourceCode,"javascript");

Contribute an new formatter

  1. Fork this repo

  2. add the new formatter into src/formatters/ that exports a method with three arguments:

    1. results (object)
    2. global options (object)
    3. formatter specific options (array)
  3. add the formatter in src/cli.coffee

  4. open a pull request

sloc adapters

Supported languages

  • Assembly
  • Agda
  • Brightscript
  • C / C++
  • C#
  • Clojure / ClojureScript
  • CoffeeScript / IcedCoffeeScript
  • Crystal
  • CSS / SCSS / SASS / LESS / Stylus
  • Dart
  • Erlang
  • F#
  • Fortran
  • Go
  • Groovy
  • Handlebars
  • Haskell
  • Haxe
  • Hilbert
  • HTML
  • hy
  • Jade
  • Java
  • JavaScript
  • JSX
  • Julia
  • Kotlin
  • LaTeX
  • LilyPond
  • LiveScript
  • Lua
  • MJS
  • Mochi
  • Monkey
  • Mustache
  • Nim
  • Nix
  • Objective-C / Objective-C++
  • OCaml
  • Perl 5
  • PHP
  • Python
  • R
  • Racket
  • Ren'Py
  • Ruby
  • Rust
  • Scala
  • Squirrel
  • SVG
  • Swift
  • Typescript
  • Visual Basic
  • XML
  • Yaml

Run tests

npm test

Build

npm run prepublish

Changelog

see CHANGELOG.md

License

sloc is licensed under the MIT license

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].