Excluding (and including) specific folders

The standard behaviour for the Meterian client is to consider the folder where it's pointed to a project. It will look for any (supported) manifest files in such folder and will activate automatically the correct analysers. The inner folder structure is indeed opaque to the scanner, which relies on the declarations in the manifest files themselves.

Some analyzers, however, can also work recursively, looking into subfolders of the current folder. This happens with Java/Ant, Dotnet, Golang, NodeJS and others. For that reason sometimes you may need to explicitly exclude or include folders, especially in complex projects.

Excluding folders

This behaviour can be controlled across all scanners that are using it providing a set of excluded folders that such analysers will not visit, using the parameter --exclude-folders as in this example, when we exclude all the "samples" folder/subfolders:

--exclude-folders=**/samples**

The ** works across directories, while * is the general wildcard. These options allows to exclude multiple paths by separating them with a comma as in the example

--exclude-folders="**/foo**,**/baz**"

Please note that if no "glob" modifiers are used, then the system automatically translates into the above format, so that --exclude-folders=foo is equivalent to --exclude-folders="**/foo**

Note: by default hidden folders are excluded, this behaviour is achieved by having the internal glob *** set as the default value of the --exclude-folders flag. Should you want to retain this behaviour while adding your own glob patterns, simply add *** following the usual comma.

Including folders

In the same way, it's also possible to include folders, which will take precedence above any exclusion:

--include-folders="**/src**,**/main**"

Glob modifiers

These are known as "glob" patterns. This is how they are defined

  • Wildcard characters:

    • *: Matches any number of characters (including zero).

    • ?: Matches exactly one character.

    • [...]: Matches any single character within the brackets.

    • [!...]: Matches any single character not within the brackets.

  • Character classes:

    • [a-z]: Matches any lowercase letter.

    • [A-Z]: Matches any uppercase letter.

    • [0-9]: Matches any digit.

    • [:alpha:]: Matches any alphabetic character.

    • [:digit:]: Matches any digit.

    • [:alnum:]: Matches any alphanumeric character.

    • [:punct:]: Matches any punctuation character.

    • [:space:]: Matches any whitespace character.

  • Path separators:

    • /: Used on Unix-like systems.

    • \: Used on Windows.

  • Recursive matching:

    • **/: Matches any number of directories.

  • Internal:

    • ***: Matches hidden folders (whatever content within a top level hidden folder will be considered hidden as well; be it individual files or nested folders and their files)

Last updated