10. Standardized Lib Function Checks

10.1. Duplicate Definitions of Wizard Lib Functions

What

Presence of definitions of functions from the wizard lib (Package yast2) outside the wizard library itself is checked such as Wizard::SetContents() etc.

Why

At the start of YaST2 develompent there was no other way of sharing code other than simply copying it. Those days are gone; YCP now supports an include mechanism similar to C or C++.

Very general code like how to create the typical YaST2 wizard window layout has now been moved to the wizard lib, a collection of include files that provide such facilities. We want to get rid of duplicate code as soon as possible for obvious reasons (consistency, maintainability, efficiency).

How

If "define" followed by one of the known function names of the wizard lib is found outside the file where this is supposed to be, a warning is issued. Both function names and file names are hardwired within check_ycp.

10.2. Definitions and Usage of Obsolete Functions

What

Usage or presence of definitions of known obsolete functions is checked, e.g. Popup::Message(), Popup::YesOrNo() etc.; using an equivalent replacement function from the wizard lib's common_popups.ycp include file is suggested.

Why

Those functions are now superseded by those from common_popups.ycp. The replacement functions usually require less parameters (thus are easier to use) and use a common and consistent widget layout.

How

The definitions are checked very much like the wizard function definitions above; function and file names are hardwired here as well.

Usage of the obsolete functions is checked simply by checking for occurrence of the function name followed by an opening parenthesis (maybe with whitespace in between) somewhere in the code.

10.3. Usage of Predefined Messages

What

Presence of predefined message strings is checked, e.g. "&Next", "&Back" etc.; using a corresponding function from the wizard lib (Label Module) is suggested, e.g. Label::NextButton(), Label::BackButton() etc.

Why

  • Ease the burden on the translators - with the predefined messages they don't need to translate the same standard texts over and over again.

  • Consistent messages for the same type of buttons etc. throughout all of YaST2.

  • Consistent keyboard shortcuts for the same button throughout all of YaST2.

  • If we ever need to change one of those standard messages, we can do that centralized.

How

The YCP code, stripped of comments, is checked for any one of the predefined messages (including any keyboard shortcuts that may be there), surrounded by translation markers ("_("...")").

Limitations

Differences in spelling or only in whitespace will not be caught. If there is no or another keyboard shortcut, the message will not be considered the same - so if anybody uses "Ne&xt" rather than "&Next", this will go undetected.