Permalink
Browse files

Update and publish the cloc metric for Oil and OSH.

Use wc-like output for my own ASDL line count script.
  • Loading branch information...
Andy Chu
Andy Chu committed Jan 21, 2018
1 parent ca8db89 commit 8d3b93a40120b0a5b8eb8e8f0e561288034514cd
Showing with 36 additions and 21 deletions.
  1. +34 −21 scripts/count.sh
  2. +2 −0 scripts/release.sh
View
@@ -1,6 +1,6 @@
#!/usr/bin/env bash
#
# Count lines ofcode in various ways.
# Count lines of code in various ways.
#
# Usage:
# ./count.sh <function name>
@@ -10,36 +10,49 @@ set -o pipefail
set -o errexit
filter-py() {
grep -E -v '__init__.py$|_test.py$'
grep -E -v '__init__.py$|_test.py$'
}
oil-core-files() {
# Oil-only would exclude core/legacy.py, etc.
oil-osh-files() {
{ ls {bin,osh,core}/*.py native/*.c osh/osh.asdl core/runtime.asdl; } |
filter-py | grep -E -v '_gen.py$|test_lib.py'
}
asdl-filter() {
# cloc doesn't understand ASDL files.
# Use a wc-like format, filtering out blank lines and comments.
asdl-cloc() {
python -c '
import sys
for line in sys.stdin:
line = line.strip()
if not line or line.startswith("--"):
continue
print line
'
total = 0
for path in sys.argv[1:]:
num_lines = 0
with open(path) as f:
for line in f:
line = line.strip()
if not line or line.startswith("--"):
continue
num_lines += 1
print "%5d %s" % (num_lines, path)
total += num_lines
print "%5d %s" % (total, "total")
' "$@"
}
cloc-oil-core() {
oil-core-files | xargs cloc
oil-osh-cloc() {
echo 'OIL AND OSH (non-blank non-comment lines)'
echo
oil-osh-files | xargs cloc --quiet "$@"
# NOTE: --csv option could be parsed into HTML.
# Or just sum with asdl-cloc!
# cloc doesn't understand ASDL files.
echo
echo 'ASDL SCHEMAS'
for name in osh/osh.asdl core/runtime.asdl; do
#cat $name | asdl-filter
local count=$(cat $name | asdl-filter | wc -l)
echo "$count $name"
done
echo 'ASDL SCHEMAS (non-blank non-comment lines)'
asdl-cloc osh/osh.asdl core/runtime.asdl
}
# TODO: Sum up all the support material. It's more than Oil itself! Turn
@@ -97,8 +110,8 @@ all() {
wc -l {osh,core,native,tools}/*_test.py | sort --numeric
echo
echo 'OIL'
oil-core-files |
echo 'OIL AND OSH'
oil-osh-files |
xargs wc -l | sort --numeric
echo
View
@@ -456,6 +456,8 @@ line-counts() {
scripts/count.sh parser > $out/parser.txt
scripts/count.sh runtime > $out/runtime.txt
scripts/count.sh oil-osh-cloc > $out/oil-osh-cloc.txt
metrics-index > $out/index.html
tree $out
}

0 comments on commit 8d3b93a

Please sign in to comment.