Skip to content

Commit 45deb77

Browse files
committed
Add recipes to calculate JavaScript LLOC
1 parent e364e25 commit 45deb77

File tree

2 files changed

+72
-0
lines changed

2 files changed

+72
-0
lines changed

tools/make/lib/stats/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# DEPENDENCIES #
33

44
include $(TOOLS_MAKE_LIB_DIR)/stats/git.mk
5+
include $(TOOLS_MAKE_LIB_DIR)/stats/lloc_javascript.mk
56
include $(TOOLS_MAKE_LIB_DIR)/stats/npm.mk
67
include $(TOOLS_MAKE_LIB_DIR)/stats/repl.mk
78
include $(TOOLS_MAKE_LIB_DIR)/stats/sloc_javascript.mk
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
2+
# VARIABLES #
3+
4+
# Define the path of the executable for calculating JavaScript LLOC:
5+
JAVASCRIPT_LLOC ?= $(TOOLS_PKGS_DIR)/static-analysis/js/lloc-file-list/bin/cli
6+
7+
# Define the command flags:
8+
JAVASCRIPT_LLOC_FLAGS ?=
9+
10+
11+
# TARGETS #
12+
13+
# Calculate LLOC.
14+
#
15+
# This target calculates JavaScript logical lines of code (LLOC).
16+
17+
stats-lloc-javascript: stats-lloc-javascript-src stats-lloc-javascript-tests stats-lloc-javascript-examples stats-lloc-javascript-benchmarks
18+
19+
.PHONY: stats-lloc-javascript
20+
21+
22+
# Calculate source code LLOC.
23+
#
24+
# This target calculates logical lines of code (LLOC) for only JavaScript source files.
25+
26+
stats-lloc-javascript-src: $(JAVASCRIPT_LLOC) $(NODE_MODULES)
27+
$(QUIET) $(FIND_SOURCES_CMD) | $(NODE) $(JAVASCRIPT_LLOC) $(JAVASCRIPT_LLOC_FLAGS)
28+
29+
.PHONY: stats-lloc-javascript-src
30+
31+
32+
# Calculate test LLOC.
33+
#
34+
# This target calculates logical lines of code (LLOC) for only JavaScript test files.
35+
36+
stats-lloc-javascript-tests: $(JAVASCRIPT_LLOC) $(NODE_MODULES)
37+
$(QUIET) $(FIND_TESTS_CMD) | $(NODE) $(JAVASCRIPT_LLOC) $(JAVASCRIPT_LLOC_FLAGS)
38+
39+
.PHONY: stats-lloc-javascript-tests
40+
41+
42+
# Calculate example code LLOC.
43+
#
44+
# This target calculates logical lines of code (LLOC) for only JavaScript example files.
45+
46+
stats-lloc-javascript-examples: $(JAVASCRIPT_LLOC) $(NODE_MODULES)
47+
$(QUIET) $(FIND_EXAMPLES_CMD) | $(NODE) $(JAVASCRIPT_LLOC) $(JAVASCRIPT_LLOC_FLAGS)
48+
49+
.PHONY: stats-lloc-javascript-examples
50+
51+
52+
# Calculate benchmark LLOC.
53+
#
54+
# This target calculates logical lines of code (LLOC) for only JavaScript benchmark files.
55+
56+
stats-lloc-javascript-benchmarks: $(JAVASCRIPT_LLOC) $(NODE_MODULES)
57+
$(QUIET) $(FIND_BENCHMARKS_CMD) | $(NODE) $(JAVASCRIPT_LLOC) $(JAVASCRIPT_LLOC_FLAGS)
58+
59+
.PHONY: stats-lloc-javascript-benchmarks
60+
61+
62+
# Calculate LLOC.
63+
#
64+
# This target calculates logical lines of code (LLOC) for JavaScript files. Note that we expect `$FILES` to be a JavaScript file list.
65+
#
66+
# TODO: address possibility of `$FILES` exceeding maximum allowed shell arguments
67+
68+
stats-lloc-javascript-files: $(JAVASCRIPT_LLOC) $(NODE_MODULES)
69+
$(QUIET) $(NODE) $(JAVASCRIPT_LLOC) $(JAVASCRIPT_LLOC_FLAGS) $(FILES)
70+
71+
.PHONY: stats-lloc-javascript-files

0 commit comments

Comments
 (0)