Skip to main content
File Rules

Include or Exclude files from language statistics using File Rules

J
Written by James McGill
Updated over 6 months ago

File Rules

File Rules allow you to include or exclude particular files or paths when computing language statistics (e.g. the number of lines of code modified in a particular Commit or Pull Request). This can be used to exclude third party, vendored or generated files from language statistics.


โ€‹
These rules are applied alongside Velocity's built in rule-set which excludes vendored and automatically generated code from common languages and frameworks.

When a file matches a rule marked as "included in code analysis", that file will be included in language analysis even if it matches Velocity's base exclusion rule set.

When a file matches a rule marked as "excluded from code analysis", that will not be included in language analysis.

Specifying Rules

Rules are specifying using Simple Regular Expression syntax, and are applied to the path of each file relative to the root of a repository. Special Regular Expression characters can be escaped using a forward slash.

Ordering

Rules are applied in no particular order, however "included in code analysis" rules will always take precedence over "excluded from code analysis" rules.

Adding new rules

By default, new rules only apply to changes analyzed by Velocity after the rule is created.

To retroactively apply the rule to all previously analyzed data points, click the Re-analyze button. Re-analysis is an expensive operation and may take several days for large organizations.

Examples

Example

Rule

Exclude any file called package.json

package\.json$

Exclude all files with the txt extension

\.txt$

Exclude package.json only if it occurs at the root of the repository

^package.json$

Exclude all files under the test/ directory

test/

Did this answer your question?