Welcome to CodeMetrics!
CodeMetrics is a lightweight API used to calculate Lua script properties such as code line count and complexity.
Installation
pastebin get qq1X1kWw CodeMetrics
How to use CodeMetrics
Command Line
To use CodeMetrics from the command line, simply execute
CodeMetrics ["path_to_script"]Doing so will print basic script information about "path_to_script" to the shell,
From Another Script
To use CodeMetrics from another script, we must first load the CodeMetrics API.
os.loadAPI("path/to/CodeMetrics")To retrieve the code properties of a Lua script, you must first create a Script 'object'.
my_script = CodeMetrics.new("path/to/myscript")There! Now we are ready to obtain information about the file "myscript"!
Here are the current functions we can execute on the object:
my_script:get_character_count() my_script:get_subroutine_count() my_script:get_cyclo_complexity() my_script:get_function_count() my_script:get_count("if") -- This can be any keyword my_script:get_line_count()CodeMetrics also takes into account comments and quotes and does
not credit you a code line if it is a comment, so no cheating!
Cyclomatic Complexity
Spoiler
Spoiler
Edited by GeorgeEpicGen, 04 August 2016 - 01:58 PM.