I have been around for a long time Roslyn Analyzer for detecting IOSP violations. On the one hand I have updated it, on the other hand there is now also a Plugin for Rider.
The integration in Rider has numerous advantages. Above all, it is now much easier to configure the analyzer. After installing the plugin, there is a settings page in Rider. The following settings can be made on this page:
- Metric - This can be used to determine how serious the IOSP violation must be to display it as a warning.
- Exclude test methods - A simple checkbox can now be used to exclude test methods from the analysis.
- Ignore namespaces - A list of namespaces can be created whose methods are ignored in the analysis.
You can also use Settings - Editor - Inspection Settings - Inspection Severity - C# - IOSP Violation to set whether the violations should be displayed as an error, warning, suggestion or hint.
The plugin is available via the JetBrains Marketplace. The installation is done as follows:
- Go to Settings - Plugins
- Select above Marketplace
- Search for IOSP
- Go right to Install
Rider or the plugin then informs you in the code about violations of the Integration Operation Segregation Principle (IOSP).
In the default settings, violations are displayed as a warning. This means that the method name is highlighted in color.
In the illustration, you can see that the name of the method, in this case „Start“, is highlighted in color. In addition, a tooltip is displayed with the mouse pointer, indicating which parts have been evaluated as an integration or operation.
The metric = 2 indicates that it is a manageable violation that can be ignored if necessary. The integration part predominates here. Only the expression 30*1000 must be assigned to an operation. Below is the source text:
public void Start(Action<IAsyncEnumerable> onUpdate) {
new TimerProvider().ExecutePeriodic(30*1000, () => {
var symbols = _favoritenProvider.FavoritenLaden();
var securities = _kursProvider.KurseErmitteln(symbols);
onUpdate(securities);
});
}
The problem could be solved by changing the expression 30*1000 into a constant.






