Default Refactoring Rules

There are four different types of rules:
  • File
  • Method/Function
  • Object
  • Line

Note that each rule may be disabled if you don't want to use it.

Default Method Rules

  1. Check if there is an unreasonable ratio of comments to code in a method
  2. Check to see if there is a RETURN within a WITH statement, a known cause of C5 errors
  3. Check to see if there are too many lines in a method (defaults to 150) - which is a sign of readability
  4. Check to see if you have more than a certain number of loop structures in code (defaults to 5)
  5. Verifies that each function has a RETURN value
  6. Verifies that a function doesn't have more than 3 return values

Default Object Rules

  1. Checks if a button named Cancel does not have the Cancel property set to .T.
  2. Checks if you are simply using the default object names
  3. Checks if there are methods in the object that have similar number of lines that could therefore be a good candidate for refactoring the code
  4. Checks if you are using THIS.Parent in a form already
  5. Checks if you are using duplicate methods in column headers which suggest a possible refactoring use for BindEvent.

Default Line Rules

  1. Warns if you are using CTOD on a line of code instead of the DATE() function
  2. Checks if you have more than 3 .Parent lines on the same line, suggesting possible too many uses of .Parent

Anyone have any others?

Last edited Oct 27, 2006 at 7:46 PM by Akselsoft, version 4


CraigRoberts Aug 3, 2008 at 8:43 PM 
Let me clarify the misuse of REINDEX.

VFP's index files became quite solid with VFP 6. And the rare event that indexes go bad, it's best to start anew with the INDEX ON command. REINDEX might fix an "out of order" problem which I've never seen.

CraigRoberts Aug 3, 2008 at 8:40 PM 

CraigRoberts Aug 3, 2008 at 8:37 PM 
ON ERROR DO ERRORLOG not used or turned off. Certainly this should be required in production code.

CraigRoberts Aug 3, 2008 at 8:35 PM 
ALLTRIM( cPK or cFK) used anywhere.

CraigRoberts Aug 3, 2008 at 8:34 PM 
Method Rules
without a
SELECT fooAlias