This is a collection of shell scripts that demonstrate how to count lines of code from repositories and/or local directories. These scripts can be used to estimate LoC counts that would be produced by a Sonar analysis of these projects, without having to implement this analysis.
Requirements:
Most scripts will produce two reports of LoC by language (.lang) and by repository (.file).
Counts lines of code from a GitHub.com organization. Requires to pass username, personal access token and the organization. The token must have repo scope.
<github_com.sh> myuser 1234567890abcdefgh myGitHubDotComOrg
Counts lines of code from a Bitbucket.org organization. Requires to pass username, app password and the workspace slug. The token must have Repositories > Read permissions.
<bitbucket_org.sh> myuser 1234567890abcdefgh myBBWorkspace
Counts lines of code from a Azure DevOps Services organization. Requires to pass personal access token and the organization. The token must have Code > Read permissions.
<azure_devops_services.sh> 1234567890abcdefgh myADOOrg
Counts lines of code from a GitLab.com Group. Requires to pass personal access token and the group. The token must have read_api and read_repository scopes.
<gitlab_com.sh> 1234567890abcdefgh myGitLabGroupID
Local Filesystem:
Counts lines of code from a local directory or file. This script only produces the LoC by language (.lang)
<filesystem.sh> PathToDirectoryorFile
Contributions and feedbacks are welcome, as PRs or issues directly with this repository, or through your established Sonar communication channel.