CleanCode icon indicating copy to clipboard operation
CleanCode copied to clipboard

Ignore ILogger as a dependency when checking for SRP

Open Mayron opened this issue 1 year ago • 2 comments

Is it possible to ignore ILogger as a dependency when analysing the code for too many dependencies? I get a warning that the class might be breaking the single responsibility principle but logging is a good practice to have and I don't think it should count as doing too much. It's everywhere in the codebase.

I would prefer to always ignore it so the below constructor could be analysed as having only 3 dependencies instead of 4: image image

Mayron avatar May 09 '24 12:05 Mayron

Hey :)

i don't know how i should feel about this, since this would add a dependency to the plugin itself.

What could be possible would be some mechanism to exclude by namespace name, but this still does not feel right. In your example the IHttpContextAccessor is also something thats more a less 'static' and will be added to all of your handlers, right? So should this be excluded as well?

Could u just increase the configuration value for this?

MO2k4 avatar May 17 '24 12:05 MO2k4

It's funny; I thought about this as well with some methods that hit their line limits, and logging entries contributed to the counts being over the max. When I dug in a bit, some of these were conditional based on #if DEBUG as well. I would prefer options that didn't include either of these since in the final builds, the logging typically plays a role outside the complexity, and the DEBUG code isn't included. My thought is that changing the configuration value for this without the additional options breaks what we are trying to accomplish related to clean code in general.

hbrof avatar Aug 14 '24 16:08 hbrof