Maintainability
Unused global variables/constants should be removed
Description
This rule states that any global variables or constants that are not being used in the PowerBuilder code should be removed. This is important to keep the code clean and organized, and to avoid any unnecessary clutter. Unused variables and constants can also lead to potential errors or bugs in the code, so it is important to ensure that all global variables and constants are being used. While checking for global variable we ignore the variable corresponding to object type. For example in window w_about, PB IDE create type global variable for w_about which is ignore while performing analysis.
Key Benefits
- Reduced Complexity: Removing unused global variables/constants reduces the complexity of code, making it easier to read and understand.
- Increased Performance: Unused global variables/constants can take up unnecessary memory and slow down the performance of the application.
- Better Code Quality: Removing unused global variables/constants helps to maintain better code quality, making it easier to maintain and debug.
Non-compliant Code Example
forward global type veinet from inet end type end forward global type veinet from inet end type global veinet veinet global variables CONSTANT long ATTACH_PARENT_PROCESS = -1 //Non compliant code (Unused global variable) long hwnd //Non compliant code (Unused global variable) end variables forward prototypes global function string callINETPOST (integer id) global function string callINETGET (integer id) global function string callINETHyperlinkToURL (integer id) end prototypes global function string callINETPOST (integer id) Blob lblb_args String ls_headers String ls_url Long ll_length veinternetresult iir_msgbox iir_msgbox = CREATE veinternetresult ls_url = "https://www.visual-expert.com/" ls_url += "EN/powerbuilder-code-pb/" ls_url += "function-source-analysis-documentation-impact.html?" lblb_args = blob("") ll_length = Len(lblb_args) ls_headers = "Content-Length: " & +String(ll_length) + "~n~n" PostURL & (ls_url, lblb_args, ls_headers, 8080, iir_msgbox) Return "" end function