Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

How to Set Source Code Filters with Kiuwan Local Analyzer (KLA)

Table of Contents

The source code filter mechanism

If there are files and directories you do not want to analyze, you can set a filter for them. KLA has a source code filter mechanism based on Ant-style include and exclude patterns. Here are some example patterns (find more here): 

Image Added

Set source code filters

  1. Specify the root directory (SOURCE_DIRwhere the source code files are located in Folder to analyze.
    (By default, KLA analyzes every file in this folder).
    Image Added

  2. Click on Advanced
    Image Added

  3. A new window displays
    Image Added

    Include patterns specify

Table of Contents

 

Before the execution of a Kiuwan analysis, you must specify the root directory where the source files are located.

 

Info

That root directory is the SOURCE_DIR of the analysis.

Kiuwan scans all the files under SOURCE_DIR before to run the analysis.

 

Likely, your SOURCE_DIR contains files and directories that you do not want to be analyzed.

Most common reasons are because your application contains open-source, 3rd-party or auto-generated code.

In those cases, you will not want that code to be analyzed because the defects found in those will not be corrected and, also, are disturbing (decreasing) the indicators of your application.

 

Info

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):

 

Image Removed

 

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.

 

Image Removed

 

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.

 

Image Removed

 

...

  1. what subset(s) of files will be analyzed.

    Exclude

...

  1. patterns specify what subset(s) of file will not be analyzed.

...

  1. If you want to add patterns, click the + button. A new window will appear: 
    Image Added

  2. If you want to remove a pattern, select it and click the - button.
     If you want to edit an existing pattern or copy the text, double click on it.
    Image Added


Info

Exclude patterns take precedence over

...

include patterns.

 

...

If you define the patterns below

...

, the analysis will not process any js file

...

:

...

  • Include : src/**.js

...

  • Exclude: **/**.js

...

The exclude pattern

...

defines:

...

exclude all .js files in any directory and with any name

...

. Therefore, the include pattern

...

has no effect.

The table below explains

 

Info

There might be subtle combinations depending on the specified include/exclude patterns, so we recommend you to use exclude to reduce the resulting fileset to be analyzed.

 

...

 

...

 

how the whole mechanism works and what fileset will be analyzed by Kiuwan:

 



Include pattern

...

...

 



NO

YES

Exclude pattern

NO

...

The whole SOURCE_DIR will be analyzed

Only the resulting fileset after inclusion of matched files will be analyzed

YES

Only

...

the resulting fileset after exclusion of matched files will be analyzed

First, the exclusion pattern reduces the SOURCE_DIR

Second, over the above fileset, only

...

those files

...

matching the include pattern will be processed