History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: RSRP-31257
Type: New Feature New Feature
Status: Open Open
Priority: Major Major
Assignee: Eugene Pasynkov
Reporter: Philip Lee
Votes: 0
Watchers: 2
Operations

If you were logged in you would be able to see more operations.
ReSharper

Use SuppressMessageAttribute to disable specific warnings

Created: 06 Nov 06 18:18   Updated: 14 Nov 07 13:48
Component/s: Code Analysis
Fix Version/s: Future Versions
Security Level: Everybody (All jira users)

Original Estimate: Unknown Remaining Estimate: Unknown Time Spent: Unknown

Build: 300


 Description  « Hide
Currently warnings have to be disabled for all instances of a warning.
It would be much nicer to disable specific warnings.
I suggest you use the existing SuppressMessageAttribute.

e.g.
[SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")]
GetMeterEvents(...){ }

you could do something like:
[SuppressMessage("JetBrains.Design", "Member could be made static")]
void AMethodThatCouldBeStatic()
{
}



 All   Comments   Work Log   Change History      Sort Order:
Philip Lee - 09 Nov 06 12:29
It would very neat if where Resharper warnings overlap static code analysis warnings, that you reused exactly the same message to avoid having two SuppressMessage attributes on the same piece of code.

For example I have this code. The property isn't used directly, but indirectly via reflection.

private class ...
{
// This property is used indirectly by the data grid.
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
public int EventSignificanceId
{
get { return _eventSignificanceId; }
}
}

So in this case I can suppress individual FxCop warnings but not Resharper warnings.


Ken Baltrinic - 24 Feb 07 07:14
I like the attributes idea for places where we already want/need such an attribute, but when we are not using those attributes, I think a cleaner approach is to use a commenting syntax. For example the following code would generate a warning that the code is suppressing all errors:

try
{
WriteToLog( message );
}
catch()
{
}

If the user elects to ignore only this instance of the warning then Resharper could insert a comment as follows.

try
{
WriteToLog( message );
}
catch() //XXXX: Intentionally suppressing all errors.
{
}

This both make the code explicit and tells Resharper to not warn on this line in the future: Note that the XXXX represents some character sequence that Resharper would recognize. This way the end user can modify the actual text of the comment if they wished w/o affecting Resharpers ability to recognize its intent.


Drew Noakes - 02 Nov 07 16:30
How does IDEA track these sorts of things (IDE warnings, not compiler warnings)? It seems to allow ignoring specific instances of warnings without adding anything to the code.

Could this be portable between IDE instances, perhaps using a human-readable file that would be included in version control?


Eugene Pasynkov - 14 Nov 07 13:48
We are still investigating the best way to resolve this issue