Problem report by description – PicInfo sample application
Assigned value not used
A local variable is assigned a value that is not actually used after the assignment. It is either overwritten or not used at all. Review the code to see if it is a programming error or if you can optimize by deleting the write statement. Make sure you are not removing any required function calls at this point, that is calls that have useful side effects. — Note: This rule only considers reachable code. If a read instruction exists in an unreachable statement, such as an impossible branch, it is not taken as a read. Before deleting any code, look for all use locations of the variable to determine whether the value could actually be required under some other circumstances, such as if you later change some condition. — Details: Arrays are excluded from this rule as well as parameters. Logic. Severity: Info. Count: 1. |
90 | Function PicGIF.ReadGIF |
Dim FileNr As Integer | |
Integer |
Case branch(es) missing for Enum
A Select Case statement branches off an Enum value, but it does not contain a Case for every Enum constant. This may indicate missing logic, possibly due to an Enum constant added later. Check to see whether this causes problems when an unhandled Enum value is passed. This rule requires every Enum constant name to be listed in a Case, even if the constants have the same value. Use of the underlying numeric values is not acceptable. Ranges such as Case X To Z are not acceptable either. Listing each individual constant helps prevent breaking existing Select Case blocks if the Enum is later changed or rearranged. To accept Case Else as a default branch, check Ignore when Case Else exists. Logic. Severity: Warning. Count: 2. |
128 | Property PicBMP.IPicInfo_ |
bmpUnknown | |
153 | Property PicBMP.IPicInfo_ |
bmpUnknown |
Control outside visible area
A control is located outside of the visible area of the form it is on. The control is not moved by code and the form does not seem to resize to reveal the control. Most user interface controls are not very useful if they are not visible. The control was possibly moved outside the form borders by a developer who thought it was not required any more but was uncertain about removing it. You should consider removing invisible controls as they may unnecessarily consume some resources. Events related to the control are possibly not executed. Code that reads or sets the control's properties and calls its methods is potentially unnecessary for the operation of the program. There are some cases where an invisible control can be useful, so you have to be careful about removing the control and related code. This rule does not work with control arrays or controls that are placed within other controls. Rule applies to VB 3-6. Dead code. Severity: Warning. Count: 1. |
1 | PicForm |
CommandButton SaveFile | |
Too far right |
Dead constant
The value of a constant is not used. You may have forgotten to use it, or it is useless in this application. You should verify which case it is. If it's useless, you may remove it if you are sure you won't need it later. The removal doesn't affect the functionality of your program. You may consider preserving the constant for the sake of completeness or later use, though. The best way to achieve this is to comment it out. The commented constant is clearly reserved for future purposes and not being used at the moment. — An extra string constant bloats the executable size while an extra numeric constant simply bloats the source code and makes it harder to understand. A dead constant may also have an obsolete value, which is not apparent before the constant is brought back to use again. These are the reasons why dead constants should be cleaned out even though they don't affect the functionality of the program. Dead code. Severity: Warning. Count: 2. |
49 | PicBMP.(declarations) |
Private Const BI_ |
|
52 | PicBMP.(declarations) |
Private Const BI_ |
Dead enum constant
An enumeration constant is not used. You may have forgotten to use it, or it is useless in this application. You should verify which case it is. If it is useless, you may remove it if you are sure you won't need it later. The removal doesn't affect the functionality of your program. You may consider keeping this constant available for the sake of completeness or later use, though. Note that removing a constant from an Enum may change the values of the constants that come after it, causing side effects. When removing an Enum constant it is safest to explicitly define a value for the next constant to prevent breaking existing code. The code may rely on the specific numeric values of the enum constants. Dead code. Severity: Warning. Count: 9. |
44 | PicMain.(declarations) |
OFN_ |
|
45 | PicMain.(declarations) |
OFN_ |
|
49 | PicMain.(declarations) |
OFN_ |
|
54 | PicMain.(declarations) |
OFN_ |
|
57 | PicMain.(declarations) |
OFN_ |
|
64 | PicMain.(declarations) |
OFN_ |
|
76 | PicMain.(declarations) |
OFN_ |
|
80 | PicMain.(declarations) |
OFN_ |
|
92 | PicMain.(declarations) |
OFN_ |
Dead procedure/declaration/event
A procedure, a DLL declaration or an Event declaration is not used by the project. It is not called by the code nor executed by any other means. You may remove it if you are sure you won't need it later. The removal doesn't affect the functionality of your program. - Event declarations are reported dead only if they are not raised nor handled. See the problem Event not raised for events that would be handled but that are not fired. Dead code. Severity: Warning. Count: 3. |
Sub PicForm.Form_ |
|
KeyPreview property is False | |
Declare Function PicMain.GetSaveFileNameA | |
Property PicGIF.Version [Get] |
Form missing Icon
A Form doesn't have an icon that is required. A default icon, generated by VB, will be shown. Rule applies to VB 3-6. Functionality. Severity: Warning. Count: 1. |
1 | PicForm |
Line too long
A line of code is longer than allowed. A typical limit is 80 characters per line, but you can also use higher limits such as 90 or 100. Long lines are hard to read and understand. Overly long lines don't fit in the view of your development environment and you need to scroll. What fits in view depends on the monitor and font. On a 1280x1024 screen you can reasonably allow about 80-90 characters in a 10pt Courier New font and maybe 100 characters in an 8pt font. Long lines won't fit on paper either, and need to be wrapped. While the Print feature of Project Analyzer wraps neatly in a syntax-aware fashion, other programs might not. As an additional bonus, enforcing short lines discourages too deep nesting. How to shorten the lines? Split complex expressions into two or more statements with temporary variables. This will make your code more self-explanatory. Splitting a line with the line continuation character (_ |
45 | PicMain.(declarations) |
181 | |
117 | Function PicMain.ShowFileOpenDialog |
296 | |
135 | Function PicMain.FileDialog |
234 |
Optional parameter never passed a value
An Optional parameter is never passed as a call argument. The passed value is always the default value of the parameter. Determine if it is a superfluous parameter that could be removed, and the parameter be replaced by a local constant. Alternatively, it is possible that callers have omitted the value in error. Review each calling line to see if the parameter should actually be passed some value. You can do this by right-clicking the procedure name and selecting References. Dead code. Severity: Info. Count: 4. |
Function PicMain.ShowFileOpenDialog | |
Optional ByVal DialogTitle As String | |
Function PicMain.ShowFileOpenDialog | |
Optional ByVal InitialDir As String | |
Function PicMain.ShowFileOpenDialog | |
Optional ByRef Flags As EFileDlgFlags = OFN_ |
|
Function PicMain.ShowFileOpenDialog | |
Optional ByRef FilterIndex As Long |
Possibly commented-out code
The line(s) may contain commented-out code. Removed code that has been left as a comment may be considered junk. It may distract developers and cause confusion about its significance. It's possibly a bad or otherwise outdated piece of code. Consider removing commented-out code to clean up your project. Project Analyzer uses heuristic rules to search for comments that resemble the actual code in the project. The rules are not foolproof, though, and a certain deal of false alarms are to be expected. In order to mark a line as being commented out on purpose, you can prefix it with a dollar: '$If fail Then End. The dollar will make the line look like non-code to Project Analyzer, thus excluding it from the check. Style. Severity: Info. Count: 1. |
49 | Sub PicForm.Form_ |
Too many parameters
A procedure has a lot of parameters. The more parameters you have, the more difficult the procedure is to use. Consider dividing the procedure. Target at a maximum of 5 parameters. Style. Severity: Info. Count: 2. |
Function PicMain.ShowFileOpenDialog | |
Function PicMain.FileDialog |
Too many uncommented lines
Several code lines were found without any comments in them. Add enough comments to make the code easier to understand. This rule finds consequtive uncommented lines. You can set the 'too many' limit to your taste. The rule counts the lines between comments. Empty lines are skipped. Lines continued with the line continuation syntax ' _ |
190 | Function PicMain.FileDialog |
34 | |
25 | PicBMP.(declarations) |
27 |
Type field written, not read
A field in a user-defined type is written but not read by your code. This may indicate a useless field or incomplete functionality. Carefully consider removing the field. Before removal you need to review how the type is being used. If it is being used in random file access or external DLL calls, changing the type may break the file structure or the calls. - This problem rule applies to VB 3-6 only. Fields of VB.NET Structures are handled via the rule Variable written, not read. Dead code. Severity: Warning. Count: 13. |
21 | PicBMP.(declarations) |
bfSize As Long | |
0 reads, 1 write | |
24 | PicBMP.(declarations) |
bfOffBits As Long | |
0 reads, 1 write | |
27 | PicBMP.(declarations) |
biSize As Long | |
0 reads, 1 write | |
30 | PicBMP.(declarations) |
biPlanes As Integer | |
0 reads, 1 write | |
33 | PicBMP.(declarations) |
biSizeImage As Long | |
0 reads, 1 write | |
34 | PicBMP.(declarations) |
biXPelsPerMeter As Long | |
0 reads, 1 write | |
35 | PicBMP.(declarations) |
biYPelsPerMeter As Long | |
0 reads, 1 write | |
36 | PicBMP.(declarations) |
biClrUsed As Long | |
0 reads, 1 write | |
37 | PicBMP.(declarations) |
biClrImportant As Long | |
0 reads, 1 write | |
40 | PicBMP.(declarations) |
bcSize As Long | |
0 reads, 1 write | |
43 | PicBMP.(declarations) |
bcPlanes As Integer | |
0 reads, 1 write | |
31 | PicGIF.(declarations) |
BackgroundColorIndex As Byte | |
0 reads, 1 write | |
32 | PicGIF.(declarations) |
PixelAspectRatio As Byte | |
0 reads, 1 write |
Variable read, not written
A variable is never written to, even though its value is read by the program. The value is always zero, empty or Nothing, depending on the data type. Review the code to see if the missing write is a flaw in the program or if it is intentional. The write statement(s) may have been deleted by accident or the developer forgot to add them in the first place. In this case one or more writes should be added. On the other hand, the write(s) may have been removed on purpose, in which case the variable now works as a constant. Consider removing the variable altogether or declaring it as a constant. The use of a constant prevents unexpected changes later in the life-cycle of the program. You can also save a little memory as constants don't require run-time data storage. — This review rule is especially important for object variables, because the variable will always contain the value Nothing. This can cause an 'Object variable not set' error at the location the object is referenced. A special case is denoted as 'No real value given, cleared/allocated only'. For an object variable this means the variable is set to Nothing but it never contains a live object. Alternatively, an array is allocated but nothing is stored in it. The array is consuming memory for no purpose. Dead code. Severity: Warning. Count: 1. |
60 | PicBMP.(declarations) |
Private StoredFilename As String | |
1 read, 0 writes |
Variable written, not read
A variable is given a value but the value is never read by the program. The variable is either useless or there is a flaw in the program. Review the write locations. Check the code to determine if it's a flaw or if the variable is simply a leftover from an earlier version. Remove the variable and the write statements if you are sure the variable is useless. Before removal, determine if the write statements contain any procedure calls that must execute. Removing these calls could make the program behave erroneously. Dead code. Severity: Warning. Count: 1. |
57 | PicBMP.(declarations) |
Private IsRLE As Boolean | |
0 reads, 2 writes |
Number of problems by file
File | Problems | Distribution |
---|---|---|
PicMain | 20 | ******************** |
PicBMP | 18 | ****************** |
PicGIF | 4 | **** |
PicForm | 4 | **** |
Problem statistics
Problem | Count | Type |
---|---|---|
Assigned value not used | 1 | Logic |
Case branch(es) missing for Enum | 2 | Logic |
Control outside visible area | 1 | Dead |
Dead constant | 2 | Dead |
Dead enum constant | 9 | Dead |
Dead procedure/declaration/event | 3 | Dead |
Form missing Icon | 1 | Func |
Line too long | 3 | Style |
Optional parameter never passed a value | 4 | Dead |
Possibly commented-out code | 1 | Style |
Too many parameters | 2 | Style |
Too many uncommented lines | 2 | Style |
Type field written, not read | 13 | Dead |
Variable read, not written | 1 | Dead |
Variable written, not read | 1 | Dead |
Type | Count | |
Style | 8 | |
Functionality | 1 | |
Logic | 3 | |
Dead code | 34 | |
Total | 46 | |
Problems/logical code line | 0,12 |
Filter: <Default>