Code covered by the MathWorks Limited License

Highlights from
fixcase

fixcase

by

 

Check and fix case of function calls

Editor's Notes:

This file was selected as MATLAB Central Pick of the Week

fixcase.m
%fixcase Check and fix case of function calls
%
%    In releases of MATLAB prior to R2011b, entering a function name that did not match any known
%    function name in the given letter case resulted in a warning. After displaying this warning
%    message, MATLAB attempted find a function that would match if letter case were ignored. If such
%    a match were found, MATLAB ran this function instead. In MATLAB R2011b, the MATLAB software
%    generates an error if it can't find an exact-case match.
%
%    fixcase attempts to find and offer fixes for function calls with incorrect case by
%    analyzing MATLAB code and checking the MATLAB path. fixcase produces an HTML report. The
%    report provides a summary of issues with links to open and fix the code in the MATLAB editor.
%    You must verify each change because fixcase might produce some inappropriate messages and
%    fixes when MATLAB uses variables in unusual ways. Similarly, fixcase might not correctly
%    analyze method calls.
%
%    fixcase checks all MATLAB files in the current folder and its subfolders. All
%    subfolders must be on the MATLAB path.
%
%    fixcase(Folder) checks all MATLAB files in Folder and its subfolders. Full
%    folder names are required. Folder and all its subfolders must be on the MATLAB path.
%
%    fixcase(Folder,DependentFolders) includes methods from classes in DependentFolders in the
%    searches. Methods from classes in the search path are included in the list of functions but
%    methods from elsewhere on the path are not included. Specify a list of folders containing
%    dependent classes in DependentFolders. Use a cell array to specify more than one dependent
%    folder.
%
%    Three possible messages are reported:
%    * CaseMismatch         - The identifier ''XXXX'' only has the case-insensitive match with
%                             the function ''xxxx''.  Function calls with case-insensitive names are
%                             no longer supported in MATLAB. View the tooltip in the Original Code
%                             column to see the correct function name.
%    * CaseMismatchScript   - The identifier ''XXXX'' only has the case-insensitive match with
%                             the function ''xxxx'' in a script.  Function calls with
%                             case-insensitive names are no longer supported in MATLAB. It is
%                             possible that the identifier is a variable which must be defined
%                             before calling the script. In that case, the message is a false
%                             positive and you should not fix it.
%    * CaseMismatchNonTrans - The identifier ''XXXX'' only has the case-insensitive match with
%                             the function ''xxxx'' in a nontransparent function or script. Function
%                             calls with case-insensitive names are no longer supported in MATLAB.
%                             This identifier may be a variable which is defined by a load, import,
%                             syms, eval command or in a call to another script. View the tooltip in
%                             the Original Code column to see further details about the
%                             nontransparent functionality. These messages are in the Detection
%                             category instead of Error, because there is a high likelihood of false
%                             positives. These messages require further investigation.
%
%   Each message contains:
%   * A File link that opens the code in the MATLAB editor, 
%   * The name of the problem call.
%   * The Tag column shows the message type and a link to Fix the code in the MATLAB editor. 
%   * The original code with the incorrect function call highlighted. The tooltip contains more
%     information about this call, including the correct case and any details about nontransparent
%     functionality.
%
%   To fix the code, click the Fix link in the Tag column. The Fix link opens the code and applies
%   the fix in the MATLAB editor. After making the fix it is important that you verify that the
%   change is correct. You can undo the change using the Undo function in the MATLAB Editor. You
%   must save the file before the change is accepted.
%
%   The first section of the report contains:
%   * A backup link. Click to create a zip file containing files to be changed. A backup is only
%     produced if the files to be changed are inside the current folder.
%   * A refresh link. Click to refresh the report. The folder summary is not produced. 
%   * A message categories summary table that contains a summary of each category. fixcase can
%     produce two message categories: 'Error' for the 'CaseMismatch' and 'CaseMismatchScript'
%     messages, and 'Detection' for 'CaseMismatchNonTrans' messages. Click on the Details link to
%     see the messages for each category in the lower section of the report.
%   * An individual message summary table that contains a detailed explanation and number of
%     occurences for each message. The auto-fix link makes all fixes for that message and
%     produces an updated report summarizing the changes. Review the code fixes made by batch
%     fixes. Open the code in the editor using the file link. Restore changes by unzipping the
%     backup zip file described in the command-line messages. Click the refresh link at the top of
%     the report after your review to see any remaining issues.
%   * A folder summary that contains the total number of messages and autofixes in each subfolder.
%     Note that the folder summary is not produced when refreshing the report.
%
%   Disclaimer:
%     The searches in fixcase are not guaranteed to find all instances where a function call
%     with incorrect case is made and might in certain circumstances suggest incorrect changes.
%     Changes should be reviewed by someone familiar with the code to verify their correctness. It
%     is only possible to verify that the code will operate correctly by running the code.
%
%     It is recommended that you back up your code before using this tool. Test the changes by
%     running the code before relying on any changes.

%   Copyright 2012 The MathWorks, Inc.
%   $Revision: $    $Date:  $

Contact us