I have this code which is a callback for Filter in WPF ICollectionView
. When I run code analysis, the cyclometic complexity is reported to be 11. I consider this line by line comparison gives a better readability. How can I improve the cyclomatic complexity or 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;
}