Skip to content

Instantly share code, notes, and snippets.

@maurelian
Last active June 11, 2023 10:33
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maurelian/a8c98a70e101353cbd280274a3f080b8 to your computer and use it in GitHub Desktop.
Save maurelian/a8c98a70e101353cbd280274a3f080b8 to your computer and use it in GitHub Desktop.

NSLOC stands for 'Normalized Source Code', which is a custom measurement we use (among others) when evaluating the complexity of a codebase.

To get the NSLOC count of a file:

  1. For all functions, reduce any multiline function declarations to a single line.
  2. Remove all comments
  3. Remove all empty lines
  4. Count the remaining lines

Example:

function foo(
  uint a, 
  bytes32 b,
  address c
 ) 

would be replaced with:

function foo(uint a, bytes32 b, address c)

We do this because listing arguments on multiple lines actually increases readability, and does not increase complexity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment