Skip to content

Instantly share code, notes, and snippets.

@KorbenC
Created October 3, 2014 13:14
Show Gist options
  • Save KorbenC/30e468e9e14f55d7acf7 to your computer and use it in GitHub Desktop.
Save KorbenC/30e468e9e14f55d7acf7 to your computer and use it in GitHub Desktop.
Counts the lines of apex code in org, combined both class and triggers.
Integer classLines = 0;
Integer triggerLines = 0;
for(ApexClass a : [Select Body From ApexClass]){
List<String> lines = a.Body.split('\n');
classLines += lines.size();
}
for(ApexTrigger a : [Select Body From ApexTrigger]){
List<String> lines = a.Body.split('\n');
triggerLines += lines.size();
}
system.debug('Apex Class lines: ' + classLines);
system.debug('Apex Trigger lines: ' + triggerLines);
system.debug('Apex Total lines: ' + (classLines+ triggerLines));
@charltonAthletic
Copy link

Very cool. Thanks

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