I have this code which is a callback for Filter in WPF
WPF ICollectionView
.
When When I run code analysis
code analysis, the cyclometic complexity
cyclometic complexity is reported to be 11
11. I consider this line by line comparison gives a better readability. How can I improve the cyclomatic complexity or How can I improve this code in general.?
private bool FilterLicenseList(object item)
{
var license = item as LicenseEntry;
if (!string.IsNullOrEmpty(Filter.Firm) && !license.Firm.Contains(Filter.Firm)) return false;
if (!string.IsNullOrEmpty(Filter.RegistrationCode) && !license.RegistrationCode.Contains(Filter.RegistrationCode)) return false;
if (!string.IsNullOrEmpty(Filter.LicenseCode) && !license.LicenseCode.Contains(Filter.LicenseCode)) return false;
if (!string.IsNullOrEmpty(Filter.Branch) && !license.Branch.Contains(Filter.Branch)) return false;
if (Filter.Active != null && license.Active != Filter.Active) return false;
return true;
}