Problem report by description - PicInfo sample application

Consider short-circuited logic

In the expressions (x And y), (x Or y), both operands (x, y) are evaluated. Short-circuiting means rewriting this so that when x=False in (x And y), y is not evaluated. The same goes for x=True in (x Or y). This saves CPU cycles, especially if y is a complex expression. In VB.NET, consider replacing And with AndAlso, and Or with OrElse. In VB Classic, consider splitting an If ..And.. condition as two nested Ifs. Short-circuiting If ..Or.. yields more complex code, usable case by case. Risks: Short-circuiting changes the logic. If the second operand calls a function, this call may not execute. Read VB help for differences between And/AndAlso and Or/OrElse. Optimization. Severity: Info. Count: 1.

85 Function PicBMP.ReadBitmapFile

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. Applies to VB 3-6. Dead. Severity: Warning. Count: 1.

1 PicForm.frm
  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. Severity: Warning. Count: 2.

49 PicBMP.(declarations)
  Private Const BI_RGB = 0&
 
52 PicBMP.(declarations)
  Private Const BI_bitfields = 3&

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. Severity: Warning. Count: 9.

44 PicMain.(declarations)
  OFN_ALLOWMULTISELECT = &H200
 
45 PicMain.(declarations)
  OFN_CREATEPROMPT = &H2000
 
49 PicMain.(declarations)
  OFN_NOCHANGEDIR = &H8
 
54 PicMain.(declarations)
  OFN_NODEREFERENCELINKS = &H100000
 
57 PicMain.(declarations)
  OFN_NONETWORKBUTTON = &H20000
 
64 PicMain.(declarations)
  OFN_NOTESTFILECREATE = &H10000
 
76 PicMain.(declarations)
  OFN_READONLY = &H1
 
80 PicMain.(declarations)
  OFN_SHAREAWARE = &H4000
 
92 PicMain.(declarations)
  OFN_SAVEDEFAULTS = OFN_OVERWRITEPROMPT Or OFN_PATHMUSTEXIST Or OFN_HIDEREADONLY Or OFN_NOREADONLYRETURN

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. Severity: Warning. Count: 3.

  Sub PicForm.Form_KeyPress
  KeyPreview property is False
 
  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. Applies to VB 3-6. Functionality. Severity: Warning. Count: 1.

1 PicForm.frm

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 ' _' count as one line. The lines are counted for each procedure individually so that small uncommented procedures will not trigger an error even if they exceed the limit together. This rule is useful for finding long uncommented blocks inside procedures that have some comments, but not enough. It differs from the 'Uncommented code' rule in that this one reports any consequtive lines without comments, while the 'Uncommented code' rule targets entire procedures with zero comments. Style. Severity: Info. Count: 3.

18 PicMain.bas
  24
 
190 PicMain.bas
  34
 
25 PicBMP.cls
  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. 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. 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. Severity: Warning. Count: 1.

57 PicBMP.(declarations)
  Private IsRLE As Boolean
  0 reads, 2 writes


Number of problems by file

File Problems  
PicBMP.cls 17 *********
PicMain.bas 14 ********
PicForm.frm 3 **
PicGIF.cls 3 **



Problem statistics

Problem Count Type
Consider short-circuited logic 1 Opt
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
Too many parameters 2 Style
Too many uncommented lines 3 Style
Type field written, not read 13 Dead
Variable read, not written 1 Dead
Variable written, not read 1 Dead
   
Type Count
Optimization 1
Style 5
Functionality 1
Dead 30
===== =====
Total 37
Problems/logical code line 0,10

Filter: <Default>