Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/shellspec/shellmetrics
Cyclomatic Complexity Analyzer for bash, mksh, zsh and POSIX shells
https://github.com/shellspec/shellmetrics
bazh cyclomatic-complexity metrics mksh script shell shell-script test yash zsh
Last synced: about 1 month ago
JSON representation
Cyclomatic Complexity Analyzer for bash, mksh, zsh and POSIX shells
- Host: GitHub
- URL: https://github.com/shellspec/shellmetrics
- Owner: shellspec
- License: mit
- Created: 2020-03-16T12:10:23.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2023-10-02T17:15:41.000Z (about 1 year ago)
- Last Synced: 2024-06-22T05:04:05.783Z (6 months ago)
- Topics: bazh, cyclomatic-complexity, metrics, mksh, script, shell, shell-script, test, yash, zsh
- Language: Shell
- Homepage:
- Size: 43 KB
- Stars: 50
- Watchers: 3
- Forks: 5
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ShellMetrics
ShellMetrics is Cyclomatic Complexity Analyzer for shell script.
[![Travis CI](https://img.shields.io/travis/com/shellspec/shellmetrics/master.svg)](https://travis-ci.com/shellspec/shellmetrics)
[![Coveralls](https://img.shields.io/coveralls/github/shellspec/shellmetrics.svg)](https://coveralls.io/github/shellspec/shellmetrics?branch=master)
[![CodeFactor Grade](https://img.shields.io/codefactor/grade/github/shellspec/shellmetrics)](https://www.codefactor.io/repository/github/shellspec/shellmetrics)
[![GitHub top language](https://img.shields.io/github/languages/top/shellspec/shellmetrics.svg)](https://github.com/shellspec/shellmetrics/search?l=Shell)
[![License](https://img.shields.io/github/license/shellspec/shellmetrics.svg)](https://github.com/shellspec/shellmetrics/blob/master/LICENSE)## Requirements
ShellMetrics is written by shell script.
One of the following shells is required: `bash`, `mksh`, `yash`, `zsh`## Installation
```sh
curl -fsSL https://git.io/shellmetrics > ~/bin/shellmetrics
chmod +x ~/bin/shellmetrics
```or
```sh
wget https://git.io/shellmetrics -O ~/bin/shellmetrics
chmod +x ~/bin/shellmetrics
```## Usage
```
Usage: shellmetrics [options] files...-s, --shell The path of shell to use as parser [default: bash]
Supported shells: bash, mksh, yash, zsh
--[no-]color Enable / Disable color [default: enabled]
--csv Generate CSV output
-p, --pretty Format pretty with wrapper function(s)
-d, --debug Display parsed data for debug instead of report
-v, --version Display the version
-h, --help You're looking at it
```Metric values vary slightly depending on the shell used.
## Example
ShellMetrics self metrics.
- NLOC - Non-comment Lines of Code
- LLOC - Logical Lines of Code
- CCN - Cyclomatic Complexity number```console
$ shellmetrics ./shellmetrics
==============================================================================
LLOC CCN Location
------------------------------------------------------------------------------
1 1 usage:9 shellmetrics
1 1 proxy:35 shellmetrics
1 1 putsn:40 shellmetrics
1 1 putsn:44 shellmetrics
4 2 putsn:39 shellmetrics
9 2 count:51 shellmetrics
2 1 is_comment_line:64 shellmetrics
2 2 is_blank_line:69 shellmetrics
3 1 repeat_string:73 shellmetrics
3 2 array:79 shellmetrics
2 1 array_is_empty:86 shellmetrics
7 2 push_array:91 shellmetrics
11 3 pop_array:102 shellmetrics
11 3 shift_array:119 shellmetrics
8 3 peel:136 shellmetrics
7 3 pretty:149 shellmetrics
2 1 process:162 shellmetrics
65 27 parse:167 shellmetrics
21 8 analyze:238 shellmetrics
56 6 default_report:274 shellmetrics
10 4 csv_report:372 shellmetrics
3 1 title:389 shellmetrics
9 5 init_mode:395 shellmetrics
9 2 main:412 shellmetrics
4 2 error:426 shellmetrics
2 1 abort:435 shellmetrics
1 1 unknown:440 shellmetrics
1 1 required:441 shellmetrics
1 1 param:442 shellmetrics
1 1 params:443 shellmetrics
2 1 params_:444 shellmetrics
20 12 parse_options:446 shellmetrics
52 2 shellmetrics
------------------------------------------------------------------------------
1 file(s), 33 function(s) analyzed. [bash 4.4.20(1)-release]==============================================================================
NLOC NLOC LLOC LLOC CCN Func File (lines:comment:blank)
total avg total avg avg cnt
------------------------------------------------------------------------------
412 12.48 332 10.06 3.18 33 shellmetrics (479:5:62)
------------------------------------------------------------------------------==============================================================================
NLOC NLOC LLOC LLOC CCN Func File lines comment blank
total avg total avg avg cnt cnt total total total
------------------------------------------------------------------------------
412 12.48 332 10.06 3.18 33 1 479 5 62
------------------------------------------------------------------------------
```## Contribution
### How to test
ShellMetrics tested by [ShellSpec](https://github.com/shellspec/shellspec).
To test, install ShellSpec and run `spellspec` on the project root directory.