I have a parameter with 3 parameters and i want to ensure that data from parameters are correct, so I have something like that:
- if param1 is null throw exception ArgumentNullException
- if param1.Property < 0 throw exception
if para1.Property > 100 throw exception
if param2 is null throw exception
- if param2.Property is null throw exception
- if param2.Property is not > 0 throw exception
and so on.
In this case I have a cyclomatic complexity of 7, and it seems that between 6 and 10 it is hard to maintenace, so it is recommended 5 or less.
I was thinking to create a method that checks if each parameter is correct, but if I have 3 parameters and 3 methdos, the complexity is 4. So I only can use one loop, or one if more...
So my question is, I want to ensure that the data that I receive from parameters are correct and later, if all is correct, do the work, but I don't know how can I check my parameters and implement my code and keep a complexity below 6.
Thanks.