Skip to content

Instantly share code, notes, and snippets.

@bgrins
Last active April 6, 2021 14:57
Show Gist options
  • Save bgrins/f32f29d97bb9b0589500b8f4d93236df to your computer and use it in GitHub Desktop.
Save bgrins/f32f29d97bb9b0589500b8f4d93236df to your computer and use it in GitHub Desktop.
Mozilla central count lines of code
#!/bin/bash
# these switches turn some bugs into errors
set -o errexit -o pipefail -o noclobber -o nounset
MOZILLA_CENTRAL=$PWD
if [ ! -f $MOZILLA_CENTRAL/test.mozbuild ]; then
echo "Error: this doesn't look like an m-c directory."
exit 1
fi
THIRD_PARTY_LIST="$(sed 's/^/\//' $MOZILLA_CENTRAL/tools/rewriting/ThirdPartyPaths.txt)"
GIT_IGNORE_LIST="$(sed '/^#/d;/^$/d' $MOZILLA_CENTRAL/.gitignore)"
IGNORE_LIST="${THIRD_PARTY_LIST}
${GIT_IGNORE_LIST}"
IGNORE_ARGS=""
while read -r line; do
IGNORE_ARGS="$IGNORE_ARGS --iglob '!$line'"
done <<< "$IGNORE_LIST"
# Find all results:
rm -f RG_FILES.txt
eval "rg -l ' ' $IGNORE_ARGS --iglob '!**test**' $MOZILLA_CENTRAL > RG_FILES.txt"
cloc --list-file=RG_FILES.txt --exclude-ext=json,rst,toml,yml
25909 text files.
25700 unique files.
3345 files ignored.
github.com/AlDanial/cloc v 1.88 T=16.75 s (1346.9 files/s, 410477.9 lines/s)
---------------------------------------------------------------------------------------
Language files blank comment code
---------------------------------------------------------------------------------------
C++ 5323 463160 357783 2307545
JavaScript 3618 152442 231336 917025
C/C++ Header 6953 227176 314132 844529
Rust 537 20150 26833 154273
Python 776 34431 39457 147336
CSS 621 15180 7885 80265
IDL 823 10692 0 79657
Java 208 9422 19728 54554
Objective-C++ 146 9988 7453 44298
YAML 236 3639 4259 41297
NAnt script 1053 6966 0 41004
HTML 115 3245 909 19980
diff 67 925 4782 18356
Markdown 169 5362 0 16200
XHTML 140 1498 849 14277
Freemarker Template 133 2459 0 11142
C 39 1759 2356 10932
JSX 73 1039 868 10422
Bourne Shell 182 1908 1958 10395
SVG 798 82 2280 9283
Sass 53 1187 179 6093
m4 26 724 834 5629
TOML 98 462 198 3779
Perl 17 609 1061 2876
make 30 723 1064 2803
Assembly 41 703 955 2619
XML 59 149 184 2164
INI 32 54 53 1449
TypeScript 17 208 236 1358
Gencat NLS 7 125 0 1304
Gradle 14 245 316 1045
HLSL 25 235 256 1023
Dockerfile 32 209 172 846
Protocol Buffers 4 237 439 830
DTD 40 284 368 807
Jinja Template 8 100 12 505
Bourne Again Shell 7 65 111 382
Windows Module Definition 7 15 36 292
Windows Resource File 10 95 136 231
Handlebars 14 15 0 229
XSLT 2 27 11 178
WiX source 1 11 25 72
DOS Batch 4 25 7 68
Mako 1 0 0 31
PowerShell 1 4 0 25
R 1 8 18 12
D 1 4 22 8
Elixir 1 0 39 6
Expect 1 1 3 1
ProGuard 1 2 15 0
---------------------------------------------------------------------------------------
SUM: 22565 978049 1029618 4869435
---------------------------------------------------------------------------------------
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment