Mike on the MATLAB Desktop
April 6th, 2009
Finding the right M-Lint message
I promise that this’ll be my last post on the new M-Lint features (for awhile anyway). In last week’s post on the new M-Lint preferences, I glossed over the new search bar, so this week we’ll dive into its features.
Every release since M-Lint was first integrated into the editor has had more and more messages, making it difficult to find a particular message to turn off. For R2009a, we took Ken’s search and filter box and added it to the M-Lint preferences panel.
Let’s say you found the “Input argument … might be unused” message annoying and wanted to turn it off, but could not remember the exact text of the message. Searching for “be unused” shows us all the messages that contain the words “be” and “unused”.
The search mechanism searches all the messages’ text, message identifier, category, and extended help, but only the message text and extended help is highlighted with the results. For instance, if we wanted to search for messages pertaining to MExceptions, we see that there are no messages that contain the term “MException”, but there are four messages that discuss MExceptions in their extended help.
In addition to filtering based upon the text of messages, the filter’s dropdown menu contains options for filtering messages based on if they are enabled/disabled, if the setting has been modified from the factory defaults, by category, and a few others.
The one thing that the new UI doesn’t make easy is finding out what the (%#ok) tag is for a particular message. This would be handy for typing in the ok’s for a particular file by hand. Since we weren’t sure how many people would use it or come to this panel to find out those tags it did not seem worth it to complicate the UI just to show them. We might revisit that again in the future if it becomes compelling.
By
Michael Katz
Mike is a developer on the MATLAB Mobile team. When not describing himself in the third person, biking, homebrewing, or rooting for the home team, he's busy trying to make the world a better place for programming.
12:37 UTC |
Posted in M-Lint, Preferences |
Permalink |
8 Comments »
You can follow any responses to this entry through the RSS 2.0 feed.
You can skip to the end and leave a response. Pinging is currently not allowed.
Leave a Reply
|
Hi!
I just wonder why there is no M-lint message for fclose or fprintf. It is common to see numbers displayed in the command window because we have forgotten the coma separator ; after a fclose(fid) or a fprint(fid,…)
Aurélien
Aurélien,
Are you thinking of the message: “This call of will produce output that will be printed.” ?
Yes Mike. It is exactly this kind of message that I thought
Mike,
I am getting the …
“This call of FPRINTF will produce output that will be printed.”
… M-Ling message. This is my code:
I know I am printing that into the file with FID, but why
get a warning for this? Thanks for clearing this up in advance.
@Noel,
That is exactly why there is a message, because you aren’t expecting fprintf to return the number of bytes written. If you run your code, you will see an output from the fprintf function. Terminate with a semicolon, and you’ll be good to go.
@Mike,
You have to admit that the M-lint message in this case is worded a little oddly:
“This call of FPRINTF will produce output that will be printed.”
I can imaging people thinking ‘Duh, that’s why I called FPRINTF – to have output ‘printed’ to a file!’
Couldn’t it just use the standard ‘Terminate statement semicolon to prevent output’? In both cases, both messages might be a little clearer if they said ‘…prevent output to the command line.’
Not only is the M-lint message confusingly worded, but the
problem it does seem to be warning about doesn’t actually happen.
The unterminated fprintf() does not actually print the
number of bytes written to the screen. Try it:
>> s=fprintf(1, ‘Hi There\n’)
Hi There
s =
9
>> %Ok, but:
>> fprintf(1, ‘Hi There\n’)
Hi There
>>
@Glenn,
The message is to let you know that there will be something printed, that is the second argument to fprint. Most MATLAB commands do not print things directly to the screen or can be suppressed when terminated with a “;”. As of particular note here is that the behavior is different with a no output from a single ouptut. Of course that doesn’t help explain the message. I have brought that to the team’s attention.