You can exclude:
- selected files
- all files with selected extensions
- all files from selected directories
- everything except files with selected extensions
- everything except files from selected directories
The exclusion of files allows you to make lines of code statistics more precise and informative. This feature will be helpful for users, who:
- Include source code from third-party libraries, and don't want to count it towards individual code contributions.
- Want automated code-generated files not to be included in lines of code statistics.
- Need to exclude from lines of code statistics files with some extensions.
- Want to count in lines of code statistics only files with selected extensions.
- Demand lines of code statistics on a directory basis.
Below on the page, you'll find:
- instructions on how to use the feature
- pattern examples
For easier navigation, use the Table of Contents at the top-right of the page.
How to use the feature
Customization of lines of code statistics is available in the repository settings. Repository administrators can modify these settings.
To exclude files from lines of code statistics of a repository:
- Go to Repository settings → Awesome Graphs → Lines of code.
- Click Add pattern and proceed to the customization page.
Here you may add patterns in .gitignore format telling what files and directories should be excluded from lines of code statistics of the repository.
Here are a few examples of the exclusion of files.
Exclude all files with the selected extensions
These patterns will exclude all files with extensions .txt and .json.
Exclude all files from the selected directories
libraries/ logs/ third_party/
These patterns will exclude all files from directories libraries, logs and third_party.
Exclude everything except files from the selected directory
These patterns will exclude all files except files from the directory src in the repository root. By using this approach you will get lines of code statistics only for the selected directory or list of directories.
Exclude everything except files with the selected extensions
These patterns will exclude all files except files with .js extensions. By using this approach you will get lines of code statistics only for the selected types of files.
Combination of patterns
* !*.c !*.cpp !*.h library/ !library/ownlib/**/*.c !library/ownlib/**/*.cpp !library/ownlib/**/*.h
All files will be excluded from statistics. Files with c, cpp, h extensions will be included into statistics. All files from the directory library will be excluded from statistics (even files with c, cpp, h extensions). Files with with c, cpp, h extensions from the subdirectory library/ownlib will be included into statistics.
You can see more examples of .gitignore patterns here.
We can prepare patterns for you. If you need help, raise a support ticket and describe your use case.