I am using a tool to calculate cylomatic complexity of a javascript file.
Example:
jsc --minimal test.js
This command will give the following output.
┌─────────────────────┬─────┬────────────┬─────────────────────┐
│ File │ LOC │ Cyclomatic │ Halstead difficulty │
├─────────────────────┼─────┼────────────┼─────────────────────┤
│ /home/shray/test.js │ 23 │ 4 │ 10 │
└─────────────────────┴─────┴────────────┴─────────────────────┘
Cyclomatic: min 4 mean 4.0 max 4
Halstead: min 10 mean 10.0 max 10
Now I use
jsc --minimal test.js | grep "Cyclomatic:"
which gives me output as
Cyclomatic: min 4 mean 4.0 max 4
Now I have a regex, Cyclomatic:[\s]*min[\s]+([0-9]+)
but I am not able to use it to extract the number showing minimum Cylomatic value.
Any help how can I just ouput the value of Min or Max Cyclomatic complexity value on the terminal output?
Cyclomatic: min 4 mean 4.0 max 4
this structure will always remain same? Just the values will change? – Pacifist Oct 4 '19 at 6:35grep
(are you using Linux or UNIX)? – roaima Oct 4 '19 at 6:38...|awk '/Cyclomatic/ {print $3,$7}'
can you try this then ? It will give you min and max numbers only for Cyclomatic. – Pacifist Oct 4 '19 at 6:43