Globalyzer in IDE

From Lingoport Wiki
Revision as of 17:29, 17 October 2019 by Olibouban (talk | contribs)
Jump to: navigation, search

Can I use Globalyzer Lite with my standard IDE?

The Globalyzer Lite client can be used with Eclipse, Visual Studio and IntelliJ IDEs.

Using Globalyzer Lite from an Integrated Development Environment

Globalyzer Lite may be used within many IDEs that support external tools, including Visual Studio, IntelliJ IDEA, and Eclipse. Configuring Lite as an external tool takes some initial setup, but is relatively easy to accomplish. Once configured, Lite may be used through the IDE's external tool menu with the click of a button. The recommended, documented tools:

  1. Scan the currently selected file/directory.
  2. Scan everything within the parent directory of the currently selected file/directory.
  3. Scan the entire project.

Demonstration videos are available for:

To configure Lite in the IDE, please see this page: Lite IDE Usage.

The developer can then use the power of the IDE to refactor the relevant issues or to mark false positives in the code using Globalyzer ignore comments, such as $NON-NLS-L$. For more information, see the Globalyzer Comment Tags in False Positives .

Those refactoring and the comment tags are now part of the code: The Continuous Globalization System using the same Lite project definition file will show the same results in the Dashboard.

How do I install Globalyzer Lite?

To install the Globalyzer Lite, you first need a Globalyzer account (see this FAQ). Once you have an account, you log into the Globalyzer Server and at the bottom of your home page there is a link to download Globalyzer Lite.

The Globalyzer Lite is a standalone Java application. It uses Rule Sets to scan code at the command line. It is used in Jenkins configured for the Continuous G11n System and can be integrated as an external tool in an IDE.

Please see installation for complete Globalyzer Lite download/installation instructions.

To install:

  1. Unzip the Globalyzer Lite zip file at a desired location
  2. Run either lite-setup.bat or depending on your system.

To verify the installation, from a command line at the location that it was installed:

java -jar globalyzer-lite.jar -version

or, show the help info:

java -jar globalyzer-lite.jar -help

Sharing Project Definition Files Between IDEs and Build Systems

It is common to check in a single project definition file per code repository. However, the desired IDE configuration may sometimes be incompatible with the desired build system configuration.

These incompatibilities are best solved by modifying the project definition file within the build system. The IDE config can then be used as the default.

Here is an example: The desired report type for Globalyzer Lite may be ScanDetailedCSV for developer usage, but will need to be ScanDetailedXML within the build system. The project definition file would then be written out with the <report-type> set to ScanDetailedCSV:


The build system can then be set to auto-replace "ScanDetailedCSV" with "ScanDetailedXML". The following Linux command will do so:

$ sed --in-place 's|ScanDetailedCSV|ScanDetailedXML|' $WORKSPACE/ProjectDefinition.xml

If desired, the opposite replacement also may be performed at the end of the build.

Finally, here is a bash function to replace the content of any XML field:

replace_xml_token() {
  sed -ri "s|(<${token_name}>).*(</${token_name}>)|\1${new_content}\2|g" $WORKSPACE/ProjectDefinition.xml

It may be used like so:

$ replace_xml_token "report-type" "ScanDetailedXML"

Lite IDE Ignore

When using Lite in an IDE (see ), you can use the power of the IDE to mark some issues in the code as to be ignored. Globalyzer uses a set of standard comments, namely $NON-NLS-L$. There are many ways to do so. We will illustrate one such way with Lite in Eclipse.

Lite is set in Eclipse

To set Lite in your Eclipse environment, refer to ; There are two sections, one for Linux, one for Windows.


Run Lite

  • Select the directory or file you want to analyze
  • Click on the external tools button

=> Lite analyzes the relevant files based on the Globalyzer Project Definition file and shows the clickable results in the Console view.


Navigate to the Issue

  • Click on the issue in the Console

=> It opens the file and highlights the line with the issue.

Refactor the Code or Ignore the Issue

Depending on what the developer sees, the issue either needs to be refactored or ignored. If the issue needs to be ignored, the //$NON-NLS-L$ comment needs to be added at the end of that line. One can simply add it by typing it. Some short cut exist and some can be created. For instance:

  • Go to the end of the line to ignore and type <Ctr><Space>
  • Choose "nls - non externalize string marker" in the list of templates.


  • Add the string "nls" and type <Ctr><Space>
  • Eclipse proposes the standard $NLS notation by default. Select that notation and type L.


The line now reads:

   	Locale locale = new Locale("en", "US"); //$NON-NLS-L$
  • Repeat the process for other false positives

Lines tagged with the //$NON-NLS-L$ will be ignored by Globalyzer the next time you run the Lite external tool.

Advanced Template

The previous illustration was done using the default template. You can modify the template to have directly //$NON-NLS-L$ on other key combination or the same nls<Ctr><Space>.

The following image shows how to use nll<Ctr><Space> to insert directory //$NON-NLS-L$.


This is one way of adding //$NON-NLS-L$ at the end of the line. Some developers will decide on other methods.