How to Set Source Code Filters
Specify the root directory
Before an analysis with Kiuwan is executed, you must specify the root directory where the source code files are located.
That root directory is the SOURCE_DIR of the analysis.
Kiuwan scans all the files under SOURCE_DIR before running the analysis.
Set source code filters
If there are files and directories you do not want to analyze, you can set a source code filter for them.
Kiuwan provides Source Code Filters to specify the exact fileset you want to analyze.
This mechanism is based on Include and Exclude Patterns.
Kiuwan’s include and exclude patterns are Ant-style patterns, used to create subsets of files given a certain fileset.
Some example patterns might be (look at https://ant.apache.org/manual/dirtasks.html for a full reference of Ant-syntax):
How to define exclusion and inclusion patterns
When using Kiuwan Local Analyzer GUI, you can define both patterns by clicking on Advanced button and next dialog will open.
By default, you will find that there are some pre-defined exclude patterns (common patterns that usually do not contain useful code to be analyzed) that you can modify if needed.
There are +/- buttons to add/remove patterns.
To create a new one, next dialog will be open and added to the current set of patterns.
For example, if you define below patterns, the analysis will not process any js file.
- include : src/**.js
- exclude: **/**.js
First, exclude pattern is saying: "exclude all .js files in any directory and with any name". That will exclude all the js files from SOURCE_DIR. Therefore, include pattern makes nothing: the subset already does not contain any js file.
Table below explain how the whole mechanism works and what fileset will be analyzed by Kiuwan
| | Include pattern |
---|
| | NO | YES |
---|
Exclude pattern | NO | Whole SOURCE_DIR will be analyzed | Only resulting fileset after inclusion of matched files will be analyzed |
---|
YES | Only Resulting fileset after exclusion of matched files will be analyzed | First, exclusion pattern reduces SOURCE_DIR Second, over the above fileset, only will be processed those files macthing the include pattern |