Creating a Rule Set
Rule Sets provide Globalyzer with the specific instructions
needed to analyze source code and report internationalization
problems. Within Globalyzer you will need to create at least one
Rule Set for each programming language you intend to scan. In the
case of Web files, a single source file can contain multiple
programming languages, hence you need to create a separate Rule Set
for each programming language contained in your Web source files.
In this lesson, you will scan both .aspx Web files and .cs source
files. The .aspx files contain in-line C#, JavaScript and
HTML. For this lesson you will need to create three separate Rule
Sets.
-
From your Home Page on the server, select Create Rule Set.
The Create Rule Set page appears.
-
Fill in the fields as follows :
- Enter csharp in the Name field.
- Select c# from the Language - Variant
dropdown menu.
- Leave the Shared checkbox unchecked to indicate
that this rule set won't be shared with other team members.
-
Click Create. The Customize Rule Set page appears,
for the newly created Rule Set, csharp.
The rule set csharp can be configured from this page.
Each rule set consists of the file extension configuration
and four types of rules: Embedded String Scan Rules,
Locale-Sensitive Method Scan Rules, General Pattern Scan Rules,
and Static File Reference Scan Rules.
-
Under the Source File Extensions heading, select the Configure link next to Detection
Rules. The Edit
File Extensions for csharp page appears.
Globalyzer will only scan source files that have the listed
extensions; all other file types will be ignored.
Notice that the extensions asax, ascx, ashx,
aspx and cs are already listed and selected. This
is because you picked c# as the programming language for
your Rule Set. Unless your application uses non-standard source
file extensions, it is usually not necessary to modify the
default File Extensions that Globalyzer provides.
If you do need to add an extension, click on New File
Extension in the middle of the screen above the list of
extensions. This will display the Create File Extension
for csharp page. You can also uncheck a default extension if you
want Globalyzer to ignore those source files.
-
Click on the Back to Summary link to return to the previous
page.
Source Code directories can be filtered in the Globalyzer Client, as you will see later,
but also in the Rule Set. Under Source File Extensions click the Configure link next to
Filtering Rules. The Edit
File Extension Filters for csharp page appears. Click on the New File Extension
Filter at the top of this page to see the following page:
This is where you can tell Globalyzer that whenever this rule set is applied to any source
code, specific parts of the source code tree should be ignored. Both Ant style and Regular Expressions are supported. For example, you could ignore test directories, by entering a filter with **/test/** as the Ant pattern; or ignore the bin directory with a **/bin/** Ant pattern. Specific filenames can also be ignored using Regular Expressions; for example the Regular Expression (?i)Debug will ignore any files that have the case-insensitive text debug in the filepath.
-
Click on the Back to Summary link to return to the previous
page.
In addition to the file extensions, There are four scan
rules (Embedded String Scan Rules, Locale-Sensitive Method Scan
Rules, General Pattern Scan Rules and Static File Reference Scan
Rules), they are each divided into two categories: Detection
Rules and Filter Rules.
Detection Rules specify conditions that the Globalyzer
source code scanner will detect in your source code and report to
you. For instance, under Locale-Sensitive
Method Scan Rules, click the Configure link for Detection Rules.
By default for C#, there are four method groups under that
heading. By clicking on New Locale-Sensitive Method Group,
another method group can be added to the default set.
The Enabled checkbox for each group allows you to
enable or disable a set of methods all at once rather than
checking or unchecking individual methods within each group.
-
Click on the Culture and Number format method group link.
The default C# methods are listed in that group. For example, if the
Compare method is detected in your C# source code, the scanner will
report it to you. Globalyzer provides custom help for most locale-sensitive methods:
Click on the link in the Help Page column of the Compare method for a description of
specific internationalization issues associated with Compare .
Note: If you are a Demo User, you will not be
able to view the Locale-Sensitive Methods. Please contact
Lingoport at sales@lingoport.com
for a more thorough evaluation.
-
Click Back to Summary to return to the previous page.
Filtering Rules specify conditions that the scanner will
overlook. For instance, during the Embedded String Scan, Globalyzer
will detect all embedded strings. However, many of these strings are
programmatic and will not be displayed to the user, and therefore do not
pose internationalization problems. To filter out these false positives
Globalyzer Rule Sets come with predefined filters. There are four types of
Embedded String Filters: String Content Filters, String Method Filters, String
Variable Filters, and
String Line Filters.
Under Embedded
String Scan Rules and Filtering Rules, click String Method Filters. Look
for the filter named CultureInfo. The method
CultureInfo
is listed because
System.Globalization.CultureInfo
takes a string argument, but this string would never appear as
text visible to a user in a user interface. Therefore,
CultureInfo
is listed as a String Method Filter by default. When Globalyzer
detects an embedded string during the string scanning process,
before reporting it as an issue, it will first check to make sure
that it is not an argument passed into any of the methods in this
list.
-
Take a few minutes to examine (but not change) the other rules,
such as General Pattern Detection Rules or Static File Reference
Filter Rules by clicking Configure to their left.
-
Repeat steps 1-3 twice to create two new Rule Sets.
-
For the first Rule Set, select html as the programming
language, and name the Rule Set html.
For the second Rule Set, select javascript as the
programming language, and name the Rule Set javascript.
To complete most of the remaining lessons, you need all three
Rule Sets: csharp, html and javascript.
In the next lesson, you will edit a Rule Set to further
refine the code scanning results.
|