Code Rules in Minor Severity

Category Severity Name Description
Maintainability Minor Boolean checks should not be inverted

The PowerBuilder code rule "Boolean checks should not be inverted" states that a Boolean check should not be written in a way that would cause it to evaluate to the opposite of what is intended. This means that when writing code, it is important to be aware of the logical structure of the code and ensure that any Boolean checks are written in the correct order. This will ensure that the code behaves as expected and does not produce unexpected results.

Maintainability Minor Boolean literals should not be redundant

The "Boolean literals should not be redundant" rule states that when writing PowerBuilder code, Boolean literals (true/false) should not be used redundantly. This means that if a Boolean value is already established, it should not be repeated unnecessarily. For example, if a Boolean value has already been set to "true," it should not be written again as "true" in the same code.

Maintainability Minor CASE should be used for sequences of simple tests

The "CASE should be used for sequences of simple tests" PowerBuilder code rule states that the CASE statement should be used when there are multiple, simple tests that need to be performed, instead of using a series of IF statements. The CASE statement is more efficient and easier to read than multiple IF statements, as it allows for a single expression to be evaluated and compared against multiple values, with each value having its own corresponding action. It also allows for a default action to be taken if none of the values match the expression.

Maintainability Minor Code elements must not be unused

This PowerBuilder code rule states that all code elements must not be unused. This means that all elements of the code, such as variables, functions, classes, and other code elements, must be used in the code in order to be considered valid. If a code element is unused, it should be removed from the code in order to make the code more efficient and reduce the risk of errors. Unused code elements can also create confusion for other developers, as they may not understand why the code element is there if it is not being used. It is important to ensure that all code elements are used appropriately in order to create clean, efficient code.

Maintainability Minor Comments should not be located at the end of lines of code

This rule states that comments should not be placed at the end of lines of code in PowerBuilder. This is because comments at the end of lines can be misinterpreted as part of the code, leading to potential errors. It is best to place comments on their own line, or at the beginning of the line of code, so that they are clearly separated from the code.

Maintainability Minor EXIT should not be used in loops

The EXIT should not be used in loops rule states that the EXIT statement should not be used to exit from a loop. Instead, the loop should be exited by using the appropriate looping construct, such as the EXIT WHEN or EXIT FOR statements. This rule ensures that code is properly structured and that loops are exited in a predictable and consistent manner.

Maintainability Minor Fields should not have public accessibility

This rule states that fields in PowerBuilder code should not be made publicly accessible. This means that they should not be declared as public variables, and should instead be declared as private or protected variables. This is important because making fields publicly accessible could open up the code to potential security risks, as it would allow external code to access and modify the fields without any restrictions. It is also important to ensure that fields are only accessible by code that is within the same class, as this will help to ensure that the code is secure and that it is only modified in the intended way.

Maintainability Minor Generic exceptions should not be ignored

The "Generic exceptions should not be ignored" rule for PowerBuilder code states that all exceptions should be handled appropriately, and not just ignored. This means that a developer should not simply ignore an exception that occurs in the code, but instead should take the time to investigate the cause of the exception and handle it in the appropriate manner. This could include using a try-catch block, logging the exception, or simply displaying an error message to the user. Ignoring an exception can lead to errors or unexpected results in the application, so it is important to always handle exceptions appropriately.

Maintainability Minor Jump statements should not be redundant

The "Jump statements should not be redundant" rule in PowerBuilder code states that jump statements, such as GOTO, EXIT, BREAK, and CONTINUE, should not be used unnecessarily. Unnecessary jump statements can make code harder to read and debug, as well as leading to unexpected behavior. When writing code, it is best to avoid redundant jump statements and use alternative control flow structures, such as loops and conditional statements, whenever possible.

Maintainability Minor Lines should not be too long

The rule "Lines should not be too long" states that PowerBuilder code should be written in a way that limits each line to a certain number of characters. This is to help improve readability of the code, as long lines can be difficult to read and understand. It also helps to keep the code organized and structured, as it can be easier to find errors or make changes when the code is written in a consistent manner. Additionally, long lines can cause performance issues, as the code may have to be parsed multiple times in order to be executed.

Maintainability Minor Lines should not end with trailing whitespaces

The PowerBuilder code rule "Lines should not end with trailing whitespaces" ensures that all lines of code in a program do not contain any unnecessary whitespace characters at the end of the line. This is important to maintain the readability and consistency of the code, as well as to prevent any potential errors that could be caused by the presence of these extra characters.

Maintainability Minor Methods must not be empty

This rule states that any methods created in PowerBuilder should not be empty. This means that each method should have some code within it that performs a specific task. This ensures that the code is well-structured, easy to read, and maintainable. Additionally, it prevents the code from becoming cluttered and difficult to debug.

Maintainability Minor Missing destructor

The Missing Destructor rule checks for PowerBuilder objects that are missing a destructor. A destructor is a method that is automatically called when an object is destroyed. It is used to free up any resources that the object has allocated, such as memory or file handles. If an object is missing a destructor, it can lead to memory leaks and other problems. This rule will generate a warning if an object is missing a destructor.

Maintainability Minor Naming conventions must be applied

The PowerBuilder code rule "Naming conventions must be applied" states that all objects, variables, and other elements of the code must be named according to the established naming conventions. This ensures that the code is consistent and easy to read, making it easier to understand and debug. It also helps to avoid confusion between different elements of the code. The naming conventions must be clearly defined and documented, and all developers must adhere to them.

Vulnerability Minor Never use Console logging in production

The rule "Never use Console logging in production" states that developers should never use Console logging when deploying their code to a production environment. Console logging is a debugging technique that allows developers to output information to the console window during code execution. While this can be useful for debugging purposes, it should not be used when the code is running in a production environment. This is because the information outputted to the console can be visible to users, which can lead to security and privacy issues. Additionally, the output from the console can also slow down the performance of the application, which can lead to an overall decrease in user experience. Therefore, it is best to avoid using Console logging in production environments.

Maintainability Minor Objects should not be duplicated (same name and same type)

This rule states that objects should not be duplicated within the PowerBuilder code. This means that objects should not have the same name and type within the code. Duplicating objects can lead to confusion and errors, as the code may not be able to distinguish between the two objects. To avoid this, objects should be given unique names and types to ensure that the code runs correctly and that the objects are distinguishable from one another.

Maintainability Minor PBLs should not exceed a certain size

The rule "PBLs should not exceed a certain size" states that PowerBuilder Library (PBL) files should not be too large. This is important to ensure that the application runs efficiently and that it is not too difficult for developers to maintain. To ensure this, developers should limit the size of PBLs to a certain size, such as 2MB or 5MB, depending on the complexity of the application. This can be done by limiting the number of objects in the PBL, such as windows, user objects, and menus, and by ensuring that the code within each object is as efficient as possible. Additionally, developers should also periodically review the size of the PBLs and remove any unused objects or code.

Maintainability Minor Return of boolean expressions should not be wrapped into an if-then-else statement

This PowerBuilder code rule states that boolean expressions should not be wrapped in an if-then-else statement. This means that when a boolean expression is used, the code should not be written in a way that requires an if-then-else statement to be used. The code should instead be written in a way that the boolean expression can be evaluated directly without the need for an if-then-else statement.

Maintainability Minor Scripts must be commented

This rule states that all scripts written in PowerBuilder must be commented. This means that any code written in a script must include comments that explain the purpose of the code and how it works. This will help other developers understand the code and make it easier to maintain. Additionally, comments can be used to document changes made to the code and to alert other developers of potential issues. Having well-commented code can also help with debugging and troubleshooting. Following this rule will help ensure that PowerBuilder code is well organized, easily maintained, and up to date.

Maintainability Minor Scripts must not exceed a certain size

This PowerBuilder code rule states that any scripts written must not exceed a certain size. This size is determined by the developer and can be set to whatever size is considered appropriate for the application. This rule helps ensure that scripts are organized and efficient, and that they do not become too large and difficult to maintain. This rule also encourages developers to break down large scripts into smaller, more manageable pieces. This helps to ensure that scripts are easier to read and maintain, and that they are more efficient and less prone to errors.

Maintainability Minor String literals should not be duplicated

The "String literals should not be duplicated" PowerBuilder code rule states that when writing code, any string literals should be written only once. This means that when writing code, any strings that are used multiple times should be stored in a variable and the variable should be used instead of the literal string. This helps to make the code more efficient and maintainable, as any changes to the string can be done in one place instead of multiple places.

Maintainability Minor Unused global variables/constants should be removed

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.

Maintainability Minor Unused local variables should be removed

This rule states that all local variables that are declared but not used within a PowerBuilder code should be removed. This is to ensure that the code is as clean and efficient as possible, and that unnecessary variables are not taking up memory space. Additionally, this rule helps to identify any potential errors or typos that may have been made when declaring variables. By removing unused local variables, the code is easier to read, understand, and debug.

Maintainability Minor Variables should comply with a naming convention

The PowerBuilder code rule "Variables should comply with a naming convention" states that all variables used in a PowerBuilder application should be named according to a specific set of guidelines. This helps to ensure that all variables are easily identifiable and that they are used consistently throughout the code. The naming convention should specify the type of variable (e.g. integer, string, etc.), the length of the variable (if applicable), and any other specific requirements that may be applicable to the variable. By following a consistent naming convention, developers can ensure that their code is more organized, readable, and maintainable.